Exemple #1
0
 public Packet5PlayerInventory(int i, int j, ItemStack itemstack)
 {
     entityID = i;
     slot     = j;
     if (itemstack == null)
     {
         itemID     = -1;
         itemDamage = 0;
     }
     else
     {
         itemID     = itemstack.itemID;
         itemDamage = itemstack.getItemDamage();
     }
 }
Exemple #2
0
 public override void writePacketData(DataOutputStream dataoutputstream)
 {
     dataoutputstream.writeByte(windowId);
     dataoutputstream.writeShort(itemSlot);
     if (myItemStack == null)
     {
         dataoutputstream.writeShort(-1);
     }
     else
     {
         dataoutputstream.writeShort(myItemStack.itemID);
         dataoutputstream.writeByte(myItemStack.stackSize);
         dataoutputstream.writeShort(myItemStack.getItemDamage());
     }
 }
Exemple #3
0
 public override void writePacketData(DataOutputStream dataoutputstream)
 {
     dataoutputstream.writeByte(window_Id);
     dataoutputstream.writeShort(inventorySlot);
     dataoutputstream.writeByte(mouseClick);
     dataoutputstream.writeShort(action);
     if (itemStack == null)
     {
         dataoutputstream.writeShort(-1);
     }
     else
     {
         dataoutputstream.writeShort(itemStack.itemID);
         dataoutputstream.writeByte(itemStack.stackSize);
         dataoutputstream.writeShort(itemStack.getItemDamage());
     }
 }
Exemple #4
0
 public override void writePacketData(DataOutputStream dataoutputstream)
 {
     dataoutputstream.writeInt(xPosition);
     dataoutputstream.write(yPosition);
     dataoutputstream.writeInt(zPosition);
     dataoutputstream.write(direction);
     if (itemStack == null)
     {
         dataoutputstream.writeShort(-1);
     }
     else
     {
         dataoutputstream.writeShort(itemStack.itemID);
         dataoutputstream.writeByte(itemStack.stackSize);
         dataoutputstream.writeShort(itemStack.getItemDamage());
     }
 }
Exemple #5
0
        public bool func_21134_a(InventoryCrafting inventorycrafting)
        {
            var arraylist = new ArrayList(field_21137_b);
            int i         = 0;

            do
            {
                if (i >= 3)
                {
                    break;
                }
                for (int j = 0; j < 3; j++)
                {
                    ItemStack itemstack = inventorycrafting.func_21084_a(j, i);
                    if (itemstack == null)
                    {
                        continue;
                    }
                    bool     flag     = false;
                    Iterator iterator = arraylist.iterator();
                    do
                    {
                        if (!iterator.hasNext())
                        {
                            break;
                        }
                        var itemstack1 = (ItemStack)iterator.next();
                        if (itemstack.itemID != itemstack1.itemID ||
                            itemstack1.getItemDamage() != -1 && itemstack.getItemDamage() != itemstack1.getItemDamage())
                        {
                            continue;
                        }
                        flag = true;
                        arraylist.remove(itemstack1);
                        break;
                    } while (true);
                    if (!flag)
                    {
                        return(false);
                    }
                }

                i++;
            } while (true);
            return(arraylist.isEmpty());
        }
Exemple #6
0
        public override void onBlockRemoval(World world, int i, int j, int k)
        {
            var tileentitychest = (TileEntityChest)world.getBlockTileEntity(i, j, k);

            for (int l = 0; l < tileentitychest.getSizeInventory(); l++)
            {
                ItemStack itemstack = tileentitychest.getStackInSlot(l);
                if (itemstack == null)
                {
                    continue;
                }
                float f  = random.nextFloat() * 0.8F + 0.1F;
                float f1 = random.nextFloat() * 0.8F + 0.1F;
                float f2 = random.nextFloat() * 0.8F + 0.1F;
                do
                {
                    if (itemstack.stackSize <= 0)
                    {
                        goto label0;
                    }
                    int i1 = random.nextInt(21) + 10;
                    if (i1 > itemstack.stackSize)
                    {
                        i1 = itemstack.stackSize;
                    }
                    itemstack.stackSize -= i1;
                    var entityitem = new EntityItem(world, i + f, j + f1, k + f2,
                                                    new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage()));
                    float f3 = 0.05F;
                    entityitem.motionX = (float)random.nextGaussian() * f3;
                    entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
                    entityitem.motionZ = (float)random.nextGaussian() * f3;
                    world.entityJoinedWorld(entityitem);
                } while (true);
            }
label0:
            base.onBlockRemoval(world, i, j, k);
        }
Exemple #7
0
        public override void setEntityDead()
        {
            for (int i = 0; i < getSizeInventory(); i++)
            {
                ItemStack itemstack = getStackInSlot(i);
                if (itemstack == null)
                {
                    continue;
                }
                float f  = rand.nextFloat() * 0.8F + 0.1F;
                float f1 = rand.nextFloat() * 0.8F + 0.1F;
                float f2 = rand.nextFloat() * 0.8F + 0.1F;
                do
                {
                    if (itemstack.stackSize <= 0)
                    {
                        break;
                    }
                    int j = rand.nextInt(21) + 10;
                    if (j > itemstack.stackSize)
                    {
                        j = itemstack.stackSize;
                    }
                    itemstack.stackSize -= j;
                    var entityitem = new EntityItem(worldObj, posX + f, posY + f1,
                                                    posZ + f2,
                                                    new ItemStack(itemstack.itemID, j, itemstack.getItemDamage()));
                    float f3 = 0.05F;
                    entityitem.motionX = (float)rand.nextGaussian() * f3;
                    entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F;
                    entityitem.motionZ = (float)rand.nextGaussian() * f3;
                    worldObj.entityJoinedWorld(entityitem);
                } while (true);
            }

            base.setEntityDead();
        }
        public ItemStack placeItem(int i, int j, EntityPlayer entityplayer)
        {
            ItemStack itemstack = null;

            if (j == 0 || j == 1)
            {
                InventoryPlayer inventoryplayer = entityplayer.inventory;
                if (i == -999)
                {
                    if (inventoryplayer.getItemStack() != null && i == -999)
                    {
                        if (j == 0)
                        {
                            entityplayer.dropPlayerItem(inventoryplayer.getItemStack());
                            inventoryplayer.setItemStack(null);
                        }
                        if (j == 1)
                        {
                            entityplayer.dropPlayerItem(inventoryplayer.getItemStack().splitStack(1));
                            if (inventoryplayer.getItemStack().stackSize == 0)
                            {
                                inventoryplayer.setItemStack(null);
                            }
                        }
                    }
                }
                else
                {
                    var slot = (Slot)inventorySlots.get(i);
                    if (slot != null)
                    {
                        slot.onSlotChanged();
                        ItemStack itemstack1 = slot.getStack();
                        ItemStack itemstack2 = inventoryplayer.getItemStack();
                        if (itemstack1 != null)
                        {
                            itemstack = itemstack1.copy();
                        }
                        if (itemstack1 == null)
                        {
                            if (itemstack2 != null && slot.isItemValid(itemstack2))
                            {
                                int k = j != 0 ? 1 : itemstack2.stackSize;
                                if (k > slot.getSlotStackLimit())
                                {
                                    k = slot.getSlotStackLimit();
                                }
                                slot.putStack(itemstack2.splitStack(k));
                                if (itemstack2.stackSize == 0)
                                {
                                    inventoryplayer.setItemStack(null);
                                }
                            }
                        }
                        else if (itemstack2 == null)
                        {
                            int l = j != 0 ? (itemstack1.stackSize + 1) / 2 : itemstack1.stackSize;
                            inventoryplayer.setItemStack(slot.decrStackSize(l));
                            if (itemstack1.stackSize == 0)
                            {
                                slot.putStack(null);
                            }
                            slot.onPickupFromSlot();
                        }
                        else if (slot.isItemValid(itemstack2))
                        {
                            if (itemstack1.itemID != itemstack2.itemID ||
                                itemstack1.getHasSubtypes() && itemstack1.getItemDamage() != itemstack2.getItemDamage())
                            {
                                if (itemstack2.stackSize <= slot.getSlotStackLimit())
                                {
                                    ItemStack itemstack3 = itemstack1;
                                    slot.putStack(itemstack2);
                                    inventoryplayer.setItemStack(itemstack3);
                                }
                            }
                            else
                            {
                                int i1 = j != 0 ? 1 : itemstack2.stackSize;
                                if (i1 > slot.getSlotStackLimit() - itemstack1.stackSize)
                                {
                                    i1 = slot.getSlotStackLimit() - itemstack1.stackSize;
                                }
                                if (i1 > itemstack2.getMaxStackSize() - itemstack1.stackSize)
                                {
                                    i1 = itemstack2.getMaxStackSize() - itemstack1.stackSize;
                                }
                                itemstack2.splitStack(i1);
                                if (itemstack2.stackSize == 0)
                                {
                                    inventoryplayer.setItemStack(null);
                                }
                                itemstack1.stackSize += i1;
                            }
                        }
                        else if (itemstack1.itemID == itemstack2.itemID && itemstack2.getMaxStackSize() > 1 &&
                                 (!itemstack1.getHasSubtypes() ||
                                  itemstack1.getItemDamage() == itemstack2.getItemDamage()))
                        {
                            int j1 = itemstack1.stackSize;
                            if (j1 > 0 && j1 + itemstack2.stackSize <= itemstack2.getMaxStackSize())
                            {
                                itemstack2.stackSize += j1;
                                itemstack1.splitStack(j1);
                                if (itemstack1.stackSize == 0)
                                {
                                    slot.putStack(null);
                                }
                                slot.onPickupFromSlot();
                            }
                        }
                    }
                }
            }
            return(itemstack);
        }