mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-16 21:05:01 +00:00
placeholder biome slot system for mutations and auto-allocation avoidance
This commit is contained in:
9 files changed
+187
-2
No files matched your search
@@ -4,25 +4,37 @@ import code.elix_x.coremods.antiidconflict.managers.BiomesManager;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@Mod(modid = Tags.MODID,
|
||||
version = Tags.VERSION,
|
||||
name = Tags.MODNAME,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
dependencies = "required-after:falsepatternlib@[0.8.2,);")
|
||||
dependencies = "required-after:falsepatternlib@[0.8.2,);\n" +
|
||||
"after:antiidconflict")
|
||||
public class EndlessIDs {
|
||||
public static final Logger LOG = LogManager.getLogger(Tags.MODNAME);
|
||||
public static BiomeGenBase[] fakeBiomeArray;
|
||||
public static boolean postInitFinished = false;
|
||||
|
||||
@Mod.EventHandler
|
||||
public static void preInit(FMLPreInitializationEvent e) {
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
if (Loader.isModLoaded("antiidconflict")) {
|
||||
antiIdConflictLatePatch();
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
postInitFinished = true;
|
||||
fakeBiomeArray = null;
|
||||
}
|
||||
|
||||
private static void antiIdConflictLatePatch() {
|
||||
BiomesManager.conflicts = new BiomesManager.ConflictingBiomes[ExtendedConstants.biomeIDCount];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class PlaceholderBiome extends BiomeGenBase {
|
||||
public PlaceholderBiome(int id, BiomeGenBase parent) {
|
||||
super(id);
|
||||
biomeName = "EndlessIDs ID conflict avoidance placeholder for ID " + parent.biomeID +
|
||||
" [" + parent.getClass().getName() + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.antiidconflict;
|
||||
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.lib.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 org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import sun.reflect.CallerSensitive;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@Mixin(BiomeGenBase.class)
|
||||
public abstract class BiomeGenBaseMixin {
|
||||
@Shadow @Final private static BiomeGenBase[] biomeList;
|
||||
|
||||
@CallerSensitive
|
||||
@Redirect(method = "getBiomeGenArray",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/world/biome/BiomeGenBase;biomeList:[Lnet/minecraft/world/biome/BiomeGenBase;",
|
||||
opcode = Opcodes.GETSTATIC),
|
||||
require = 1)
|
||||
private static BiomeGenBase[] returnFakeArray() {
|
||||
if (!EndlessIDs.postInitFinished) {
|
||||
val trace = Thread.currentThread().getStackTrace()[3];
|
||||
if (trace.getMethodName().equals("updateBiomesFolder") &&
|
||||
trace.getClassName().equals("code.elix_x.coremods.antiidconflict.managers.BiomesManager")) {
|
||||
return EndlessIDs.fakeBiomeArray;
|
||||
}
|
||||
}
|
||||
return biomeList;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.antiidconflict;
|
||||
|
||||
import code.elix_x.coremods.antiidconflict.core.AsmHooks;
|
||||
import com.falsepattern.endlessids.PlaceholderBiome;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.Redirect;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@Mixin(BiomeGenBase.class)
|
||||
public abstract class BiomeGenBasePlaceholderMixin {
|
||||
@Shadow @Final private static BiomeGenBase[] biomeList;
|
||||
|
||||
@SuppressWarnings({"InvalidInjectorMethodSignature", "UnresolvedMixinReference", "MixinAnnotationTarget"})
|
||||
@Redirect(method = "<init>(IZ)V",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lcode/elix_x/coremods/antiidconflict/core/AsmHooks;getBiomeID(IZ)I",
|
||||
remap = false),
|
||||
require = 1)
|
||||
private int removePlaceholders(int id, boolean register) {
|
||||
if (biomeList[id] instanceof PlaceholderBiome) {
|
||||
biomeList[id] = null;
|
||||
}
|
||||
return AsmHooks.getBiomeID(id, register);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.biome;
|
||||
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.PlaceholderBiome;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Mixin(value = BiomeDictionary.class,
|
||||
remap = false)
|
||||
public abstract class BiomeDictionaryMixin {
|
||||
@Inject(method = "registerAllBiomesAndGenerateEvents",
|
||||
at = @At("HEAD"),
|
||||
require = 1)
|
||||
private static void cleanupBiomeArray(CallbackInfo ci) {
|
||||
val biomes = BiomeGenBase.getBiomeGenArray();
|
||||
EndlessIDs.fakeBiomeArray = Arrays.copyOf(biomes, biomes.length);
|
||||
for (int i = 0; i < biomes.length; i++) {
|
||||
if (biomes[i] instanceof PlaceholderBiome) {
|
||||
biomes[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -1,18 +1,42 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.biome;
|
||||
|
||||
import com.falsepattern.endlessids.PlaceholderBiome;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
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 org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(BiomeGenBase.class)
|
||||
public abstract class BiomeGenBaseMixin {
|
||||
@Shadow @Final private static BiomeGenBase[] biomeList;
|
||||
|
||||
@Shadow @Final public int biomeID;
|
||||
|
||||
@ModifyConstant(method = "<clinit>",
|
||||
constant = @Constant(intValue = VanillaConstants.biomeIDCount),
|
||||
require = 1)
|
||||
private static int extendBiomeList(int constant) {
|
||||
return ExtendedConstants.biomeIDCount;
|
||||
}
|
||||
|
||||
@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) return;
|
||||
if (biomeID >= 128 && biomeList[biomeID - 128] == null) {
|
||||
new PlaceholderBiome(biomeID - 128, (BiomeGenBase) (Object) this);
|
||||
}
|
||||
if (biomeID <= ExtendedConstants.biomeIDCount - 129 && biomeList[biomeID + 128] == null) {
|
||||
new PlaceholderBiome(biomeID + 128, (BiomeGenBase) (Object) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.biome;
|
||||
|
||||
import com.falsepattern.endlessids.PlaceholderBiome;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.Redirect;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@Mixin(BiomeGenBase.class)
|
||||
public abstract class BiomeGenBasePlaceholderMixin {
|
||||
@Shadow @Final private static BiomeGenBase[] biomeList;
|
||||
|
||||
@Mutable
|
||||
@Shadow @Final public int biomeID;
|
||||
|
||||
@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;
|
||||
}
|
||||
biomeID = id;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,9 @@ public enum Mixin implements IMixin {
|
||||
S26PacketMapChunkBulkMixin(Side.COMMON, always(), "vanilla.networking.S26PacketMapChunkBulkMixin"),
|
||||
//endregion Minecraft->common->networking
|
||||
//region Minecraft->common->biome
|
||||
BiomeDictionaryMixin(Side.COMMON, always(), "vanilla.biome.BiomeDictionaryMixin"),
|
||||
BiomeGenBaseMixin(Side.COMMON, always(), "vanilla.biome.BiomeGenBaseMixin"),
|
||||
BiomesGenBasePlaceholderMixin(Side.COMMON, avoid(TargetedMod.ANTIIDCONFLICT), "vanilla.biome.BiomeGenBasePlaceholderMixin"),
|
||||
//endregion Minecraft->common->biome
|
||||
//region Minecraft->common->misc
|
||||
BlockFireMixin(Side.COMMON, always(), "vanilla.misc.BlockFireMixin"),
|
||||
@@ -54,6 +56,10 @@ public enum Mixin implements IMixin {
|
||||
RenderGlobalMixin(Side.CLIENT, always(), "vanilla.RenderGlobalMixin"),
|
||||
//endregion Minecraft->client
|
||||
//endregion Minecraft
|
||||
//region AntiIDConflict->common
|
||||
AIDCBiomesGenBaseMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.BiomeGenBaseMixin"),
|
||||
AIDCBiomesGenBasePlaceholderMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.BiomeGenBasePlaceholderMixin"),
|
||||
//endregion AntiIDConflict->common
|
||||
//region CoFHLib->common
|
||||
CoFHLibCofhBlockHelperMixin(Side.COMMON, require(TargetedMod.COFHLIB), "cofhlib.BlockHelperMixin"),
|
||||
//endregion CoFHLib->common
|
||||
|
||||
@@ -11,6 +11,7 @@ import static com.falsepattern.lib.mixin.ITargetedMod.PredicateHelpers.*;
|
||||
@RequiredArgsConstructor
|
||||
public enum TargetedMod implements ITargetedMod {
|
||||
|
||||
ANTIIDCONFLICT("Anti ID Conflict", false, startsWith("antiidconflict")),
|
||||
COFHLIB("CoFH Lib", false, startsWith("cofhlib-")),
|
||||
DRAGONAPI("DragonAPI", false, startsWith("dragonapi")),
|
||||
GALACTICRAFTCORE("GalactiCraftCore", false, startsWith("galacticraftcore")),
|
||||
|
||||
Reference in new issue
Block a user