From 02d43cb670978c35201e02a513365c0a03cf057b Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Tue, 5 Jan 2021 12:00:27 +0300 Subject: [PATCH] More generator options --- .../mixin/common/DimensionTypeMixin.java | 11 +++++++- .../mixin/common/EndPortalFeatureMixin.java | 26 +++++++++++++++++++ .../mixin/common/EndSpikeFeatureMixin.java | 26 +++++++++++++++++++ .../world/generator/GeneratorOptions.java | 18 +++++++++++++ .../resources/betterend.mixins.common.json | 2 ++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java create mode 100644 src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java diff --git a/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java b/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java index 0c462a2c..99a889f9 100644 --- a/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java +++ b/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java @@ -12,14 +12,23 @@ import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; import net.minecraft.world.gen.chunk.NoiseChunkGenerator; import ru.betterend.world.generator.BetterEndBiomeSource; +import ru.betterend.world.generator.GeneratorOptions; @Mixin(value = DimensionType.class, priority = 100) public class DimensionTypeMixin { @Inject(method = "createEndGenerator", at = @At("HEAD"), cancellable = true) - private static void replaceGenerator(Registry biomeRegistry, Registry chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable info) { + private static void beReplaceGenerator(Registry biomeRegistry, Registry chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable info) { info.setReturnValue(new NoiseChunkGenerator(new BetterEndBiomeSource(biomeRegistry, seed), seed, () -> { return (ChunkGeneratorSettings) chunkGeneratorSettingsRegistry.getOrThrow(ChunkGeneratorSettings.END); })); info.cancel(); } + + @Inject(method = "hasEnderDragonFight", at = @At("HEAD"), cancellable = true) + private void beHasEnderDragonFight(CallbackInfoReturnable info) { + if (!GeneratorOptions.hasDragonFights()) { + info.setReturnValue(false); + info.cancel(); + } + } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java new file mode 100644 index 00000000..c0592b43 --- /dev/null +++ b/src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java @@ -0,0 +1,26 @@ +package ru.betterend.mixin.common; + +import java.util.Random; + +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 net.minecraft.util.math.BlockPos; +import net.minecraft.world.StructureWorldAccess; +import net.minecraft.world.gen.chunk.ChunkGenerator; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; +import net.minecraft.world.gen.feature.EndPortalFeature; +import ru.betterend.world.generator.GeneratorOptions; + +@Mixin(EndPortalFeature.class) +public class EndPortalFeatureMixin { + @Inject(method = "generate", at = @At("HEAD"), cancellable = true) + private void bePortalGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig, CallbackInfoReturnable info) { + if (!GeneratorOptions.hasPortal()) { + info.setReturnValue(false); + info.cancel(); + } + } +} diff --git a/src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java new file mode 100644 index 00000000..0b1a8eb1 --- /dev/null +++ b/src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java @@ -0,0 +1,26 @@ +package ru.betterend.mixin.common; + +import java.util.Random; + +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 net.minecraft.util.math.BlockPos; +import net.minecraft.world.StructureWorldAccess; +import net.minecraft.world.gen.chunk.ChunkGenerator; +import net.minecraft.world.gen.feature.EndSpikeFeature; +import net.minecraft.world.gen.feature.EndSpikeFeatureConfig; +import ru.betterend.world.generator.GeneratorOptions; + +@Mixin(EndSpikeFeature.class) +public class EndSpikeFeatureMixin { + @Inject(method = "generate", at = @At("HEAD"), cancellable = true) + private void beSpikeGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, EndSpikeFeatureConfig endSpikeFeatureConfig, CallbackInfoReturnable info) { + if (!GeneratorOptions.hasPillars()) { + info.setReturnValue(false); + info.cancel(); + } + } +} diff --git a/src/main/java/ru/betterend/world/generator/GeneratorOptions.java b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java index fd6b1a8f..c12b6441 100644 --- a/src/main/java/ru/betterend/world/generator/GeneratorOptions.java +++ b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java @@ -5,10 +5,16 @@ import ru.betterend.config.Configs; public class GeneratorOptions { private static int biomeSizeLand; private static int biomeSizeVoid; + private static boolean hasPortal; + private static boolean hasPillars; + private static boolean hasDragonFights; public static void init() { biomeSizeLand = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeLand", 256); biomeSizeVoid = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeVoid", 256); + hasPortal = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPortal", true); + hasPillars = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPillars", true); + hasDragonFights = Configs.GENERATOR_CONFIG.getBooleanRoot("hasDragonFights", true); } public static int getBiomeSizeLand() { @@ -18,4 +24,16 @@ public class GeneratorOptions { public static int getBiomeSizeVoid() { return biomeSizeVoid; } + + public static boolean hasPortal() { + return hasPortal; + } + + public static boolean hasPillars() { + return hasPillars; + } + + public static boolean hasDragonFights() { + return hasDragonFights; + } } diff --git a/src/main/resources/betterend.mixins.common.json b/src/main/resources/betterend.mixins.common.json index d3a8fe85..e63a15f7 100644 --- a/src/main/resources/betterend.mixins.common.json +++ b/src/main/resources/betterend.mixins.common.json @@ -15,8 +15,10 @@ "ComposterBlockAccessor", "ChorusFlowerBlockMixin", "LandPathNodeMakerMixin", + "EndPortalFeatureMixin", "ChorusPlantBlockMixin", "RecipeManagerAccessor", + "EndSpikeFeatureMixin", "MinecraftServerMixin", "TagGroupLoaderMixin", "EndermanEntityMixin",