Exemple #1
0
 // Referenced classes of package net.minecraft.src:
 //            ItemFood, ItemStack, Item, World,
 //            EntityPlayer
 public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                              itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                              )
 {
     base.OnItemRightClick(itemstack, world, entityplayer);
     return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.BOWL));
 }
 public virtual net.minecraft.src.ItemStack DecrStackSize(int slotId, int num)
 {
     net.minecraft.src.ItemStack[] aitemstack = mainInventory;
     if (slotId >= mainInventory.Length)
     {
         aitemstack = armorInventory;
         slotId    -= mainInventory.Length;
     }
     if (aitemstack[slotId] != null)
     {
         if (aitemstack[slotId].stackSize <= num)
         {
             net.minecraft.src.ItemStack itemstack = aitemstack[slotId];
             aitemstack[slotId] = null;
             return(itemstack);
         }
         net.minecraft.src.ItemStack itemstack1 = aitemstack[slotId].SplitStack(num);
         if (aitemstack[slotId].stackSize <= 0)                 //SHARP: == to <=, ideally it should never matter
         {
             aitemstack[slotId] = null;
         }
         return(itemstack1);
     }
     else
     {
         return(null);
     }
 }
Exemple #3
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)
        {
            int i1 = world.GetBlockId(i, j, k);
            int j1 = world.GetBlockId(i, j + 1, k);

            if (l != 0 && j1 == 0 && i1 == net.minecraft.src.Block.GRASS.ID || i1 == net.minecraft.src.Block
                .DIRT.ID)
            {
                net.minecraft.src.Block block = net.minecraft.src.Block.SOIL;
                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);
                if (world.singleplayerWorld)
                {
                    return(true);
                }
                else
                {
                    world.SetBlockWithNotify(i, j, k, block.ID);
                    itemstack.DamageItem(1, entityplayer);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
        public virtual bool Func_325_c(int i, int j, int k)
        {
            int l  = thisWorld.GetBlockId(i, j, k);
            int i1 = thisWorld.GetBlockMetadata(i, j, k);

            thisWorld.SendSoundEffectToAllPlayersWithin64(thisPlayer, 2001, i, j, k, l + thisWorld.GetBlockMetadata(
                                                              i, j, k) * 256);
            bool flag = RemoveBlock(i, j, k);

            net.minecraft.src.ItemStack itemstack = thisPlayer.GetCurrentEquippedItem();
            if (itemstack != null)
            {
                itemstack.Func_25124_a(l, i, j, k, thisPlayer);
                if (itemstack.stackSize == 0)
                {
                    itemstack.Func_577_a(thisPlayer);
                    thisPlayer.DestroyCurrentEquippedItem();
                }
            }
            if (flag && thisPlayer.CanHarvestBlock(net.minecraft.src.Block.blocksList[l]))
            {
                net.minecraft.src.Block.blocksList[l].HarvestBlock(thisWorld, thisPlayer, i, j, k
                                                                   , i1);
                ((net.minecraft.src.EntityPlayerMP)thisPlayer).netServerHandler.SendPacket(
                    new net.minecraft.src.Packet53BlockChange(i, j, k, thisWorld));
            }
            return(flag);
        }
Exemple #5
0
 public TileEntityChest()
 {
     // Referenced classes of package net.minecraft.src:
     //            TileEntity, IInventory, ItemStack, NBTTagCompound,
     //            NBTTagList, World, EntityPlayer
     items = new net.minecraft.src.ItemStack[27];             // CRAFTBUKKIT 36 -> 27
 }
 public Achievement(int i, string s, int j, int k, net.minecraft.src.ItemStack itemstack
                    , net.minecraft.src.Achievement achievement)
     : base(0x500000 + i, net.minecraft.src.StatCollector.TranslateToLocal("achievement." + s))
 {
     // Referenced classes of package net.minecraft.src:
     //            StatBase, ItemStack, StatCollector, AchievementList,
     //            Item, Block
     theItemStack  = itemstack;
     field_27063_l = net.minecraft.src.StatCollector.TranslateToLocal("achievement." + s + ".desc");
     field_25067_a = j;
     field_27991_b = k;
     if (j < net.minecraft.src.AchievementList.field_27114_a)
     {
         net.minecraft.src.AchievementList.field_27114_a = j;
     }
     if (k < net.minecraft.src.AchievementList.field_27113_b)
     {
         net.minecraft.src.AchievementList.field_27113_b = k;
     }
     if (j > net.minecraft.src.AchievementList.field_27112_c)
     {
         net.minecraft.src.AchievementList.field_27112_c = j;
     }
     if (k > net.minecraft.src.AchievementList.field_27111_d)
     {
         net.minecraft.src.AchievementList.field_27111_d = k;
     }
     field_27992_c = achievement;
 }
Exemple #7
0
 protected internal override void ReadEntityFromNBT(net.minecraft.src.NBTTagCompound nbttagcompound)
 {
     health = nbttagcompound.GetShort("Health") & 0xff;
     age    = nbttagcompound.GetShort("Age");
     net.minecraft.src.NBTTagCompound nbttagcompound1 = nbttagcompound.GetCompoundTag("Item");
     item = new net.minecraft.src.ItemStack(nbttagcompound1);
 }
Exemple #8
0
 public virtual void SmeltItem()
 {
     if (!CanSmelt())
     {
         return;
     }
     net.minecraft.src.ItemStack itemstack = net.minecraft.src.FurnaceRecipes.Smelting
                                                 ().GetSmeltingResult(furnaceItemStacks[0].GetItem().ID);
     if (furnaceItemStacks[2] == null)
     {
         furnaceItemStacks[2] = itemstack.Copy();
     }
     else
     {
         if (furnaceItemStacks[2].itemID == itemstack.itemID)
         {
             furnaceItemStacks[2].stackSize++;
         }
     }
     furnaceItemStacks[0].stackSize--;
     if (furnaceItemStacks[0].stackSize <= 0)
     {
         furnaceItemStacks[0] = null;
     }
 }
Exemple #9
0
 private bool CanSmelt()
 {
     if (furnaceItemStacks[0] == null)
     {
         return(false);
     }
     net.minecraft.src.ItemStack itemstack = net.minecraft.src.FurnaceRecipes.Smelting
                                                 ().GetSmeltingResult(furnaceItemStacks[0].GetItem().ID);
     if (itemstack == null)
     {
         return(false);
     }
     if (furnaceItemStacks[2] == null)
     {
         return(true);
     }
     if (!furnaceItemStacks[2].IsItemEqual(itemstack))
     {
         return(false);
     }
     if (furnaceItemStacks[2].stackSize < GetInventoryStackLimit() && furnaceItemStacks
         [2].stackSize < furnaceItemStacks[2].GetMaxStackSize())
     {
         return(true);
     }
     return(furnaceItemStacks[2].stackSize < itemstack.GetMaxStackSize());
 }
 public virtual void ReadFromNBT(net.minecraft.src.NBTTagList nbttaglist)
 {
     mainInventory  = new net.minecraft.src.ItemStack[36];
     armorInventory = new net.minecraft.src.ItemStack[4];
     for (int i = 0; i < nbttaglist.TagCount(); i++)
     {
         net.minecraft.src.NBTTagCompound nbttagcompound = (net.minecraft.src.NBTTagCompound
                                                            )nbttaglist.TagAt(i);
         int j = nbttagcompound.GetByte("Slot");
         net.minecraft.src.ItemStack itemstack = new net.minecraft.src.ItemStack(nbttagcompound
                                                                                 );
         if (itemstack.GetItem() == null)
         {
             continue;
         }
         if (j >= 0 && j < mainInventory.Length)
         {
             mainInventory[j] = itemstack;
         }
         if (j >= 100 && j < armorInventory.Length + 100)
         {
             armorInventory[j - 100] = itemstack;
         }
     }
 }
        internal virtual void AddShapelessRecipe(net.minecraft.src.ItemStack itemstack, object[] aobj)
        {
            List <ItemStack> arraylist = new List <ItemStack>();

            object[] aobj1 = aobj;
            int      i     = aobj1.Length;

            for (int j = 0; j < i; j++)
            {
                object obj = aobj1[j];
                if (obj is net.minecraft.src.ItemStack)
                {
                    arraylist.Add(((net.minecraft.src.ItemStack)obj).Copy());
                    continue;
                }
                if (obj is net.minecraft.src.Item)
                {
                    arraylist.Add(new net.minecraft.src.ItemStack((net.minecraft.src.Item)obj));
                    continue;
                }
                if (obj is net.minecraft.src.Block)
                {
                    arraylist.Add(new net.minecraft.src.ItemStack((net.minecraft.src.Block)obj));
                }
                else
                {
                    throw new System.Exception("Invalid shapeless recipy!");
                }
            }
            recipes.Add(new net.minecraft.src.ShapelessRecipes(itemstack, arraylist));
        }
Exemple #12
0
        public virtual void DropPlayerItemWithRandomChoice(net.minecraft.src.ItemStack itemstack, bool randomDirection)
        {
            if (itemstack == null)
            {
                return;
            }
            net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj, posX, (posY - 0.30000001192092896D) + (double)GetEyeHeight(), posZ, itemstack);
            entityitem.delayBeforeCanPickup = 40;
            float f = 0.1F;

            if (randomDirection)
            {
                float f2 = rand.NextFloat() * 0.5F;
                float f4 = rand.NextFloat() * 3.141593F * 2.0F;
                entityitem.motionX = -net.minecraft.src.MathHelper.Sin(f4) * f2;
                entityitem.motionZ = net.minecraft.src.MathHelper.Cos(f4) * f2;
                entityitem.motionY = 0.20000000298023224D;
            }
            else
            {
                float f1 = 0.3F;
                entityitem.motionX = -net.minecraft.src.MathHelper.Sin((rotationYaw / 180F) * 3.141593F) * net.minecraft.src.MathHelper.Cos((rotationPitch / 180F) * 3.141593F) * f1;
                entityitem.motionZ = net.minecraft.src.MathHelper.Cos((rotationYaw / 180F) * 3.141593F) * net.minecraft.src.MathHelper.Cos((rotationPitch / 180F) * 3.141593F) * f1;
                entityitem.motionY = -net.minecraft.src.MathHelper.Sin((rotationPitch / 180F) * 3.141593F) * f1 + 0.1F;
                f1 = 0.02F;
                float f3 = rand.NextFloat() * 3.141593F * 2.0F;
                f1 *= rand.NextFloat();
                entityitem.motionX += System.Math.Cos(f3) * (double)f1;
                entityitem.motionY += (rand.NextFloat() - rand.NextFloat()) * 0.1F;
                entityitem.motionZ += System.Math.Sin(f3) * (double)f1;
            }
            JoinEntityItemWithWorld(entityitem);
            AddStat(net.minecraft.src.StatList.StatDrop, 1);
        }
 public override net.minecraft.src.ItemStack Func_27086_a(int i)
 {
     net.minecraft.src.ItemStack itemstack = null;
     net.minecraft.src.Slot      slot      = (net.minecraft.src.Slot)inventorySlots[i];
     if (slot != null && slot.Func_27006_b())
     {
         net.minecraft.src.ItemStack itemstack1 = slot.GetStack();
         itemstack = itemstack1.Copy();
         if (i < field_27088_b * 9)
         {
             Func_28126_a(itemstack1, field_27088_b * 9, inventorySlots.Count, true);
         }
         else
         {
             Func_28126_a(itemstack1, 0, field_27088_b * 9, false);
         }
         if (itemstack1.stackSize == 0)
         {
             slot.PutStack(null);
         }
         else
         {
             slot.OnSlotChanged();
         }
     }
     return(itemstack);
 }
        public virtual bool AddItemStackToInventory(net.minecraft.src.ItemStack itemstack
                                                    )
        {
            if (!itemstack.IsItemDamaged())
            {
                int i;
                do
                {
                    i = itemstack.stackSize;
                    itemstack.stackSize = Func_21083_d(itemstack);
                }while (itemstack.stackSize > 0 && itemstack.stackSize < i);
                return(itemstack.stackSize < i);
            }
            int j = GetFirstEmptyStack();

            if (j >= 0)
            {
                mainInventory[j] = net.minecraft.src.ItemStack.CloneStack(itemstack);
                mainInventory[j].animationsToGo = 5;
                itemstack.stackSize             = 0;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #15
0
        private int GetItemBurnTime(net.minecraft.src.ItemStack itemstack)
        {
            if (itemstack == null)
            {
                return(0);
            }
            int i = itemstack.GetItem().ID;

            if (i < 256 && net.minecraft.src.Block.blocksList[i].blockMaterial == net.minecraft.src.Material
                .wood)
            {
                return(300);
            }
            if (i == net.minecraft.src.Item.STICK.ID)
            {
                return(100);
            }
            if (i == net.minecraft.src.Item.COAL.ID)
            {
                return(1600);
            }
            if (i == net.minecraft.src.Item.LAVA_BUCKET.ID)
            {
                return(20000);
            }
            return(i != net.minecraft.src.Block.SAPLING.ID ? 0 : 100);
        }
Exemple #16
0
 public EntityItem(net.minecraft.src.World world, double x, double y, double z, net.minecraft.src.ItemStack itemstack)
     : base(world)
 {
     // Referenced classes of package net.minecraft.src:
     //            Entity, MathHelper, World, Material,
     //            AxisAlignedBB, Block, NBTTagCompound, ItemStack,
     //            EntityPlayer, InventoryPlayer, AchievementList, Item
     age          = 0;
     health       = 5;
     field_432_ae = (float)(SharpRandom.NextDouble() * 3.1415926535897931D * 2D);
     SetSize(0.25F, 0.25F);
     yOffset = height / 2.0F;
     SetPosition(x, y, z);
     item = itemstack;
     // CRAFTBUKKIT start - infinite item fix
     if (this.item.stackSize <= -1)
     {
         this.item.stackSize = 1;
     }
     // CRAFTBUKKIT end
     rotationYaw = (float)(SharpRandom.NextDouble() * 360D);
     motionX     = (float)(SharpRandom.NextDouble() * 0.20000000298023224D - 0.10000000149011612D);
     motionY     = 0.20000000298023224D;
     motionZ     = (float)(SharpRandom.NextDouble() * 0.20000000298023224D - 0.10000000149011612D);
 }
Exemple #17
0
 protected internal override void ReadEntityFromNBT(net.minecraft.src.NBTTagCompound
                                                    nbttagcompound)
 {
     minecartType = nbttagcompound.GetInteger("Type");
     if (minecartType == 2)
     {
         pushX = nbttagcompound.GetDouble("PushX");
         pushZ = nbttagcompound.GetDouble("PushZ");
         fuel  = nbttagcompound.GetShort("Fuel");
     }
     else
     {
         if (minecartType == 1)
         {
             net.minecraft.src.NBTTagList nbttaglist = nbttagcompound.GetTagList("Items");
             cargoItems = new net.minecraft.src.ItemStack[GetSizeInventory()];
             for (int i = 0; i < nbttaglist.TagCount(); i++)
             {
                 net.minecraft.src.NBTTagCompound nbttagcompound1 = (net.minecraft.src.NBTTagCompound
                                                                     )nbttaglist.TagAt(i);
                 int j = nbttagcompound1.GetByte("Slot");
                 if (j >= 0 && j < cargoItems.Length)
                 {
                     cargoItems[j] = new net.minecraft.src.ItemStack(nbttagcompound1);
                 }
             }
         }
     }
 }
 public ShapelessRecipes(net.minecraft.src.ItemStack itemstack, List <ItemStack> list)
 {
     // Referenced classes of package net.minecraft.src:
     //            IRecipe, InventoryCrafting, ItemStack
     field_21138_a = itemstack;
     field_21137_b = list;
 }
 public Packet103SetSlot(int i, int j, net.minecraft.src.ItemStack itemstack)
 {
     // Referenced classes of package net.minecraft.src:
     //            Packet, ItemStack, NetHandler
     windowId    = i;
     itemSlot    = j;
     myItemStack = itemstack != null?itemstack.Copy() : itemstack;
 }
Exemple #20
0
 public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                              itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                              )
 {
     itemstack.stackSize--;
     entityplayer.Heal(healAmount);
     return(itemstack);
 }
Exemple #21
0
 public TileEntityDispenser()
 {
     // Referenced classes of package net.minecraft.src:
     //            TileEntity, IInventory, ItemStack, NBTTagCompound,
     //            NBTTagList, World, EntityPlayer
     dispenserContents = new net.minecraft.src.ItemStack[9];
     dispenserRandom   = new SharpBukkitLive.SharpBukkit.SharpRandom();
 }
Exemple #22
0
 public virtual net.minecraft.src.EntityItem EntityDropItem(net.minecraft.src.ItemStack
                                                            itemstack, float f)
 {
     net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj
                                                                                , posX, posY + (double)f, posZ, itemstack);
     entityitem.delayBeforeCanPickup = 10;
     worldObj.AddEntity(entityitem);
     return(entityitem);
 }
Exemple #23
0
 public virtual void SetInventorySlotContents(int i, net.minecraft.src.ItemStack itemstack
                                              )
 {
     cargoItems[i] = itemstack;
     if (itemstack != null && itemstack.stackSize > GetInventoryStackLimit())
     {
         itemstack.stackSize = GetInventoryStackLimit();
     }
 }
 public virtual void SetInventorySlotContents(int slotId, net.minecraft.src.ItemStack itemstack)
 {
     net.minecraft.src.ItemStack[] aitemstack = mainInventory;
     if (slotId >= aitemstack.Length)
     {
         slotId    -= aitemstack.Length;
         aitemstack = armorInventory;
     }
     aitemstack[slotId] = itemstack;
 }
Exemple #25
0
 public virtual void SetInventorySlotContents(int i, net.minecraft.src.ItemStack itemstack
                                              )
 {
     dispenserContents[i] = itemstack;
     if (itemstack != null && itemstack.stackSize > GetInventoryStackLimit())
     {
         itemstack.stackSize = GetInventoryStackLimit();
     }
     OnInventoryChanged();
 }
Exemple #26
0
 public override bool Func_25007_a(net.minecraft.src.ItemStack itemstack, int i, int
                                   j, int k, int l, net.minecraft.src.EntityLiving entityliving)
 {
     if (i == net.minecraft.src.Block.LEAVES.ID || i == net.minecraft.src.Block.WEB
         .ID)
     {
         itemstack.DamageItem(1, entityliving);
     }
     return(base.Func_25007_a(itemstack, i, j, k, l, entityliving));
 }
Exemple #27
0
        public InventoryCrafting(net.minecraft.src.Container container, int i, int j)
        {
            // Referenced classes of package net.minecraft.src:
            //            IInventory, ItemStack, Container, EntityPlayer
            int k = i * j;

            stackList     = new net.minecraft.src.ItemStack[k];
            eventHandler  = container;
            field_21085_b = i;
        }
Exemple #28
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 (world.CanBlockBePlacedAt(field_253_a, i, j, k, false, l))
     {
         net.minecraft.src.Block block = net.minecraft.src.Block.blocksList[field_253_a];
         if (world.SetBlockWithNotify(i, j, k, field_253_a))
         {
             net.minecraft.src.Block.blocksList[field_253_a].OnBlockPlaced(world, i, j, k, l);
             net.minecraft.src.Block.blocksList[field_253_a].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);
 }
Exemple #29
0
 //TODO: Bukkit fixes
 public TileEntityFurnace()
 {
     // Referenced classes of package net.minecraft.src:
     //            TileEntity, IInventory, ItemStack, NBTTagCompound,
     //            NBTTagList, World, BlockFurnace, FurnaceRecipes,
     //            Item, Block, Material, EntityPlayer
     furnaceItemStacks   = new net.minecraft.src.ItemStack[3];
     furnaceBurnTime     = 0;
     currentItemBurnTime = 0;
     furnaceCookTime     = 0;
 }
Exemple #30
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 (l == 0)
     {
         return(false);
     }
     if (!world.GetBlockMaterial(i, j, k).IsSolid())
     {
         return(false);
     }
     if (l == 1)
     {
         j++;
     }
     if (l == 2)
     {
         k--;
     }
     if (l == 3)
     {
         k++;
     }
     if (l == 4)
     {
         i--;
     }
     if (l == 5)
     {
         i++;
     }
     if (!net.minecraft.src.Block.SIGN_POST.CanPlaceBlockAt(world, i, j, k))
     {
         return(false);
     }
     if (l == 1)
     {
         world.SetBlockAndMetadataWithNotify(
             i, j, k,
             net.minecraft.src.Block.SIGN_POST.ID,
             net.minecraft.src.MathHelper.Floor_double((double)(((entityplayer.rotationYaw + 180F) * 16F) / 360F) + 0.5D) & 0xf);
     }
     else
     {
         world.SetBlockAndMetadataWithNotify(i, j, k, net.minecraft.src.Block.WALL_SIGN.ID, l);
     }
     itemstack.stackSize--;
     net.minecraft.src.TileEntitySign tileentitysign = (net.minecraft.src.TileEntitySign
                                                        )world.GetBlockTileEntity(i, j, k);
     if (tileentitysign != null)
     {
         entityplayer.DisplayGUIEditSign(tileentitysign);
     }
     return(true);
 }