From 0d3b4e763caa7ea16b8af7359ad33dd195d03477 Mon Sep 17 00:00:00 2001 From: Sergey Shatunov Date: Mon, 1 Feb 2016 22:45:16 +0700 Subject: [PATCH] Forward bukkit's CraftPlayer during cloning player Fix #318 --- .../entity/player/EntityPlayerMP.java.patch | 10 +++++++++- .../network/NetHandlerPlayServer.java.patch | 4 ++-- .../craftbukkit/entity/CraftLivingEntity.java | 13 ++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch b/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch index 2f72840..229915b 100644 --- a/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch +++ b/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch @@ -705,7 +705,15 @@ public void addChatComponentMessage(IChatComponent p_146105_1_) { this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_)); -@@ -1037,6 +1363,114 @@ +@@ -878,6 +1204,7 @@ + + public void clonePlayer(EntityPlayer p_71049_1_, boolean p_71049_2_) + { ++ if (p_71049_1_ instanceof EntityPlayerMP) ((org.bukkit.craftbukkit.entity.CraftLivingEntity) (bukkitEntity = ((EntityPlayerMP) p_71049_1_).bukkitEntity)).updateEntity(this); + super.clonePlayer(p_71049_1_, p_71049_2_); + this.lastExperience = -1; + this.lastHealth = -1.0F; +@@ -1037,6 +1364,114 @@ return this.field_143005_bX; } diff --git a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch index 8c696cd..86b75d8 100644 --- a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -1795,7 +1795,7 @@ { packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e())); @@ -1093,16 +2398,18 @@ - { + if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem()) { - itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8)); @@ -1818,7 +1818,7 @@ finally { @@ -1135,19 +2442,18 @@ - + { if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book) { - itemstack1.setTagInfo("author", new NBTTagString(this.playerEntity.getCommandSenderName())); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0945436..cfa9d18 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -48,15 +48,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public Class entityClass; public String entityName; // Cauldron end - - public CraftLivingEntity(final CraftServer server, final net.minecraft.entity.EntityLivingBase entity) { - super(server, entity); - // Cauldron start + + public void updateEntity(net.minecraft.entity.EntityLivingBase entity) { + super.entity = entity; this.entityClass = entity.getClass(); this.entityName = EntityRegistry.getCustomEntityTypeName(entityClass); if (entityName == null) entityName = entity.getCommandSenderName(); - // Cauldron end + } + + public CraftLivingEntity(final CraftServer server, final net.minecraft.entity.EntityLivingBase entity) { + super(server, entity); + updateEntity(entity); // KCauldron if (entity instanceof net.minecraft.entity.EntityLiving) { equipment = new CraftEntityEquipment(this);