Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.creepinson.block;
- import net.minecraft.block.BlockDirectional;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.IProperty;
- import net.minecraft.block.properties.PropertyDirection;
- import net.minecraft.block.state.BlockStateContainer;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.util.EnumBlockRenderType;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.Mirror;
- import net.minecraft.util.Rotation;
- import net.minecraft.util.math.AxisAlignedBB;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- public class CreepinoSkull extends ModBlocks {
- protected static final AxisAlignedBB DEFAULT_AABB = new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 0.5D, 0.75D);
- protected static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.25D, 0.25D, 0.5D, 0.75D, 0.75D, 1.0D);
- protected static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.25D, 0.25D, 0.0D, 0.75D, 0.75D, 0.5D);
- protected static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.5D, 0.25D, 0.25D, 1.0D, 0.75D, 0.75D);
- protected static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.25D, 0.25D, 0.5D, 0.75D, 0.75D);
- public static final PropertyDirection FACING = BlockDirectional.FACING;
- public CreepinoSkull(Material mat, String name, CreativeTabs tab, float hardness, float resistance, int harvest,
- String tool) {
- super(mat, name, tab, hardness, resistance, harvest, tool);
- this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
- }
- @Override
- public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
- EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
- if (!worldIn.isRemote) {
- }
- return true;
- }
- public boolean isOpaqueCube(IBlockState state) {
- return false;
- }
- public boolean isFullCube(IBlockState state) {
- return false;
- }
- @Override
- public EnumBlockRenderType getRenderType(IBlockState state) {
- return EnumBlockRenderType.MODEL;
- }
- public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
- switch ((EnumFacing) state.getValue(FACING)) {
- default:
- return DEFAULT_AABB;
- case NORTH:
- return NORTH_AABB;
- case SOUTH:
- return SOUTH_AABB;
- case WEST:
- return WEST_AABB;
- case EAST:
- return EAST_AABB;
- }
- }
- public IBlockState getStateFromMeta(int meta) {
- return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta & 7));
- }
- /**
- * Convert the BlockState into the correct metadata value
- */
- public int getMetaFromState(IBlockState state) {
- int i = 0;
- i = i | ((EnumFacing) state.getValue(FACING)).getIndex();
- return i;
- }
- public IBlockState withRotation(IBlockState state, Rotation rot) {
- return state.withProperty(FACING, rot.rotate((EnumFacing) state.getValue(FACING)));
- }
- public IBlockState withMirror(IBlockState state, Mirror mirrorIn) {
- return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING)));
- }
- protected BlockStateContainer createBlockState() {
- return new BlockStateContainer(this, new IProperty[] { FACING });
- }
- @Override
- public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
- float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
- return this.blockState.getBaseState().withProperty(FACING, facing);
- }
- }
Add Comment
Please, Sign In to add comment