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

The following examples show how to use net.minecraft.init.Items#bucket() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockLargePot.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
protected boolean applyItemToGarden (World world, int x, int y, int z, EntityPlayer player, ItemStack itemStack, float hitX, float hitY, float hitZ, boolean hitValid) {
    ItemStack item = (itemStack == null) ? player.inventory.getCurrentItem() : itemStack;
    if (item == null)
        return false;

    TileEntityGarden garden = getTileEntity(world, x, y, z);

    if (garden.getSubstrate() != null) {
        if (item.getItem() == Items.bucket) {
            if (Block.getBlockFromItem(garden.getSubstrate().getItem()) == Blocks.water) {
                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.water_bucket));
                garden.setSubstrate(null);
                garden.markDirty();
                world.markBlockForUpdate(x, y, z);
            }
            return true;
        }

        if (item.getItem() == Items.water_bucket) {
            applyWaterToSubstrate(world, x, y, z, garden, player);
            return true;
        }
        else if (item.getItem() instanceof ItemHoe) {
            applyHoeToSubstrate(world, x, y, z, garden, player);
            return true;
        }
    }

    return super.applyItemToGarden(world, x, y, z, player, itemStack, hitX, hitY, hitZ, hitValid);
}
 
Example 2
Source File: EventHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void FillBucket(FillBucketEvent event){
    MovingObjectPosition p = event.target;
    if(event.current == null || event.current.getItem() != Items.bucket || event.world.getBlockMetadata(p.blockX, p.blockY, p.blockZ) != 0) return;
    ItemStack result = attemptFill(event.world, event.target);
    if(result != null) {
        event.result = result;
        AchievementHandler.giveAchievement(event.entityPlayer, result);
        event.setResult(Result.ALLOW);
    }
}
 
Example 3
Source File: BRLoader.java    From BigReactors with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onBucketFill(FillBucketEvent e)
{
    if(e.current.getItem() != Items.bucket)
    {
        return;
    }
    ItemStack filledBucket = fillBucket(e.world, e.target);
    if(filledBucket != null)
    {
        e.world.setBlockToAir(e.target.blockX, e.target.blockY, e.target.blockZ);
        e.result = filledBucket;
        e.setResult(Result.ALLOW);
    }
}