mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 18:45:09 +00:00
Fix out of range entity id handling for ModLoader mods a bit more. Thanks Herobrine mod!
This commit is contained in:
1 parent
b1b4c61b80
commit
0eb7180fc1
1 file changed
+23
-5
@@ -21,6 +21,8 @@ import com.google.common.collect.BiMap;
|
|||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.primitives.UnsignedBytes;
|
||||||
|
import com.google.common.primitives.UnsignedInteger;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
@@ -179,16 +181,32 @@ public class EntityRegistry
|
|||||||
private int validateAndClaimId(int id)
|
private int validateAndClaimId(int id)
|
||||||
{
|
{
|
||||||
// workaround for broken ML
|
// workaround for broken ML
|
||||||
if (id < 0)
|
int realId = id;
|
||||||
|
if (id < Byte.MIN_VALUE)
|
||||||
{
|
{
|
||||||
id += 3000;
|
FMLLog.warning("Compensating for modloader out of range compensation by mod : entityId %d for mod %s is now %d", id, Loader.instance().activeModContainer().getModId(), realId);
|
||||||
|
realId += 3000;
|
||||||
}
|
}
|
||||||
if (!availableIndicies.get(id))
|
|
||||||
|
if (realId < 0)
|
||||||
|
{
|
||||||
|
realId += Byte.MAX_VALUE;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UnsignedBytes.checkedCast(realId);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.SEVERE, "The entity ID %d for mod %s is not an unsigned byte and may not work", id, Loader.instance().activeModContainer().getModId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!availableIndicies.get(realId))
|
||||||
{
|
{
|
||||||
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);
|
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);
|
availableIndicies.clear(realId);
|
||||||
return id;
|
return realId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
|
public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
|
||||||
|
|||||||
Reference in new issue
Block a user