Add new PlayerEvent.Clone called when an EntityPlayer is cloned via dimension travil or respawn.

This commit is contained in:
Lex Manos 2014-05-24 10:50:52 -07:00
parent 8145de123e
commit dc10db1d90
2 changed files with 29 additions and 4 deletions

View File

@ -509,7 +509,7 @@
}
else if (this.field_70170_p.func_82736_K().func_82766_b("keepInventory"))
{
@@ -1876,6 +2024,17 @@
@@ -1876,6 +2024,18 @@
}
this.field_71078_a = p_71049_1_.field_71078_a;
@ -524,10 +524,11 @@
+ {
+ getEntityData().func_74782_a(PERSISTED_NBT_TAG, old.func_74775_l(PERSISTED_NBT_TAG));
+ }
+ MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerEvent.Clone(p_71049_1_, this, !p_71049_2_));
}
protected boolean func_70041_e_()
@@ -1914,7 +2073,14 @@
@@ -1914,7 +2074,14 @@
public void func_70062_b(int p_70062_1_, ItemStack p_70062_2_)
{
@ -543,7 +544,7 @@
}
@SideOnly(Side.CLIENT)
@@ -1959,7 +2125,7 @@
@@ -1959,7 +2126,7 @@
public IChatComponent func_145748_c_()
{
@ -552,7 +553,7 @@
chatcomponenttext.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " "));
return chatcomponenttext;
}
@@ -2042,6 +2208,118 @@
@@ -2042,6 +2209,118 @@
FMLNetworkHandler.openGui(this, mod, modGuiId, world, x, y, z);
}

View File

@ -68,4 +68,28 @@ public class PlayerEvent extends LivingEvent
this.displayname = username;
}
}
/**
* Fired when the EntityPlayer is cloned, typically caused by the network sending a RESPAWN_PLAYER event.
* Either caused by death, or by traveling from the End to the overworld.
*/
public static class Clone extends PlayerEvent
{
/**
* The old EntityPlayer that this new entity is a clone of.
*/
public final EntityPlayer original;
/**
* True if this event was fired because the player died.
* False if it was fired because the entity switched dimensions.
*/
public final boolean wasDeath;
public Clone(EntityPlayer _new, EntityPlayer oldPlayer, boolean wasDeath)
{
super(_new);
this.original = oldPlayer;
this.wasDeath = wasDeath;
}
}
}