Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Custom_Slab extends BlockSlab
- {
- public static final PropertyEnum<Custom_Slab.Variant> VARIANT = PropertyEnum.<Custom_Slab.Variant>create("variant", Custom_Slab.Variant.class);
- public Custom_Slab mySlab;
- public Custom_Slab(String name, Custom_Slab slabIn, float hardness, float resistance, int harvestLevel)
- {
- super(Material.ROCK);
- setUnlocalizedName(name);
- setRegistryName(name);
- setSoundType(SoundType.STONE);
- setHardness(hardness);
- setResistance(resistance);
- setHarvestLevel("pickaxe", harvestLevel);
- setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
- IBlockState iblockstate = this.blockState.getBaseState();
- mySlab = slabIn;
- if (!this.isDouble())
- {
- iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
- }
- this.setDefaultState(iblockstate.withProperty(VARIANT, Custom_Slab.Variant.DEFAULT));
- this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
- }
- public Item getItemDropped(IBlockState state, Random rand, int fortune)
- {
- return Item.getItemFromBlock(mySlab);
- }
- public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
- {
- return new ItemStack(mySlab);
- }
- public IBlockState getStateFromMeta(int meta)
- {
- IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, Custom_Slab.Variant.DEFAULT);
- if (!this.isDouble())
- {
- iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
- }
- return iblockstate;
- }
- public int getMetaFromState(IBlockState state)
- {
- int i = 0;
- if (!this.isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP)
- {
- i |= 8;
- }
- return i;
- }
- protected BlockStateContainer createBlockState()
- {
- return this.isDouble() ? new BlockStateContainer(this, new IProperty[] {VARIANT}) : new BlockStateContainer(this, new IProperty[] {HALF, VARIANT});
- }
- public String getUnlocalizedName(int meta)
- {
- return super.getUnlocalizedName();
- }
- public IProperty<?> getVariantProperty()
- {
- return VARIANT;
- }
- public Comparable<?> getTypeForItem(ItemStack stack)
- {
- return Custom_Slab.Variant.DEFAULT;
- }
- public static class Double extends Custom_Slab
- {
- public Double(String name, Custom_Slab slabIn, float hardness, float resistance, int harvestLevel)
- {
- super(name, slabIn, hardness, resistance, harvestLevel);
- }
- public boolean isDouble()
- {
- return true;
- }
- }
- public static class Half extends Custom_Slab
- {
- public Half(String name, Custom_Slab slabIn, float hardness, float resistance, int harvestLevel)
- {
- super(name, slabIn, hardness, resistance, harvestLevel);
- }
- public boolean isDouble()
- {
- return false;
- }
- }
- public static enum Variant implements IStringSerializable
- {
- DEFAULT;
- public String getName()
- {
- return "default";
- }
- }
- @Override
- public boolean isDouble()
- {
- IBlockState iblockstate = this.blockState.getBaseState();
- if (this.isDouble())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- ....
- public class Init_Blocks
- {
- public static Custom_Slab endbrick_slab;
- public static Custom_Slab endbrick_double_slab;
- @SubscribeEvent
- public static void registerBlocks(RegistryEvent.Register<Block> event)
- {
- //Harvest Levels:
- //0 - Wood 1 - Stone 2 - Iron 3 - Diamond 4 - Harder than Diamond
- //Hardness Levels:
- //1 - Sign 2 - Wood 3 - Iron Ore 4 - Cobweb 5 - Block of Iron
- //Resistance Levels:
- //5 - Sign 15 - Coal Ore 30 - Block of Iron 6000 - Obsidian
- // Hardness Resistance HarvestLevel
- endbrick_slab = new Custom_Slab.Half("endbrick_slab", endbrick_slab, 0.8F, 10.0F, 2);
- endbrick_double_slab = new Custom_Slab.Double("endbrick_double_slab", endbrick_double_slab, 0.8F, 10.0F, 2);
- event.getRegistry().registerAll(endbrick_slab, endbrick_double_slab);
- }
- @SubscribeEvent
- @SideOnly(Side.CLIENT)
- public static void registerModels(ModelRegistryEvent event)
- {
- registerBlocks(endbrick_slab); registerBlocks(endbrick_double_slab);
- }
- public static void registerBlocks(Block block)
- {
- ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
- }
- }
- ....
- @Mod.EventBusSubscriber
- public class Common_Event_Registry
- {
- @SubscribeEvent
- public static void registerBlocks(RegistryEvent.Register<Block> event)
- {
- Init_Blocks.registerBlocks(event);
- }
- }
- ....
- Blockstates:
- endbrick_slab:
- {
- "variants": {
- "half=bottom,variant=default": { "model": "megamod:half_slab_endbrick" },
- "half=top,variant=default": { "model": "megamod:upper_slab_endbrick" }
- }
- }
- ....
- endbrick_double_slab:
- {
- "variants": {
- "variant=default": { "model": "end_bricks" }
- }
- }
- ....
- en_us.lang:
- tile.endbrick_slab.name=Endbrick Slab
- ....
- models\block:
- half_slab_endbrick:
- {
- "parent": "block/half_slab",
- "textures": {
- "bottom": "blocks/end_bricks",
- "top": "blocks/end_bricks",
- "side": "blocks/end_bricks"
- }
- }
- ....
- upper_slab_endbrick:
- {
- "parent": "block/upper_slab",
- "textures": {
- "bottom": "blocks/end_bricks",
- "top": "blocks/end_bricks",
- "side": "blocks/end_bricks"
- }
- }
- ....
- models\item:
- endbrick_slab:
- {
- "parent": "megamod:block/half_slab_endbrick",
- "display": {
- "thirdperson": {
- "rotation": [ 10, -45, 170 ],
- "translation": [ 0, 1.5, -2.75 ],
- "scale": [ 0.375, 0.375, 0.375 ]
- }
- }
- }
- ....
- endbrick_double_slab:
- {
- "parent": "block/end_bricks"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement