TechMage66

_PROTOTYPE_BLOCK_ROTATION

Mar 5th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. package com.techmage.magetech.block;
  2.  
  3. import net.minecraft.block.properties.PropertyDirection;
  4. import net.minecraft.block.state.BlockState;
  5. import net.minecraft.block.state.IBlockState;
  6. import net.minecraft.entity.EntityLivingBase;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.util.BlockPos;
  9. import net.minecraft.util.EnumFacing;
  10. import net.minecraft.world.World;
  11.  
  12. public class _PROTOTYPE_BLOCK_ROTATION extends BlockMageTech
  13. {
  14.     public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
  15.  
  16.     public _PROTOTYPE_BLOCK_ROTATION()
  17.     {
  18.         useNeighborBrightness = true;
  19.  
  20.         setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
  21.     }
  22.  
  23.     @Override
  24.     public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
  25.     {
  26.         worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()));
  27.     }
  28.  
  29.     @Override
  30.     public IBlockState getStateFromMeta(int meta)
  31.     {
  32.         EnumFacing facing = EnumFacing.getFront(meta);
  33.  
  34.         if (facing.getAxis() == EnumFacing.Axis.Y)
  35.             facing = EnumFacing.NORTH;
  36.  
  37.         return getDefaultState().withProperty(FACING, facing);
  38.     }
  39.  
  40.     @Override
  41.     public int getMetaFromState(IBlockState state)
  42.     {
  43.         return state.getValue(FACING).getIndex();
  44.     }
  45.  
  46.     @Override
  47.     protected BlockState createBlockState()
  48.     {
  49.         return new BlockState(this, FACING);
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment