public void func_20007_a(Packet102WindowClick packet102windowclick) { if (playerEntity.currentCraftingInventory.windowId == packet102windowclick.window_Id && playerEntity.currentCraftingInventory.getCanCraft(playerEntity)) { ItemStack itemstack = playerEntity.currentCraftingInventory.func_27085_a( packet102windowclick.inventorySlot, packet102windowclick.mouseClick, packet102windowclick.field_27039_f, playerEntity); if (ItemStack.areItemStacksEqual(packet102windowclick.itemStack, itemstack)) { playerEntity.playerNetServerHandler.sendPacket( new Packet106Transaction( packet102windowclick.window_Id, packet102windowclick.action, true)); playerEntity.isChangingQuantityOnly = true; playerEntity.currentCraftingInventory.updateCraftingMatrix(); playerEntity.updateHeldItem(); playerEntity.isChangingQuantityOnly = false; } else { field_10_k.put( Integer.valueOf(playerEntity.currentCraftingInventory.windowId), Short.valueOf(packet102windowclick.action)); playerEntity.playerNetServerHandler.sendPacket( new Packet106Transaction( packet102windowclick.window_Id, packet102windowclick.action, false)); playerEntity.currentCraftingInventory.setCanCraft(playerEntity, false); ArrayList arraylist = new ArrayList(); for (int i = 0; i < playerEntity.currentCraftingInventory.inventorySlots.size(); i++) { arraylist.add( ((Slot) playerEntity.currentCraftingInventory.inventorySlots.get(i)).getStack()); } playerEntity.updateCraftingInventory(playerEntity.currentCraftingInventory, arraylist); } } }
public void handleWindowClick(Packet102WindowClick par1Packet102WindowClick) { if (playerEntity.craftingInventory.windowId == par1Packet102WindowClick.window_Id && playerEntity.craftingInventory.isPlayerNotUsingContainer(playerEntity)) { ItemStack itemstack = playerEntity.craftingInventory.slotClick( par1Packet102WindowClick.inventorySlot, par1Packet102WindowClick.mouseClick, par1Packet102WindowClick.holdingShift, playerEntity); if (ItemStack.areItemStacksEqual(par1Packet102WindowClick.itemStack, itemstack)) { playerEntity.serverForThisPlayer.sendPacketToPlayer( new Packet106Transaction( par1Packet102WindowClick.window_Id, par1Packet102WindowClick.action, true)); playerEntity.playerInventoryBeingManipulated = true; playerEntity.craftingInventory.updateCraftingResults(); playerEntity.sendInventoryToPlayer(); playerEntity.playerInventoryBeingManipulated = false; } else { field_72586_s.addKey( playerEntity.craftingInventory.windowId, Short.valueOf(par1Packet102WindowClick.action)); playerEntity.serverForThisPlayer.sendPacketToPlayer( new Packet106Transaction( par1Packet102WindowClick.window_Id, par1Packet102WindowClick.action, false)); playerEntity.craftingInventory.setPlayerIsPresent(playerEntity, false); ArrayList arraylist = new ArrayList(); for (int i = 0; i < playerEntity.craftingInventory.inventorySlots.size(); i++) { arraylist.add(((Slot) playerEntity.craftingInventory.inventorySlots.get(i)).getStack()); } playerEntity.sendContainerAndContentsToPlayer(playerEntity.craftingInventory, arraylist); } } }
public void handlePlace(Packet15Place par1Packet15Place) { WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension); ItemStack itemstack = playerEntity.inventory.getCurrentItem(); boolean flag = false; int i = par1Packet15Place.getXPosition(); int j = par1Packet15Place.getYPosition(); int k = par1Packet15Place.getZPosition(); int l = par1Packet15Place.getDirection(); boolean flag1 = worldserver.actionsAllowed = worldserver.provider.worldType != 0 || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username) || mcServer.isSinglePlayer(); if (par1Packet15Place.getDirection() == 255) { if (itemstack == null) { return; } playerEntity.theItemInWorldManager.tryUseItem(playerEntity, worldserver, itemstack); } else if (par1Packet15Place.getYPosition() < mcServer.getBuildLimit() - 1 || par1Packet15Place.getDirection() != 1 && par1Packet15Place.getYPosition() < mcServer.getBuildLimit()) { ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint(); int i1 = MathHelper.abs_int(i - chunkcoordinates.posX); int j1 = MathHelper.abs_int(k - chunkcoordinates.posZ); if (i1 > j1) { j1 = i1; } if (field_72587_r && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D) < 64D && (j1 > 16 || flag1)) { playerEntity.theItemInWorldManager.activateBlockOrUseItem( playerEntity, worldserver, itemstack, i, j, k, l, par1Packet15Place.getXOffset(), par1Packet15Place.getYOffset(), par1Packet15Place.getZOffset()); } flag = true; } else { playerEntity.serverForThisPlayer.sendPacketToPlayer( new Packet3Chat( (new StringBuilder()) .append("\2477Height limit for building is ") .append(mcServer.getBuildLimit()) .toString())); flag = true; } if (flag) { playerEntity.serverForThisPlayer.sendPacketToPlayer( new Packet53BlockChange(i, j, k, worldserver)); if (l == 0) { j--; } if (l == 1) { j++; } if (l == 2) { k--; } if (l == 3) { k++; } if (l == 4) { i--; } if (l == 5) { i++; } playerEntity.serverForThisPlayer.sendPacketToPlayer( new Packet53BlockChange(i, j, k, worldserver)); } itemstack = playerEntity.inventory.getCurrentItem(); if (itemstack != null && itemstack.stackSize == 0) { playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null; itemstack = null; } if (itemstack == null || itemstack.getMaxItemUseDuration() == 0) { playerEntity.playerInventoryBeingManipulated = true; playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = ItemStack.copyItemStack( playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]); Slot slot = playerEntity.craftingInventory.getSlotFromInventory( playerEntity.inventory, playerEntity.inventory.currentItem); playerEntity.craftingInventory.updateCraftingResults(); playerEntity.playerInventoryBeingManipulated = false; if (!ItemStack.areItemStacksEqual( playerEntity.inventory.getCurrentItem(), par1Packet15Place.getItemStack())) { sendPacketToPlayer( new Packet103SetSlot( playerEntity.craftingInventory.windowId, slot.slotNumber, playerEntity.inventory.getCurrentItem())); } } worldserver.actionsAllowed = false; }
public void handlePlace(Packet15Place packet15place) { WorldServer worldserver = mcServer.getWorldManager(playerEntity.dimension); ItemStack itemstack = playerEntity.inventory.getCurrentItem(); boolean flag = worldserver.field_819_z = worldserver.worldProvider.worldType != 0 || mcServer.configManager.isOp(playerEntity.username); if (packet15place.direction == 255) { if (itemstack == null) { return; } playerEntity.itemInWorldManager.func_6154_a(playerEntity, worldserver, itemstack); } else { int i = packet15place.xPosition; int j = packet15place.yPosition; int k = packet15place.zPosition; int l = packet15place.direction; ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint(); int i1 = (int) MathHelper.abs(i - chunkcoordinates.posX); int j1 = (int) MathHelper.abs(k - chunkcoordinates.posZ); if (i1 > j1) { j1 = i1; } if (hasMoved && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D) < 64D && (j1 > 16 || flag)) { playerEntity.itemInWorldManager.activeBlockOrUseItem( playerEntity, worldserver, itemstack, i, j, k, l); } playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver)); if (l == 0) { j--; } if (l == 1) { j++; } if (l == 2) { k--; } if (l == 3) { k++; } if (l == 4) { i--; } if (l == 5) { i++; } playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver)); } itemstack = playerEntity.inventory.getCurrentItem(); if (itemstack != null && itemstack.stackSize == 0) { playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null; } playerEntity.isChangingQuantityOnly = true; playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = ItemStack.func_20117_a( playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]); Slot slot = playerEntity.currentCraftingInventory.func_20127_a( playerEntity.inventory, playerEntity.inventory.currentItem); playerEntity.currentCraftingInventory.updateCraftingMatrix(); playerEntity.isChangingQuantityOnly = false; if (!ItemStack.areItemStacksEqual( playerEntity.inventory.getCurrentItem(), packet15place.itemStack)) { sendPacket( new Packet103SetSlot( playerEntity.currentCraftingInventory.windowId, slot.id, playerEntity.inventory.getCurrentItem())); } worldserver.field_819_z = false; }