Exemplo n.º 1
0
        public override void func_20007_a(Packet102 packet102)
        {
            if (playerEntity.currentCraftingInventory.windowId == packet102.window_Id &&
                playerEntity.currentCraftingInventory.getCanCraft(playerEntity))
            {
                ItemStack itemstack = playerEntity.currentCraftingInventory.placeItem(packet102.inventorySlot,
                                                                                      packet102.mouseClick, playerEntity);
                if (ItemStack.areItemStacksEqual(packet102.itemStack, itemstack))
                {
                    playerEntity.playerNetServerHandler.sendPacket(new Packet106(packet102.window_Id, packet102.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(packet102.action));
                    playerEntity.playerNetServerHandler.sendPacket(new Packet106(packet102.window_Id, packet102.action,
                                                                                 false));
                    playerEntity.currentCraftingInventory.setCanCraft(playerEntity, false);
                    var 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);
                }
            }
        }
Exemplo n.º 2
0
        public virtual void updateCraftingMatrix()
        {
            for (int i = 0; i < inventorySlots.size(); i++)
            {
                ItemStack itemstack  = ((Slot)inventorySlots.get(i)).getStack();
                var       itemstack1 = (ItemStack)inventoryItemStacks.get(i);
                if (ItemStack.areItemStacksEqual(itemstack1, itemstack))
                {
                    continue;
                }
                itemstack1 = itemstack != null?itemstack.copy() : null;

                inventoryItemStacks.set(i, itemstack1);
                for (int j = 0; j < crafters.size(); j++)
                {
                    ((ICrafting)crafters.get(j)).updateCraftingInventorySlot(this, i, itemstack1);
                }
            }
        }
Exemplo n.º 3
0
        public override void handlePlace(Packet15Place packet15place)
        {
            ItemStack itemstack = playerEntity.inventory.getCurrentItem();
            bool      flag      = mcServer.worldMngr.field_819_z = mcServer.configManager.isOp(playerEntity.username);

            if (packet15place.direction == 255)
            {
                if (itemstack == null)
                {
                    return;
                }
                playerEntity.itemInWorldManager.func_6154_a(playerEntity, mcServer.worldMngr, itemstack);
            }
            else
            {
                int i = packet15place.xPosition;
                int j = packet15place.yPosition;
                int k = packet15place.zPosition;
                int l = packet15place.direction;
                ChunkCoordinates chunkcoordinates = mcServer.worldMngr.func_22078_l();
                var i1 = (int)MathHelper.abs(i - chunkcoordinates.posX);
                var j1 = (int)MathHelper.abs(k - chunkcoordinates.posZ);
                if (i1 > j1)
                {
                    j1 = i1;
                }
                if (j1 > 16 || flag)
                {
                    playerEntity.itemInWorldManager.activeBlockOrUseItem(playerEntity, mcServer.worldMngr, itemstack, i,
                                                                         j, k, l);
                }
                playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, mcServer.worldMngr));
                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, mcServer.worldMngr));
            }
            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 Packet103(playerEntity.currentCraftingInventory.windowId, slot.id,
                                         playerEntity.inventory.getCurrentItem()));
            }
            mcServer.worldMngr.field_819_z = false;
        }