package techreborn.blocks; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import techreborn.client.TechRebornCreativeTabMisc; import techreborn.tiles.TileEntityFlare; import javax.annotation.Nullable; import java.util.List; /** * Created by modmuss50 on 06/11/2016. */ public class BlockFlare extends BlockContainer { public static final AxisAlignedBB FLARE_BB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.1D, 1.0D); public static final PropertyEnum COLOR = PropertyEnum.create("color", EnumDyeColor.class); public BlockFlare() { super(Material.REDSTONE_LIGHT); setCreativeTab(TechRebornCreativeTabMisc.instance); setUnlocalizedName("techreborn.flare"); this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE)); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { if (worldIn.isRemote) { //Only needed on the client return new TileEntityFlare(); } return null; } public int damageDropped(IBlockState state) { return (state.getValue(COLOR)).getMetadata(); } @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { for (EnumDyeColor enumdyecolor : EnumDyeColor.values()) { list.add(new ItemStack(itemIn, 1, enumdyecolor.getMetadata())); } } public MapColor getMapColor(IBlockState state) { return (state.getValue(COLOR)).getMapColor(); } public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta)); } public int getMetaFromState(IBlockState state) { return (state.getValue(COLOR)).getMetadata(); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, COLOR); } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } public boolean isFullCube() { return false; } @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { return FLARE_BB; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return FLARE_BB; } }