Created
June 22, 2013 00:51
-
-
Save mooman219/5835354 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 void openInventory(Inventory inventory) { | |
if(isInventoryOpen()) { | |
EntityPlayer handle = getHandle(); | |
CraftPlayer craftPlayer = (CraftPlayer) player; | |
CraftInventory craftInventory = (CraftInventory) inventory; | |
IInventory iinventory = craftInventory.getInventory(); | |
Container container = new ContainerChest(handle.inventory, iinventory); | |
container.checkReachable = false; | |
// | |
dropItemInHand(); | |
sendPacket(new Packet101CloseWindow(handle.activeContainer.windowId)); | |
// | |
handle.activeContainer.transferTo(container, craftPlayer); | |
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); | |
} | |
} | |
public void dropItemInHand() { | |
EntityPlayer handle = getHandle(); | |
PlayerInventory playerinventory = handle.inventory; | |
if (playerinventory.getCarried() != null) { | |
handle.drop(playerinventory.getCarried()); | |
playerinventory.setCarried((ItemStack) null); | |
} | |
} | |
public boolean isInventoryOpen() { | |
EntityPlayer handle = getHandle(); | |
return handle.activeContainer != handle.defaultContainer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment