1
0
forked from xjboss/KCauldronX

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.plugin.Plugin;
import net.minecraft.entity.EntityLivingBase;
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private CraftInventoryPlayer inventory;
private CraftInventory enderChest;
@ -38,6 +40,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
super(server, entity);
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() {
return getHandle().getCommandSenderName();

View File

@ -17,11 +17,15 @@ import org.bukkit.Material;
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) {
this.inventory = inventory;
}
public void updateInventory(net.minecraft.inventory.IInventory inventory) {
this.inventory = inventory;
}
public net.minecraft.inventory.IInventory getInventory() {
return inventory;

View File

@ -11,7 +11,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
public CraftInventoryPlayer(net.minecraft.entity.player.InventoryPlayer inventory) {
super(inventory);
}
@Override
public net.minecraft.entity.player.InventoryPlayer getInventory() {
return (net.minecraft.entity.player.InventoryPlayer) inventory;