-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental feature to mess with biome stuff
- Loading branch information
Showing
3 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/vazkii/quark/content/experimental/module/ClimateControlRemoverModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
78
src/main/java/vazkii/quark/mixin/ClimateParameterPointMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters