Java Code Examples for net.minecraft.init.Items.bucket()

The following are Jave code examples for showing how to use bucket() of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: ItemBucketMilk.java   View Source Code Vote up 6 votes
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        playerIn.clearActivePotions();
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return stack.stackSize <= 0 ? new ItemStack(Items.bucket) : stack;
}
 
Example 2
Project: DecompiledMinecraft   File: ItemBucketMilk.java   View Source Code Vote up 6 votes
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        playerIn.clearActivePotions();
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return stack.stackSize <= 0 ? new ItemStack(Items.bucket) : stack;
}
 
Example 3
Project: BaseClient   File: EntityCow.java   View Source Code Vote up 6 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.bucket && !player.capabilities.isCreativeMode && !this.isChild())
    {
        if (itemstack.stackSize-- == 1)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.milk_bucket));
        }
        else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
        {
            player.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false);
        }

        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 4
Project: DecompiledMinecraft   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
 */
public void smeltItem()
{
    if (this.canSmelt())
    {
        ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);

        if (this.furnaceItemStacks[2] == null)
        {
            this.furnaceItemStacks[2] = itemstack.copy();
        }
        else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem())
        {
            ++this.furnaceItemStacks[2].stackSize;
        }

        if (this.furnaceItemStacks[0].getItem() == Item.getItemFromBlock(Blocks.sponge) && this.furnaceItemStacks[0].getMetadata() == 1 && this.furnaceItemStacks[1] != null && this.furnaceItemStacks[1].getItem() == Items.bucket)
        {
            this.furnaceItemStacks[1] = new ItemStack(Items.water_bucket);
        }

        --this.furnaceItemStacks[0].stackSize;

        if (this.furnaceItemStacks[0].stackSize <= 0)
        {
            this.furnaceItemStacks[0] = null;
        }
    }
}
 
Example 5
Project: BaseClient   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item,
 * side
 */
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
{
    if (direction == EnumFacing.DOWN && index == 1)
    {
        Item item = stack.getItem();

        if (item != Items.water_bucket && item != Items.bucket)
        {
            return false;
        }
    }

    return true;
}
 
Example 6
Project: DecompiledMinecraft   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item,
 * side
 */
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
{
    if (direction == EnumFacing.DOWN && index == 1)
    {
        Item item = stack.getItem();

        if (item != Items.water_bucket && item != Items.bucket)
        {
            return false;
        }
    }

    return true;
}
 
Example 7
Project: Technical   File: PumpRecipes.java   View Source Code Vote up 5 votes
public static boolean isItemUsedInRecipe(ItemStack itemStack) {
	Item[] itemsUsed = new Item[] { Items.bucket };
	for(Item item : itemsUsed)
		if(item == itemStack.getItem())
			return true;
	return false;
}
 
Example 8
Project: BaseClient   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
 */
public void smeltItem()
{
    if (this.canSmelt())
    {
        ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);

        if (this.furnaceItemStacks[2] == null)
        {
            this.furnaceItemStacks[2] = itemstack.copy();
        }
        else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem())
        {
            ++this.furnaceItemStacks[2].stackSize;
        }

        if (this.furnaceItemStacks[0].getItem() == Item.getItemFromBlock(Blocks.sponge) && this.furnaceItemStacks[0].getMetadata() == 1 && this.furnaceItemStacks[1] != null && this.furnaceItemStacks[1].getItem() == Items.bucket)
        {
            this.furnaceItemStacks[1] = new ItemStack(Items.water_bucket);
        }

        --this.furnaceItemStacks[0].stackSize;

        if (this.furnaceItemStacks[0].stackSize <= 0)
        {
            this.furnaceItemStacks[0] = null;
        }
    }
}
 
Example 9
Project: BaseClient   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item,
 * side
 */
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
{
    if (direction == EnumFacing.DOWN && index == 1)
    {
        Item item = stack.getItem();

        if (item != Items.water_bucket && item != Items.bucket)
        {
            return false;
        }
    }

    return true;
}
 
Example 10
Project: Proyecto-DASI   File: CraftingHelper.java   View Source Code Vote up 4 votes
/** Consume fuel from the player's inventory.<br>
 * Take it first from their cache, if present, and then from their inventory, starting
 * at the first slot and working upwards.
 * @param player
 * @param burnAmount amount of fuel to burn, in ticks.
 */
public static void burnInventory(EntityPlayerMP player, int burnAmount, ItemStack input)
{
    if (!fuelCaches.containsKey(player))
        fuelCaches.put(player, -burnAmount);
    else
        fuelCaches.put(player, fuelCaches.get(player) - burnAmount);
    int index = 0;
    while (fuelCaches.get(player) < 0 && index < player.inventory.mainInventory.length)
    {
        ItemStack is = player.inventory.mainInventory[index];
        if (is != null)
        {
            int burnTime = TileEntityFurnace.getItemBurnTime(is);
            if (burnTime != 0)
            {
                // Consume item:
                if (is.stackSize > 1)
                    is.stackSize--;
                else
                {
                    // If this is a bucket of lava, we need to consume the lava but leave the bucket.
                    if (is.getItem() == Items.lava_bucket)
                    {
                        // And if we're cooking wet sponge, we need to leave the bucket filled with water.
                        if (input.getItem() == Item.getItemFromBlock(Blocks.sponge) && input.getMetadata() == 1)
                            player.inventory.mainInventory[index] = new ItemStack(Items.water_bucket);
                        else
                            player.inventory.mainInventory[index] = new ItemStack(Items.bucket);
                    }
                    else
                        player.inventory.mainInventory[index] = null;
                    index++;
                }
                fuelCaches.put(player, fuelCaches.get(player) + burnTime);
            }
            else
                index++;
        }
        else
            index++;
    }
}
 
Example 11
Project: DecompiledMinecraft   File: ItemBucket.java   View Source Code Vote up 4 votes
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    boolean flag = this.isFull == Blocks.air;
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, flag);

    if (movingobjectposition == null)
    {
        return itemStackIn;
    }
    else
    {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = movingobjectposition.getBlockPos();

            if (!worldIn.isBlockModifiable(playerIn, blockpos))
            {
                return itemStackIn;
            }

            if (flag)
            {
                if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
                {
                    return itemStackIn;
                }

                IBlockState iblockstate = worldIn.getBlockState(blockpos);
                Material material = iblockstate.getBlock().getMaterial();

                if (material == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
                {
                    worldIn.setBlockToAir(blockpos);
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return this.fillBucket(itemStackIn, playerIn, Items.water_bucket);
                }

                if (material == Material.lava && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
                {
                    worldIn.setBlockToAir(blockpos);
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return this.fillBucket(itemStackIn, playerIn, Items.lava_bucket);
                }
            }
            else
            {
                if (this.isFull == Blocks.air)
                {
                    return new ItemStack(Items.bucket);
                }

                BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit);

                if (!playerIn.canPlayerEdit(blockpos1, movingobjectposition.sideHit, itemStackIn))
                {
                    return itemStackIn;
                }

                if (this.tryPlaceContainedLiquid(worldIn, blockpos1) && !playerIn.capabilities.isCreativeMode)
                {
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return new ItemStack(Items.bucket);
                }
            }
        }

        return itemStackIn;
    }
}
 
Example 12
Project: Technical   File: TileEntityCentrifugeAdvanced.java   View Source Code Vote up 4 votes
@Override
public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
	return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
}
 
Example 13
Project: Technical   File: TileEntityElectricFurnace.java   View Source Code Vote up 4 votes
@Override
public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
	return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
}
 
Example 14
Project: Technical   File: TileEntityElectricFurnaceMedium.java   View Source Code Vote up 4 votes
@Override
public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
	return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
}
 
Example 15
Project: DecompiledMinecraft   File: SlotFurnaceFuel.java   View Source Code Vote up 4 votes
public static boolean isBucket(ItemStack stack)
{
    return stack != null && stack.getItem() != null && stack.getItem() == Items.bucket;
}
 
Example 16
Project: Technical   File: TileEntityBlastFurnaceMedium.java   View Source Code Vote up 4 votes
@Override
public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
	return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
}
 
Example 17
Project: BaseClient   File: ItemBucket.java   View Source Code Vote up 4 votes
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    boolean flag = this.isFull == Blocks.air;
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, flag);

    if (movingobjectposition == null)
    {
        return itemStackIn;
    }
    else
    {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = movingobjectposition.getBlockPos();

            if (!worldIn.isBlockModifiable(playerIn, blockpos))
            {
                return itemStackIn;
            }

            if (flag)
            {
                if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
                {
                    return itemStackIn;
                }

                IBlockState iblockstate = worldIn.getBlockState(blockpos);
                Material material = iblockstate.getBlock().getMaterial();

                if (material == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
                {
                    worldIn.setBlockToAir(blockpos);
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return this.fillBucket(itemStackIn, playerIn, Items.water_bucket);
                }

                if (material == Material.lava && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
                {
                    worldIn.setBlockToAir(blockpos);
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return this.fillBucket(itemStackIn, playerIn, Items.lava_bucket);
                }
            }
            else
            {
                if (this.isFull == Blocks.air)
                {
                    return new ItemStack(Items.bucket);
                }

                BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit);

                if (!playerIn.canPlayerEdit(blockpos1, movingobjectposition.sideHit, itemStackIn))
                {
                    return itemStackIn;
                }

                if (this.tryPlaceContainedLiquid(worldIn, blockpos1) && !playerIn.capabilities.isCreativeMode)
                {
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return new ItemStack(Items.bucket);
                }
            }
        }

        return itemStackIn;
    }
}
 
Example 18
Project: BaseClient   File: SlotFurnaceFuel.java   View Source Code Vote up 4 votes
public static boolean isBucket(ItemStack stack)
{
    return stack != null && stack.getItem() != null && stack.getItem() == Items.bucket;
}
 
Example 19
Project: BaseClient   File: SlotFurnaceFuel.java   View Source Code Vote up 4 votes
public static boolean isBucket(ItemStack stack)
{
    return stack != null && stack.getItem() != null && stack.getItem() == Items.bucket;
}
 
Example 20
Project: Technical   File: TileEntityElectrolyser.java   View Source Code Vote up 4 votes
@Override
public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
	return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
}