Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final PropertyDirection FACING = PropertyDirection.create("facing");
- public LeafChest(String name, Material materialIn) {
- //irrelevant code omitted from paste for clarity
- //irrelevant code omitted from paste for clarity
- setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
- //irrelevant code omitted from paste for clarity
- }
- @Override
- public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
- if(stack.hasDisplayName()) {
- TileEntity tileentity = worldIn.getTileEntity(pos);
- if(tileentity instanceof TileEntityLeafChest) {
- ((TileEntityLeafChest)tileentity).setCustomName(stack.getDisplayName());
- }
- }
- }
- @Override
- public IBlockState getStateFromMeta(int meta) {
- IBlockState state = this.getDefaultState();
- state = state.withProperty(FACING, EnumFacing.getFront(meta));
- return state;
- }
- @Override
- public int getMetaFromState(IBlockState state) {
- return ((EnumFacing)state.getValue(FACING)).getIndex();
- }
- @Override
- protected BlockStateContainer createBlockState() {
- return new BlockStateContainer(this, new IProperty[] {FACING});
- }
- //Facing
- @Override
- public IBlockState getStateForPlacement(World worldIn, BlockPos pos,EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
- {
- IBlockState iBlockState = worldIn.getBlockState(pos.offset(facing.getOpposite()));
- if(iBlockState.getBlock() == this)
- {
- EnumFacing enumFacing = (EnumFacing)iBlockState.getValue(FACING);
- if(enumFacing == facing)
- {
- return this.getDefaultState().withProperty(FACING, facing.getOpposite());
- }
- }
- return this.getDefaultState().withProperty(FACING, facing);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement