Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 7c489fe

Browse files
committed
glitch requested this
1 parent 90402ca commit 7c489fe

9 files changed

Lines changed: 35 additions & 10 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## TODO
2+
* Use IForgeDimension for the getHorizonHeight client mixin to World

patchwork-level-generators/src/main/java/net/minecraftforge/common/extensions/IForgeWorldType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ default ChunkGenerator<?> createChunkGenerator(World world) {
107107
default <T extends LayerSampler, C extends LayerSampleContext<T>> LayerFactory<T> getBiomeLayer(LayerFactory<T> parentLayer, OverworldChunkGeneratorConfig settings, LongFunction<C> contextFactory) {
108108
parentLayer = (new SetBaseBiomesLayer(getWorldType(), settings)).create(contextFactory.apply(200L), parentLayer);
109109
parentLayer = AddBambooJungleLayer.INSTANCE.create(contextFactory.apply(1001L), parentLayer);
110-
parentLayer = AccessorBiomeLayers.stack(1000L, ScaleLayer.NORMAL, parentLayer, 2, contextFactory);
110+
parentLayer = AccessorBiomeLayers.patchwork$stack(1000L, ScaleLayer.NORMAL, parentLayer, 2, contextFactory);
111111
parentLayer = EaseBiomeEdgeLayer.INSTANCE.create(contextFactory.apply(1000L), parentLayer);
112112
return parentLayer;
113113
}

patchwork-level-generators/src/main/java/net/patchworkmc/impl/levelgenerators/PatchworkGeneratorType.java renamed to patchwork-level-generators/src/main/java/net/patchworkmc/api/levelgenerators/PatchworkGeneratorType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
package net.patchworkmc.impl.levelgenerators;
20+
package net.patchworkmc.api.levelgenerators;
2121

2222
import net.minecraftforge.common.extensions.IForgeWorldType;
2323

24+
/**
25+
* Used by Patchwork to mark forge level generator types. Added in the patching phase by patcher.
26+
*/
2427
public interface PatchworkGeneratorType extends IForgeWorldType {
2528
}

patchwork-level-generators/src/main/java/net/patchworkmc/mixin/levelgenerators/AccessorBiomeLayers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@Mixin(BiomeLayers.class)
3434
public interface AccessorBiomeLayers {
3535
@Invoker("stack")
36-
static <T extends LayerSampler, C extends LayerSampleContext<T>> LayerFactory<T> stack(long seed, ParentedLayer layer, LayerFactory<T> parent, int count, LongFunction<C> contextProvider) {
36+
static <T extends LayerSampler, C extends LayerSampleContext<T>> LayerFactory<T> patchwork$stack(long seed, ParentedLayer layer, LayerFactory<T> parent, int count, LongFunction<C> contextProvider) {
3737
throw new RuntimeException("Failed to create invoker: BiomeLayers#stack!");
3838
}
3939
}

patchwork-level-generators/src/main/java/net/patchworkmc/mixin/levelgenerators/MixinBiomeLayers.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* License along with this library; if not, write to the Free Software
1717
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
19-
19+
2020
package net.patchworkmc.mixin.levelgenerators;
2121

2222
import java.util.function.LongFunction;
@@ -55,7 +55,7 @@
5555
import net.minecraft.world.gen.chunk.OverworldChunkGeneratorConfig;
5656
import net.minecraft.world.level.LevelGeneratorType;
5757

58-
import net.patchworkmc.impl.levelgenerators.PatchworkGeneratorType;
58+
import net.patchworkmc.api.levelgenerators.PatchworkGeneratorType;
5959

6060
@Mixin(BiomeLayers.class)
6161
public class MixinBiomeLayers {
@@ -69,25 +69,31 @@ private static <T extends LayerSampler, C extends LayerSampleContext<T>> void bu
6969
if (generatorType instanceof PatchworkGeneratorType) {
7070
LayerFactory<T> continentLayer = ContinentLayer.INSTANCE.create(contextProvider.apply(1L));
7171
continentLayer = ScaleLayer.FUZZY.create(contextProvider.apply(2000L), continentLayer);
72+
7273
continentLayer = IncreaseEdgeCurvatureLayer.INSTANCE.create(contextProvider.apply(1L), continentLayer);
7374
continentLayer = ScaleLayer.NORMAL.create(contextProvider.apply(2001L), continentLayer);
75+
7476
continentLayer = IncreaseEdgeCurvatureLayer.INSTANCE.create(contextProvider.apply(2L), continentLayer);
7577
continentLayer = IncreaseEdgeCurvatureLayer.INSTANCE.create(contextProvider.apply(50L), continentLayer);
7678
continentLayer = IncreaseEdgeCurvatureLayer.INSTANCE.create(contextProvider.apply(70L), continentLayer);
7779
continentLayer = AddIslandLayer.INSTANCE.create(contextProvider.apply(2L), continentLayer);
80+
7881
LayerFactory<T> layerFactory2 = OceanTemperatureLayer.INSTANCE.create(contextProvider.apply(2L));
7982
layerFactory2 = stack(2001L, ScaleLayer.NORMAL, layerFactory2, 6, contextProvider);
83+
8084
continentLayer = AddColdClimatesLayer.INSTANCE.create(contextProvider.apply(2L), continentLayer);
8185
continentLayer = IncreaseEdgeCurvatureLayer.INSTANCE.create(contextProvider.apply(3L), continentLayer);
8286
continentLayer = AddClimateLayers.AddTemperateBiomesLayer.INSTANCE.create(contextProvider.apply(2L), continentLayer);
8387
continentLayer = AddClimateLayers.AddCoolBiomesLayer.INSTANCE.create(contextProvider.apply(2L), continentLayer);
8488
continentLayer = AddClimateLayers.AddSpecialBiomesLayer.INSTANCE.create(contextProvider.apply(3L), continentLayer);
8589
continentLayer = ScaleLayer.NORMAL.create(contextProvider.apply(2002L), continentLayer);
8690
continentLayer = ScaleLayer.NORMAL.create(contextProvider.apply(2003L), continentLayer);
91+
8792
continentLayer = IncreaseEdgeCurvatureLayer.INSTANCE.create(contextProvider.apply(4L), continentLayer);
8893
continentLayer = AddMushroomIslandLayer.INSTANCE.create(contextProvider.apply(5L), continentLayer);
8994
continentLayer = AddDeepOceanLayer.INSTANCE.create(contextProvider.apply(4L), continentLayer);
9095
continentLayer = stack(1000L, ScaleLayer.NORMAL, continentLayer, 0, contextProvider);
96+
9197
int biomeSize = 4;
9298
int riverSize = biomeSize;
9399

@@ -102,13 +108,17 @@ private static <T extends LayerSampler, C extends LayerSampleContext<T>> void bu
102108

103109
LayerFactory<T> riverLayer = stack(1000L, ScaleLayer.NORMAL, continentLayer, 0, contextProvider);
104110
riverLayer = SimpleLandNoiseLayer.INSTANCE.create(contextProvider.apply(100L), riverLayer);
111+
105112
LayerFactory<T> noiseLayer = ((IForgeWorldType) generatorType).getBiomeLayer(continentLayer, settings, contextProvider);
106113
LayerFactory<T> layerFactory5 = stack(1000L, ScaleLayer.NORMAL, riverLayer, 2, contextProvider);
114+
107115
noiseLayer = AddHillsLayer.INSTANCE.create(contextProvider.apply(1000L), noiseLayer, layerFactory5);
116+
108117
riverLayer = stack(1000L, ScaleLayer.NORMAL, riverLayer, 2, contextProvider);
109118
riverLayer = stack(1000L, ScaleLayer.NORMAL, riverLayer, riverSize, contextProvider);
110119
riverLayer = NoiseToRiverLayer.INSTANCE.create(contextProvider.apply(1L), riverLayer);
111120
riverLayer = SmoothenShorelineLayer.INSTANCE.create(contextProvider.apply(1000L), riverLayer);
121+
112122
noiseLayer = AddSunflowerPlainsLayer.INSTANCE.create(contextProvider.apply(1001L), noiseLayer);
113123

114124
for (int k = 0; k < biomeSize; ++k) {
@@ -126,6 +136,7 @@ private static <T extends LayerSampler, C extends LayerSampleContext<T>> void bu
126136
noiseLayer = SmoothenShorelineLayer.INSTANCE.create(contextProvider.apply(1000L), noiseLayer);
127137
noiseLayer = AddRiversLayer.INSTANCE.create(contextProvider.apply(100L), noiseLayer, riverLayer);
128138
noiseLayer = ApplyOceanTemperatureLayer.INSTANCE.create(contextProvider.apply(100L), noiseLayer, layerFactory2);
139+
129140
LayerFactory<T> biomeLayer = CellScaleLayer.INSTANCE.create(contextProvider.apply(10L), noiseLayer);
130141
info.setReturnValue(ImmutableList.of(noiseLayer, biomeLayer, noiseLayer));
131142
}

patchwork-level-generators/src/main/java/net/patchworkmc/mixin/levelgenerators/MixinCreateWorldScreen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import net.minecraft.text.Text;
3434
import net.minecraft.world.level.LevelGeneratorType;
3535

36-
import net.patchworkmc.impl.levelgenerators.PatchworkGeneratorType;
36+
import net.patchworkmc.api.levelgenerators.PatchworkGeneratorType;
3737

3838
@Mixin(CreateWorldScreen.class)
3939
public abstract class MixinCreateWorldScreen extends Screen {
@@ -43,6 +43,7 @@ protected MixinCreateWorldScreen(Text title) {
4343

4444
@Shadow
4545
private int generatorType;
46+
@Shadow
4647
private MinecraftClient minecraft;
4748

4849
@Inject(at = @At("RETURN"), method = "method_19926")

patchwork-level-generators/src/main/java/net/patchworkmc/mixin/levelgenerators/MixinDimension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import net.minecraft.world.dimension.Dimension;
3232
import net.minecraft.world.level.LevelGeneratorType;
3333

34-
import net.patchworkmc.impl.levelgenerators.PatchworkGeneratorType;
34+
import net.patchworkmc.api.levelgenerators.PatchworkGeneratorType;
3535

3636
@Mixin(Dimension.class)
3737
public class MixinDimension {

patchwork-level-generators/src/main/java/net/patchworkmc/mixin/levelgenerators/MixinServerWorld.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import net.minecraft.world.dimension.DimensionType;
3434
import net.minecraft.world.level.LevelGeneratorType;
3535

36+
import net.patchworkmc.api.levelgenerators.PatchworkGeneratorType;
3637
import net.patchworkmc.impl.levelgenerators.ChunkManagerValues;
37-
import net.patchworkmc.impl.levelgenerators.PatchworkGeneratorType;
3838

3939
@Mixin(ServerWorld.class)
4040
public abstract class MixinServerWorld {
@@ -43,7 +43,15 @@ private static void createChunkGenerator(World world, Dimension dimension, Callb
4343
LevelGeneratorType generatorType = world.getLevelProperties().getGeneratorType();
4444

4545
if (generatorType instanceof PatchworkGeneratorType) {
46-
info.setReturnValue(new ServerChunkManager((ServerWorld) world, ChunkManagerValues.file, ChunkManagerValues.dataFixer, ChunkManagerValues.structureManager, ChunkManagerValues.workerExecutor, ((IForgeWorldType) generatorType).createChunkGenerator(world), ChunkManagerValues.viewDistance, ChunkManagerValues.progressListener, () -> {
46+
info.setReturnValue(new ServerChunkManager((ServerWorld) world,
47+
ChunkManagerValues.file,
48+
ChunkManagerValues.dataFixer,
49+
ChunkManagerValues.structureManager,
50+
ChunkManagerValues.workerExecutor,
51+
((IForgeWorldType) generatorType).createChunkGenerator(world),
52+
ChunkManagerValues.viewDistance,
53+
ChunkManagerValues.progressListener,
54+
() -> {
4755
return ChunkManagerValues.server.getWorld(DimensionType.OVERWORLD).getPersistentStateManager();
4856
}));
4957
}

patchwork-level-generators/src/main/java/net/patchworkmc/mixin/levelgenerators/MixinWorld.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import net.minecraft.world.level.LevelGeneratorType;
1313
import net.minecraft.world.level.LevelProperties;
1414

15-
import net.patchworkmc.impl.levelgenerators.PatchworkGeneratorType;
15+
import net.patchworkmc.api.levelgenerators.PatchworkGeneratorType;
1616

1717
@Mixin(World.class)
1818
public class MixinWorld {

0 commit comments

Comments
 (0)