Advertisement
Frousties

BlockArrowRight.class

Jun 11th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.27 KB | None | 0 0
  1. package com.randomdumps.mod.blocks;
  2.  
  3. import javax.annotation.Nullable;
  4.  
  5. import com.google.common.base.Predicate;
  6. import com.randomdumps.mod.RandomDumps;
  7. import com.randomdumps.mod.Reference;
  8. import com.sun.xml.internal.bind.annotation.OverrideAnnotationOf;
  9.  
  10. import net.minecraft.block.BlockHorizontal;
  11. import net.minecraft.block.material.Material;
  12. import net.minecraft.block.properties.PropertyDirection;
  13. import net.minecraft.block.state.BlockStateContainer;
  14. import net.minecraft.block.state.IBlockState;
  15. import net.minecraft.entity.EntityLivingBase;
  16. import net.minecraft.util.BlockRenderLayer;
  17. import net.minecraft.util.EnumFacing;
  18. import net.minecraft.util.math.AxisAlignedBB;
  19. import net.minecraft.util.math.BlockPos;
  20. import net.minecraft.world.IBlockAccess;
  21. import net.minecraft.world.World;
  22.  
  23. public class BlockArrowRight extends BlockHorizontal {
  24.    
  25.     //Tried to set a variable for vertical values
  26.     //public static final PropertyDirection ORIENT = PropertyDirection.create("orient", EnumFacing.Plane.VERTICAL);
  27.    
  28.     private static AxisAlignedBB BOUNDING_BOX_EAST_WALL = new AxisAlignedBB(1, 0.0625*7, 0, 0.0625 * 14, 0.0625 * 15, 1);
  29.     private static AxisAlignedBB BOUNDING_BOX_SOUTH_WALL = new AxisAlignedBB(0, 0.0625*7, 1, 1, 0.0625 * 15, 0.0625 * 14);
  30.     private static AxisAlignedBB BOUNDING_BOX_WEST_WALL = new AxisAlignedBB(0, 0.0625*7, 0, 0.0625 * 2, 1, 1);
  31.     private static AxisAlignedBB BOUNDING_BOX_NORTH_WALL = new AxisAlignedBB(0, 0.0625*7, 0, 1, 0.0625 * 15, 0.0625 * 2);
  32.    
  33.     private static AxisAlignedBB BOUNDING_BOX_EAST = new AxisAlignedBB(0.0625 * 11, 0, 0, 0.0625 * 8, 1, 1);
  34.     private static AxisAlignedBB BOUNDING_BOX_SOUTH = new AxisAlignedBB(0, 0, 0.0625 * 11, 1, 1, 0.0625 * 8);
  35.     private static AxisAlignedBB BOUNDING_BOX_WEST = new AxisAlignedBB(0.0625 * 8, 0, 0, 0.0625 * 5, 1, 1);
  36.     private static AxisAlignedBB BOUNDING_BOX_NORTH = new AxisAlignedBB(0, 0, 0.0625 * 8, 1, 1, 0.0625 * 5);
  37.    
  38.     public BlockArrowRight() {
  39.         super(Material.WOOD);
  40.         setUnlocalizedName(Reference.DumpBlocks.ARROW_RIGHT.getUnlocalizedName());
  41.         setRegistryName(Reference.DumpBlocks.ARROW_RIGHT.getRegistryName());
  42.         setCreativeTab(RandomDumps.RANDOM_TAB);
  43.         setHardness(0.8F);
  44.         setSoundType(blockSoundType.WOOD);
  45.         setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.EAST));
  46.     }
  47.  
  48.     public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
  49.         //Detect if the block is facing up, if not, consider it's fixed to a wall
  50.         if((EnumFacing)state.getValue(FACING) != EnumFacing.UP) {
  51.             switch ((EnumFacing)state.getValue(FACING)) {
  52.                 case NORTH:
  53.                     return BOUNDING_BOX_NORTH_WALL;
  54.                 case SOUTH:
  55.                     return BOUNDING_BOX_SOUTH_WALL;
  56.                 case WEST:
  57.                     return BOUNDING_BOX_WEST_WALL;
  58.                 case EAST:
  59.                 default:
  60.                     return BOUNDING_BOX_EAST_WALL;
  61.             }
  62.         } else { switch ((EnumFacing)state.getValue(FACING)) {
  63.                 case NORTH:
  64.                     return BOUNDING_BOX_NORTH;
  65.                 case SOUTH:
  66.                     return BOUNDING_BOX_SOUTH;
  67.                 case WEST:
  68.                     return BOUNDING_BOX_WEST;
  69.                 case EAST:
  70.                 default:
  71.                     return BOUNDING_BOX_EAST;
  72.             }
  73.         }
  74.     }
  75.    
  76.     @Override
  77.     public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
  78.         IBlockState state = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
  79.         return state.withProperty(FACING, placer.getHorizontalFacing());
  80.     }
  81.    
  82.     @Override
  83.     public int getMetaFromState(IBlockState state) {
  84.         return state.getValue(FACING).getHorizontalIndex();
  85.     }
  86.    
  87.     @Override
  88.     public IBlockState getStateFromMeta(int meta) {
  89.         return getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
  90.     }
  91.    
  92.     @Override
  93.     protected BlockStateContainer createBlockState() {
  94.         return new BlockStateContainer(this, FACING);
  95.     }
  96.    
  97.     @Override
  98.     public boolean isFullCube(IBlockState state) {
  99.         return false;
  100.     }
  101.    
  102.     @Override
  103.     public boolean isOpaqueCube(IBlockState state) {
  104.         return false;
  105.     }
  106.    
  107.     @Override
  108.     public BlockRenderLayer getBlockLayer() {
  109.         return BlockRenderLayer.SOLID;
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement