From 9ad6e66aafcda4a172a4b839b6a66a2a6d124023 Mon Sep 17 00:00:00 2001 From: UselessBullets <80850784+UselessBullets@users.noreply.github.com> Date: Fri, 10 Nov 2023 13:48:26 -0600 Subject: [PATCH] More world types (#11) * Added Retro Worldtype API * Abstract decorator code slightly * Bug Fixes * Woods World type * Paradise Support * Floating Worldtype Support * added Hell WorldType * Tree Fix * Update OverworldInitialization.java --- .../terrainapi/TerrainInitialization.java | 131 ---------------- .../java/useless/terrainapi/TerrainMain.java | 1 + .../generation/ChunkDecoratorAPI.java | 28 +++- .../terrainapi/generation/Parameters.java | 7 +- .../api/ChunkGeneratorFloatingAPI.java | 14 ++ .../generation/hell/HellConfig.java | 10 ++ .../generation/hell/HellFunctions.java | 141 ++++++++++++++++++ .../api/ChunkDecoratorOverworldHellAPI.java | 106 +++++++++++++ .../api/ChunkGeneratorOverworldHellAPI.java | 13 ++ .../nether/api/ChunkDecoratorNetherAPI.java | 29 ++-- .../overworld/OverworldFunctions.java | 87 +++++++---- .../api/ChunkDecoratorOverworldAPI.java | 50 ++----- .../api/ChunkGeneratorParadiseAPI.java | 15 ++ .../generation/retro/RetroConfig.java | 6 + .../generation/retro/RetroFunctions.java | 77 ++++++++++ .../retro/api/ChunkDecoratorRetroAPI.java | 103 +++++++++++++ .../retro/api/ChunkGeneratorRetroAPI.java | 13 ++ .../api/ChunkGeneratorOverworldWoodsAPI.java | 14 ++ .../initialization/BaseInitialization.java | 19 +++ .../initialization/TerrainInitialization.java | 26 ++++ .../worldtypes/HellInitialization.java | 63 ++++++++ .../worldtypes/NetherInitialization.java | 40 +++++ .../worldtypes/OverworldInitialization.java | 119 +++++++++++++++ .../worldtypes/RetroInitialization.java | 64 ++++++++ .../worldtypes/WorldTypeFloatingMixin.java | 17 +++ .../worldtypes/WorldTypeNetherMixin.java | 18 +++ .../WorldTypeOverworldHellMixin.java | 17 +++ .../WorldTypeOverworldMixin.java | 2 +- .../WorldTypeOverworldRetroMixin.java | 18 +++ .../WorldTypeOverworldWoodsMixin.java | 18 +++ .../worldtypes/WorldTypeParadiseMixin.java | 18 +++ src/main/resources/fabric.mod.json | 2 +- src/main/resources/terrainapi.mixins.json | 8 +- 33 files changed, 1073 insertions(+), 221 deletions(-) delete mode 100644 src/main/java/useless/terrainapi/TerrainInitialization.java create mode 100644 src/main/java/useless/terrainapi/generation/floating/api/ChunkGeneratorFloatingAPI.java create mode 100644 src/main/java/useless/terrainapi/generation/hell/HellConfig.java create mode 100644 src/main/java/useless/terrainapi/generation/hell/HellFunctions.java create mode 100644 src/main/java/useless/terrainapi/generation/hell/api/ChunkDecoratorOverworldHellAPI.java create mode 100644 src/main/java/useless/terrainapi/generation/hell/api/ChunkGeneratorOverworldHellAPI.java create mode 100644 src/main/java/useless/terrainapi/generation/paradise/api/ChunkGeneratorParadiseAPI.java create mode 100644 src/main/java/useless/terrainapi/generation/retro/RetroConfig.java create mode 100644 src/main/java/useless/terrainapi/generation/retro/RetroFunctions.java create mode 100644 src/main/java/useless/terrainapi/generation/retro/api/ChunkDecoratorRetroAPI.java create mode 100644 src/main/java/useless/terrainapi/generation/retro/api/ChunkGeneratorRetroAPI.java create mode 100644 src/main/java/useless/terrainapi/generation/woods/api/ChunkGeneratorOverworldWoodsAPI.java create mode 100644 src/main/java/useless/terrainapi/initialization/BaseInitialization.java create mode 100644 src/main/java/useless/terrainapi/initialization/TerrainInitialization.java create mode 100644 src/main/java/useless/terrainapi/initialization/worldtypes/HellInitialization.java create mode 100644 src/main/java/useless/terrainapi/initialization/worldtypes/NetherInitialization.java create mode 100644 src/main/java/useless/terrainapi/initialization/worldtypes/OverworldInitialization.java create mode 100644 src/main/java/useless/terrainapi/initialization/worldtypes/RetroInitialization.java create mode 100644 src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeFloatingMixin.java create mode 100644 src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeNetherMixin.java create mode 100644 src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldHellMixin.java rename src/main/java/useless/terrainapi/mixin/{ => worldtypes}/WorldTypeOverworldMixin.java (95%) create mode 100644 src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldRetroMixin.java create mode 100644 src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldWoodsMixin.java create mode 100644 src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeParadiseMixin.java diff --git a/src/main/java/useless/terrainapi/TerrainInitialization.java b/src/main/java/useless/terrainapi/TerrainInitialization.java deleted file mode 100644 index 0675618..0000000 --- a/src/main/java/useless/terrainapi/TerrainInitialization.java +++ /dev/null @@ -1,131 +0,0 @@ -package useless.terrainapi; - -import net.minecraft.core.block.Block; -import net.minecraft.core.world.biome.Biome; -import net.minecraft.core.world.biome.Biomes; -import net.minecraft.core.world.generate.feature.*; -import useless.terrainapi.api.TerrainAPI; -import useless.terrainapi.generation.Parameters; -import useless.terrainapi.generation.nether.NetherFunctions; -import useless.terrainapi.generation.nether.api.ChunkDecoratorNetherAPI; -import useless.terrainapi.generation.overworld.OverworldConfig; -import useless.terrainapi.generation.overworld.OverworldFunctions; -import useless.terrainapi.generation.overworld.api.ChunkDecoratorOverworldAPI; - -public class TerrainInitialization implements TerrainAPI { - private static boolean hasInitialized = false; - private static final OverworldConfig overworldConfig = ChunkDecoratorOverworldAPI.overworldConfig; - @Override - public String getModID() { - return TerrainMain.MOD_ID; - } - @Override - public void onInitialize() { - if (hasInitialized) {return;} - hasInitialized = true; - initializeDefaultValues(); - - initializeOverworldStructures(); - initializeOverworldOre(); - initializeOverworldRandom(); - initializeOverworldBiome(); - - initializeNether(); - } - public static void initializeDefaultValues(){ - overworldConfig.setOreValues(TerrainMain.MOD_ID, Block.blockClay, 32, 20, 1f); - - overworldConfig.addGrassDensity(Biomes.OVERWORLD_FOREST, 2); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_MEADOW, 2); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_RAINFOREST, 10); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_DESERT, 5); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_SEASONAL_FOREST, 2); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_TAIGA, 1); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_BOREAL_FOREST, 5); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_PLAINS, 10); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_SWAMPLAND, 4); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_SHRUBLAND, 2); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_OUTBACK_GRASSY, 25); - overworldConfig.addGrassDensity(Biomes.OVERWORLD_BIRCH_FOREST, 10); - - overworldConfig.addFlowerDensity(Biomes.OVERWORLD_SEASONAL_FOREST, 1); - overworldConfig.addFlowerDensity(Biomes.OVERWORLD_MEADOW, 2); - overworldConfig.addFlowerDensity(Biomes.OVERWORLD_BOREAL_FOREST, 2); - overworldConfig.addFlowerDensity(Biomes.OVERWORLD_SHRUBLAND, 1); - - overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_FOREST, 2); - overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_SWAMPLAND, 2); - overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_TAIGA, 2); - overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_PLAINS, 3); - overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_OUTBACK_GRASSY, 2); - overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_OUTBACK, 2); - - overworldConfig.addTreeDensity(Biomes.OVERWORLD_FOREST, 5); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_BIRCH_FOREST, 4); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_RAINFOREST, 10); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_SEASONAL_FOREST, 2); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_TAIGA, 5); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_BOREAL_FOREST, 3); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_DESERT, -1000); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_TUNDRA, -1000); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_PLAINS, -1000); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_SWAMPLAND, 4); - overworldConfig.addTreeDensity(Biomes.OVERWORLD_OUTBACK_GRASSY, 0); - - overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_RAINFOREST, Block.tallgrassFern); - overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_SWAMPLAND, Block.tallgrassFern); - overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_BOREAL_FOREST, Block.tallgrassFern); - overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_TAIGA, Block.tallgrassFern); - - overworldConfig.addLakeDensity(Biomes.OVERWORLD_SWAMPLAND, 2); - overworldConfig.addLakeDensity(Biomes.OVERWORLD_DESERT, 0); - } - public static void initializeOverworldStructures() { - ChunkDecoratorOverworldAPI.structureFeatures.addFeature(OverworldFunctions::generateSwamp, null); - ChunkDecoratorOverworldAPI.structureFeatures.addFeature(OverworldFunctions::generateLakeFeature, null); - ChunkDecoratorOverworldAPI.structureFeatures.addFeature(OverworldFunctions::generateLavaLakeFeature, null); - ChunkDecoratorOverworldAPI.structureFeatures.addFeature(OverworldFunctions::generateDungeons, null); - ChunkDecoratorOverworldAPI.structureFeatures.addFeature(OverworldFunctions::generateLabyrinths, null); - } - public static void initializeOverworldOre(){ - String currentBlock = Block.blockClay.getKey(); - ChunkDecoratorOverworldAPI.oreFeatures.addFeature(new WorldFeatureClay(overworldConfig.clusterSize.get(currentBlock)), overworldConfig.chancesPerChunk.get(currentBlock), overworldConfig.verticalRange.get(currentBlock)); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.dirt, 32, 20, 1f, false); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.gravel, 32, 10, 1f, false); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreCoalStone, 16, 20, 1f, true); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreIronStone, 8, 20, 1/2f, true); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreGoldStone, 8, 2, 1/4f, true); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreRedstoneStone, 7, 8, 1/8f, true); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreDiamondStone, 7, 1, 1/8f, true); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.mossStone, 32, 1, 1/2f, true); - ChunkDecoratorOverworldAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreLapisStone, 6, 1, 1/8f, true); - } - public static void initializeOverworldRandom(){ - ChunkDecoratorOverworldAPI.randomFeatures.addFeature(new WorldFeatureFlowers(Block.flowerRed.id), 2, 1); - ChunkDecoratorOverworldAPI.randomFeatures.addFeature(new WorldFeatureFlowers(Block.mushroomBrown.id), 4, 1); - ChunkDecoratorOverworldAPI.randomFeatures.addFeature(new WorldFeatureFlowers(Block.mushroomRed.id), 8, 1); - ChunkDecoratorOverworldAPI.randomFeatures.addFeatureSurface(new WorldFeatureSugarCane(), 5); - ChunkDecoratorOverworldAPI.randomFeatures.addFeatureSurface(new WorldFeaturePumpkin(), 128); - ChunkDecoratorOverworldAPI.randomFeatures.addFeatureSurface(new WorldFeatureSponge(), 64); - } - public static void initializeOverworldBiome(){ - ChunkDecoratorOverworldAPI.biomeFeatures.addFeatureSurface(new WorldFeatureRichScorchedDirt(10), 1, new Biome[]{Biomes.OVERWORLD_OUTBACK, Biomes.OVERWORLD_OUTBACK_GRASSY}); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeature(OverworldFunctions::getTreeFeature, null, OverworldFunctions::getTreeDensity, null, -1f); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeatureSurface(new WorldFeatureSugarCaneTall(), 1, new Biome[]{Biomes.OVERWORLD_RAINFOREST}); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeature(OverworldFunctions::flowerTypeCondition, null, (Parameters x) -> ChunkDecoratorOverworldAPI.overworldConfig.getFlowerDensity(x.biome, 0), null, 1f); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeature((Parameters x) -> new WorldFeatureFlowers(Block.flowerYellow.id), null, (Parameters x) -> ChunkDecoratorOverworldAPI.overworldConfig.getYellowFlowerDensity(x.biome, 0), null, 1); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeature(OverworldFunctions::grassTypeCondition, null, (Parameters x) -> ChunkDecoratorOverworldAPI.overworldConfig.getGrassDensity(x.biome, 0), null, 1); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeature(new WorldFeatureSpinifexPatch(), 1, 4, new Biome[]{Biomes.OVERWORLD_OUTBACK}); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeature(new WorldFeatureDeadBush(Block.deadbush.id), 1, 2, new Biome[]{Biomes.OVERWORLD_DESERT}); - ChunkDecoratorOverworldAPI.biomeFeatures.addFeature(new WorldFeatureCactus(), 1, 10, new Biome[]{Biomes.OVERWORLD_DESERT}); - } - public static void initializeNether(){ - ChunkDecoratorNetherAPI.oreFeatures.addFeature(new WorldFeatureNetherLava(Block.fluidLavaFlowing.id), 8,120/128f); - ChunkDecoratorNetherAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreNethercoalNetherrack, 12, 10, 120/128f, false); - ChunkDecoratorNetherAPI.oreFeatures.addFeature((Parameters x) -> new WorldFeatureFire(), null, NetherFunctions::netherFireDensity, null, 120/128f); - ChunkDecoratorNetherAPI.oreFeatures.addFeature((Parameters x) -> new WorldFeatureGlowstoneA(), null, NetherFunctions::netherFireDensity, null, 120/128f); - ChunkDecoratorNetherAPI.oreFeatures.addFeature(new WorldFeatureGlowstoneB(), 10, 120/128f); - ChunkDecoratorNetherAPI.randomFeatures.addFeature(new WorldFeatureLake(Block.fluidLavaStill.id), 8, 120/128f); - } -} - diff --git a/src/main/java/useless/terrainapi/TerrainMain.java b/src/main/java/useless/terrainapi/TerrainMain.java index fe982ec..1a65483 100644 --- a/src/main/java/useless/terrainapi/TerrainMain.java +++ b/src/main/java/useless/terrainapi/TerrainMain.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; import useless.terrainapi.api.TerrainAPI; import useless.terrainapi.config.ConfigManager; +import useless.terrainapi.initialization.TerrainInitialization; public class TerrainMain implements ModInitializer { diff --git a/src/main/java/useless/terrainapi/generation/ChunkDecoratorAPI.java b/src/main/java/useless/terrainapi/generation/ChunkDecoratorAPI.java index 80f054d..be4b68d 100644 --- a/src/main/java/useless/terrainapi/generation/ChunkDecoratorAPI.java +++ b/src/main/java/useless/terrainapi/generation/ChunkDecoratorAPI.java @@ -1,6 +1,7 @@ package useless.terrainapi.generation; import net.minecraft.core.block.Block; +import net.minecraft.core.block.BlockSand; import net.minecraft.core.world.World; import net.minecraft.core.world.biome.Biome; import net.minecraft.core.world.chunk.Chunk; @@ -17,6 +18,8 @@ public abstract class ChunkDecoratorAPI implements ChunkDecorator { public final int maxY; public final int rangeY; public final float oreHeightModifier; + public long chunkSeed; + protected Parameters parameterBase; protected ChunkDecoratorAPI(World world) { this.world = world; @@ -26,8 +29,31 @@ protected ChunkDecoratorAPI(World world) { this.oreHeightModifier = (float)rangeY / 128.0f; } @Override + public void decorate(Chunk chunk){ + int chunkX = chunk.xPosition; + int chunkZ = chunk.zPosition; + + int xCoord = chunkX * 16; + int zCoord = chunkZ * 16; + int yCoord = this.world.getHeightValue(xCoord + 16, zCoord + 16); + + Biome biome = this.world.getBlockBiome(xCoord + 16, yCoord, zCoord + 16); + + Random random = new Random(this.world.getRandomSeed()); + long l1 = random.nextLong() / 2L * 2L + 1L; + long l2 = random.nextLong() / 2L * 2L + 1L; + chunkSeed = (long)chunkX * l1 + (long)chunkZ * l2 ^ this.world.getRandomSeed(); + random.setSeed(chunkSeed); + parameterBase = new Parameters(biome, random, chunk, this); + + BlockSand.fallInstantly = true; + + decorateAPI(); + + BlockSand.fallInstantly = false; + } @ApiStatus.Internal - public abstract void decorate(Chunk chunk); + public abstract void decorateAPI(); @ApiStatus.Internal public abstract void generateStructures(Biome biome, Chunk chunk, Random random); @ApiStatus.Internal diff --git a/src/main/java/useless/terrainapi/generation/Parameters.java b/src/main/java/useless/terrainapi/generation/Parameters.java index 594f198..81940e2 100644 --- a/src/main/java/useless/terrainapi/generation/Parameters.java +++ b/src/main/java/useless/terrainapi/generation/Parameters.java @@ -2,7 +2,6 @@ import net.minecraft.core.world.biome.Biome; import net.minecraft.core.world.chunk.Chunk; -import net.minecraft.core.world.generate.chunk.ChunkDecorator; import java.util.Random; @@ -13,13 +12,13 @@ public class Parameters { public Biome biome; public Random random; public Chunk chunk; - public ChunkDecorator decorator; + public ChunkDecoratorAPI decorator; public Object[] customParameters = new Object[0]; - public Parameters(Biome biome, Random random, Chunk chunk, ChunkDecorator chunkDecorator, Object[] customParameters){ + public Parameters(Biome biome, Random random, Chunk chunk, ChunkDecoratorAPI chunkDecorator, Object[] customParameters){ this(biome, random, chunk, chunkDecorator); this.customParameters = customParameters; } - public Parameters(Biome biome, Random random, Chunk chunk, ChunkDecorator chunkDecorator){ + public Parameters(Biome biome, Random random, Chunk chunk, ChunkDecoratorAPI chunkDecorator){ this.biome = biome; this.random = random; this.chunk = chunk; diff --git a/src/main/java/useless/terrainapi/generation/floating/api/ChunkGeneratorFloatingAPI.java b/src/main/java/useless/terrainapi/generation/floating/api/ChunkGeneratorFloatingAPI.java new file mode 100644 index 0000000..7bcf957 --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/floating/api/ChunkGeneratorFloatingAPI.java @@ -0,0 +1,14 @@ +package useless.terrainapi.generation.floating.api; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.MapGenCaves; +import net.minecraft.core.world.generate.chunk.perlin.ChunkGeneratorPerlin; +import net.minecraft.core.world.generate.chunk.perlin.overworld.SurfaceGeneratorOverworld; +import net.minecraft.core.world.generate.chunk.perlin.paradise.TerrainGeneratorParadise; +import useless.terrainapi.generation.overworld.api.ChunkDecoratorOverworldAPI; + +public class ChunkGeneratorFloatingAPI extends ChunkGeneratorPerlin { + public ChunkGeneratorFloatingAPI(World world) { + super(world, new ChunkDecoratorOverworldAPI(world), new TerrainGeneratorParadise(world), new SurfaceGeneratorOverworld(world), new MapGenCaves(false)); + } +} diff --git a/src/main/java/useless/terrainapi/generation/hell/HellConfig.java b/src/main/java/useless/terrainapi/generation/hell/HellConfig.java new file mode 100644 index 0000000..de95363 --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/hell/HellConfig.java @@ -0,0 +1,10 @@ +package useless.terrainapi.generation.hell; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import useless.terrainapi.config.OreConfig; + +public class HellConfig extends OreConfig { + @SerializedName("Inverse Leaves Probability") @Expose + public int invLeavesProbability = 1234; +} diff --git a/src/main/java/useless/terrainapi/generation/hell/HellFunctions.java b/src/main/java/useless/terrainapi/generation/hell/HellFunctions.java new file mode 100644 index 0000000..e505bac --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/hell/HellFunctions.java @@ -0,0 +1,141 @@ +package useless.terrainapi.generation.hell; + +import net.minecraft.core.block.Block; +import net.minecraft.core.world.generate.feature.WorldFeature; +import net.minecraft.core.world.generate.feature.WorldFeatureLabyrinth; +import net.minecraft.core.world.generate.feature.WorldFeatureLake; +import net.minecraft.core.world.generate.feature.WorldFeatureLiquid; +import net.minecraft.core.world.generate.feature.tree.WorldFeatureTree; +import net.minecraft.core.world.generate.feature.tree.WorldFeatureTreeFancy; +import org.jetbrains.annotations.Nullable; +import useless.terrainapi.generation.Parameters; +import useless.terrainapi.generation.hell.api.ChunkDecoratorOverworldHellAPI; + +import java.util.Random; + +public class HellFunctions { + public static HellConfig hellConfig = ChunkDecoratorOverworldHellAPI.hellConfig; + /**Vanilla labyrinth generation code + * @param parameters Parameters Container + * @return null + */ + @Nullable + public static Void generateLabyrinths(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + for (int i = 0; i < 1; ++i) { + int xPos = x + parameters.random.nextInt(16) + 8; + int zPos = z + parameters.random.nextInt(16) + 8; + int yPos = parameters.decorator.world.getHeightValue(xPos, zPos) - (parameters.random.nextInt(2) + 2); + if (parameters.random.nextInt(10) == 0) { + yPos -= parameters.random.nextInt(10) + 30; + } + if (parameters.random.nextInt(512) != 0) continue; + Random lRand = parameters.chunk.getChunkRandom(75644760L); + new WorldFeatureLabyrinth().generate(parameters.decorator.world, lRand, xPos, yPos, zPos); + } + return null; + } + + /**Vanilla random fluid generation code, takes two custom parameters (int)Chances and (int)BlockID + * @param parameters Parameters Container + * @return null + */ + public static Void generateRandomFluid(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + int chances = (int) parameters.customParameters[0]; + int fluidId = (int) parameters.customParameters[1]; + for (int i = 0; i < chances; ++i) { + int blockX = x + parameters.random.nextInt(16) + 8; + int blockY = parameters.decorator.minY + parameters.random.nextInt(parameters.random.nextInt(parameters.decorator.rangeY - 8) + 8); + int blockZ = z + parameters.random.nextInt(16) + 8; + new WorldFeatureLiquid(fluidId).generate(parameters.decorator.world, parameters.random, blockX, blockY, blockZ); + } + return null; + } + + /**Vanilla lava lake generation code + * @param parameters Parameters Container + * @return null + */ + @Nullable + public static Void generateLavaLakeFeature(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + if (parameters.random.nextInt(32) == 0) { + int xf = x + parameters.random.nextInt(16) + 8; + int yf = parameters.decorator.minY + parameters.random.nextInt(parameters.decorator.rangeY); + int zf = z + parameters.random.nextInt(16) + 8; + if (yf < parameters.decorator.minY + parameters.decorator.rangeY / 2 || parameters.random.nextInt(10) == 0) { + new WorldFeatureLake(Block.fluidLavaStill.id).generate(parameters.decorator.world, parameters.random, xf, yf, zf); + } + } + return null; + } + /**Vanilla obsidian lava lake generation code + * @param parameters Parameters Container + * @return null + */ + @Nullable + public static Void generateObsidianLakeFeature(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + if (parameters.random.nextInt(16) == 0) { + int j1 = x + parameters.random.nextInt(16) + 8; + int i5 = parameters.decorator.minY + parameters.random.nextInt(parameters.decorator.rangeY - 16) + 8; + int j8 = z + parameters.random.nextInt(16) + 8; + if (i5 < parameters.decorator.minY + parameters.decorator.rangeY / 2 || parameters.random.nextInt(10) == 0) { + if (parameters.random.nextInt(4) == 0) { + new WorldFeatureLake(Block.obsidian.id).generate(parameters.decorator.world, parameters.random, j1, i5, j8); + } else { + new WorldFeatureLake(Block.fluidLavaStill.id).generate(parameters.decorator.world, parameters.random, j1, i5, j8); + } + } + } + return null; + } + + /**Vanilla tree feature generator + * @param parameters Parameters Container + * @return Tree feature as specified by Biome#getRandomWorldGenForTrees + */ + public static WorldFeature getTreeFeature(Parameters parameters){ + boolean hasLeaves = parameters.random.nextInt(hellConfig.invLeavesProbability) == 0; + WorldFeature tree = parameters.random.nextInt(10) == 0 ? new WorldFeatureTreeFancy(hasLeaves ? Block.leavesOak.id : 0, Block.logOak.id) : new WorldFeatureTree(hasLeaves ? Block.leavesOak.id : 0, Block.logOak.id, 4); + tree.func_517_a(1.0, 1.0, 1.0); + return tree; + } + + /**Vanilla tree density + * @param parameters Parameters Container + * @return treeDensityOverride if applicable, otherwise returns the biome's tree density from OverworldConfig's tree density hashmap + */ + public static Integer getTreeDensity(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + double d = 0.5; + ChunkDecoratorOverworldHellAPI decoratorHell = (ChunkDecoratorOverworldHellAPI) parameters.decorator; + int treeDensity = (int)((decoratorHell.treeDensityNoise.get((double)x * d, (double)z * d) / 8.0 + parameters.random.nextDouble() * 4.0 + 4.0) / 3.0); + if (parameters.random.nextInt(10) == 0) { + ++treeDensity; + } + return treeDensity/2; + } + + /**Vanilla hell tree generator + * @param parameters Parameters Container, takes two custom parameters getTreeFeature function and getTreeDensity function + * @return null + */ + public static Void generateTrees(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + for (int i = 0; i < getTreeDensity(parameters); i++) { + int xf = x + parameters.random.nextInt(16) + 8; + int zf = z + parameters.random.nextInt(16) + 8; + int yf = parameters.decorator.world.getHeightValue(xf, zf); + getTreeFeature(parameters).generate(parameters.decorator.world, parameters.random, xf, yf, zf); + } + return null; + } +} diff --git a/src/main/java/useless/terrainapi/generation/hell/api/ChunkDecoratorOverworldHellAPI.java b/src/main/java/useless/terrainapi/generation/hell/api/ChunkDecoratorOverworldHellAPI.java new file mode 100644 index 0000000..012e5ca --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/hell/api/ChunkDecoratorOverworldHellAPI.java @@ -0,0 +1,106 @@ +package useless.terrainapi.generation.hell.api; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.biome.Biome; +import net.minecraft.core.world.chunk.Chunk; +import net.minecraft.core.world.generate.feature.WorldFeature; +import net.minecraft.core.world.noise.PerlinNoise; +import org.jetbrains.annotations.ApiStatus; +import useless.terrainapi.config.ConfigManager; +import useless.terrainapi.generation.ChunkDecoratorAPI; +import useless.terrainapi.generation.Parameters; +import useless.terrainapi.generation.StructureFeatures; +import useless.terrainapi.generation.hell.HellConfig; +import useless.terrainapi.generation.overworld.OverworldBiomeFeatures; +import useless.terrainapi.generation.overworld.OverworldOreFeatures; +import useless.terrainapi.generation.overworld.OverworldRandomFeatures; + +import java.util.Random; + +public class ChunkDecoratorOverworldHellAPI extends ChunkDecoratorAPI { + public final PerlinNoise treeDensityNoise; + public static HellConfig hellConfig = ConfigManager.getConfig("hell", HellConfig.class); + public static StructureFeatures structureFeatures = new StructureFeatures(); + public static OverworldOreFeatures oreFeatures = new OverworldOreFeatures(hellConfig); + public static OverworldRandomFeatures randomFeatures = new OverworldRandomFeatures(); + public static OverworldBiomeFeatures biomeFeatures = new OverworldBiomeFeatures(); + protected ChunkDecoratorOverworldHellAPI(World world) { + super(world); + this.treeDensityNoise = new PerlinNoise(world.getRandomSeed(), 8, 74); + } + + @Override + @ApiStatus.Internal + public void decorateAPI() { + int xCoord = parameterBase.chunk.xPosition * 16; + int zCoord = parameterBase.chunk.zPosition * 16; + + generateStructures(parameterBase.biome, parameterBase.chunk, parameterBase.random); + generateOreFeatures(parameterBase.biome, xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateBiomeFeature(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateRandomFeatures(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); + + if (this.world.getBlockId(xCoord, minY + this.world.getWorldType().getOceanY() - 1, zCoord) == this.world.getWorldType().getOceanBlock()) { + this.world.setBlockWithNotify(xCoord, minY + this.world.getWorldType().getOceanY() - 1, zCoord, this.world.getWorldType().getOceanBlock()); + } + } + @ApiStatus.Internal + public void generateStructures(Biome biome, Chunk chunk, Random random){ + int featureSize = structureFeatures.featureFunctionList.size(); + for (int i = 0; i < featureSize; i++) { + structureFeatures.featureFunctionList.get(i) + .apply(new Parameters(parameterBase, structureFeatures.featureParametersList.get(i))); + } + } + @ApiStatus.Internal + public void generateOreFeatures(Biome biome, int x, int z, Random random, Chunk chunk){ + int featureSize = oreFeatures.featureFunctionsList.size(); + for (int i = 0; i < featureSize; i++) { + WorldFeature feature = oreFeatures.featureFunctionsList.get(i) + .apply(new Parameters(parameterBase, oreFeatures.featureParametersList.get(i))); + + int density = oreFeatures.densityFunctionsList.get(i) + .apply(new Parameters(parameterBase, oreFeatures.densityParametersList.get(i))); + + float rangeModifier = oreFeatures.rangeModifierList.get(i); + generateWithChancesUnderground(feature, density, (int) (rangeModifier * rangeY), x, z, random); + } + } + @ApiStatus.Internal + public void generateRandomFeatures(Biome biome, int x, int z, Random random, Chunk chunk){ + int featureSize = randomFeatures.featureFunctionsList.size(); + for (int i = 0; i < featureSize; i++) { + if (random.nextInt(randomFeatures.inverseProbabilityList.get(i)) != 0) {continue;} + WorldFeature feature = randomFeatures.featureFunctionsList.get(i) + .apply(new Parameters(parameterBase, randomFeatures.featureParametersList.get(i))); + + int density = randomFeatures.densityFunctionsList.get(i) + .apply(new Parameters(parameterBase, randomFeatures.densityParametersList.get(i))); + + float rangeModifier = randomFeatures.rangeModifierList.get(i); + if (-1.01 <= rangeModifier && rangeModifier <= -0.99){ + generateWithChancesSurface(feature, density, x, z, 8, 8, random); + } else { + generateWithChancesUnderground(feature, density, (int) (rangeModifier * rangeY), x, z, 8, 8, random); + } + } + } + @ApiStatus.Internal + public void generateBiomeFeature(Biome biome, int x, int z, Random random, Chunk chunk){ + int featureSize = biomeFeatures.featureFunctionsList.size(); + for (int i = 0; i < featureSize; i++) { + WorldFeature feature = biomeFeatures.featureFunctionsList.get(i) + .apply(new Parameters(parameterBase, biomeFeatures.featureParametersList.get(i))); + + int density = biomeFeatures.densityFunctionsList.get(i) + .apply(new Parameters(parameterBase, biomeFeatures.densityParametersList.get(i))); + + float rangeModifier = biomeFeatures.rangeModifierList.get(i); + if (-1.01 <= rangeModifier && rangeModifier <= -0.99){ + generateWithChancesSurface(feature, density, x, z, 8, 8, random); + } else { + generateWithChancesUnderground(feature, density, (int) (rangeModifier * rangeY), x, z, 8, 8, random); + } + } + } +} diff --git a/src/main/java/useless/terrainapi/generation/hell/api/ChunkGeneratorOverworldHellAPI.java b/src/main/java/useless/terrainapi/generation/hell/api/ChunkGeneratorOverworldHellAPI.java new file mode 100644 index 0000000..e2de6e0 --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/hell/api/ChunkGeneratorOverworldHellAPI.java @@ -0,0 +1,13 @@ +package useless.terrainapi.generation.hell.api; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.MapGenCaves; +import net.minecraft.core.world.generate.chunk.perlin.ChunkGeneratorPerlin; +import net.minecraft.core.world.generate.chunk.perlin.overworld.SurfaceGeneratorOverworld; +import net.minecraft.core.world.generate.chunk.perlin.overworld.TerrainGeneratorOverworld; + +public class ChunkGeneratorOverworldHellAPI extends ChunkGeneratorPerlin { + public ChunkGeneratorOverworldHellAPI(World world) { + super(world, new ChunkDecoratorOverworldHellAPI(world), new TerrainGeneratorOverworld(world), new SurfaceGeneratorOverworld(world), new MapGenCaves(false)); + } +} diff --git a/src/main/java/useless/terrainapi/generation/nether/api/ChunkDecoratorNetherAPI.java b/src/main/java/useless/terrainapi/generation/nether/api/ChunkDecoratorNetherAPI.java index 127e597..0fd7a70 100644 --- a/src/main/java/useless/terrainapi/generation/nether/api/ChunkDecoratorNetherAPI.java +++ b/src/main/java/useless/terrainapi/generation/nether/api/ChunkDecoratorNetherAPI.java @@ -23,35 +23,42 @@ public class ChunkDecoratorNetherAPI extends ChunkDecoratorAPI { public static NetherOreFeatures oreFeatures = new NetherOreFeatures(netherConfig); public static NetherRandomFeatures randomFeatures = new NetherRandomFeatures(); public static NetherBiomeFeatures biomeFeatures = new NetherBiomeFeatures(); - private Parameters parameterBase; protected ChunkDecoratorNetherAPI(World world) { super(world); } @Override - @ApiStatus.Internal public void decorate(Chunk chunk) { int chunkX = chunk.xPosition; int chunkZ = chunk.zPosition; + int xCoord = chunkX * 16; int zCoord = chunkZ * 16; - Random random = new Random((long)chunkX * 341873128712L + (long)chunkZ * 132897987541L); - Random structureRand = new Random((long)chunkX * 341873128712L + (long)chunkZ * 341873128712L); + int yCoord = this.world.getHeightValue(xCoord + 16, zCoord + 16); - Biome biome = this.world.getBlockBiome(xCoord + 16, maxY-1, zCoord + 16); + Biome biome = this.world.getBlockBiome(xCoord + 16, yCoord, zCoord + 16); - BlockSand.fallInstantly = true; + chunkSeed = (long)chunkX * 341873128712L + (long)chunkZ * 132897987541L; + Random random = new Random(chunkSeed); parameterBase = new Parameters(biome, random, chunk, this); - generateStructures(biome, chunk, structureRand); - generateOreFeatures(biome, xCoord, zCoord, random, chunk); - generateBiomeFeature(biome,xCoord, zCoord, random, chunk); - generateRandomFeatures(biome,xCoord, zCoord, random, chunk); - + BlockSand.fallInstantly = true; + decorateAPI(); BlockSand.fallInstantly = false; } + @Override + @ApiStatus.Internal + public void decorateAPI() { + int xCoord = parameterBase.chunk.xPosition * 16; + int zCoord = parameterBase.chunk.zPosition * 16; + generateStructures(parameterBase.biome, parameterBase.chunk, parameterBase.random); + generateOreFeatures(parameterBase.biome, xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateBiomeFeature(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateRandomFeatures(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); + } + @ApiStatus.Internal public void generateStructures(Biome biome, Chunk chunk, Random random){ int featureSize = structureFeatures.featureFunctionList.size(); diff --git a/src/main/java/useless/terrainapi/generation/overworld/OverworldFunctions.java b/src/main/java/useless/terrainapi/generation/overworld/OverworldFunctions.java index 69ca54e..98d75fd 100644 --- a/src/main/java/useless/terrainapi/generation/overworld/OverworldFunctions.java +++ b/src/main/java/useless/terrainapi/generation/overworld/OverworldFunctions.java @@ -99,7 +99,7 @@ public static int getStandardBiomesDensity(Parameters parameters){ * @return number of chances per chunk scaled by the oreHeightModifier if in valid biome */ public static int getStandardOreBiomesDensity(Parameters parameters){ - float oreHeightModifier = ((ChunkDecoratorOverworldAPI) parameters.decorator).oreHeightModifier; + float oreHeightModifier = parameters.decorator.oreHeightModifier; int chance = (int) parameters.customParameters[0]; Biome[] biomes = (Biome[]) parameters.customParameters[1]; if (biomes == null) {return chance;} @@ -116,15 +116,14 @@ public static int getStandardOreBiomesDensity(Parameters parameters){ public static Void generateDungeons(Parameters parameters){ int x = parameters.chunk.xPosition * 16; int z = parameters.chunk.zPosition * 16; - ChunkDecoratorOverworldAPI decoratorOverworldAPI = (ChunkDecoratorOverworldAPI) parameters.decorator; - for (int i = 0; i < 8.0f * decoratorOverworldAPI.oreHeightModifier; i++) { + for (int i = 0; i < 8.0f * parameters.decorator.oreHeightModifier; i++) { int xPos = x + parameters.random.nextInt(16) + 8; - int yPos = decoratorOverworldAPI.minY + parameters.random.nextInt(decoratorOverworldAPI.rangeY); + int yPos = parameters.decorator.minY + parameters.random.nextInt(parameters.decorator.rangeY); int zPos = z + parameters.random.nextInt(16) + 8; if (parameters.random.nextInt(2) == 0){ - new WorldFeatureDungeon(Block.brickClay.id, Block.brickClay.id, null).generate(decoratorOverworldAPI.world, parameters.random, xPos, yPos, zPos); + new WorldFeatureDungeon(Block.brickClay.id, Block.brickClay.id, null).generate(parameters.decorator.world, parameters.random, xPos, yPos, zPos); } else { - new WorldFeatureDungeon(Block.cobbleStone.id, Block.cobbleStoneMossy.id, null).generate(decoratorOverworldAPI.world, parameters.random, xPos, yPos, zPos); + new WorldFeatureDungeon(Block.cobbleStone.id, Block.cobbleStoneMossy.id, null).generate(parameters.decorator.world, parameters.random, xPos, yPos, zPos); } } return null; @@ -136,19 +135,18 @@ public static Void generateDungeons(Parameters parameters){ */ @Nullable public static Void generateLabyrinths(Parameters parameters){ - ChunkDecoratorOverworldAPI decorator = (ChunkDecoratorOverworldAPI) parameters.decorator; int x = parameters.chunk.xPosition * 16; int z = parameters.chunk.zPosition * 16; for (int i = 0; i < 1; ++i) { int xPos = x + parameters.random.nextInt(16) + 8; int zPos = z + parameters.random.nextInt(16) + 8; - int yPos = decorator.world.getHeightValue(xPos, zPos) - (parameters.random.nextInt(2) + 2); + int yPos = parameters.decorator.world.getHeightValue(xPos, zPos) - (parameters.random.nextInt(2) + 2); if (parameters.random.nextInt(5) == 0) { yPos -= parameters.random.nextInt(10) + 30; } if (parameters.random.nextInt(700) != 0) continue; Random lRand = parameters.chunk.getChunkRandom(75644760L); - new WorldFeatureLabyrinth().generate(decorator.world, lRand, xPos, yPos, zPos); + new WorldFeatureLabyrinth().generate(parameters.decorator.world, lRand, xPos, yPos, zPos); } return null; } @@ -161,27 +159,26 @@ public static Void generateSwamp(Parameters parameters){ if (parameters.biome != Biomes.OVERWORLD_SWAMPLAND) return null; int x = parameters.chunk.xPosition * 16; int z = parameters.chunk.zPosition * 16; - ChunkDecoratorOverworldAPI decorator = (ChunkDecoratorOverworldAPI) parameters.decorator; - Random swampRand = new Random(decorator.chunkSeed); + Random swampRand = new Random(parameters.decorator.chunkSeed); for (int dx = 0; dx < 16; ++dx) { for (int dz = 0; dz < 16; ++dz) { if (!(swampRand.nextFloat() < 0.5f)) continue; - int topBlock = decorator.world.getHeightValue(x + dx, z + dz); - int id = decorator.world.getBlockId(x + dx, topBlock - 1, z + dz); + int topBlock = parameters.decorator.world.getHeightValue(x + dx, z + dz); + int id = parameters.decorator.world.getBlockId(x + dx, topBlock - 1, z + dz); if (id != Block.grass.id) continue; - int posXId = decorator.world.getBlockId(x + dx + 1, topBlock - 1, z + dz); + int posXId = parameters.decorator.world.getBlockId(x + dx + 1, topBlock - 1, z + dz); if (posXId == 0) continue; - int negXId = decorator.world.getBlockId(x + dx - 1, topBlock - 1, z + dz); + int negXId = parameters.decorator.world.getBlockId(x + dx - 1, topBlock - 1, z + dz); if (negXId == 0) continue; - int posZId = decorator.world.getBlockId(x + dx, topBlock - 1, z + dz + 1); + int posZId = parameters.decorator.world.getBlockId(x + dx, topBlock - 1, z + dz + 1); if (posZId == 0) continue; - int negZId = decorator.world.getBlockId(x + dx, topBlock - 1, z + dz - 1); + int negZId = parameters.decorator.world.getBlockId(x + dx, topBlock - 1, z + dz - 1); if (negZId == 0) continue; - int negYId = decorator.world.getBlockId(x + dx, topBlock - 2, z + dz); + int negYId = parameters.decorator.world.getBlockId(x + dx, topBlock - 2, z + dz); if (negYId == 0) continue; if ((!Block.blocksList[posXId].blockMaterial.isSolid() && Block.blocksList[posXId].blockMaterial != Material.water) @@ -189,8 +186,8 @@ public static Void generateSwamp(Parameters parameters){ || (!Block.blocksList[posZId].blockMaterial.isSolid() && Block.blocksList[posZId].blockMaterial != Material.water) || (!Block.blocksList[negZId].blockMaterial.isSolid() && Block.blocksList[negZId].blockMaterial != Material.water) || !Block.blocksList[negYId].blockMaterial.isSolid()) continue; - decorator.world.setBlock(x + dx, topBlock - 1, z + dz, Block.fluidWaterStill.id); - decorator.world.setBlock(x + dx, topBlock, z + dz, 0); + parameters.decorator.world.setBlock(x + dx, topBlock - 1, z + dz, Block.fluidWaterStill.id); + parameters.decorator.world.setBlock(x + dx, topBlock, z + dz, 0); } } return null; @@ -205,17 +202,15 @@ public static Void generateLakeFeature(Parameters parameters){ int x = parameters.chunk.xPosition * 16; int z = parameters.chunk.zPosition * 16; - ChunkDecoratorOverworldAPI decorator = (ChunkDecoratorOverworldAPI) parameters.decorator; - if (lakeChance != 0 && parameters.random.nextInt(lakeChance) == 0) { int fluid = Block.fluidWaterStill.id; if (parameters.biome.hasSurfaceSnow()) { fluid = Block.ice.id; } - int i1 = x + parameters.random.nextInt(16) + 8; - int l4 = decorator.minY + parameters.random.nextInt(decorator.rangeY); - int i8 = z + parameters.random.nextInt(16) + 8; - new WorldFeatureLake(fluid).generate(decorator.world, parameters.random, i1, l4, i8); + int xf = x + parameters.random.nextInt(16) + 8; + int yf = parameters.decorator.minY + parameters.random.nextInt(parameters.decorator.rangeY); + int zf = z + parameters.random.nextInt(16) + 8; + new WorldFeatureLake(fluid).generate(parameters.decorator.world, parameters.random, xf, yf, zf); } return null; } @@ -227,15 +222,47 @@ public static Void generateLakeFeature(Parameters parameters){ public static Void generateLavaLakeFeature(Parameters parameters){ int x = parameters.chunk.xPosition * 16; int z = parameters.chunk.zPosition * 16; - ChunkDecoratorOverworldAPI decorator = (ChunkDecoratorOverworldAPI) parameters.decorator; if (parameters.random.nextInt(8) == 0) { int xf = x + parameters.random.nextInt(16) + 8; - int yf = decorator.minY + parameters.random.nextInt(parameters.random.nextInt(decorator.rangeY - decorator.rangeY / 16) + decorator.rangeY / 16); + int yf = parameters.decorator.minY + parameters.random.nextInt(parameters.random.nextInt(parameters.decorator.rangeY - parameters.decorator.rangeY / 16) + parameters.decorator.rangeY / 16); int zf = z + parameters.random.nextInt(16) + 8; - if (yf < decorator.minY + decorator.rangeY / 2 || parameters.random.nextInt(10) == 0) { - new WorldFeatureLake(Block.fluidLavaStill.id).generate(decorator.world, parameters.random, xf, yf, zf); + if (yf < parameters.decorator.minY + parameters.decorator.rangeY / 2 || parameters.random.nextInt(10) == 0) { + new WorldFeatureLake(Block.fluidLavaStill.id).generate(parameters.decorator.world, parameters.random, xf, yf, zf); } } return null; } + /**Vanilla random fluid generation code, takes two custom parameters (int)Chances and (int)BlockID + * @param parameters Parameters Container + * @return null + */ + public static Void generateRandomFluid(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + int chances = (int) parameters.customParameters[0]; + int fluidId = (int) parameters.customParameters[1]; + for (int i = 0; i < chances; ++i) { + int blockX = x + parameters.random.nextInt(16) + 8; + int blockY = parameters.decorator.minY + parameters.random.nextInt(parameters.random.nextInt(parameters.decorator.rangeY - 8) + 8); + int blockZ = z + parameters.random.nextInt(16) + 8; + new WorldFeatureLiquid(fluidId).generate(parameters.decorator.world, parameters.random, blockX, blockY, blockZ); + } + return null; + } + + /**Vanilla tree generator + * @param parameters Parameters Container, takes two custom parameters getTreeFeature function and getTreeDensity function + * @return null + */ + public static Void generateTrees(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + for (int i = 0; i < getTreeDensity(parameters); i++) { + int xf = x + parameters.random.nextInt(16) + 8; + int zf = z + parameters.random.nextInt(16) + 8; + int yf = parameters.decorator.world.getHeightValue(xf, zf); + getTreeFeature(parameters).generate(parameters.decorator.world, parameters.random, xf, yf, zf); + } + return null; + } } diff --git a/src/main/java/useless/terrainapi/generation/overworld/api/ChunkDecoratorOverworldAPI.java b/src/main/java/useless/terrainapi/generation/overworld/api/ChunkDecoratorOverworldAPI.java index 20655ba..d3530ed 100644 --- a/src/main/java/useless/terrainapi/generation/overworld/api/ChunkDecoratorOverworldAPI.java +++ b/src/main/java/useless/terrainapi/generation/overworld/api/ChunkDecoratorOverworldAPI.java @@ -1,23 +1,17 @@ package useless.terrainapi.generation.overworld.api; -import net.minecraft.core.block.Block; -import net.minecraft.core.block.BlockSand; -import net.minecraft.core.block.material.Material; import net.minecraft.core.world.World; import net.minecraft.core.world.biome.Biome; -import net.minecraft.core.world.biome.Biomes; import net.minecraft.core.world.chunk.Chunk; import net.minecraft.core.world.generate.feature.WorldFeature; -import net.minecraft.core.world.generate.feature.WorldFeatureLake; -import net.minecraft.core.world.generate.feature.WorldFeatureLiquid; import net.minecraft.core.world.noise.PerlinNoise; import org.jetbrains.annotations.ApiStatus; import useless.terrainapi.config.ConfigManager; -import useless.terrainapi.generation.overworld.OverworldConfig; import useless.terrainapi.generation.ChunkDecoratorAPI; import useless.terrainapi.generation.Parameters; import useless.terrainapi.generation.StructureFeatures; import useless.terrainapi.generation.overworld.OverworldBiomeFeatures; +import useless.terrainapi.generation.overworld.OverworldConfig; import useless.terrainapi.generation.overworld.OverworldOreFeatures; import useless.terrainapi.generation.overworld.OverworldRandomFeatures; @@ -27,13 +21,11 @@ public class ChunkDecoratorOverworldAPI extends ChunkDecoratorAPI { public static OverworldConfig overworldConfig = ConfigManager.getConfig("overworld", OverworldConfig.class); public final PerlinNoise treeDensityNoise; public final int treeDensityOverride; - private Parameters parameterBase; public static StructureFeatures structureFeatures = new StructureFeatures(); public static OverworldOreFeatures oreFeatures = new OverworldOreFeatures(overworldConfig); public static OverworldRandomFeatures randomFeatures = new OverworldRandomFeatures(); public static OverworldBiomeFeatures biomeFeatures = new OverworldBiomeFeatures(); - public long chunkSeed; - protected ChunkDecoratorOverworldAPI(World world, int treeDensityOverride) { + public ChunkDecoratorOverworldAPI(World world, int treeDensityOverride) { super(world); this.treeDensityOverride = treeDensityOverride; this.treeDensityNoise = new PerlinNoise(world.getRandomSeed(), 8, 74); @@ -44,38 +36,14 @@ public ChunkDecoratorOverworldAPI(World world) { } @Override @ApiStatus.Internal - public void decorate(Chunk chunk) { - int chunkX = chunk.xPosition; - int chunkZ = chunk.zPosition; - - int xCoord = chunkX * 16; - int zCoord = chunkZ * 16; - int yCoord = this.world.getHeightValue(xCoord + 16, zCoord + 16); - - Biome biome = this.world.getBlockBiome(xCoord + 16, yCoord, zCoord + 16); - - Random random = new Random(this.world.getRandomSeed()); - long l1 = random.nextLong() / 2L * 2L + 1L; - long l2 = random.nextLong() / 2L * 2L + 1L; - chunkSeed = (long)chunkX * l1 + (long)chunkZ * l2 ^ this.world.getRandomSeed(); - random.setSeed(chunkSeed); - - BlockSand.fallInstantly = true; - - parameterBase = new Parameters(biome, random, chunk, this); - - generateStructures(biome, chunk, random); - generateOreFeatures(biome, xCoord, zCoord, random, chunk); - generateBiomeFeature(biome,xCoord, zCoord, random, chunk); - generateRandomFeatures(biome,xCoord, zCoord, random, chunk); - - generateWithChancesUnderground(new WorldFeatureLiquid(Block.fluidWaterFlowing.id), 50, rangeY, xCoord, zCoord, 8, 8, random); - generateWithChancesUnderground(new WorldFeatureLiquid(Block.fluidLavaFlowing.id), 20, rangeY, xCoord, zCoord, 8, 8, random); - + public void decorateAPI() { + int xCoord = parameterBase.chunk.xPosition * 16; + int zCoord = parameterBase.chunk.zPosition * 16; + generateStructures(parameterBase.biome, parameterBase.chunk, parameterBase.random); + generateOreFeatures(parameterBase.biome, xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateBiomeFeature(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateRandomFeatures(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); freezeSurface(xCoord, zCoord); - - BlockSand.fallInstantly = false; - } @ApiStatus.Internal public void generateStructures(Biome biome, Chunk chunk, Random random){ diff --git a/src/main/java/useless/terrainapi/generation/paradise/api/ChunkGeneratorParadiseAPI.java b/src/main/java/useless/terrainapi/generation/paradise/api/ChunkGeneratorParadiseAPI.java new file mode 100644 index 0000000..5c704e2 --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/paradise/api/ChunkGeneratorParadiseAPI.java @@ -0,0 +1,15 @@ +package useless.terrainapi.generation.paradise.api; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.MapGenCaves; +import net.minecraft.core.world.generate.chunk.perlin.ChunkGeneratorPerlin; +import net.minecraft.core.world.generate.chunk.perlin.overworld.SurfaceGeneratorOverworld; +import net.minecraft.core.world.generate.chunk.perlin.paradise.TerrainGeneratorParadise; +import useless.terrainapi.generation.overworld.api.ChunkDecoratorOverworldAPI; + +public class ChunkGeneratorParadiseAPI + extends ChunkGeneratorPerlin { + public ChunkGeneratorParadiseAPI(World world) { + super(world, new ChunkDecoratorOverworldAPI(world), new TerrainGeneratorParadise(world), new SurfaceGeneratorOverworld(world), new MapGenCaves(false)); + } +} diff --git a/src/main/java/useless/terrainapi/generation/retro/RetroConfig.java b/src/main/java/useless/terrainapi/generation/retro/RetroConfig.java new file mode 100644 index 0000000..e52c4bc --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/retro/RetroConfig.java @@ -0,0 +1,6 @@ +package useless.terrainapi.generation.retro; + +import useless.terrainapi.config.OreConfig; + +public class RetroConfig extends OreConfig { +} diff --git a/src/main/java/useless/terrainapi/generation/retro/RetroFunctions.java b/src/main/java/useless/terrainapi/generation/retro/RetroFunctions.java new file mode 100644 index 0000000..229275d --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/retro/RetroFunctions.java @@ -0,0 +1,77 @@ +package useless.terrainapi.generation.retro; + +import net.minecraft.core.block.Block; +import net.minecraft.core.world.generate.feature.WorldFeature; +import net.minecraft.core.world.generate.feature.WorldFeatureDungeon; +import net.minecraft.core.world.generate.feature.tree.WorldFeatureTree; +import net.minecraft.core.world.generate.feature.tree.WorldFeatureTreeFancy; +import useless.terrainapi.generation.Parameters; +import useless.terrainapi.generation.retro.api.ChunkDecoratorRetroAPI; + +public class RetroFunctions { + public static RetroConfig retroConfig = ChunkDecoratorRetroAPI.retroConfig; + + /**Vanilla dungeon generation code + * @param parameters Parameters Container + * @return null + */ + public static Void generateDungeon(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + for (int i1 = 0; i1 < 8; ++i1) { + int structX = x + parameters.random.nextInt(16) + 8; + int structY = parameters.decorator.minY + parameters.random.nextInt(parameters.decorator.rangeY); + int structZ = z + parameters.random.nextInt(16) + 8; + new WorldFeatureDungeon(Block.cobbleStone.id, Block.cobbleStoneMossy.id, null).generate(parameters.decorator.world, parameters.random, structX, structY, structZ); + } + return null; + } + + /**Vanilla tree feature generator + * @param parameters Parameters Container + * @return Tree feature as specified by Biome#getRandomWorldGenForTrees + */ + public static WorldFeature getTreeFeature(Parameters parameters){ + WorldFeature tree = new WorldFeatureTree(Block.leavesOakRetro.id, Block.logOak.id, 4); + if (parameters.random.nextInt(10) == 0) { + tree = new WorldFeatureTreeFancy(Block.leavesOakRetro.id, Block.logOak.id); + } + tree.func_517_a(1.0, 1.0, 1.0); + return tree; + } + + /**Vanilla tree density + * @param parameters Parameters Container + * @return treeDensityOverride if applicable, otherwise returns the biome's tree density from OverworldConfig's tree density hashmap + */ + public static Integer getTreeDensity(Parameters parameters){ + double d = 0.5; + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + ChunkDecoratorRetroAPI decoratorRetro = (ChunkDecoratorRetroAPI) parameters.decorator; + int density = (int)((decoratorRetro.treeDensityNoise.get((double)x * d, (double)z * d) / 8.0 + parameters.random.nextDouble() * 4.0 + 4.0) / 3.0); + if (density < 0) { + density = 0; + } + if (parameters.random.nextInt(10) == 0) { + ++density; + } + return density; + } + + /**Vanilla tree generator + * @param parameters Parameters Container, takes two custom parameters getTreeFeature function and getTreeDensity function + * @return null + */ + public static Void generateTrees(Parameters parameters){ + int x = parameters.chunk.xPosition * 16; + int z = parameters.chunk.zPosition * 16; + for (int i = 0; i < getTreeDensity(parameters); i++) { + int xf = x + parameters.random.nextInt(16) + 8; + int zf = z + parameters.random.nextInt(16) + 8; + int yf = parameters.decorator.world.getHeightValue(xf, zf); + getTreeFeature(parameters).generate(parameters.decorator.world, parameters.random, xf, yf, zf); + } + return null; + } +} diff --git a/src/main/java/useless/terrainapi/generation/retro/api/ChunkDecoratorRetroAPI.java b/src/main/java/useless/terrainapi/generation/retro/api/ChunkDecoratorRetroAPI.java new file mode 100644 index 0000000..b57273f --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/retro/api/ChunkDecoratorRetroAPI.java @@ -0,0 +1,103 @@ +package useless.terrainapi.generation.retro.api; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.biome.Biome; +import net.minecraft.core.world.chunk.Chunk; +import net.minecraft.core.world.generate.feature.WorldFeature; +import net.minecraft.core.world.noise.RetroPerlinNoise; +import org.jetbrains.annotations.ApiStatus; +import useless.terrainapi.config.ConfigManager; +import useless.terrainapi.generation.ChunkDecoratorAPI; +import useless.terrainapi.generation.Parameters; +import useless.terrainapi.generation.StructureFeatures; +import useless.terrainapi.generation.overworld.OverworldBiomeFeatures; +import useless.terrainapi.generation.overworld.OverworldOreFeatures; +import useless.terrainapi.generation.overworld.OverworldRandomFeatures; +import useless.terrainapi.generation.retro.RetroConfig; + +import java.util.Random; + +public class ChunkDecoratorRetroAPI extends ChunkDecoratorAPI { + public static RetroConfig retroConfig = ConfigManager.getConfig("retro", RetroConfig.class); + public final RetroPerlinNoise treeDensityNoise; + public final boolean snowCovered; + public static StructureFeatures structureFeatures = new StructureFeatures(); + public static OverworldOreFeatures oreFeatures = new OverworldOreFeatures(retroConfig); + public static OverworldRandomFeatures randomFeatures = new OverworldRandomFeatures(); + public static OverworldBiomeFeatures biomeFeatures = new OverworldBiomeFeatures(); + protected ChunkDecoratorRetroAPI(World world) { + super(world); + this.treeDensityNoise = new RetroPerlinNoise(world.getRandomSeed(), 8, 74); + this.snowCovered = false; + } + @Override + public void decorateAPI() { + int xCoord = parameterBase.chunk.xPosition * 16; + int zCoord = parameterBase.chunk.zPosition * 16; + generateStructures(parameterBase.biome, parameterBase.chunk, parameterBase.random); + generateOreFeatures(parameterBase.biome, xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateBiomeFeature(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); + generateRandomFeatures(parameterBase.biome,xCoord, zCoord, parameterBase.random, parameterBase.chunk); + freezeSurface(xCoord, zCoord); + } + + @ApiStatus.Internal + public void generateStructures(Biome biome, Chunk chunk, Random random){ + int featureSize = structureFeatures.featureFunctionList.size(); + for (int i = 0; i < featureSize; i++) { + structureFeatures.featureFunctionList.get(i) + .apply(new Parameters(parameterBase, structureFeatures.featureParametersList.get(i))); + } + } + @ApiStatus.Internal + public void generateOreFeatures(Biome biome, int x, int z, Random random, Chunk chunk){ + int featureSize = oreFeatures.featureFunctionsList.size(); + for (int i = 0; i < featureSize; i++) { + WorldFeature feature = oreFeatures.featureFunctionsList.get(i) + .apply(new Parameters(parameterBase, oreFeatures.featureParametersList.get(i))); + + int density = oreFeatures.densityFunctionsList.get(i) + .apply(new Parameters(parameterBase, oreFeatures.densityParametersList.get(i))); + + float rangeModifier = oreFeatures.rangeModifierList.get(i); + generateWithChancesUnderground(feature, density, (int) (rangeModifier * rangeY), x, z, random); + } + } + @ApiStatus.Internal + public void generateRandomFeatures(Biome biome, int x, int z, Random random, Chunk chunk){ + int featureSize = randomFeatures.featureFunctionsList.size(); + for (int i = 0; i < featureSize; i++) { + if (random.nextInt(randomFeatures.inverseProbabilityList.get(i)) != 0) {continue;} + WorldFeature feature = randomFeatures.featureFunctionsList.get(i) + .apply(new Parameters(parameterBase, randomFeatures.featureParametersList.get(i))); + + int density = randomFeatures.densityFunctionsList.get(i) + .apply(new Parameters(parameterBase, randomFeatures.densityParametersList.get(i))); + + float rangeModifier = randomFeatures.rangeModifierList.get(i); + if (-1.01 <= rangeModifier && rangeModifier <= -0.99){ + generateWithChancesSurface(feature, density, x, z, 8, 8, random); + } else { + generateWithChancesUnderground(feature, density, (int) (rangeModifier * rangeY), x, z, 8, 8, random); + } + } + } + @ApiStatus.Internal + public void generateBiomeFeature(Biome biome, int x, int z, Random random, Chunk chunk){ + int featureSize = biomeFeatures.featureFunctionsList.size(); + for (int i = 0; i < featureSize; i++) { + WorldFeature feature = biomeFeatures.featureFunctionsList.get(i) + .apply(new Parameters(parameterBase, biomeFeatures.featureParametersList.get(i))); + + int density = biomeFeatures.densityFunctionsList.get(i) + .apply(new Parameters(parameterBase, biomeFeatures.densityParametersList.get(i))); + + float rangeModifier = biomeFeatures.rangeModifierList.get(i); + if (-1.01 <= rangeModifier && rangeModifier <= -0.99){ + generateWithChancesSurface(feature, density, x, z, 8, 8, random); + } else { + generateWithChancesUnderground(feature, density, (int) (rangeModifier * rangeY), x, z, 8, 8, random); + } + } + } +} diff --git a/src/main/java/useless/terrainapi/generation/retro/api/ChunkGeneratorRetroAPI.java b/src/main/java/useless/terrainapi/generation/retro/api/ChunkGeneratorRetroAPI.java new file mode 100644 index 0000000..72609e5 --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/retro/api/ChunkGeneratorRetroAPI.java @@ -0,0 +1,13 @@ +package useless.terrainapi.generation.retro.api; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.MapGenCaves; +import net.minecraft.core.world.generate.chunk.perlin.ChunkGeneratorPerlin; +import net.minecraft.core.world.generate.chunk.perlin.overworld.retro.SurfaceGeneratorOverworldRetro; +import net.minecraft.core.world.generate.chunk.perlin.overworld.retro.TerrainGeneratorOverworldRetro; + +public class ChunkGeneratorRetroAPI extends ChunkGeneratorPerlin { + public ChunkGeneratorRetroAPI(World world) { + super(world, new ChunkDecoratorRetroAPI(world), new TerrainGeneratorOverworldRetro(world), new SurfaceGeneratorOverworldRetro(world), new MapGenCaves(true)); + } +} diff --git a/src/main/java/useless/terrainapi/generation/woods/api/ChunkGeneratorOverworldWoodsAPI.java b/src/main/java/useless/terrainapi/generation/woods/api/ChunkGeneratorOverworldWoodsAPI.java new file mode 100644 index 0000000..bf7ec06 --- /dev/null +++ b/src/main/java/useless/terrainapi/generation/woods/api/ChunkGeneratorOverworldWoodsAPI.java @@ -0,0 +1,14 @@ +package useless.terrainapi.generation.woods.api; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.MapGenCaves; +import net.minecraft.core.world.generate.chunk.perlin.ChunkGeneratorPerlin; +import net.minecraft.core.world.generate.chunk.perlin.overworld.SurfaceGeneratorOverworld; +import net.minecraft.core.world.generate.chunk.perlin.overworld.TerrainGeneratorOverworld; +import useless.terrainapi.generation.overworld.api.ChunkDecoratorOverworldAPI; + +public class ChunkGeneratorOverworldWoodsAPI extends ChunkGeneratorPerlin { + public ChunkGeneratorOverworldWoodsAPI(World world) { + super(world, new ChunkDecoratorOverworldAPI(world, 50), new TerrainGeneratorOverworld(world), new SurfaceGeneratorOverworld(world), new MapGenCaves(false)); + } +} diff --git a/src/main/java/useless/terrainapi/initialization/BaseInitialization.java b/src/main/java/useless/terrainapi/initialization/BaseInitialization.java new file mode 100644 index 0000000..11a171c --- /dev/null +++ b/src/main/java/useless/terrainapi/initialization/BaseInitialization.java @@ -0,0 +1,19 @@ +package useless.terrainapi.initialization; + +public abstract class BaseInitialization { + private boolean hasInitialized = false; + public void init() { + if (hasInitialized) return; + hasInitialized = true; + initValues(); + initStructure(); + initOre(); + initRandom(); + initBiome(); + } + protected abstract void initValues(); + protected abstract void initStructure(); + protected abstract void initOre(); + protected abstract void initRandom(); + protected abstract void initBiome(); +} diff --git a/src/main/java/useless/terrainapi/initialization/TerrainInitialization.java b/src/main/java/useless/terrainapi/initialization/TerrainInitialization.java new file mode 100644 index 0000000..15758c4 --- /dev/null +++ b/src/main/java/useless/terrainapi/initialization/TerrainInitialization.java @@ -0,0 +1,26 @@ +package useless.terrainapi.initialization; + +import useless.terrainapi.TerrainMain; +import useless.terrainapi.api.TerrainAPI; +import useless.terrainapi.initialization.worldtypes.HellInitialization; +import useless.terrainapi.initialization.worldtypes.NetherInitialization; +import useless.terrainapi.initialization.worldtypes.OverworldInitialization; +import useless.terrainapi.initialization.worldtypes.RetroInitialization; + +public class TerrainInitialization implements TerrainAPI { + private static boolean hasInitialized = false; + @Override + public String getModID() { + return TerrainMain.MOD_ID; + } + @Override + public void onInitialize() { + if (hasInitialized) {return;} + hasInitialized = true; + new OverworldInitialization().init(); + new NetherInitialization().init(); + new RetroInitialization().init(); + new HellInitialization().init(); + } +} + diff --git a/src/main/java/useless/terrainapi/initialization/worldtypes/HellInitialization.java b/src/main/java/useless/terrainapi/initialization/worldtypes/HellInitialization.java new file mode 100644 index 0000000..c215c95 --- /dev/null +++ b/src/main/java/useless/terrainapi/initialization/worldtypes/HellInitialization.java @@ -0,0 +1,63 @@ +package useless.terrainapi.initialization.worldtypes; + +import net.minecraft.core.block.Block; +import net.minecraft.core.world.generate.feature.WorldFeatureClay; +import net.minecraft.core.world.generate.feature.WorldFeatureDeadBush; +import useless.terrainapi.TerrainMain; +import useless.terrainapi.generation.StructureFeatures; +import useless.terrainapi.generation.hell.HellConfig; +import useless.terrainapi.generation.hell.HellFunctions; +import useless.terrainapi.generation.hell.api.ChunkDecoratorOverworldHellAPI; +import useless.terrainapi.generation.overworld.OverworldBiomeFeatures; +import useless.terrainapi.generation.overworld.OverworldFunctions; +import useless.terrainapi.generation.overworld.OverworldOreFeatures; +import useless.terrainapi.generation.overworld.OverworldRandomFeatures; +import useless.terrainapi.initialization.BaseInitialization; + +public class HellInitialization extends BaseInitialization { + private static final HellConfig hellConfig = ChunkDecoratorOverworldHellAPI.hellConfig; + public static final StructureFeatures structureFeatures = ChunkDecoratorOverworldHellAPI.structureFeatures; + public static final OverworldOreFeatures oreFeatures = ChunkDecoratorOverworldHellAPI.oreFeatures; + public static final OverworldRandomFeatures randomFeatures = ChunkDecoratorOverworldHellAPI.randomFeatures; + public static final OverworldBiomeFeatures biomeFeatures = ChunkDecoratorOverworldHellAPI.biomeFeatures; + @Override + protected void initValues() { + hellConfig.setOreValues(TerrainMain.MOD_ID, Block.blockClay, 32, 20, 1); + } + + @Override + protected void initStructure() { + structureFeatures.addFeature(HellFunctions::generateLavaLakeFeature, null); + structureFeatures.addFeature(HellFunctions::generateObsidianLakeFeature, null); + structureFeatures.addFeature(HellFunctions::generateRandomFluid, new Object[]{50, Block.fluidWaterFlowing.id}); + structureFeatures.addFeature(OverworldFunctions::generateDungeons, null); + structureFeatures.addFeature(HellFunctions::generateLabyrinths, null); + structureFeatures.addFeature(HellFunctions::generateTrees, null); + structureFeatures.addFeature(OverworldFunctions::generateRandomFluid, new Object[]{5, Block.fluidWaterFlowing.id}); + structureFeatures.addFeature(HellFunctions::generateRandomFluid, new Object[]{20, Block.fluidLavaFlowing.id}); + } + + @Override + protected void initOre() { + String blockKey = Block.blockClay.getKey(); + oreFeatures.addFeature(new WorldFeatureClay(hellConfig.clusterSize.get(blockKey)), hellConfig.chancesPerChunk.get(blockKey), hellConfig.verticalRange.get(blockKey)); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.dirt, 32, 20, 1, false); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.gravel, 32, 10, 1, false); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreCoalStone, 16, 20, 1, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreIronStone, 8, 20, 1f/2, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreGoldStone, 8, 2, 1f/4, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreRedstoneStone, 7, 8, 1f/8, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreDiamondStone, 7, 1, 1f/8,true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreLapisStone, 6, 1, 1f/4, true); + } + + @Override + protected void initRandom() { + + } + + @Override + protected void initBiome() { + biomeFeatures.addFeature(new WorldFeatureDeadBush(Block.deadbush.id), 1, 10, null); + } +} diff --git a/src/main/java/useless/terrainapi/initialization/worldtypes/NetherInitialization.java b/src/main/java/useless/terrainapi/initialization/worldtypes/NetherInitialization.java new file mode 100644 index 0000000..d638754 --- /dev/null +++ b/src/main/java/useless/terrainapi/initialization/worldtypes/NetherInitialization.java @@ -0,0 +1,40 @@ +package useless.terrainapi.initialization.worldtypes; + +import net.minecraft.core.block.Block; +import net.minecraft.core.world.generate.feature.*; +import useless.terrainapi.TerrainMain; +import useless.terrainapi.generation.Parameters; +import useless.terrainapi.generation.nether.NetherFunctions; +import useless.terrainapi.generation.nether.api.ChunkDecoratorNetherAPI; +import useless.terrainapi.initialization.BaseInitialization; + +public class NetherInitialization extends BaseInitialization { + @Override + protected void initValues() { + + } + + @Override + protected void initStructure() { + + } + + @Override + protected void initOre() { + ChunkDecoratorNetherAPI.oreFeatures.addFeature(new WorldFeatureNetherLava(Block.fluidLavaFlowing.id), 8,120/128f); + ChunkDecoratorNetherAPI.oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreNethercoalNetherrack, 12, 10, 120/128f, false); + ChunkDecoratorNetherAPI.oreFeatures.addFeature((Parameters x) -> new WorldFeatureFire(), null, NetherFunctions::netherFireDensity, null, 120/128f); + ChunkDecoratorNetherAPI.oreFeatures.addFeature((Parameters x) -> new WorldFeatureGlowstoneA(), null, NetherFunctions::netherFireDensity, null, 120/128f); + ChunkDecoratorNetherAPI.oreFeatures.addFeature(new WorldFeatureGlowstoneB(), 10, 120/128f); + } + + @Override + protected void initRandom() { + ChunkDecoratorNetherAPI.randomFeatures.addFeature(new WorldFeatureLake(Block.fluidLavaStill.id), 8, 120/128f); + } + + @Override + protected void initBiome() { + + } +} diff --git a/src/main/java/useless/terrainapi/initialization/worldtypes/OverworldInitialization.java b/src/main/java/useless/terrainapi/initialization/worldtypes/OverworldInitialization.java new file mode 100644 index 0000000..34d170e --- /dev/null +++ b/src/main/java/useless/terrainapi/initialization/worldtypes/OverworldInitialization.java @@ -0,0 +1,119 @@ +package useless.terrainapi.initialization.worldtypes; + +import net.minecraft.core.block.Block; +import net.minecraft.core.world.biome.Biome; +import net.minecraft.core.world.biome.Biomes; +import net.minecraft.core.world.generate.feature.*; +import useless.terrainapi.TerrainMain; +import useless.terrainapi.generation.Parameters; +import useless.terrainapi.generation.StructureFeatures; +import useless.terrainapi.generation.overworld.*; +import useless.terrainapi.generation.overworld.api.ChunkDecoratorOverworldAPI; +import useless.terrainapi.initialization.BaseInitialization; + +public class OverworldInitialization extends BaseInitialization { + + private static final OverworldConfig overworldConfig = ChunkDecoratorOverworldAPI.overworldConfig; + public static final StructureFeatures structureFeatures = ChunkDecoratorOverworldAPI.structureFeatures; + public static final OverworldOreFeatures oreFeatures = ChunkDecoratorOverworldAPI.oreFeatures; + public static final OverworldRandomFeatures randomFeatures = ChunkDecoratorOverworldAPI.randomFeatures; + public static final OverworldBiomeFeatures biomeFeatures = ChunkDecoratorOverworldAPI.biomeFeatures; + @Override + protected void initValues() { + overworldConfig.setOreValues(TerrainMain.MOD_ID, Block.blockClay, 32, 20, 1f); + + overworldConfig.addGrassDensity(Biomes.OVERWORLD_FOREST, 2); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_MEADOW, 2); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_RAINFOREST, 10); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_DESERT, 5); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_SEASONAL_FOREST, 2); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_TAIGA, 1); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_BOREAL_FOREST, 5); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_PLAINS, 10); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_SWAMPLAND, 4); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_SHRUBLAND, 2); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_OUTBACK_GRASSY, 25); + overworldConfig.addGrassDensity(Biomes.OVERWORLD_BIRCH_FOREST, 10); + + overworldConfig.addFlowerDensity(Biomes.OVERWORLD_SEASONAL_FOREST, 1); + overworldConfig.addFlowerDensity(Biomes.OVERWORLD_MEADOW, 2); + overworldConfig.addFlowerDensity(Biomes.OVERWORLD_BOREAL_FOREST, 2); + overworldConfig.addFlowerDensity(Biomes.OVERWORLD_SHRUBLAND, 1); + + overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_FOREST, 2); + overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_SWAMPLAND, 2); + overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_TAIGA, 2); + overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_PLAINS, 3); + overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_OUTBACK_GRASSY, 2); + overworldConfig.addYellowFlowerDensity(Biomes.OVERWORLD_OUTBACK, 2); + + overworldConfig.addTreeDensity(Biomes.OVERWORLD_FOREST, 5); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_BIRCH_FOREST, 4); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_RAINFOREST, 10); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_SEASONAL_FOREST, 2); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_TAIGA, 5); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_BOREAL_FOREST, 3); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_DESERT, -1000); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_TUNDRA, -1000); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_PLAINS, -1000); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_SWAMPLAND, 4); + overworldConfig.addTreeDensity(Biomes.OVERWORLD_OUTBACK_GRASSY, 0); + + overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_RAINFOREST, Block.tallgrassFern); + overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_SWAMPLAND, Block.tallgrassFern); + overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_BOREAL_FOREST, Block.tallgrassFern); + overworldConfig.addRandomGrassBlock(Biomes.OVERWORLD_TAIGA, Block.tallgrassFern); + + overworldConfig.addLakeDensity(Biomes.OVERWORLD_SWAMPLAND, 2); + overworldConfig.addLakeDensity(Biomes.OVERWORLD_DESERT, 0); + } + + @Override + protected void initStructure() { + structureFeatures.addFeature(OverworldFunctions::generateSwamp, null); + structureFeatures.addFeature(OverworldFunctions::generateLakeFeature, null); + structureFeatures.addFeature(OverworldFunctions::generateLavaLakeFeature, null); + structureFeatures.addFeature(OverworldFunctions::generateDungeons, null); + structureFeatures.addFeature(OverworldFunctions::generateLabyrinths, null); + structureFeatures.addFeature(OverworldFunctions::generateTrees, null); + structureFeatures.addFeature(OverworldFunctions::generateRandomFluid, new Object[]{50, Block.fluidWaterFlowing.id}); + structureFeatures.addFeature(OverworldFunctions::generateRandomFluid, new Object[]{20, Block.fluidLavaFlowing.id}); + } + + @Override + protected void initOre() { + String currentBlock = Block.blockClay.getKey(); + oreFeatures.addFeature(new WorldFeatureClay(overworldConfig.clusterSize.get(currentBlock)), overworldConfig.chancesPerChunk.get(currentBlock), overworldConfig.verticalRange.get(currentBlock)); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.dirt, 32, 20, 1f, false); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.gravel, 32, 10, 1f, false); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreCoalStone, 16, 20, 1f, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreIronStone, 8, 20, 1/2f, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreGoldStone, 8, 2, 1/4f, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreRedstoneStone, 7, 8, 1/8f, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreDiamondStone, 7, 1, 1/8f, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.mossStone, 32, 1, 1/2f, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID,Block.oreLapisStone, 6, 1, 1/8f, true); + } + + @Override + protected void initRandom() { + randomFeatures.addFeature(new WorldFeatureFlowers(Block.flowerRed.id), 2, 1); + randomFeatures.addFeature(new WorldFeatureFlowers(Block.mushroomBrown.id), 4, 1); + randomFeatures.addFeature(new WorldFeatureFlowers(Block.mushroomRed.id), 8, 1); + randomFeatures.addFeatureSurface(new WorldFeatureSugarCane(), 5); + randomFeatures.addFeatureSurface(new WorldFeaturePumpkin(), 128); + randomFeatures.addFeatureSurface(new WorldFeatureSponge(), 64); + } + + @Override + protected void initBiome() { + biomeFeatures.addFeatureSurface(new WorldFeatureRichScorchedDirt(10), 1, new Biome[]{Biomes.OVERWORLD_OUTBACK, Biomes.OVERWORLD_OUTBACK_GRASSY}); + biomeFeatures.addFeatureSurface(new WorldFeatureSugarCaneTall(), 1, new Biome[]{Biomes.OVERWORLD_RAINFOREST}); + biomeFeatures.addFeature(OverworldFunctions::flowerTypeCondition, null, (Parameters x) -> overworldConfig.getFlowerDensity(x.biome, 0), null, 1f); + biomeFeatures.addFeature((Parameters x) -> new WorldFeatureFlowers(Block.flowerYellow.id), null, (Parameters x) -> overworldConfig.getYellowFlowerDensity(x.biome, 0), null, 1); + biomeFeatures.addFeature(OverworldFunctions::grassTypeCondition, null, (Parameters x) -> overworldConfig.getGrassDensity(x.biome, 0), null, 1); + biomeFeatures.addFeature(new WorldFeatureSpinifexPatch(), 1, 4, new Biome[]{Biomes.OVERWORLD_OUTBACK}); + biomeFeatures.addFeature(new WorldFeatureDeadBush(Block.deadbush.id), 1, 2, new Biome[]{Biomes.OVERWORLD_DESERT}); + biomeFeatures.addFeature(new WorldFeatureCactus(), 1, 10, new Biome[]{Biomes.OVERWORLD_DESERT}); + } +} diff --git a/src/main/java/useless/terrainapi/initialization/worldtypes/RetroInitialization.java b/src/main/java/useless/terrainapi/initialization/worldtypes/RetroInitialization.java new file mode 100644 index 0000000..05495a0 --- /dev/null +++ b/src/main/java/useless/terrainapi/initialization/worldtypes/RetroInitialization.java @@ -0,0 +1,64 @@ +package useless.terrainapi.initialization.worldtypes; + +import net.minecraft.core.block.Block; +import net.minecraft.core.world.generate.feature.WorldFeatureCactus; +import net.minecraft.core.world.generate.feature.WorldFeatureClay; +import net.minecraft.core.world.generate.feature.WorldFeatureFlowers; +import net.minecraft.core.world.generate.feature.WorldFeatureSugarCane; +import useless.terrainapi.TerrainMain; +import useless.terrainapi.config.OreConfig; +import useless.terrainapi.generation.StructureFeatures; +import useless.terrainapi.generation.overworld.OverworldBiomeFeatures; +import useless.terrainapi.generation.overworld.OverworldFunctions; +import useless.terrainapi.generation.overworld.OverworldOreFeatures; +import useless.terrainapi.generation.overworld.OverworldRandomFeatures; +import useless.terrainapi.generation.retro.RetroFunctions; +import useless.terrainapi.generation.retro.api.ChunkDecoratorRetroAPI; +import useless.terrainapi.initialization.BaseInitialization; + +public class RetroInitialization extends BaseInitialization { + private static final OreConfig retroConfig = ChunkDecoratorRetroAPI.retroConfig; + public static final StructureFeatures structureFeatures = ChunkDecoratorRetroAPI.structureFeatures; + public static final OverworldOreFeatures oreFeatures = ChunkDecoratorRetroAPI.oreFeatures; + public static final OverworldRandomFeatures randomFeatures = ChunkDecoratorRetroAPI.randomFeatures; + public static final OverworldBiomeFeatures biomeFeatures = ChunkDecoratorRetroAPI.biomeFeatures; + @Override + protected void initValues() { + retroConfig.setOreValues(TerrainMain.MOD_ID, Block.blockClay, 32, 10, 1); + } + + @Override + protected void initStructure() { + structureFeatures.addFeature(RetroFunctions::generateDungeon, null); + structureFeatures.addFeature(RetroFunctions::generateTrees, null); + structureFeatures.addFeature(OverworldFunctions::generateRandomFluid, new Object[]{50, Block.fluidWaterFlowing.id}); + structureFeatures.addFeature(OverworldFunctions::generateRandomFluid, new Object[]{20, Block.fluidLavaFlowing.id}); + } + + @Override + protected void initOre() { + String currentBlock = Block.blockClay.getKey(); + oreFeatures.addFeature(new WorldFeatureClay(retroConfig.clusterSize.get(currentBlock)), retroConfig.chancesPerChunk.get(currentBlock), retroConfig.verticalRange.get(currentBlock)); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.dirt, 32, 20, 1, false); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.gravel, 32, 10, 1, false); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreCoalStone, 16, 20, 1, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreIronStone, 8, 20, 1f/2, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreGoldStone, 8, 2, 1f/4, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreRedstoneStone, 7, 8, 1f/8, true); + oreFeatures.addManagedOreFeature(TerrainMain.MOD_ID, Block.oreDiamondStone, 7, 1, 1f/8, true); + } + + @Override + protected void initRandom() { + randomFeatures.addFeature(new WorldFeatureFlowers(Block.flowerRed.id), 2, 1); + randomFeatures.addFeature(new WorldFeatureFlowers(Block.mushroomBrown.id), 4, 1); + randomFeatures.addFeature(new WorldFeatureFlowers(Block.mushroomRed.id), 8, 1); + } + + @Override + protected void initBiome() { + biomeFeatures.addFeature(new WorldFeatureFlowers(Block.flowerYellow.id), 1, 2, null); + biomeFeatures.addFeature(new WorldFeatureSugarCane(), 1, 10, null); + biomeFeatures.addFeature(new WorldFeatureCactus(), 1, 1, null); + } +} diff --git a/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeFloatingMixin.java b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeFloatingMixin.java new file mode 100644 index 0000000..63ae1e4 --- /dev/null +++ b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeFloatingMixin.java @@ -0,0 +1,17 @@ +package useless.terrainapi.mixin.worldtypes; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.chunk.ChunkGenerator; +import net.minecraft.core.world.type.WorldTypeOverworldFloating; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import useless.terrainapi.generation.floating.api.ChunkGeneratorFloatingAPI; +@Mixin(value = WorldTypeOverworldFloating.class, remap = false) +public class WorldTypeFloatingMixin { + @Inject(method = "createChunkGenerator(Lnet/minecraft/core/world/World;)Lnet/minecraft/core/world/generate/chunk/ChunkGenerator;", at = @At("HEAD"), cancellable = true) + private void customChunkGenerator(World world, CallbackInfoReturnable cir){ + cir.setReturnValue(new ChunkGeneratorFloatingAPI(world)); + } +} diff --git a/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeNetherMixin.java b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeNetherMixin.java new file mode 100644 index 0000000..ebbd4e4 --- /dev/null +++ b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeNetherMixin.java @@ -0,0 +1,18 @@ +package useless.terrainapi.mixin.worldtypes; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.chunk.ChunkGenerator; +import net.minecraft.core.world.type.WorldTypeNether; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import useless.terrainapi.generation.nether.api.ChunkGeneratorNetherAPI; + +@Mixin(value = WorldTypeNether.class, remap = false, priority = 999) +public class WorldTypeNetherMixin { + @Inject(method = "createChunkGenerator(Lnet/minecraft/core/world/World;)Lnet/minecraft/core/world/generate/chunk/ChunkGenerator;", at = @At("HEAD"), cancellable = true) + private void customChunkGenerator(World world, CallbackInfoReturnable cir){ + cir.setReturnValue(new ChunkGeneratorNetherAPI(world)); + } +} diff --git a/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldHellMixin.java b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldHellMixin.java new file mode 100644 index 0000000..c522bc1 --- /dev/null +++ b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldHellMixin.java @@ -0,0 +1,17 @@ +package useless.terrainapi.mixin.worldtypes; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.chunk.ChunkGenerator; +import net.minecraft.core.world.type.WorldTypeOverworldHell; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import useless.terrainapi.generation.hell.api.ChunkGeneratorOverworldHellAPI; +@Mixin(value = WorldTypeOverworldHell.class, remap = false) +public class WorldTypeOverworldHellMixin { + @Inject(method = "createChunkGenerator(Lnet/minecraft/core/world/World;)Lnet/minecraft/core/world/generate/chunk/ChunkGenerator;", at = @At("HEAD"), cancellable = true) + private void customChunkGenerator(World world, CallbackInfoReturnable cir){ + cir.setReturnValue(new ChunkGeneratorOverworldHellAPI(world)); + } +} diff --git a/src/main/java/useless/terrainapi/mixin/WorldTypeOverworldMixin.java b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldMixin.java similarity index 95% rename from src/main/java/useless/terrainapi/mixin/WorldTypeOverworldMixin.java rename to src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldMixin.java index a84b0bd..8c19c51 100644 --- a/src/main/java/useless/terrainapi/mixin/WorldTypeOverworldMixin.java +++ b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldMixin.java @@ -1,4 +1,4 @@ -package useless.terrainapi.mixin; +package useless.terrainapi.mixin.worldtypes; import net.minecraft.core.world.World; import net.minecraft.core.world.generate.chunk.ChunkGenerator; diff --git a/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldRetroMixin.java b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldRetroMixin.java new file mode 100644 index 0000000..4caaa89 --- /dev/null +++ b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldRetroMixin.java @@ -0,0 +1,18 @@ +package useless.terrainapi.mixin.worldtypes; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.chunk.ChunkGenerator; +import net.minecraft.core.world.type.WorldTypeOverworldRetro; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import useless.terrainapi.generation.retro.api.ChunkGeneratorRetroAPI; + +@Mixin(value = WorldTypeOverworldRetro.class, remap = false, priority = 999) +public class WorldTypeOverworldRetroMixin { + @Inject(method = "createChunkGenerator(Lnet/minecraft/core/world/World;)Lnet/minecraft/core/world/generate/chunk/ChunkGenerator;", at = @At("HEAD"), cancellable = true) + private void customChunkGenerator(World world, CallbackInfoReturnable cir){ + cir.setReturnValue(new ChunkGeneratorRetroAPI(world)); + } +} diff --git a/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldWoodsMixin.java b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldWoodsMixin.java new file mode 100644 index 0000000..6d9ac46 --- /dev/null +++ b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeOverworldWoodsMixin.java @@ -0,0 +1,18 @@ +package useless.terrainapi.mixin.worldtypes; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.chunk.ChunkGenerator; +import net.minecraft.core.world.type.WorldTypeOverworldWoods; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import useless.terrainapi.generation.woods.api.ChunkGeneratorOverworldWoodsAPI; + +@Mixin(value = WorldTypeOverworldWoods.class, remap = false) +public class WorldTypeOverworldWoodsMixin { + @Inject(method = "createChunkGenerator(Lnet/minecraft/core/world/World;)Lnet/minecraft/core/world/generate/chunk/ChunkGenerator;", at = @At("HEAD"), cancellable = true) + private void customChunkGenerator(World world, CallbackInfoReturnable cir){ + cir.setReturnValue(new ChunkGeneratorOverworldWoodsAPI(world)); + } +} diff --git a/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeParadiseMixin.java b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeParadiseMixin.java new file mode 100644 index 0000000..d75e8a3 --- /dev/null +++ b/src/main/java/useless/terrainapi/mixin/worldtypes/WorldTypeParadiseMixin.java @@ -0,0 +1,18 @@ +package useless.terrainapi.mixin.worldtypes; + +import net.minecraft.core.world.World; +import net.minecraft.core.world.generate.chunk.ChunkGenerator; +import net.minecraft.core.world.type.WorldTypeParadise; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import useless.terrainapi.generation.paradise.api.ChunkGeneratorParadiseAPI; + +@Mixin(value = WorldTypeParadise.class, remap = false) +public class WorldTypeParadiseMixin { + @Inject(method = "createChunkGenerator(Lnet/minecraft/core/world/World;)Lnet/minecraft/core/world/generate/chunk/ChunkGenerator;", at = @At("HEAD"), cancellable = true) + private void customChunkGenerator(World world, CallbackInfoReturnable cir){ + cir.setReturnValue(new ChunkGeneratorParadiseAPI(world)); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 76329cd..da7dd01 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,7 +21,7 @@ "useless.terrainapi.TerrainMain" ], "terrain-api": [ - "useless.terrainapi.TerrainInitialization" + "useless.terrainapi.initialization.TerrainInitialization" ] }, "mixins": [ diff --git a/src/main/resources/terrainapi.mixins.json b/src/main/resources/terrainapi.mixins.json index e407a34..f9295ef 100644 --- a/src/main/resources/terrainapi.mixins.json +++ b/src/main/resources/terrainapi.mixins.json @@ -6,7 +6,13 @@ "mixins": [ "MinecraftMixin", "MinecraftServerMixin", - "WorldTypeOverworldMixin" + "worldtypes.WorldTypeFloatingMixin", + "worldtypes.WorldTypeNetherMixin", + "worldtypes.WorldTypeOverworldHellMixin", + "worldtypes.WorldTypeOverworldMixin", + "worldtypes.WorldTypeOverworldRetroMixin", + "worldtypes.WorldTypeOverworldWoodsMixin", + "worldtypes.WorldTypeParadiseMixin" ], "client": [ ],