3
0

Update references to inventory for CraftPlayer during cloning

Fix #321
This commit is contained in:
Sergey Shatunov 2016-02-02 14:45:32 +07:00
parent f9b7fa7da4
commit 412dab0029
3 changed files with 15 additions and 2 deletions

View File

@ -27,6 +27,8 @@ import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import net.minecraft.entity.EntityLivingBase;
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private CraftInventoryPlayer inventory; private CraftInventoryPlayer inventory;
private CraftInventory enderChest; private CraftInventory enderChest;
@ -39,6 +41,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
mode = server.getDefaultGameMode(); mode = server.getDefaultGameMode();
} }
@Override
public void updateEntity(EntityLivingBase entity) {
super.updateEntity(entity);
if (inventory != null) inventory.updateInventory(((net.minecraft.entity.player.EntityPlayer) entity).inventory);
if (enderChest != null) enderChest.updateInventory(((net.minecraft.entity.player.EntityPlayer) entity).getInventoryEnderChest());
}
public String getName() { public String getName() {
return getHandle().getCommandSenderName(); return getHandle().getCommandSenderName();
} }

View File

@ -17,12 +17,16 @@ import org.bukkit.Material;
public class CraftInventory implements Inventory { public class CraftInventory implements Inventory {
protected final net.minecraft.inventory.IInventory inventory; protected net.minecraft.inventory.IInventory inventory;
public CraftInventory(net.minecraft.inventory.IInventory inventory) { public CraftInventory(net.minecraft.inventory.IInventory inventory) {
this.inventory = inventory; this.inventory = inventory;
} }
public void updateInventory(net.minecraft.inventory.IInventory inventory) {
this.inventory = inventory;
}
public net.minecraft.inventory.IInventory getInventory() { public net.minecraft.inventory.IInventory getInventory() {
return inventory; return inventory;
} }