Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.theviolentsquirrels.questsystem.block;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.PropertyEnum;
- import net.minecraft.block.state.BlockState;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.util.IStringSerializable;
- import net.theviolentsquirrels.questsystem.Main;
- public class BlockBarrel extends Block {
- public static final PropertyEnum TYPE = PropertyEnum.create("mode", EnumType.class);
- public BlockBarrel(String unlocalizedName) {
- super (Material.wood);
- this.setUnlocalizedName(unlocalizedName);
- this.setCreativeTab(Main.tab);
- this.setHardness(2.0f);
- this.setResistance(10.0f);
- this.setHarvestLevel("axe", 0);
- this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumType.NORMAL));
- }
- /**
- * Called throughout the code as a replacement for block instanceof BlockContainer
- * Moving this to the Block base class allows for mods that wish to extend vanilla
- * blocks, and also want to have a tile entity on that block, may.
- * <p/>
- * Return true from this function to specify this block has a tile entity.
- *
- * @param state State of the current block
- * @return True if block has a tile entity, false otherwise
- */
- @Override
- public boolean hasTileEntity(IBlockState state) {
- return (false);
- }
- /**
- * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
- */
- @Override
- public int getRenderType() {
- return (3);
- }
- @Override
- protected BlockState createBlockState() {
- return (new BlockState(this, TYPE));
- }
- /**
- * Convert the given metadata into a BlockState for this Block
- *
- * @param meta
- */
- @Override
- public IBlockState getStateFromMeta(int meta) {
- return (this.getDefaultState().withProperty(TYPE, EnumType.byMetadata(meta)));
- }
- /**
- * Convert the BlockState into the correct metadata value
- *
- * @param state
- */
- @Override
- public int getMetaFromState(IBlockState state) {
- return (((EnumType) state.getValue(TYPE)).getMetadata());
- }
- public enum EnumType implements IStringSerializable {
- NORMAL(0, "normal"),
- FERMENTED(1, "fermented");
- private final int meta;
- private final String name;
- private static final EnumType[] META_LOOKUP = new EnumType[values().length];
- static {
- for (EnumType type : values())
- META_LOOKUP[type.getMetadata()] = type;
- }
- EnumType(int meta, String name) {
- this.meta = meta;
- this.name = name;
- }
- @Override
- public String getName() {
- return (this.name);
- }
- public int getMetadata() {
- return (this.meta);
- }
- public static EnumType byMetadata(int meta) {
- if (meta < 0 || meta >= META_LOOKUP.length) meta = 0;
- return (META_LOOKUP[meta]);
- }
- @Override
- public String toString() {
- return (this.getName());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement