From c8abc41aa06a790887a9b84041ee7413c2e36ed0 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Wed, 7 May 2014 14:52:09 -0700 Subject: [PATCH] Fix extended entity properties being lost when leaving the end, This introduces the concept of calling IExtendedEntityProperties.init when entites/worlds change. Lets see if mods explode. --- .../net/minecraft/entity/Entity.java.patch | 2 +- .../entity/player/EntityPlayer.java.patch | 19 +++++++++++++++---- .../common/IExtendedEntityProperties.java | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index 5f2c3978c..7a5064e74 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -54,7 +54,7 @@ + public ArrayList capturedDrops = new ArrayList(); + private UUID persistentID; -+ private HashMap extendedProperties; ++ protected HashMap extendedProperties; + public int func_145782_y() { diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index 1d1e587e7..4ad85e0a1 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -498,7 +498,18 @@ this.field_71074_e = p_71008_1_; this.field_71072_f = p_71008_2_; -@@ -1876,6 +2020,17 @@ +@@ -1865,6 +2009,10 @@ + this.field_71106_cc = p_71049_1_.field_71106_cc; + this.func_85040_s(p_71049_1_.func_71037_bA()); + this.field_82152_aq = p_71049_1_.field_82152_aq; ++ //Copy and re-init ExtendedProperties when switching dimensions. ++ this.extendedProperties = p_71049_1_.extendedProperties; ++ for (net.minecraftforge.common.IExtendedEntityProperties p : this.extendedProperties.values()) ++ p.init(this, this.field_70170_p); + } + else if (this.field_70170_p.func_82736_K().func_82766_b("keepInventory")) + { +@@ -1876,6 +2024,17 @@ } this.field_71078_a = p_71049_1_.field_71078_a; @@ -516,7 +527,7 @@ } protected boolean func_70041_e_() -@@ -1914,7 +2069,14 @@ +@@ -1914,7 +2073,14 @@ public void func_70062_b(int p_70062_1_, ItemStack p_70062_2_) { @@ -532,7 +543,7 @@ } @SideOnly(Side.CLIENT) -@@ -1959,7 +2121,7 @@ +@@ -1959,7 +2125,7 @@ public IChatComponent func_145748_c_() { @@ -541,7 +552,7 @@ chatcomponenttext.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " ")); return chatcomponenttext; } -@@ -2042,6 +2204,118 @@ +@@ -2042,6 +2208,118 @@ FMLNetworkHandler.openGui(this, mod, modGuiId, world, x, y, z); } diff --git a/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java b/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java index 48702bdc0..87ea4da8c 100644 --- a/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java +++ b/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java @@ -30,6 +30,8 @@ public interface IExtendedEntityProperties { * Used to initialize the extended properties with the entity that this is attached to, as well * as the world object. * Called automatically if you register with the EntityConstructing event. + * May be called multiple times if the extended properties is moved over to a new entity. + * Such as when a player switches dimension {Minecraft re-creates the player entity} * @param entity The entity that this extended properties is attached to * @param world The world in which the entity exists */