From 614d0a58d21f36c52a664367bcc172e939d0e3f9 Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Sun, 10 Jan 2021 16:42:31 +0300 Subject: [PATCH] Chorus plant mixins config, Helix tree enhancements --- .../mixin/common/ChorusFlowerBlockMixin.java | 10 +++++-- .../mixin/common/ChorusPlantBlockMixin.java | 27 +++++++++++++++---- .../mixin/common/ChorusPlantFeatureMixin.java | 8 +++++- .../ru/betterend/registry/EndFeatures.java | 21 ++++++++------- .../features/trees/HelixTreeFeature.java | 12 ++++++--- .../world/generator/GeneratorOptions.java | 12 +++++++++ 6 files changed, 69 insertions(+), 21 deletions(-) diff --git a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java index 6c354ff5..88cec28b 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java @@ -29,6 +29,7 @@ import net.minecraft.world.WorldView; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; import ru.betterend.util.BlocksHelper; +import ru.betterend.world.generator.GeneratorOptions; @Mixin(value = ChorusFlowerBlock.class, priority = 100) public abstract class ChorusFlowerBlockMixin extends Block { @@ -59,7 +60,12 @@ public abstract class ChorusFlowerBlockMixin extends Block { int i = state.get(ChorusFlowerBlock.AGE); if (i < 5) { this.grow(world, up, i + 1); - BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true)); + if (GeneratorOptions.changeChorusPlant()) { + BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true)); + } + else { + BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true)); + } info.cancel(); } } @@ -69,7 +75,7 @@ public abstract class ChorusFlowerBlockMixin extends Block { @Inject(method = "generate", at = @At("RETURN"), cancellable = true) private static void beOnGenerate(WorldAccess world, BlockPos pos, Random random, int size, CallbackInfo info) { BlockState state = world.getBlockState(pos); - if (state.isOf(Blocks.CHORUS_PLANT)) { + if (GeneratorOptions.changeChorusPlant() && state.isOf(Blocks.CHORUS_PLANT)) { BlocksHelper.setWithoutUpdate(world, pos, state.with(BlocksHelper.ROOTS, true)); } } diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java index f133d166..b06d48a8 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java @@ -23,6 +23,7 @@ import net.minecraft.world.WorldView; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; import ru.betterend.util.BlocksHelper; +import ru.betterend.world.generator.GeneratorOptions; @Mixin(value = ChorusPlantBlock.class, priority = 100) public abstract class ChorusPlantBlockMixin extends Block { @@ -32,12 +33,16 @@ public abstract class ChorusPlantBlockMixin extends Block { @Inject(method = "*", at = @At("TAIL")) private void beOnInit(AbstractBlock.Settings settings, CallbackInfo info) { - this.setDefaultState(this.getDefaultState().with(BlocksHelper.ROOTS, false)); + if (GeneratorOptions.changeChorusPlant()) { + this.setDefaultState(this.getDefaultState().with(BlocksHelper.ROOTS, false)); + } } @Inject(method = "appendProperties", at = @At("TAIL")) private void beAddProperties(StateManager.Builder builder, CallbackInfo info) { - builder.add(BlocksHelper.ROOTS); + if (GeneratorOptions.changeChorusPlant()) { + builder.add(BlocksHelper.ROOTS); + } } @Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true) @@ -69,11 +74,18 @@ public abstract class ChorusPlantBlockMixin extends Block { BlockState plant = info.getReturnValue(); if (plant.isOf(Blocks.CHORUS_PLANT)) { if (world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { - plant = plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true); + if (GeneratorOptions.changeChorusPlant()) { + plant = plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true); + } + else { + plant = plant.with(Properties.DOWN, true); + } info.cancel(); } else { - plant = plant.with(BlocksHelper.ROOTS, false); + if (GeneratorOptions.changeChorusPlant()) { + plant = plant.with(BlocksHelper.ROOTS, false); + } info.cancel(); } info.setReturnValue(plant); @@ -87,7 +99,12 @@ public abstract class ChorusPlantBlockMixin extends Block { World world = ctx.getWorld(); BlockState plant = info.getReturnValue(); if (ctx.canPlace() && plant.isOf(Blocks.CHORUS_PLANT) && world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { - info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true)); + if (GeneratorOptions.changeChorusPlant()) { + info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true)); + } + else { + info.setReturnValue(plant.with(Properties.DOWN, true)); + } info.cancel(); } } diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java index 7742405a..1c11ceca 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java @@ -19,6 +19,7 @@ import net.minecraft.world.gen.feature.DefaultFeatureConfig; import ru.betterend.registry.EndBlocks; import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; +import ru.betterend.world.generator.GeneratorOptions; @Mixin(ChorusPlantFeature.class) public class ChorusPlantFeatureMixin { @@ -28,7 +29,12 @@ public class ChorusPlantFeatureMixin { ChorusFlowerBlock.generate(structureWorldAccess, blockPos, random, MHelper.randRange(8, 16, random)); BlockState bottom = structureWorldAccess.getBlockState(blockPos); if (bottom.isOf(Blocks.CHORUS_PLANT)) { - BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(BlocksHelper.ROOTS, true).with(ConnectingBlock.DOWN, true)); + if ((GeneratorOptions.changeChorusPlant())) { + BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(BlocksHelper.ROOTS, true).with(ConnectingBlock.DOWN, true)); + } + else { + BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(ConnectingBlock.DOWN, true)); + } } info.setReturnValue(true); } diff --git a/src/main/java/ru/betterend/registry/EndFeatures.java b/src/main/java/ru/betterend/registry/EndFeatures.java index 1ea1d4a5..393f5019 100644 --- a/src/main/java/ru/betterend/registry/EndFeatures.java +++ b/src/main/java/ru/betterend/registry/EndFeatures.java @@ -50,6 +50,7 @@ import ru.betterend.world.features.trees.MossyGlowshroomFeature; import ru.betterend.world.features.trees.PythadendronTreeFeature; import ru.betterend.world.features.trees.TenaneaFeature; import ru.betterend.world.features.trees.UmbrellaTreeFeature; +import ru.betterend.world.generator.GeneratorOptions; public class EndFeatures { // Trees // @@ -156,15 +157,17 @@ public class EndFeatures { public static final EndFeature CRASHED_SHIP = EndFeature.makeChansedFeature("crashed_ship", new CrashedShipFeature(), 500); public static void registerBiomeFeatures(Identifier id, Biome biome, List>>> features) { - if (id.getNamespace().equals("minecraft")) { - String path = id.getPath(); - if (path.equals("end_highlands") || path.equals("end_midlands") || path.equals("small_end_islands")) { - int pos = GenerationStep.Feature.VEGETAL_DECORATION.ordinal(); - if (pos < features.size()) { - List>> list = features.get(pos); - // If only chorus plants are enabled - if (list.size() == 1) { - features.get(pos).clear(); + if (GeneratorOptions.removeChorusFromVanillaBiomes()) { + if (id.getNamespace().equals("minecraft")) { + String path = id.getPath(); + if (path.equals("end_highlands") || path.equals("end_midlands") || path.equals("small_end_islands")) { + int pos = GenerationStep.Feature.VEGETAL_DECORATION.ordinal(); + if (pos < features.size()) { + List>> list = features.get(pos); + // If only chorus plants are enabled + if (list.size() == 1) { + features.get(pos).clear(); + } } } } diff --git a/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java b/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java index 4a9496cb..bb2ad265 100644 --- a/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java @@ -80,14 +80,18 @@ public class HelixTreeFeature extends DefaultFeature { }); spline.clear(); - for (int i = 0; i <= 20; i++) { - float radius = 1 - i * 0.05F; + float rad = MHelper.randRange(8F, 11F, random); + int count = MHelper.randRange(20, 30, random); + float scaleM = 20F / (float) count * scale * 1.75F; + float hscale = 20F / (float) count * 0.05F; + for (int i = 0; i <= count; i++) { + float radius = 1 - i * hscale; radius = radius * radius * 2 - 1; radius *= radius; - radius = (1 - radius) * 8F * scale; + radius = (1 - radius) * rad * scale; dx = (float) Math.sin(i * 0.45F + angle) * radius; dz = (float) Math.cos(i * 0.45F + angle) * radius; - spline.add(new Vector3f(dx, i * scale * 1.75F, dz)); + spline.add(new Vector3f(dx, i * scaleM, dz)); } Vector3f start = new Vector3f(); diff --git a/src/main/java/ru/betterend/world/generator/GeneratorOptions.java b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java index 5df80e81..45da95c7 100644 --- a/src/main/java/ru/betterend/world/generator/GeneratorOptions.java +++ b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java @@ -9,6 +9,8 @@ public class GeneratorOptions { private static boolean hasPillars; private static boolean hasDragonFights; private static boolean swapOverworldToEnd; + private static boolean changeChorusPlant; + private static boolean removeChorusFromVanillaBiomes; public static void init() { biomeSizeLand = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeLand", 256); @@ -17,6 +19,8 @@ public class GeneratorOptions { hasPillars = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPillars", true); hasDragonFights = Configs.GENERATOR_CONFIG.getBooleanRoot("hasDragonFights", true); swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false); + changeChorusPlant = Configs.GENERATOR_CONFIG.getBooleanRoot("changeChorusPlant", true); + removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBooleanRoot("removeChorusFromVanillaBiomes", true); } public static int getBiomeSizeLand() { @@ -42,4 +46,12 @@ public class GeneratorOptions { public static boolean swapOverworldToEnd() { return swapOverworldToEnd; } + + public static boolean changeChorusPlant() { + return changeChorusPlant; + } + + public static boolean removeChorusFromVanillaBiomes() { + return removeChorusFromVanillaBiomes; + } }