From 1bd53fe75faf84db7ee56ceb8e62d3856cf313c8 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 30 Oct 2012 09:13:18 -0400 Subject: [PATCH] Fix some whitespace issues, handle possibly bugged entities as well --- .../minecraft/src/AnvilChunkLoader.java.patch | 30 +++++++++++-- .../net/minecraft/src/EntityList.java.patch | 44 +++++++++++++++++++ .../net/minecraft/src/TileEntity.java.patch | 20 +++++---- .../common/net/minecraft/src/World.java.patch | 2 +- 4 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 fml/patches/common/net/minecraft/src/EntityList.java.patch diff --git a/fml/patches/common/net/minecraft/src/AnvilChunkLoader.java.patch b/fml/patches/common/net/minecraft/src/AnvilChunkLoader.java.patch index 5849d88bfa..0fa1f715de 100644 --- a/fml/patches/common/net/minecraft/src/AnvilChunkLoader.java.patch +++ b/fml/patches/common/net/minecraft/src/AnvilChunkLoader.java.patch @@ -10,7 +10,29 @@ public class AnvilChunkLoader implements IThreadedFileIO, IChunkLoader { -@@ -242,8 +245,15 @@ +@@ -227,9 +230,18 @@ + p_75820_1_.field_76644_m = true; + var10 = new NBTTagCompound(); + +- if (var19.func_70039_c(var10)) +- { +- var15.func_74742_a(var10); ++ try ++ { ++ if (var19.func_70039_c(var10)) ++ { ++ var15.func_74742_a(var10); ++ } ++ } ++ catch (Exception e) ++ { ++ FMLLog.log(Level.SEVERE, e, ++ "An Entity type %s has thrown an exception trying to write state. It will not persist. Report this to the mod author", ++ var19.getClass().getName()); + } + } + } +@@ -242,8 +254,17 @@ { TileEntity var21 = (TileEntity)var17.next(); var10 = new NBTTagCompound(); @@ -18,12 +40,14 @@ - var16.func_74742_a(var10); + try + { -+ var21.func_70310_b(var10); ++ var21.func_70310_b(var10); + var16.func_74742_a(var10); + } + catch (Exception e) + { -+ FMLLog.log(Level.SEVERE, e, "A TileEntity type %s has throw an exception trying to write state. It will not persist. Report this to the mod author", var21.getClass().getName()); ++ FMLLog.log(Level.SEVERE, e, ++ "A TileEntity type %s has throw an exception trying to write state. It will not persist. Report this to the mod author", ++ var21.getClass().getName()); + } } diff --git a/fml/patches/common/net/minecraft/src/EntityList.java.patch b/fml/patches/common/net/minecraft/src/EntityList.java.patch new file mode 100644 index 0000000000..4d38cda42c --- /dev/null +++ b/fml/patches/common/net/minecraft/src/EntityList.java.patch @@ -0,0 +1,44 @@ +--- ../src-base/common/net/minecraft/src/EntityList.java ++++ ../src-work/common/net/minecraft/src/EntityList.java +@@ -3,6 +3,9 @@ + import java.util.HashMap; + import java.util.LinkedHashMap; + import java.util.Map; ++import java.util.logging.Level; ++ ++import cpw.mods.fml.common.FMLLog; + + public class EntityList + { +@@ -52,10 +55,10 @@ + public static Entity func_75615_a(NBTTagCompound p_75615_0_, World p_75615_1_) + { + Entity var2 = null; +- ++ Class var3 = null; + try + { +- Class var3 = (Class)field_75625_b.get(p_75615_0_.func_74779_i("id")); ++ var3 = (Class)field_75625_b.get(p_75615_0_.func_74779_i("id")); + + if (var3 != null) + { +@@ -69,7 +72,17 @@ + + if (var2 != null) + { +- var2.func_70020_e(p_75615_0_); ++ try ++ { ++ var2.func_70020_e(p_75615_0_); ++ } ++ catch (Exception e) ++ { ++ FMLLog.log(Level.SEVERE, 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"), var3.getName()); ++ var2 = null; ++ } + } + else + { diff --git a/fml/patches/common/net/minecraft/src/TileEntity.java.patch b/fml/patches/common/net/minecraft/src/TileEntity.java.patch index 8571c3ea0d..9c79a98848 100644 --- a/fml/patches/common/net/minecraft/src/TileEntity.java.patch +++ b/fml/patches/common/net/minecraft/src/TileEntity.java.patch @@ -25,20 +25,22 @@ if (var2 != null) { -@@ -92,7 +94,15 @@ +@@ -92,7 +94,17 @@ if (var1 != null) { - var1.func_70307_a(p_70317_0_); -+ try -+ { -+ var1.func_70307_a(p_70317_0_); -+ } -+ catch (Exception e) -+ { -+ FMLLog.log(Level.SEVERE, e, "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", p_70317_0_.func_74779_i("id"), var2.getName()); ++ try ++ { ++ var1.func_70307_a(p_70317_0_); ++ } ++ catch (Exception e) ++ { ++ FMLLog.log(Level.SEVERE, e, ++ "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", ++ p_70317_0_.func_74779_i("id"), var2.getName()); + var1 = null; -+ } ++ } } else { diff --git a/fml/patches/common/net/minecraft/src/World.java.patch b/fml/patches/common/net/minecraft/src/World.java.patch index d161a50230..d1e75b44dc 100644 --- a/fml/patches/common/net/minecraft/src/World.java.patch +++ b/fml/patches/common/net/minecraft/src/World.java.patch @@ -16,7 +16,7 @@ - this.field_72996_f.removeAll(this.field_72997_g); - Iterator var5 = this.field_72997_g.iterator(); + List fml_entitiesToRemove = ImmutableList.copyOf(this.field_72997_g); -+ this.field_72996_f.removeAll(fml_entitiesToRemove); ++ this.field_72996_f.removeAll(fml_entitiesToRemove); + Iterator var5 = fml_entitiesToRemove.iterator(); int var3; int var4;