feat: crash game on biome id conflict
This commit is contained in:
parent
8a5cb94ded
commit
e7bf699fe5
|
@ -24,7 +24,7 @@ apply from: './gradle/scripts/mixins.gradle'
|
|||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
version = "1.2.0"
|
||||
version = "1.3.0"
|
||||
group= "dev.tilera.modding"
|
||||
archivesBaseName = "cwg"
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||
import dev.tilera.cwg.caves.MapGenCavesSwiss;
|
||||
import dev.tilera.cwg.command.CommandChangeWorld;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.terraingen.InitMapGenEvent;
|
||||
|
||||
|
@ -17,6 +18,7 @@ public class ClassicWorldgen {
|
|||
|
||||
public static final WorldType CLASSIC = new WorldTypeClassic("onesix");
|
||||
public static WorldType USED = null;
|
||||
public static BiomeGenBase[] biomeCache = new BiomeGenBase[256];
|
||||
|
||||
@Mod.Instance
|
||||
public static ClassicWorldgen INSTANCE;
|
||||
|
|
|
@ -4,6 +4,9 @@ import org.spongepowered.asm.mixin.Final;
|
|||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import dev.tilera.cwg.ClassicWorldgen;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
@ -18,6 +21,20 @@ public abstract class MixinBiomeGenBase {
|
|||
@Final
|
||||
protected static NoiseGeneratorPerlin temperatureNoise;
|
||||
|
||||
@Inject(method = "<init>(IZ)V", at = @At("TAIL"))
|
||||
public void constructorHead(int id, boolean register, CallbackInfo ci) {
|
||||
if (register) {
|
||||
if (ClassicWorldgen.biomeCache.length > id) {
|
||||
BiomeGenBase self = (BiomeGenBase)(Object)this;
|
||||
if (ClassicWorldgen.biomeCache[id] != null && ClassicWorldgen.biomeCache[id] != self) {
|
||||
throw new RuntimeException("Biome ID conflict: " + id + " : " + self.biomeName + " : " + ClassicWorldgen.biomeCache[id].biomeName);
|
||||
} else {
|
||||
ClassicWorldgen.biomeCache[id] = self;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason No snow on hills
|
||||
|
|
Loading…
Reference in a new issue