Java Code Examples for net.minecraft.init.Blocks.anvil()

The following are Jave code examples for showing how to use anvil() of the net.minecraft.init.Blocks 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: EntityFallingBlock.java   View Source Code Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    Block block = this.fallTile.getBlock();

    if (this.hurtEntities)
    {
        int i = MathHelper.ceiling_float_int(distance - 1.0F);

        if (i > 0)
        {
            List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
            boolean flag = block == Blocks.anvil;
            DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;

            for (Entity entity : list)
            {
                entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
            }

            if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
            {
                int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
                ++j;

                if (j > 2)
                {
                    this.canSetAsBlock = true;
                }
                else
                {
                    this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
                }
            }
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: EntityFallingBlock.java   View Source Code Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    Block block = this.fallTile.getBlock();

    if (this.hurtEntities)
    {
        int i = MathHelper.ceiling_float_int(distance - 1.0F);

        if (i > 0)
        {
            List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
            boolean flag = block == Blocks.anvil;
            DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;

            for (Entity entity : list)
            {
                entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
            }

            if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
            {
                int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
                ++j;

                if (j > 2)
                {
                    this.canSetAsBlock = true;
                }
                else
                {
                    this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
                }
            }
        }
    }
}
 
Example 3
Project: BaseClient   File: EntityFallingBlock.java   View Source Code Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    Block block = this.fallTile.getBlock();

    if (this.hurtEntities)
    {
        int i = MathHelper.ceiling_float_int(distance - 1.0F);

        if (i > 0)
        {
            List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
            boolean flag = block == Blocks.anvil;
            DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;

            for (Entity entity : list)
            {
                entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
            }

            if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
            {
                int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
                ++j;

                if (j > 2)
                {
                    this.canSetAsBlock = true;
                }
                else
                {
                    this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
                }
            }
        }
    }
}
 
Example 4
Project: BaseClient   File: EntityFallingBlock.java   View Source Code Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    Block block = this.fallTile.getBlock();

    if (this.hurtEntities)
    {
        int i = MathHelper.ceiling_float_int(distance - 1.0F);

        if (i > 0)
        {
            List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
            boolean flag = block == Blocks.anvil;
            DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;

            for (Entity entity : list)
            {
                entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
            }

            if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
            {
                int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
                ++j;

                if (j > 2)
                {
                    this.canSetAsBlock = true;
                }
                else
                {
                    this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
                }
            }
        }
    }
}
 
Example 5
Project: connor41-etfuturum2   File: NewAnvil.java   View Source Code Vote up 5 votes
public static void onPlayerInteract(PlayerInteractEvent event) {
	if (!EtFuturum.enableAnvil)
		return;

	World world = event.world;
	int x = event.x;
	int y = event.y;
	int z = event.z;

	if (world == null || world.isRemote)
		return;
	if (world.getBlock(x, y, z) == Blocks.anvil)
		world.setBlock(x, y, z, ModBlocks.anvil, world.getBlockMetadata(x, y, z), 3);
}
 
Example 6
Project: DecompiledMinecraft   File: World.java   View Source Code Vote up 4 votes
public boolean canBlockBePlaced(Block blockIn, BlockPos pos, boolean p_175716_3_, EnumFacing side, Entity entityIn, ItemStack itemStackIn)
{
    Block block = this.getBlockState(pos).getBlock();
    AxisAlignedBB axisalignedbb = p_175716_3_ ? null : blockIn.getCollisionBoundingBox(this, pos, blockIn.getDefaultState());
    return axisalignedbb != null && !this.checkNoEntityCollision(axisalignedbb, entityIn) ? false : (block.getMaterial() == Material.circuits && blockIn == Blocks.anvil ? true : block.getMaterial().isReplaceable() && blockIn.canReplace(this, pos, side, itemStackIn));
}
 
Example 7
Project: DecompiledMinecraft   File: EntityFallingBlock.java   View Source Code Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
    int i = tagCompund.getByte("Data") & 255;

    if (tagCompund.hasKey("Block", 8))
    {
        this.fallTile = Block.getBlockFromName(tagCompund.getString("Block")).getStateFromMeta(i);
    }
    else if (tagCompund.hasKey("TileID", 99))
    {
        this.fallTile = Block.getBlockById(tagCompund.getInteger("TileID")).getStateFromMeta(i);
    }
    else
    {
        this.fallTile = Block.getBlockById(tagCompund.getByte("Tile") & 255).getStateFromMeta(i);
    }

    this.fallTime = tagCompund.getByte("Time") & 255;
    Block block = this.fallTile.getBlock();

    if (tagCompund.hasKey("HurtEntities", 99))
    {
        this.hurtEntities = tagCompund.getBoolean("HurtEntities");
        this.fallHurtAmount = tagCompund.getFloat("FallHurtAmount");
        this.fallHurtMax = tagCompund.getInteger("FallHurtMax");
    }
    else if (block == Blocks.anvil)
    {
        this.hurtEntities = true;
    }

    if (tagCompund.hasKey("DropItem", 99))
    {
        this.shouldDropItem = tagCompund.getBoolean("DropItem");
    }

    if (tagCompund.hasKey("TileEntityData", 10))
    {
        this.tileEntityData = tagCompund.getCompoundTag("TileEntityData");
    }

    if (block == null || block.getMaterial() == Material.air)
    {
        this.fallTile = Blocks.sand.getDefaultState();
    }
}
 
Example 8
Project: DecompiledMinecraft   File: ContainerRepair.java   View Source Code Vote up 4 votes
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.theWorld.getBlockState(this.selfPosition).getBlock() != Blocks.anvil ? false : playerIn.getDistanceSq((double)this.selfPosition.getX() + 0.5D, (double)this.selfPosition.getY() + 0.5D, (double)this.selfPosition.getZ() + 0.5D) <= 64.0D;
}
 
Example 9
Project: DecompiledMinecraft   File: World.java   View Source Code Vote up 4 votes
public boolean canBlockBePlaced(Block blockIn, BlockPos pos, boolean p_175716_3_, EnumFacing side, Entity entityIn, ItemStack itemStackIn)
{
    Block block = this.getBlockState(pos).getBlock();
    AxisAlignedBB axisalignedbb = p_175716_3_ ? null : blockIn.getCollisionBoundingBox(this, pos, blockIn.getDefaultState());
    return axisalignedbb != null && !this.checkNoEntityCollision(axisalignedbb, entityIn) ? false : (block.getMaterial() == Material.circuits && blockIn == Blocks.anvil ? true : block.getMaterial().isReplaceable() && blockIn.canReplace(this, pos, side, itemStackIn));
}
 
Example 10
Project: DecompiledMinecraft   File: EntityFallingBlock.java   View Source Code Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
    int i = tagCompund.getByte("Data") & 255;

    if (tagCompund.hasKey("Block", 8))
    {
        this.fallTile = Block.getBlockFromName(tagCompund.getString("Block")).getStateFromMeta(i);
    }
    else if (tagCompund.hasKey("TileID", 99))
    {
        this.fallTile = Block.getBlockById(tagCompund.getInteger("TileID")).getStateFromMeta(i);
    }
    else
    {
        this.fallTile = Block.getBlockById(tagCompund.getByte("Tile") & 255).getStateFromMeta(i);
    }

    this.fallTime = tagCompund.getByte("Time") & 255;
    Block block = this.fallTile.getBlock();

    if (tagCompund.hasKey("HurtEntities", 99))
    {
        this.hurtEntities = tagCompund.getBoolean("HurtEntities");
        this.fallHurtAmount = tagCompund.getFloat("FallHurtAmount");
        this.fallHurtMax = tagCompund.getInteger("FallHurtMax");
    }
    else if (block == Blocks.anvil)
    {
        this.hurtEntities = true;
    }

    if (tagCompund.hasKey("DropItem", 99))
    {
        this.shouldDropItem = tagCompund.getBoolean("DropItem");
    }

    if (tagCompund.hasKey("TileEntityData", 10))
    {
        this.tileEntityData = tagCompund.getCompoundTag("TileEntityData");
    }

    if (block == null || block.getMaterial() == Material.air)
    {
        this.fallTile = Blocks.sand.getDefaultState();
    }
}
 
Example 11
Project: DecompiledMinecraft   File: ContainerRepair.java   View Source Code Vote up 4 votes
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.theWorld.getBlockState(this.selfPosition).getBlock() != Blocks.anvil ? false : playerIn.getDistanceSq((double)this.selfPosition.getX() + 0.5D, (double)this.selfPosition.getY() + 0.5D, (double)this.selfPosition.getZ() + 0.5D) <= 64.0D;
}
 
Example 12
Project: BaseClient   File: World.java   View Source Code Vote up 4 votes
public boolean canBlockBePlaced(Block blockIn, BlockPos pos, boolean p_175716_3_, EnumFacing side, Entity entityIn, ItemStack itemStackIn)
{
    Block block = this.getBlockState(pos).getBlock();
    AxisAlignedBB axisalignedbb = p_175716_3_ ? null : blockIn.getCollisionBoundingBox(this, pos, blockIn.getDefaultState());
    return axisalignedbb != null && !this.checkNoEntityCollision(axisalignedbb, entityIn) ? false : (block.getMaterial() == Material.circuits && blockIn == Blocks.anvil ? true : block.getMaterial().isReplaceable() && blockIn.canReplace(this, pos, side, itemStackIn));
}
 
Example 13
Project: BaseClient   File: EntityFallingBlock.java   View Source Code Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
    int i = tagCompund.getByte("Data") & 255;

    if (tagCompund.hasKey("Block", 8))
    {
        this.fallTile = Block.getBlockFromName(tagCompund.getString("Block")).getStateFromMeta(i);
    }
    else if (tagCompund.hasKey("TileID", 99))
    {
        this.fallTile = Block.getBlockById(tagCompund.getInteger("TileID")).getStateFromMeta(i);
    }
    else
    {
        this.fallTile = Block.getBlockById(tagCompund.getByte("Tile") & 255).getStateFromMeta(i);
    }

    this.fallTime = tagCompund.getByte("Time") & 255;
    Block block = this.fallTile.getBlock();

    if (tagCompund.hasKey("HurtEntities", 99))
    {
        this.hurtEntities = tagCompund.getBoolean("HurtEntities");
        this.fallHurtAmount = tagCompund.getFloat("FallHurtAmount");
        this.fallHurtMax = tagCompund.getInteger("FallHurtMax");
    }
    else if (block == Blocks.anvil)
    {
        this.hurtEntities = true;
    }

    if (tagCompund.hasKey("DropItem", 99))
    {
        this.shouldDropItem = tagCompund.getBoolean("DropItem");
    }

    if (tagCompund.hasKey("TileEntityData", 10))
    {
        this.tileEntityData = tagCompund.getCompoundTag("TileEntityData");
    }

    if (block == null || block.getMaterial() == Material.air)
    {
        this.fallTile = Blocks.sand.getDefaultState();
    }
}
 
Example 14
Project: BaseClient   File: ContainerRepair.java   View Source Code Vote up 4 votes
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.theWorld.getBlockState(this.selfPosition).getBlock() != Blocks.anvil ? false : playerIn.getDistanceSq((double)this.selfPosition.getX() + 0.5D, (double)this.selfPosition.getY() + 0.5D, (double)this.selfPosition.getZ() + 0.5D) <= 64.0D;
}
 
Example 15
Project: BaseClient   File: World.java   View Source Code Vote up 4 votes
public boolean canBlockBePlaced(Block blockIn, BlockPos pos, boolean p_175716_3_, EnumFacing side, Entity entityIn, ItemStack itemStackIn)
{
    Block block = this.getBlockState(pos).getBlock();
    AxisAlignedBB axisalignedbb = p_175716_3_ ? null : blockIn.getCollisionBoundingBox(this, pos, blockIn.getDefaultState());
    return axisalignedbb != null && !this.checkNoEntityCollision(axisalignedbb, entityIn) ? false : (block.getMaterial() == Material.circuits && blockIn == Blocks.anvil ? true : block.getMaterial().isReplaceable() && blockIn.canReplace(this, pos, side, itemStackIn));
}
 
Example 16
Project: BaseClient   File: EntityFallingBlock.java   View Source Code Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
    int i = tagCompund.getByte("Data") & 255;

    if (tagCompund.hasKey("Block", 8))
    {
        this.fallTile = Block.getBlockFromName(tagCompund.getString("Block")).getStateFromMeta(i);
    }
    else if (tagCompund.hasKey("TileID", 99))
    {
        this.fallTile = Block.getBlockById(tagCompund.getInteger("TileID")).getStateFromMeta(i);
    }
    else
    {
        this.fallTile = Block.getBlockById(tagCompund.getByte("Tile") & 255).getStateFromMeta(i);
    }

    this.fallTime = tagCompund.getByte("Time") & 255;
    Block block = this.fallTile.getBlock();

    if (tagCompund.hasKey("HurtEntities", 99))
    {
        this.hurtEntities = tagCompund.getBoolean("HurtEntities");
        this.fallHurtAmount = tagCompund.getFloat("FallHurtAmount");
        this.fallHurtMax = tagCompund.getInteger("FallHurtMax");
    }
    else if (block == Blocks.anvil)
    {
        this.hurtEntities = true;
    }

    if (tagCompund.hasKey("DropItem", 99))
    {
        this.shouldDropItem = tagCompund.getBoolean("DropItem");
    }

    if (tagCompund.hasKey("TileEntityData", 10))
    {
        this.tileEntityData = tagCompund.getCompoundTag("TileEntityData");
    }

    if (block == null || block.getMaterial() == Material.air)
    {
        this.fallTile = Blocks.sand.getDefaultState();
    }
}
 
Example 17
Project: BaseClient   File: ContainerRepair.java   View Source Code Vote up 4 votes
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.theWorld.getBlockState(this.selfPosition).getBlock() != Blocks.anvil ? false : playerIn.getDistanceSq((double)this.selfPosition.getX() + 0.5D, (double)this.selfPosition.getY() + 0.5D, (double)this.selfPosition.getZ() + 0.5D) <= 64.0D;
}