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); } } }
/** Updates crafting matrix; called from onCraftMatrixChanged. Args: none */ public void updateCraftingResults() { for (int var1 = 0; var1 < this.inventorySlots.size(); ++var1) { ItemStack var2 = ((Slot) this.inventorySlots.get(var1)).getStack(); ItemStack var3 = (ItemStack) this.inventoryItemStacks.get(var1); if (!ItemStack.areItemStacksEqual(var3, var2)) { var3 = var2 == null ? null : var2.copy(); this.inventoryItemStacks.set(var1, var3); Iterator var4 = this.crafters.iterator(); while (var4.hasNext()) { ICrafting var5 = (ICrafting) var4.next(); var5.updateCraftingInventorySlot(this, var1, var3); } } } }
public void handleWindowClick(Packet102WindowClick par1Packet102WindowClick) { if (this.playerEntity.craftingInventory.windowId == par1Packet102WindowClick.window_Id && this.playerEntity.craftingInventory.getCanCraft(this.playerEntity)) { ItemStack var2 = this.playerEntity.craftingInventory.slotClick( par1Packet102WindowClick.inventorySlot, par1Packet102WindowClick.mouseClick, par1Packet102WindowClick.holdingShift, this.playerEntity); if (ItemStack.areItemStacksEqual(par1Packet102WindowClick.itemStack, var2)) { this.playerEntity.playerNetServerHandler.sendPacket( new Packet106Transaction( par1Packet102WindowClick.window_Id, par1Packet102WindowClick.action, true)); this.playerEntity.isChangingQuantityOnly = true; this.playerEntity.craftingInventory.updateCraftingResults(); this.playerEntity.updateHeldItem(); this.playerEntity.isChangingQuantityOnly = false; } else { this.field_72586_s.addKey( this.playerEntity.craftingInventory.windowId, Short.valueOf(par1Packet102WindowClick.action)); this.playerEntity.playerNetServerHandler.sendPacket( new Packet106Transaction( par1Packet102WindowClick.window_Id, par1Packet102WindowClick.action, false)); this.playerEntity.craftingInventory.setCanCraft(this.playerEntity, false); ArrayList var3 = new ArrayList(); for (int var4 = 0; var4 < this.playerEntity.craftingInventory.inventorySlots.size(); ++var4) { var3.add( ((Slot) this.playerEntity.craftingInventory.inventorySlots.get(var4)).getStack()); } this.playerEntity.updateCraftingInventory(this.playerEntity.craftingInventory, var3); } } }
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; }
public void handlePlace(Packet15Place par1Packet15Place) { WorldServer var2 = this.mcServer.getWorldManager(this.playerEntity.dimension); ItemStack var3 = this.playerEntity.inventory.getCurrentItem(); boolean var4 = false; int var5 = par1Packet15Place.getXPosition(); int var6 = par1Packet15Place.getYPosition(); int var7 = par1Packet15Place.getZPosition(); int var8 = par1Packet15Place.getDirection(); boolean var9 = var2.disableSpawnProtection = var2.provider.worldType != 0 || this.mcServer.getConfigurationManager().isOp(this.playerEntity.username) || this.mcServer.isSinglePlayer(); if (par1Packet15Place.getDirection() == 255) { if (var3 == null) { return; } this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, var2, var3); } else if (par1Packet15Place.getYPosition() >= this.mcServer.getBuildLimit() - 1 && (par1Packet15Place.getDirection() == 1 || par1Packet15Place.getYPosition() >= this.mcServer.getBuildLimit())) { this.playerEntity.playerNetServerHandler.sendPacket( new Packet3Chat("\u00a77Height limit for building is " + this.mcServer.getBuildLimit())); var4 = true; } else { ChunkCoordinates var10 = var2.getSpawnPoint(); int var11 = MathHelper.abs(var5 - var10.posX); int var12 = MathHelper.abs(var7 - var10.posZ); if (var11 > var12) { var12 = var11; } if (this.hasMoved && this.playerEntity.getDistanceSq( (double) var5 + 0.5D, (double) var6 + 0.5D, (double) var7 + 0.5D) < 64.0D && (var12 > 16 || var9)) { this.playerEntity.theItemInWorldManager.activateBlockOrUseItem( this.playerEntity, var2, var3, var5, var6, var7, var8, par1Packet15Place.getXOffset(), par1Packet15Place.getYOffset(), par1Packet15Place.getZOffset()); } var4 = true; } if (var4) { this.playerEntity.playerNetServerHandler.sendPacket( new Packet53BlockChange(var5, var6, var7, var2)); if (var8 == 0) { --var6; } if (var8 == 1) { ++var6; } if (var8 == 2) { --var7; } if (var8 == 3) { ++var7; } if (var8 == 4) { --var5; } if (var8 == 5) { ++var5; } this.playerEntity.playerNetServerHandler.sendPacket( new Packet53BlockChange(var5, var6, var7, var2)); } var3 = this.playerEntity.inventory.getCurrentItem(); if (var3 != null && var3.stackSize == 0) { this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = null; var3 = null; } if (var3 == null || var3.getMaxItemUseDuration() == 0) { this.playerEntity.isChangingQuantityOnly = true; this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack( this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]); Slot var13 = this.playerEntity.craftingInventory.func_75147_a( this.playerEntity.inventory, this.playerEntity.inventory.currentItem); this.playerEntity.craftingInventory.updateCraftingResults(); this.playerEntity.isChangingQuantityOnly = false; if (!ItemStack.areItemStacksEqual( this.playerEntity.inventory.getCurrentItem(), par1Packet15Place.getItemStack())) { this.sendPacket( new Packet103SetSlot( this.playerEntity.craftingInventory.windowId, var13.slotNumber, this.playerEntity.inventory.getCurrentItem())); } } var2.disableSpawnProtection = false; }