surround my dynamics

This commit is contained in:
FalsePattern committed 2022-07-03 22:35:19 +02:00
1 parent d594898485
commit 0c3e745afa
4 files changed
+25 -6

No files matched your search

@@ -23,8 +23,10 @@ public abstract class BiomeGenBasePlaceholderMixin {
remap = false),
require = 1)
private int removePlaceholders(int id, boolean register) {
if (biomeList[id] instanceof PlaceholderBiome) {
biomeList[id] = null;
if (register) {
if (biomeList[id] instanceof PlaceholderBiome) {
biomeList[id] = null;
}
}
return AsmHooks.getBiomeID(id, register);
}
@@ -34,8 +34,8 @@ public abstract class BiomeGenBaseMixin {
@Inject(method = "<init>(IZ)V",
at = @At(value = "RETURN"),
require = 1)
private void generatePlaceholders(int p_i1971_1_, boolean register, CallbackInfo ci) {
if (((Object) this) instanceof PlaceholderBiome) {
private void generatePlaceholders(int id, boolean register, CallbackInfo ci) {
if (((Object) this) instanceof PlaceholderBiome || !register) {
return;
}
if (biomeID >= 128 && biomeList[biomeID - 128] == null) {
@@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.world.biome.BiomeGenBase;
@@ -22,15 +23,30 @@ public abstract class BiomeGenBasePlaceholderMixin {
@Final
public int biomeID;
private static ThreadLocal<Boolean> wantsRegister;
@Redirect(method = "<init>(IZ)V",
at = @At(value = "FIELD",
opcode = Opcodes.PUTFIELD,
target = "Lnet/minecraft/world/biome/BiomeGenBase;biomeID:I"),
require = 1)
private void removePlaceholders(BiomeGenBase instance, int id) {
if (biomeList[id] instanceof PlaceholderBiome) {
biomeList[id] = null;
if (wantsRegister.get()) {
if (biomeList[id] instanceof PlaceholderBiome) {
biomeList[id] = null;
}
}
biomeID = id;
}
@ModifyVariable(method = "<init>(IZ)V",
at = @At(value = "HEAD"),
index = 2,
require = 1,
argsOnly = true)
private static boolean modifyArg(boolean register) {
if (wantsRegister == null) wantsRegister = new ThreadLocal<>();
wantsRegister.set(register);
return register;
}
}