public virtual bool Func_21134_a(net.minecraft.src.InventoryCrafting inventorycrafting
                                         )
        {
            System.Collections.ArrayList arraylist = new System.Collections.ArrayList(field_21137_b
                                                                                      );
            int i = 0;

            do
            {
                if (i >= 3)
                {
                    break;
                }
                for (int j = 0; j < 3; j++)
                {
                    net.minecraft.src.ItemStack itemstack = inventorycrafting.Func_21084_a(j, i);
                    if (itemstack == null)
                    {
                        continue;
                    }
                    bool flag = false;
                    System.Collections.IEnumerator iterator = arraylist.GetEnumerator();
                    do
                    {
                        if (!iterator.MoveNext())
                        {
                            break;
                        }
                        net.minecraft.src.ItemStack itemstack1 = (net.minecraft.src.ItemStack)iterator.Current;
                        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.Count < 1);
        }
Exemple #2
0
 private bool Func_21139_a(net.minecraft.src.InventoryCrafting inventorycrafting,
                           int i, int j, bool flag)
 {
     for (int k = 0; k < 3; k++)
     {
         for (int l = 0; l < 3; l++)
         {
             int i1 = k - i;
             int j1 = l - j;
             net.minecraft.src.ItemStack itemstack = null;
             if (i1 >= 0 && j1 >= 0 && i1 < field_21140_b && j1 < field_21144_c)
             {
                 if (flag)
                 {
                     itemstack = field_21143_d[(field_21140_b - i1 - 1) + j1 * field_21140_b];
                 }
                 else
                 {
                     itemstack = field_21143_d[i1 + j1 * field_21140_b];
                 }
             }
             net.minecraft.src.ItemStack itemstack1 = inventorycrafting.Func_21084_a(k, l);
             if (itemstack1 == null && itemstack == null)
             {
                 continue;
             }
             if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack ==
                 null)
             {
                 return(false);
             }
             if (itemstack.itemID != itemstack1.itemID)
             {
                 return(false);
             }
             if (itemstack.GetItemDamage() != -1 && itemstack.GetItemDamage() != itemstack1.GetItemDamage
                     ())
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #3
0
 public override void SaddleEntity(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityLiving
                                   entityliving)
 {
     if (entityliving is net.minecraft.src.EntitySheep)
     {
         net.minecraft.src.EntitySheep entitysheep = (net.minecraft.src.EntitySheep)entityliving;
         int i = net.minecraft.src.BlockCloth.Func_21033_c(itemstack.GetItemDamage());
         if (!entitysheep.Func_21069_f_() && entitysheep.GetFleeceColor() != i)
         {
             entitysheep.SetFleeceColor(i);
             itemstack.stackSize--;
         }
     }
 }
Exemple #4
0
        public virtual net.minecraft.src.MapData Func_28023_a(net.minecraft.src.ItemStack
                                                              itemstack, net.minecraft.src.World world)
        {
            string s = (new java.lang.StringBuilder()).Append("map_").Append(itemstack.GetItemDamage
                                                                                 ()).ToString();

            net.minecraft.src.MapData mapdata = (net.minecraft.src.MapData)world.Func_28103_a
                                                    (Sharpen.Runtime.GetClassForType(typeof(net.minecraft.src.MapData)), (new java.lang.StringBuilder
                                                                                                                              ()).Append("map_").Append(itemstack.GetItemDamage()).ToString());
            if (mapdata == null)
            {
                itemstack.SetItemDamage(world.Func_28104_b("map"));
                string s1 = (new java.lang.StringBuilder()).Append("map_").Append(itemstack.GetItemDamage
                                                                                      ()).ToString();
                mapdata = new net.minecraft.src.MapData(s1);
                mapdata.field_28164_b = world.GetWorldInfo().GetSpawnX();
                mapdata.field_28163_c = world.GetWorldInfo().GetSpawnZ();
                mapdata.field_28161_e = 3;
                mapdata.field_28162_d = unchecked ((byte)world.worldProvider.worldType);
                mapdata.Func_28146_a();
                world.Func_28102_a(s1, mapdata);
            }
            return(mapdata);
        }
Exemple #5
0
 public override net.minecraft.src.Packet Func_28022_b(net.minecraft.src.ItemStack
                                                       itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                       )
 {
     byte[] abyte0 = Func_28023_a(itemstack, world).Func_28154_a(itemstack, world, entityplayer
                                                                 );
     if (abyte0 == null)
     {
         return(null);
     }
     else
     {
         return(new net.minecraft.src.Packet131MapData((short)net.minecraft.src.Item.MAP
                                                       .ID, (short)itemstack.GetItemDamage(), abyte0));
     }
 }
Exemple #6
0
        public override void Func_28020_c(net.minecraft.src.ItemStack itemstack, net.minecraft.src.World
                                          world, net.minecraft.src.EntityPlayer entityplayer)
        {
            itemstack.SetItemDamage(world.Func_28104_b("map"));
            string s = (new java.lang.StringBuilder()).Append("map_").Append(itemstack.GetItemDamage
                                                                                 ()).ToString();

            net.minecraft.src.MapData mapdata = new net.minecraft.src.MapData(s);
            world.Func_28102_a(s, mapdata);
            mapdata.field_28164_b = net.minecraft.src.MathHelper.Floor_double(entityplayer.posX
                                                                              );
            mapdata.field_28163_c = net.minecraft.src.MathHelper.Floor_double(entityplayer.posZ
                                                                              );
            mapdata.field_28161_e = 3;
            mapdata.field_28162_d = unchecked ((byte)world.worldProvider.worldType);
            mapdata.Func_28146_a();
        }
Exemple #7
0
 public Packet5PlayerInventory(int id, int slot, net.minecraft.src.ItemStack itemstack)
 {
     // Referenced classes of package net.minecraft.src:
     //            Packet, ItemStack, NetHandler
     entityID  = id;
     this.slot = slot;
     if (itemstack == null)
     {
         itemID     = -1;
         itemDamage = 0;
     }
     else
     {
         itemID     = itemstack.itemID;
         itemDamage = itemstack.GetItemDamage();
     }
 }
        private int Func_21083_d(net.minecraft.src.ItemStack itemstack)
        {
            int i = itemstack.itemID;
            int j = itemstack.stackSize;
            int k = Func_21082_c(itemstack);

            if (k < 0)
            {
                k = GetFirstEmptyStack();
            }
            if (k < 0)
            {
                return(j);
            }
            if (mainInventory[k] == null)
            {
                mainInventory[k] = new net.minecraft.src.ItemStack(i, 0, itemstack.GetItemDamage(
                                                                       ));
            }
            int l = j;

            if (l > mainInventory[k].GetMaxStackSize() - mainInventory[k].stackSize)
            {
                l = mainInventory[k].GetMaxStackSize() - mainInventory[k].stackSize;
            }
            if (l > GetInventoryStackLimit() - mainInventory[k].stackSize)
            {
                l = GetInventoryStackLimit() - mainInventory[k].stackSize;
            }
            if (l == 0)
            {
                return(j);
            }
            else
            {
                j -= l;
                mainInventory[k].stackSize     += l;
                mainInventory[k].animationsToGo = 5;
                return(j);
            }
        }
        /// <exception cref="System.IO.IOException"/>
        private static void WriteWatchableObject(java.io.DataOutputStream dataoutputstream, net.minecraft.src.WatchableObject watchableobject)
        {
            int i = (watchableobject.GetObjectType() << 5 | watchableobject.GetDataValueId()
                     & 0x1f) & 0xff;

            dataoutputstream.WriteByte(i);
            switch (watchableobject.GetObjectType())
            {
            case 0:
            {
                // '\0'
                dataoutputstream.WriteByte(((byte)watchableobject.GetObject()));
                break;
            }

            case 1:
            {
                // '\001'
                dataoutputstream.WriteShort(((short)watchableobject.GetObject()));
                break;
            }

            case 2:
            {
                // '\002'
                dataoutputstream.WriteInt(((int)watchableobject.GetObject()));
                break;
            }

            case 3:
            {
                // '\003'
                dataoutputstream.WriteFloat(((float)watchableobject.GetObject()));
                break;
            }

            case 4:
            {
                // '\004'
                net.minecraft.src.Packet.WriteString((string)watchableobject.GetObject(), dataoutputstream
                                                     );
                break;
            }

            case 5:
            {
                // '\005'
                net.minecraft.src.ItemStack itemstack = (net.minecraft.src.ItemStack)watchableobject
                                                        .GetObject();
                dataoutputstream.WriteShort(itemstack.GetItem().ID);
                dataoutputstream.WriteByte(itemstack.stackSize);
                dataoutputstream.WriteShort(itemstack.GetItemDamage());
                break;
            }

            case 6:
            {
                // '\006'
                net.minecraft.src.ChunkCoordinates chunkcoordinates = (net.minecraft.src.ChunkCoordinates
                                                                       )watchableobject.GetObject();
                dataoutputstream.WriteInt(chunkcoordinates.posX);
                dataoutputstream.WriteInt(chunkcoordinates.posY);
                dataoutputstream.WriteInt(chunkcoordinates.posZ);
                break;
            }
            }
        }
Exemple #10
0
 public override bool AttackEntityFrom(net.minecraft.src.Entity entity, int i)
 {
     if (worldObj.singleplayerWorld || isDead)
     {
         return(true);
     }
     forwardDirection = -forwardDirection;
     field_9167_b     = 10;
     SetBeenAttacked();
     damageTaken += i * 10;
     if (damageTaken > 40)
     {
         if (riddenByEntity != null)
         {
             riddenByEntity.MountEntity(this);
         }
         SetEntityDead();
         DropItemWithOffset(net.minecraft.src.Item.MINECART.ID, 1, 0.0F);
         if (minecartType == 1)
         {
             net.minecraft.src.EntityMinecart entityminecart = this;
             for (int j = 0; j < entityminecart.GetSizeInventory(); j++)
             {
                 net.minecraft.src.ItemStack itemstack = entityminecart.GetStackInSlot(j);
                 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)
                     {
                         goto label0_continue;
                     }
                     int k = rand.Next(21) + 10;
                     if (k > itemstack.stackSize)
                     {
                         k = itemstack.stackSize;
                     }
                     itemstack.stackSize -= k;
                     net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj
                                                                                                , posX + (double)f, posY + (double)f1, posZ + (double)f2, new net.minecraft.src.ItemStack
                                                                                                    (itemstack.itemID, k, 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.AddEntity(entityitem);
                 }while (true);
                 label0_continue :;
             }
             label0_break :;
             DropItemWithOffset(net.minecraft.src.Block.CHEST.ID, 1, 0.0F);
         }
         else
         {
             if (minecartType == 2)
             {
                 DropItemWithOffset(net.minecraft.src.Block.FURNACE.ID, 1, 0.0F);
             }
         }
     }
     return(true);
 }
 private int Func_21082_c(net.minecraft.src.ItemStack itemstack)
 {
     for (int i = 0; i < mainInventory.Length; i++)
     {
         if (mainInventory[i] != null && mainInventory[i].itemID == itemstack.itemID && mainInventory
             [i].Func_21132_c() && mainInventory[i].stackSize < mainInventory[i].GetMaxStackSize
                 () && mainInventory[i].stackSize < GetInventoryStackLimit() && (!mainInventory[i
                                                                                 ].GetHasSubtypes() || mainInventory[i].GetItemDamage() == itemstack.GetItemDamage
                                                                                     ()))
         {
             return(i);
         }
     }
     return(-1);
 }
 public override void OnBlockRemoval(net.minecraft.src.World world, int i, int j,
                                     int k)
 {
     net.minecraft.src.TileEntityDispenser tileentitydispenser = (net.minecraft.src.TileEntityDispenser
                                                                  )world.GetBlockTileEntity(i, j, k);
     for (int l = 0; l < tileentitydispenser.GetSizeInventory(); l++)
     {
         net.minecraft.src.ItemStack itemstack = tileentitydispenser.GetStackInSlot(l);
         if (itemstack == null)
         {
             continue;
         }
         float f  = field_28032_a.NextFloat() * 0.8F + 0.1F;
         float f1 = field_28032_a.NextFloat() * 0.8F + 0.1F;
         float f2 = field_28032_a.NextFloat() * 0.8F + 0.1F;
         do
         {
             if (itemstack.stackSize <= 0)
             {
                 goto label0_continue;
             }
             int i1 = field_28032_a.Next(21) + 10;
             if (i1 > itemstack.stackSize)
             {
                 i1 = itemstack.stackSize;
             }
             itemstack.stackSize -= i1;
             net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world,
                                                                                        (float)i + f, (float)j + f1, (float)k + f2, new net.minecraft.src.ItemStack(itemstack
                                                                                                                                                                    .itemID, i1, itemstack.GetItemDamage()));
             float f3 = 0.05F;
             entityitem.motionX = (float)field_28032_a.NextGaussian() * f3;
             entityitem.motionY = (float)field_28032_a.NextGaussian() * f3 + 0.2F;
             entityitem.motionZ = (float)field_28032_a.NextGaussian() * f3;
             world.AddEntity(entityitem);
         }while (true);
         label0_continue :;
     }
     label0_break :;
     base.OnBlockRemoval(world, i, j, k);
 }
Exemple #13
0
 public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
 {
     if (itemstack.GetItemDamage() == 15)
     {
         int i1 = world.GetBlockId(i, j, k);
         if (i1 == net.minecraft.src.Block.SAPLING.ID)
         {
             if (!world.singleplayerWorld)
             {
                 ((net.minecraft.src.BlockSapling)net.minecraft.src.Block.SAPLING).GrowTree(world,
                                                                                            i, j, k, world.rand);
                 itemstack.stackSize--;
             }
             return(true);
         }
         if (i1 == net.minecraft.src.Block.CROPS.ID)
         {
             if (!world.singleplayerWorld)
             {
                 ((net.minecraft.src.BlockCrops)net.minecraft.src.Block.CROPS).Fertilize(world, i,
                                                                                         j, k);
                 itemstack.stackSize--;
             }
             return(true);
         }
         if (i1 == net.minecraft.src.Block.GRASS.ID)
         {
             if (!world.singleplayerWorld)
             {
                 itemstack.stackSize--;
                 for (int j1 = 0; j1 < 128; j1++)
                 {
                     int k1 = i;
                     int l1 = j + 1;
                     int i2 = k;
                     for (int j2 = 0; j2 < j1 / 16; j2++)
                     {
                         k1 += itemRand.Next(3) - 1;
                         l1 += ((itemRand.Next(3) - 1) * itemRand.Next(3)) / 2;
                         i2 += itemRand.Next(3) - 1;
                         if (world.GetBlockId(k1, l1 - 1, i2) != net.minecraft.src.Block.GRASS.ID ||
                             world.IsBlockNormalCube(k1, l1, i2))
                         {
                             goto label0_continue;
                         }
                     }
                     if (world.GetBlockId(k1, l1, i2) != 0)
                     {
                         continue;
                     }
                     if (itemRand.Next(10) != 0)
                     {
                         world.SetBlockAndMetadataWithNotify(k1, l1, i2, net.minecraft.src.Block.LONG_GRASS
                                                             .ID, 1);
                         continue;
                     }
                     if (itemRand.Next(3) != 0)
                     {
                         world.SetBlockWithNotify(k1, l1, i2, net.minecraft.src.Block.YELLOW_FLOWER.ID);
                     }
                     else
                     {
                         world.SetBlockWithNotify(k1, l1, i2, net.minecraft.src.Block.RED_ROSE.ID);
                     }
                     label0_continue :;
                 }
                 label0_break :;
             }
             return(true);
         }
     }
     return(false);
 }
Exemple #14
0
 public virtual net.minecraft.src.ItemStack Func_27085_a(int i, int j, bool flag,
                                                         net.minecraft.src.EntityPlayer entityplayer)
 {
     net.minecraft.src.ItemStack itemstack = null;
     if (j == 0 || j == 1)
     {
         net.minecraft.src.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
         {
             if (flag)
             {
                 net.minecraft.src.ItemStack itemstack1 = Func_27086_a(i);
                 if (itemstack1 != null)
                 {
                     int k = itemstack1.stackSize;
                     itemstack = itemstack1.Copy();
                     net.minecraft.src.Slot slot1 = (net.minecraft.src.Slot)inventorySlots[i];
                     if (slot1 != null && slot1.GetStack() != null)
                     {
                         int l = slot1.GetStack().stackSize;
                         if (l < k)
                         {
                             Func_27085_a(i, j, flag, entityplayer);
                         }
                     }
                 }
             }
             else
             {
                 net.minecraft.src.Slot slot = (net.minecraft.src.Slot)inventorySlots[i];
                 if (slot != null)
                 {
                     slot.OnSlotChanged();
                     net.minecraft.src.ItemStack itemstack2 = slot.GetStack();
                     net.minecraft.src.ItemStack itemstack3 = inventoryplayer.GetItemStack();
                     if (itemstack2 != null)
                     {
                         itemstack = itemstack2.Copy();
                     }
                     if (itemstack2 == null)
                     {
                         if (itemstack3 != null && slot.IsItemValid(itemstack3))
                         {
                             int i1 = j != 0 ? 1 : itemstack3.stackSize;
                             if (i1 > slot.GetSlotStackLimit())
                             {
                                 i1 = slot.GetSlotStackLimit();
                             }
                             slot.PutStack(itemstack3.SplitStack(i1));
                             if (itemstack3.stackSize == 0)
                             {
                                 inventoryplayer.SetItemStack(null);
                             }
                         }
                     }
                     else
                     {
                         if (itemstack3 == null)
                         {
                             int j1 = j != 0 ? (itemstack2.stackSize + 1) / 2 : itemstack2.stackSize;
                             net.minecraft.src.ItemStack itemstack5 = slot.DecrStackSize(j1);
                             inventoryplayer.SetItemStack(itemstack5);
                             if (itemstack2.stackSize == 0)
                             {
                                 slot.PutStack(null);
                             }
                             slot.OnPickupFromSlot(inventoryplayer.GetItemStack());
                         }
                         else
                         {
                             if (slot.IsItemValid(itemstack3))
                             {
                                 if (itemstack2.itemID != itemstack3.itemID || itemstack2.GetHasSubtypes() && itemstack2
                                     .GetItemDamage() != itemstack3.GetItemDamage())
                                 {
                                     if (itemstack3.stackSize <= slot.GetSlotStackLimit())
                                     {
                                         net.minecraft.src.ItemStack itemstack4 = itemstack2;
                                         slot.PutStack(itemstack3);
                                         inventoryplayer.SetItemStack(itemstack4);
                                     }
                                 }
                                 else
                                 {
                                     int k1 = j != 0 ? 1 : itemstack3.stackSize;
                                     if (k1 > slot.GetSlotStackLimit() - itemstack2.stackSize)
                                     {
                                         k1 = slot.GetSlotStackLimit() - itemstack2.stackSize;
                                     }
                                     if (k1 > itemstack3.GetMaxStackSize() - itemstack2.stackSize)
                                     {
                                         k1 = itemstack3.GetMaxStackSize() - itemstack2.stackSize;
                                     }
                                     itemstack3.SplitStack(k1);
                                     if (itemstack3.stackSize == 0)
                                     {
                                         inventoryplayer.SetItemStack(null);
                                     }
                                     itemstack2.stackSize += k1;
                                 }
                             }
                             else
                             {
                                 if (itemstack2.itemID == itemstack3.itemID && itemstack3.GetMaxStackSize() > 1 &&
                                     (!itemstack2.GetHasSubtypes() || itemstack2.GetItemDamage() == itemstack3.GetItemDamage
                                          ()))
                                 {
                                     int l1 = itemstack2.stackSize;
                                     if (l1 > 0 && l1 + itemstack3.stackSize <= itemstack3.GetMaxStackSize())
                                     {
                                         itemstack3.stackSize += l1;
                                         itemstack2.SplitStack(l1);
                                         if (itemstack2.stackSize == 0)
                                         {
                                             slot.PutStack(null);
                                         }
                                         slot.OnPickupFromSlot(inventoryplayer.GetItemStack());
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(itemstack);
 }
Exemple #15
0
 public override void SetEntityDead()
 {
     for (int i = 0; i < GetSizeInventory(); i++)
     {
         net.minecraft.src.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)
             {
                 goto label0_continue;
             }
             int j = rand.Next(21) + 10;
             if (j > itemstack.stackSize)
             {
                 j = itemstack.stackSize;
             }
             itemstack.stackSize -= j;
             net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj
                                                                                        , posX + (double)f, posY + (double)f1, posZ + (double)f2, new net.minecraft.src.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.AddEntity(entityitem);
         }while (true);
         label0_continue :;
     }
     label0_break :;
     base.SetEntityDead();
 }
Exemple #16
0
        protected internal virtual void Func_28126_a(net.minecraft.src.ItemStack itemstack
                                                     , int i, int j, bool flag)
        {
            int k = i;

            if (flag)
            {
                k = j - 1;
            }
            if (itemstack.Func_21132_c())
            {
                while (itemstack.stackSize > 0 && (!flag && k < j || flag && k >= i))
                {
                    net.minecraft.src.Slot      slot       = (net.minecraft.src.Slot)inventorySlots[k];
                    net.minecraft.src.ItemStack itemstack1 = slot.GetStack();
                    if (itemstack1 != null && itemstack1.itemID == itemstack.itemID && (!itemstack.GetHasSubtypes
                                                                                            () || itemstack.GetItemDamage() == itemstack1.GetItemDamage()))
                    {
                        int i1 = itemstack1.stackSize + itemstack.stackSize;
                        if (i1 <= itemstack.GetMaxStackSize())
                        {
                            itemstack.stackSize  = 0;
                            itemstack1.stackSize = i1;
                            slot.OnSlotChanged();
                        }
                        else
                        {
                            if (itemstack1.stackSize < itemstack.GetMaxStackSize())
                            {
                                itemstack.stackSize -= itemstack.GetMaxStackSize() - itemstack1.stackSize;
                                itemstack1.stackSize = itemstack.GetMaxStackSize();
                                slot.OnSlotChanged();
                            }
                        }
                    }
                    if (flag)
                    {
                        k--;
                    }
                    else
                    {
                        k++;
                    }
                }
            }
            if (itemstack.stackSize > 0)
            {
                int l;
                if (flag)
                {
                    l = j - 1;
                }
                else
                {
                    l = i;
                }
                do
                {
                    if ((flag || l >= j) && (!flag || l < i))
                    {
                        break;
                    }
                    net.minecraft.src.Slot      slot1      = (net.minecraft.src.Slot)inventorySlots[l];
                    net.minecraft.src.ItemStack itemstack2 = slot1.GetStack();
                    if (itemstack2 == null)
                    {
                        slot1.PutStack(itemstack.Copy());
                        slot1.OnSlotChanged();
                        itemstack.stackSize = 0;
                        break;
                    }
                    if (flag)
                    {
                        l--;
                    }
                    else
                    {
                        l++;
                    }
                }while (true);
            }
        }
Exemple #17
0
 public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
 {
     if (world.GetBlockId(i, j, k) == net.minecraft.src.Block.SNOW.ID)
     {
         l = 0;
     }
     else
     {
         if (l == 0)
         {
             j--;
         }
         if (l == 1)
         {
             j++;
         }
         if (l == 2)
         {
             k--;
         }
         if (l == 3)
         {
             k++;
         }
         if (l == 4)
         {
             i--;
         }
         if (l == 5)
         {
             i++;
         }
     }
     if (itemstack.stackSize == 0)
     {
         return(false);
     }
     if (j == 127 && net.minecraft.src.Block.blocksList[blockID].blockMaterial.IsSolid
             ())
     {
         return(false);
     }
     if (world.CanBlockBePlacedAt(blockID, i, j, k, false, l))
     {
         net.minecraft.src.Block block = net.minecraft.src.Block.blocksList[blockID];
         if (world.SetBlockAndMetadataWithNotify(i, j, k, blockID, GetMetadata(itemstack.GetItemDamage
                                                                                   ())))
         {
             net.minecraft.src.Block.blocksList[blockID].OnBlockPlaced(world, i, j, k, l);
             net.minecraft.src.Block.blocksList[blockID].OnBlockPlacedBy(world, i, j, k, entityplayer
                                                                         );
             world.PlaySoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, block.stepSound
                                   .Func_737_c(), (block.stepSound.GetVolume() + 1.0F) / 2.0F, block.stepSound.GetPitch
                                       () * 0.8F);
             itemstack.stackSize--;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }