package minestrapteam.mods.minestrappolation.block;
import minestrapteam.mods.minestrappolation.lib.MBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockFlesh extends MBlock
{
public BlockFlesh(Material materialIn, MapColor mapColorIn)
{
super(materialIn, mapColorIn);
}
@Override
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
float f = 0.0625F;
return new AxisAlignedBB(pos.getX() + f, pos.getY(), pos.getZ() + f, pos.getX() + 1 - f,
pos.getY() + 1 - (2 * f), pos.getZ() + 1 - f);
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
float f = 0.0625F;
return new AxisAlignedBB(pos.getX() + f, pos.getY(), pos.getZ() + f, pos.getX() + 1 - f,
pos.getY() + 1 - (2 * f), pos.getZ() + 1 - f);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube()
{
return false;
}
@Override
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return true;
}
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.isSideSolid(pos.offset(EnumFacing.DOWN), EnumFacing.UP, true);
}
@Override
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!this.canBlockStay(worldIn, pos, EnumFacing.DOWN))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
protected boolean canBlockStay(World worldIn, BlockPos pos, EnumFacing facing)
{
return worldIn.isSideSolid(pos.offset(facing), facing.getOpposite(), true);
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
if ((playerIn.getCurrentEquippedItem() != null)
&& playerIn.getCurrentEquippedItem().getItem() == Items.potionitem && (playerIn.getCurrentEquippedItem()
.getItemDamage() == 8193
|| playerIn
.getCurrentEquippedItem()
.getItemDamage()
== 8225 || playerIn
.getCurrentEquippedItem()
.getItemDamage()
== 8257
|| playerIn
.getCurrentEquippedItem()
.getItemDamage()
== 16385 || playerIn
.getCurrentEquippedItem()
.getItemDamage()
== 16417
|| playerIn
.getCurrentEquippedItem()
.getItemDamage()
== 16449))
{
playerIn.destroyCurrentEquippedItem();
worldIn.setBlockState(pos, MBlocks.block_flesh_reactive.getDefaultState());
return true;
}
return false;
}
}