Exemple #1
0
        /// <summary>
        /// Callback for when the crafting gui is closed.
        /// </summary>
        public override void OnCraftGuiClosed(EntityPlayer par1EntityPlayer)
        {
            base.OnCraftGuiClosed(par1EntityPlayer);

            for (int i = 0; i < 4; i++)
            {
                ItemStack itemstack = CraftMatrix.GetStackInSlotOnClosing(i);

                if (itemstack != null)
                {
                    par1EntityPlayer.DropPlayerItem(itemstack);
                }
            }

            CraftResult.SetInventorySlotContents(0, null);
        }
Exemple #2
0
        /// <summary>
        /// Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
        /// </summary>
        public override ItemStack OnItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
        {
            MovingObjectPosition movingobjectposition = GetMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);

            if (movingobjectposition == null)
            {
                return(par1ItemStack);
            }

            if (movingobjectposition.TypeOfHit == EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.BlockX;
                int j = movingobjectposition.BlockY;
                int k = movingobjectposition.BlockZ;

                if (!par2World.CanMineBlock(par3EntityPlayer, i, j, k))
                {
                    return(par1ItemStack);
                }

                if (!par3EntityPlayer.CanPlayerEdit(i, j, k))
                {
                    return(par1ItemStack);
                }

                if (par2World.GetBlockMaterial(i, j, k) == Material.Water)
                {
                    par1ItemStack.StackSize--;

                    if (par1ItemStack.StackSize <= 0)
                    {
                        return(new ItemStack(Item.Potion));
                    }

                    if (!par3EntityPlayer.Inventory.AddItemStackToInventory(new ItemStack(Item.Potion)))
                    {
                        par3EntityPlayer.DropPlayerItem(new ItemStack(Item.Potion.ShiftedIndex, 1, 0));
                    }
                }
            }

            return(par1ItemStack);
        }
Exemple #3
0
        /// <summary>
        /// Callback for when the crafting gui is closed.
        /// </summary>
        public override void OnCraftGuiClosed(EntityPlayer par1EntityPlayer)
        {
            base.OnCraftGuiClosed(par1EntityPlayer);

            if (WorldObj.IsRemote)
            {
                return;
            }

            for (int i = 0; i < 9; i++)
            {
                ItemStack itemstack = CraftMatrix.GetStackInSlotOnClosing(i);

                if (itemstack != null)
                {
                    par1EntityPlayer.DropPlayerItem(itemstack);
                }
            }
        }