SHARE
TWEET

BlockSlabBase.java

FlowArg Aug 22nd, 2019 20 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public abstract class BlockSlabBase extends BlockSlab
  2. {
  3.     Block half;
  4.     public static final PropertyEnum<Variant> VARIANT = PropertyEnum.<Variant>create("variant", Variant.class);
  5.  
  6.     public BlockSlabBase(String name, Material materialIn, BlockSlab half)
  7.     {
  8.         super(materialIn);
  9.         setUnlocalizedName(name);
  10.         setRegistryName(name);
  11.         setCreativeTab(Main.blockslabtab);
  12.         this.useNeighborBrightness = !this.isDouble();
  13.  
  14.         IBlockState state = this.blockState.getBaseState().withProperty(VARIANT, Variant.DEFAULT);
  15.         if(!this.isDouble()) state = state.withProperty(HALF, EnumBlockHalf.BOTTOM);
  16.         setDefaultState(state);
  17.  
  18.         this.half = half;
  19.  
  20.         BlockInit.BLOCK.add(this);
  21.     }
  22.  
  23.     @Override
  24.     public Item getItemDropped(IBlockState state, Random rand, int fortune)
  25.     {
  26.         return Item.getItemFromBlock(half);
  27.     }
  28.  
  29.     @Override
  30.     public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
  31.     {
  32.         return new ItemStack(half);
  33.     }
  34.  
  35.     @Override
  36.     public IBlockState getStateFromMeta(int meta)
  37.     {
  38.         IBlockState state = this.blockState.getBaseState().withProperty(VARIANT, Variant.DEFAULT);
  39.         if(!this.isDouble()) state = state.withProperty(HALF, ((meta&8) != 0) ? EnumBlockHalf.TOP : EnumBlockHalf.BOTTOM);
  40.         return state;
  41.     }
  42.  
  43.     @Override
  44.     public int getMetaFromState(IBlockState state)
  45.     {
  46.         int meta = 0;
  47.         if(!this.isDouble() && state.getValue(HALF) == EnumBlockHalf.TOP) meta |= 8;
  48.         return meta;
  49.     }
  50.  
  51.     @Override
  52.     protected BlockStateContainer createBlockState()
  53.     {
  54.         if(!this.isDouble()) return new BlockStateContainer(this, new IProperty[] {VARIANT,HALF});
  55.         else return new BlockStateContainer(this, new IProperty[] {VARIANT});
  56.     }
  57.  
  58.     @Override
  59.     public String getUnlocalizedName(int meta)
  60.     {
  61.         return super.getUnlocalizedName();
  62.     }
  63.  
  64.     @Override
  65.     public IProperty<?> getVariantProperty()
  66.     {
  67.         return VARIANT;
  68.     }
  69.  
  70.     @Override
  71.     public Comparable<?> getTypeForItem(ItemStack stack)
  72.     {
  73.         return Variant.DEFAULT;
  74.     }
  75.  
  76.     public static enum Variant implements IStringSerializable
  77.     {
  78.         DEFAULT;
  79.  
  80.         @Override
  81.         public String getName()
  82.         {
  83.             return "default";
  84.         }
  85.     }
  86. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top