diff --git a/src/main/java/vazkii/quark/content/experimental/module/ClimateControlRemoverModule.java b/src/main/java/vazkii/quark/content/experimental/module/ClimateControlRemoverModule.java new file mode 100644 index 0000000000..a38c67aa98 --- /dev/null +++ b/src/main/java/vazkii/quark/content/experimental/module/ClimateControlRemoverModule.java @@ -0,0 +1,44 @@ +package vazkii.quark.content.experimental.module; + +import vazkii.quark.base.module.LoadModule; +import vazkii.quark.base.module.ModuleCategory; +import vazkii.quark.base.module.QuarkModule; +import vazkii.quark.base.module.config.Config; + +@LoadModule(category = ModuleCategory.EXPERIMENTAL, enabledByDefault = false) +public class ClimateControlRemoverModule extends QuarkModule { + + public static boolean staticEnabled; + + @Config(description = "Disables the temperature comparison when choosing biomes to generate.") + public static boolean disableTemperature = false; + + @Config(description = "Disables the humidity comparison when choosing biomes to generate.") + public static boolean disableHumidity = false; + + @Config(description = "Disables the 'continentalness' comparison when choosing biomes to generate.\n" + + "WARNING: Enabling this will probably make oceans act a lot more like rivers.") + public static boolean disableContinentalness = false; + + @Config(description = "Disables the 'erosion' comparison when choosing biomes to generate.\n" + + "WARNING: Enabling this will probably create very extreme height differences, and will make the End more chaotic.") + public static boolean disableErosion = false; + + @Config(description = "Disables the 'depth' comparison when choosing biomes to generate.\n" + + "WARNING: Enabling this will probably make cave biomes appear at unusual heights.") + public static boolean disableDepth = false; + + @Config(description = "Disables the 'weirdness' comparison when choosing biomes to generate.\n" + + "WARNING: Enabling this will... well, probably make things weird.") + public static boolean disableWeirdness = false; + + @Config(description = "Disables the 'offset' parameter when choosing biomes to generate.\n" + + "WARNING: Enabling this will make rarer nether biomes more common.") + public static boolean disableOffset = false; + + @Override + public void configChanged() { + staticEnabled = enabled; + } + +} diff --git a/src/main/java/vazkii/quark/mixin/ClimateParameterPointMixin.java b/src/main/java/vazkii/quark/mixin/ClimateParameterPointMixin.java new file mode 100644 index 0000000000..44a57896a6 --- /dev/null +++ b/src/main/java/vazkii/quark/mixin/ClimateParameterPointMixin.java @@ -0,0 +1,78 @@ +package vazkii.quark.mixin; + +import com.google.common.collect.ImmutableList; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.world.level.biome.Climate; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import vazkii.quark.content.experimental.module.ClimateControlRemoverModule; + +import java.util.ArrayList; +import java.util.List; + +@Mixin(Climate.ParameterPoint.class) +public class ClimateParameterPointMixin { + + @Shadow @Final private Climate.Parameter temperature; + @Shadow @Final private Climate.Parameter humidity; + @Shadow @Final private Climate.Parameter continentalness; + @Shadow @Final private Climate.Parameter erosion; + @Shadow @Final private Climate.Parameter depth; + @Shadow @Final private Climate.Parameter weirdness; + + @Shadow @Final private long offset; + + @WrapOperation(method = "fitness", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Climate$Parameter;distance(J)J")) + public long giveMinimumDistanceForDisabledParameters(Climate.Parameter parameter, long targetValue, Operation original) { + if (ClimateControlRemoverModule.staticEnabled && + ((parameter == temperature && ClimateControlRemoverModule.disableTemperature) || + (parameter == humidity && ClimateControlRemoverModule.disableHumidity) || + (parameter == continentalness && ClimateControlRemoverModule.disableContinentalness) || + (parameter == erosion && ClimateControlRemoverModule.disableErosion) || + (parameter == depth && ClimateControlRemoverModule.disableDepth) || + (parameter == weirdness && ClimateControlRemoverModule.disableWeirdness))) return 0; + + return original.call(parameter, targetValue); + } + + + @ModifyExpressionValue(method = "fitness", at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/biome/Climate$ParameterPoint;offset:J", opcode = Opcodes.GETFIELD)) + public long giveMinimumOffsetIfDisabled(long originalOffset) { + if (ClimateControlRemoverModule.staticEnabled && ClimateControlRemoverModule.disableOffset) + return 0; + return originalOffset; + } + + @ModifyReturnValue(method = "parameterSpace", at = @At("RETURN")) + public List dummyOutDisabledParameters(List original) { + if (ClimateControlRemoverModule.staticEnabled) { + Climate.Parameter dummyParameter = new Climate.Parameter(0, 0); + + List newParameterSpace = new ArrayList<>(original.size()); + + for (Climate.Parameter parameter : original) { + if (((parameter == temperature && ClimateControlRemoverModule.disableTemperature) || + (parameter == humidity && ClimateControlRemoverModule.disableHumidity) || + (parameter == continentalness && ClimateControlRemoverModule.disableContinentalness) || + (parameter == erosion && ClimateControlRemoverModule.disableErosion) || + (parameter == depth && ClimateControlRemoverModule.disableDepth) || + (parameter == weirdness && ClimateControlRemoverModule.disableWeirdness)) || + (parameter.min() == parameter.max() && parameter.min() == offset && ClimateControlRemoverModule.disableOffset)) + newParameterSpace.add(dummyParameter); + else + newParameterSpace.add(parameter); + } + + return ImmutableList.copyOf(newParameterSpace); + } + + return original; + } + +} diff --git a/src/main/resources/quark.mixins.json b/src/main/resources/quark.mixins.json index 4b4fb66bbb..03b107af6b 100644 --- a/src/main/resources/quark.mixins.json +++ b/src/main/resources/quark.mixins.json @@ -16,6 +16,7 @@ "BeehiveBlockEntityMixin", "BlockItemMixin", "BoatMixin", + "ClimateParameterPointMixin", "CrossbowMultishotMixin", "DamageEnchantmentMixin", "DamageSourceMixin",