net.minecraft.block.BlockCauldron Java Examples

The following examples show how to use net.minecraft.block.BlockCauldron. 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: TileEntitySaltFurnace.java    From TofuCraftReload with MIT License 6 votes vote down vote up
/**
 * gets the water Level of the cauldron above this block
 *
 * @return water level. 0-3, int.
 * If there is no cauldron, returns negative value. -1, -2: must put fire one/two blck above, -3: inflammable
 */
@SuppressWarnings("deprecation")
public int getCauldronStatus() {
    IBlockState stateUp = this.world.getBlockState(this.pos.up());
    if (stateUp.getBlock() == Blocks.CAULDRON)
        return stateUp.getValue(BlockCauldron.LEVEL);
    else {
        Block block = stateUp.getBlock();
        if (block.isAir(stateUp, world, this.getPos().up()) || block == Blocks.FIRE) return -1;
        else if (!block.getMaterial(stateUp).getCanBurn()) return -3;
        else {
            IBlockState state2Up = this.world.getBlockState(this.pos.up(2));
            if (state2Up.getBlock().isAir(state2Up, world, this.pos.up(2))) return -2;
            else return -3;
        }
    }
}
 
Example #2
Source File: MetaItem1.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onEntityItemUpdate(EntityItem itemEntity) {
    int damage = itemEntity.getItem().getMetadata();
    if (damage >= this.metaItemOffset || itemEntity.getEntityWorld().isRemote)
        return false;
    Material material = Material.MATERIAL_REGISTRY.getObjectById(damage % 1000);
    OrePrefix prefix = this.orePrefixes[(damage / 1000)];
    if (!purifyMap.containsKey(prefix))
        return false;
    BlockPos blockPos = new BlockPos(itemEntity);
    IBlockState blockState = itemEntity.getEntityWorld().getBlockState(blockPos);
    int waterLevel = blockState.getBlock() instanceof BlockCauldron ?
        blockState.getValue(BlockCauldron.LEVEL) : 0;
    if (waterLevel == 0)
        return false;
    itemEntity.getEntityWorld().setBlockState(blockPos,
        blockState.withProperty(BlockCauldron.LEVEL, waterLevel - 1));
    ItemStack replacementStack = OreDictUnifier.get(purifyMap.get(prefix), material,
        itemEntity.getItem().getCount());
    itemEntity.setItem(replacementStack);
    return false;
}
 
Example #3
Source File: ItemHeavyChain.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public boolean onItemUse (ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    Block block = world.getBlock(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);

    if (block instanceof BlockCauldron && side == 1 && itemStack.getItemDamage() == 0) {
        int waterLevel = BlockCauldron.func_150027_b(meta);
        if (waterLevel == 0)
            return false;

        ItemStack newItem = new ItemStack(ModBlocks.heavyChain, 1, 3);
        itemStack.stackSize--;

        EntityItem itemEntity = new EntityItem(world, x + .5, y + 1.5, z + .5, newItem);
        itemEntity.playSound("random.splash", 0.25F, 1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.4F);

        world.spawnEntityInWorld(itemEntity);
        return true;
    }

    return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
 
Example #4
Source File: ItemLatticeMetal.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public boolean onItemUse (ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    Block block = world.getBlock(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);

    if (block instanceof BlockCauldron && side == 1 && itemStack.getItemDamage() == 0) {
        int waterLevel = BlockCauldron.func_150027_b(meta);
        if (waterLevel == 0)
            return false;

        ItemStack newItem = new ItemStack(ModBlocks.latticeMetal, 1, 1);
        itemStack.stackSize--;

        EntityItem itemEntity = new EntityItem(world, x + .5, y + 1.5, z + .5, newItem);
        itemEntity.playSound("random.splash", 0.25F, 1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.4F);

        world.spawnEntityInWorld(itemEntity);
        return true;
    }

    return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
 
Example #5
Source File: ItemLightChain.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public boolean onItemUse (ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    Block block = world.getBlock(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);

    if (block instanceof BlockCauldron && side == 1 && itemStack.getItemDamage() == 0) {
        int waterLevel = BlockCauldron.func_150027_b(meta);
        if (waterLevel == 0)
            return false;

        ItemStack newItem = new ItemStack(ModBlocks.lightChain, 1, 3);
        itemStack.stackSize--;

        EntityItem itemEntity = new EntityItem(world, x + .5, y + 1.5, z + .5, newItem);
        itemEntity.playSound("random.splash", 0.25F, 1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.4F);

        world.spawnEntityInWorld(itemEntity);
        return true;
    }

    return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
 
Example #6
Source File: TileEntitySaltFurnace.java    From TofuCraftReload with MIT License 5 votes vote down vote up
private void updateCauldronStatus() {
    int stat = this.getCauldronStatus();

    if (this.lastCauldronStatus != stat && this.world.getBlockState(this.pos.up()).getBlock() == Blocks.CAULDRON) {
        int metadata = this.world.getBlockState(this.pos.up()).getValue(BlockCauldron.LEVEL);
        IBlockState newMetadata = Blocks.CAULDRON.getDefaultState().withProperty(BlockCauldron.LEVEL, metadata);
        this.world.setBlockState(this.pos.up(), newMetadata, 2);
        this.lastCauldronStatus = stat;
    }
}
 
Example #7
Source File: ItemPotteryPatternDirty.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public boolean onItemUse (ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (side != 1)
        return false;

    Block block = world.getBlock(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);

    if (block instanceof BlockCauldron) {
        int waterLevel = BlockCauldron.func_150027_b(meta);
        if (waterLevel == 0)
            return false;

        int index = getPatternIndex(world);
        if (index == -1)
            return false;

        PatternConfig pattern = GardenContainers.config.getPattern(index);
        if (pattern == null)
            return false;

        ItemStack stamp = new ItemStack(ModItems.potteryPattern, 1, pattern.getId());

        itemStack.stackSize--;

        world.spawnEntityInWorld(new EntityItem(world, x + .5, y + 1.5, z + .5, stamp));

        return true;
    }

    return false;
}
 
Example #8
Source File: DyeWashingHandler.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onPlayerInteractBlock(PlayerInteractEvent.RightClickBlock event) {
	
	if (event.getWorld().isRemote ||
	    event.getEntityPlayer().isSneaking()) return;
	
	// Check if item is washable and currently dyed.
	ItemStack stack = event.getItemStack();
	if (!(stack.getItem() instanceof IDyeableItem) ||
	    !((IDyeableItem)stack.getItem()).canWash(stack) ||
	    !NbtUtils.has(stack, "display", "color")) return;
	
	// Check if block is a cauldron.
	IBlockState state = event.getWorld().getBlockState(event.getPos());
	if (!(state.getBlock() instanceof BlockCauldron)) return;
	BlockCauldron block = (BlockCauldron)state.getBlock();
	
	// Check if water is in the cauldron.
	int level = state.getValue(BlockCauldron.LEVEL);
	if (level <= 0) return;
	
	// Remove the color from the item!
	NbtUtils.remove(stack, "display", "color");
	// Use up some water from the cauldron!
	block.setWaterLevel(event.getWorld(), event.getPos(), state, level - 1);
	// Increase "armor cleaned" statistic! Wheee!
	event.getEntityPlayer().addStat(StatList.ARMOR_CLEANED);
	
	// Cancel the event, as the item / cauldron was used.
	event.setCanceled(true);
	
}
 
Example #9
Source File: TileEntitySaltFurnace.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * returns water level without checking wether there is a cauldron or not.
 */
private int getCauldronWaterLevel() {
    return world.getBlockState(this.pos.up()).getValue(BlockCauldron.LEVEL);
}
 
Example #10
Source File: TileEntitySaltFurnace.java    From TofuCraftReload with MIT License 4 votes vote down vote up
private void setCauldronWaterLevel(int level) {
    world.setBlockState(this.pos.up(), this.world.getBlockState(this.pos.up()).withProperty(BlockCauldron.LEVEL, level), 2);
}