Created
June 23, 2013 21:08
-
-
Save mooman219/5846551 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isInventoryOpen() { | |
EntityPlayer handle = getHandle(); | |
return handle.activeContainer != handle.defaultContainer; | |
} | |
public void openInventory(Inventory inventory) { | |
if(isInventoryOpen()) { | |
EntityPlayer handle = getHandle(); | |
CraftPlayer craftPlayer = (CraftPlayer) player; | |
CraftInventory craftInventory = (CraftInventory) inventory; | |
PlayerInventory handleinventory = handle.inventory; | |
IInventory iinventory = craftInventory.getInventory(); | |
Container container = new ContainerChest(handle.inventory, iinventory); | |
container.checkReachable = false; | |
sendPacket(new Packet101CloseWindow(handle.activeContainer.windowId)); | |
handle.activeContainer.transferTo(container, craftPlayer); | |
if (handleinventory.getCarried() != null) { | |
handle.updateInventory(container); | |
} | |
int counter = handle.nextContainerCounter(); | |
int windowType = CraftContainer.getNotchInventoryType(inventory.getType()); | |
String title = iinventory.getName(); | |
int size = iinventory.getSize(); | |
boolean useTitle = true; | |
handle.playerConnection.sendPacket(new Packet100OpenWindow(counter, windowType, title, size, useTitle)); | |
handle.activeContainer = container; | |
handle.activeContainer.windowId = counter; | |
handle.activeContainer.addSlotListener(handle); | |
} else { | |
player.openInventory(inventory); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment