From d6326deeb0c3643e1382286a309ceca209ca13d0 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 26 Aug 2012 12:52:50 -0400 Subject: [PATCH] Fix a couple of modloader mods. Thanks! --- common/cpw/mods/fml/common/FMLLog.java | 4 ++-- .../mods/fml/common/registry/EntityRegistry.java | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/cpw/mods/fml/common/FMLLog.java b/common/cpw/mods/fml/common/FMLLog.java index d703b6bd85..f9e6d676df 100644 --- a/common/cpw/mods/fml/common/FMLLog.java +++ b/common/cpw/mods/fml/common/FMLLog.java @@ -9,12 +9,12 @@ public class FMLLog public static void log(Level level, String format, Object... data) { - coreLog.log(level, String.format(format, data)); + coreLog.log(level, format, data); } public static void log(Level level, Throwable ex, String format, Object... data) { - coreLog.log(level, ex, String.format(format, data)); + coreLog.log(level, ex, format, data); } public static void severe(String format, Object... data) diff --git a/common/cpw/mods/fml/common/registry/EntityRegistry.java b/common/cpw/mods/fml/common/registry/EntityRegistry.java index 08e1644136..adefea298d 100644 --- a/common/cpw/mods/fml/common/registry/EntityRegistry.java +++ b/common/cpw/mods/fml/common/registry/EntityRegistry.java @@ -107,7 +107,7 @@ public class EntityRegistry private EntityRegistry() { availableIndicies = new BitSet(256); - availableIndicies.set(0,255); + availableIndicies.set(1,255); for (Object id : EntityList.field_75623_d.keySet()) { availableIndicies.clear((Integer)id); @@ -129,6 +129,7 @@ public class EntityRegistry { instance().doModEntityRegistration(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates); } + private void doModEntityRegistration(Class entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) { ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); @@ -164,17 +165,23 @@ public class EntityRegistry FMLLog.warning("The mod %s tried to register the entity class %s which was already registered - if you wish to override default naming for FML mod entities, register it here first", Loader.instance().activeModContainer().getModId(), entityClass); return; } - instance().validateAndClaimId(id); + id = instance().validateAndClaimId(id); EntityList.func_75618_a(entityClass, entityName, id); } - private void validateAndClaimId(int id) + private int validateAndClaimId(int id) { + // workaround for broken ML + if (id < 0) + { + id += 3000; + } if (!availableIndicies.get(id)) { - throw new RuntimeException(String.format("Unable to claim entity id %d", id)); + FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id); } availableIndicies.clear(id); + return id; } public static void registerGlobalEntityID(Class entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)