123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package me.km.blocks;
- import me.km.KajetansMod;
- import net.minecraft.block.BlockSlab;
- import static net.minecraft.block.BlockSlab.HALF;
- import net.minecraft.block.SoundType;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.IProperty;
- import net.minecraft.block.state.BlockStateContainer;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.BlockRenderLayer;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- public class BlockModSlab extends BlockSlab implements IBlockBase
- {
- protected String name;
-
- public BlockModSlab(Material material, String name, String local)
- {
- super(material);
- this.name = name;
- this.setRegistryName(name);
- super.setUnlocalizedName(local);
- super.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
-
- this.setDefaultState(this.blockState.getBaseState().withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM));
- super.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
- super.useNeighborBrightness = true;
- }
-
- @Override
- public void registerItemModel(Item itemBlock)
- {
- KajetansMod.proxy.registerItemRenderer(itemBlock, 0, name);
- }
-
- @Override
- public BlockModSlab setSoundType(SoundType sound)
- {
- super.setSoundType(sound);
- return this;
- }
- @Override
- public IBlockState getStateFromMeta(int meta)
- {
- IBlockState iblockstate = this.getDefaultState();
- if(!this.isDouble())
- {
- iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
- }
- return iblockstate;
- }
- @Override
- public int getMetaFromState(IBlockState state)
- {
- int i = 0;
- if(state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP)
- {
- i |= 8;
- }
- return i;
- }
- @Override
- protected BlockStateContainer createBlockState()
- {
- if(this.isDouble())
- {
- return new BlockStateContainer(this);
- }
- return new BlockStateContainer(this, new IProperty[] {HALF});
- }
- @Override
- public IProperty<?> getVariantProperty()
- {
- return null;
- }
- @Override
- public Comparable<?> getTypeForItem(ItemStack stack)
- {
- return null;
- }
- @Override
- public String getUnlocalizedName(int meta)
- {
- return super.getUnlocalizedName();
- }
-
- @Override
- public boolean isDouble()
- {
- return false;
- }
-
- @SideOnly(Side.CLIENT)
- @Override
- public BlockRenderLayer getBlockLayer()
- {
- return BlockRenderLayer.CUTOUT;
- }
- }
|