ForgePatch/patches/minecraft/net/minecraft/entity/EntityList.java.patch

51 lines
2.0 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/EntityList.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityList.java
@@ -92,6 +92,7 @@
public static void func_75618_a(Class <? extends Entity > p_75618_0_, String p_75618_1_, int p_75618_2_)
{
+ if (p_75618_2_ < 0 || p_75618_2_ > 255) throw new IllegalArgumentException("Attempted to register a entity with invalid ID: " + p_75618_2_ + " Name: " + p_75618_1_ + " Class: " + p_75618_0_);
if (field_75625_b.containsKey(p_75618_1_))
{
throw new IllegalArgumentException("ID is already registered: " + p_75618_1_);
@@ -151,9 +152,10 @@
{
Entity entity = null;
+ Class <? extends Entity > oclass = null;
try
{
- Class <? extends Entity > oclass = (Class)field_75625_b.get(p_75615_0_.func_74779_i("id"));
+ oclass = field_75625_b.get(p_75615_0_.func_74779_i("id"));
if (oclass != null)
{
@@ -167,7 +169,17 @@
if (entity != null)
{
+ try
+ {
entity.func_70020_e(p_75615_0_);
+ }
+ catch (Exception e)
+ {
+ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, e,
+ "An Entity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
+ p_75615_0_.func_74779_i("id"), oclass.getName());
+ entity = null;
+ }
}
else
{
@@ -207,7 +219,8 @@
@Nullable
public static Entity func_188429_b(String p_188429_0_, World p_188429_1_)
{
- return func_75616_a(func_180122_a(p_188429_0_), p_188429_1_);
+ Entity e = func_75620_a(p_188429_0_, p_188429_1_); // Forge: Support entities without global ID
+ return e == null ? func_75620_a("Pig", p_188429_1_) : e;
}
public static int func_75619_a(Entity p_75619_0_)