Skip to content

Commit

Permalink
experimental feature to mess with biome stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
yrsegal committed Oct 13, 2023
1 parent efbb510 commit cf2a2a0
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}

}
78 changes: 78 additions & 0 deletions src/main/java/vazkii/quark/mixin/ClimateParameterPointMixin.java
Original file line number Diff line number Diff line change
@@ -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<Long> 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<Climate.Parameter> dummyOutDisabledParameters(List<Climate.Parameter> original) {
if (ClimateControlRemoverModule.staticEnabled) {
Climate.Parameter dummyParameter = new Climate.Parameter(0, 0);

List<Climate.Parameter> 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;
}

}
1 change: 1 addition & 0 deletions src/main/resources/quark.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"BeehiveBlockEntityMixin",
"BlockItemMixin",
"BoatMixin",
"ClimateParameterPointMixin",
"CrossbowMultishotMixin",
"DamageEnchantmentMixin",
"DamageSourceMixin",
Expand Down

0 comments on commit cf2a2a0

Please sign in to comment.