Search in sources :

Example 1 with BlockCauldron

use of net.minecraft.block.BlockCauldron in project SpongeCommon by SpongePowered.

the class DefaultTeleportHelperFilter method isSafeBodyMaterial.

@Override
public boolean isSafeBodyMaterial(BlockState blockState) {
    IBlockState state = BlockUtil.toNative(blockState);
    Material material = state.getMaterial();
    // Deny blocks that suffocate
    if (state.causesSuffocation()) {
        return false;
    }
    // Deny dangerous lava
    if (material == Material.LAVA) {
        return false;
    }
    // Deny non-passable non "full" blocks
    return !(state.getBlock() instanceof BlockSlab || state.getBlock() instanceof BlockCauldron || state.getBlock() instanceof BlockAnvil || state.getBlock() instanceof BlockFence || state.getBlock() instanceof BlockChorusPlant || state.getBlock() instanceof BlockSnow || material == Material.GLASS || material == Material.LEAVES);
}
Also used : BlockSnow(net.minecraft.block.BlockSnow) IBlockState(net.minecraft.block.state.IBlockState) BlockSlab(net.minecraft.block.BlockSlab) BlockCauldron(net.minecraft.block.BlockCauldron) BlockAnvil(net.minecraft.block.BlockAnvil) Material(net.minecraft.block.material.Material) BlockFence(net.minecraft.block.BlockFence) BlockChorusPlant(net.minecraft.block.BlockChorusPlant)

Example 2 with BlockCauldron

use of net.minecraft.block.BlockCauldron in project Charset by CharsetMC.

the class DyeableItemWashHandler method onBlockInteract.

@SubscribeEvent
public void onBlockInteract(PlayerInteractEvent.RightClickBlock event) {
    if (!event.getWorld().isRemote && !event.getEntityPlayer().isSneaking()) {
        ItemStack stack = event.getEntityPlayer().getHeldItem(event.getHand());
        if (!stack.isEmpty() && stack.getItem() instanceof IDyeableItem) {
            IBlockState state = event.getWorld().getBlockState(event.getPos());
            if (state.getBlock() instanceof BlockCauldron && state.getPropertyKeys().contains(BlockCauldron.LEVEL)) {
                event.setCanceled(true);
                int level = state.getValue(BlockCauldron.LEVEL);
                if (level > 0 && ((IDyeableItem) stack.getItem()).hasColor(stack)) {
                    if (((IDyeableItem) stack.getItem()).removeColor(stack)) {
                        event.getWorld().setBlockState(event.getPos(), state.withProperty(BlockCauldron.LEVEL, level - 1));
                        event.getEntityPlayer().addStat(StatList.ARMOR_CLEANED);
                    }
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IDyeableItem(pl.asie.charset.lib.item.IDyeableItem) BlockCauldron(net.minecraft.block.BlockCauldron) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockCauldron (net.minecraft.block.BlockCauldron)2 IBlockState (net.minecraft.block.state.IBlockState)2 BlockAnvil (net.minecraft.block.BlockAnvil)1 BlockChorusPlant (net.minecraft.block.BlockChorusPlant)1 BlockFence (net.minecraft.block.BlockFence)1 BlockSlab (net.minecraft.block.BlockSlab)1 BlockSnow (net.minecraft.block.BlockSnow)1 Material (net.minecraft.block.material.Material)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 IDyeableItem (pl.asie.charset.lib.item.IDyeableItem)1