Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BlockOres extends Block implements IHasModel, IMetaName
- {
- replace
- public static final PropertyEnum<EnumHandler.EnumType> VARIANT = PropertyEnum.<EnumHandler.EnumType>create("variant", EnumHandler.EnumType.class);
- with and change to fit you mod watch out i use TYPE so you may want to change that to VARIANT
- public static final PropertyEnum<BlockTestEnum.EnumType> TYPE = PropertyEnum.<BlockTestEnum.EnumType>create("type", BlockTestEnum.EnumType.class);
- private String name, dimension;
- public BlockOres(String name, String dimension)
- {
- super(Material.ROCK);
- setUnlocalizedName(name);
- setRegistryName(name);
- setCreativeTab(Main.HTTYDHeadTab);
- setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, EnumHandler.EnumType.GRONKLE_IRON));
- this.name = name;
- this.dimension = dimension;
- ModBlocks.BLOCKS.add(this);
- ModItems.ITEMS.add(new ItemBlockVariants(this).setRegistryName(this.getRegistryName()));
- }
- @Override
- public int damageDropped(IBlockState state) {
- return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta();
- }
- @Override
- public int getMetaFromState(IBlockState state)
- {
- return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta();
- }
- @Override
- public IBlockState getStateFromMeta(int meta)
- {
- return this.getDefaultState().withProperty(VARIANT, EnumHandler.EnumType.byMetadata(meta));
- }
- @Override
- public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos,EntityPlayer player)
- {
- return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
- }
- @Override
- public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items)
- {
- for(EnumHandler.EnumType variant : EnumHandler.EnumType.values())
- {
- items.add(new ItemStack(this, 1, variant.getMeta()));
- }
- }
- @Override
- protected BlockStateContainer createBlockState()
- {
- return new BlockStateContainer(this, new IProperty[ ] {VARIANT});
- }
- @Override
- public String getSpecialName(ItemStack stack) {
- return EnumHandler.EnumType.values()[stack.getItemDamage()].getName();
- }
- @Override
- public void registerModels()
- {
- for(int i = 0; i < EnumHandler.EnumType.values().length; i++)
- {
- Main.proxy.registerVariantRenderer(Item.getItemFromBlock(this), i, "ore_" + this.dimension + "_" + EnumHandler.EnumType.values()[i].getName(), "inventory");
- }
- }
- using my code here but you can change to fit your need
- public static enum EnumType implements IStringSerializable
- {
- texture0(0, "texture0"),
- texture1(1, "texture1"),
- texture2(2, "texture2"),
- texture3(3, "texture3"),
- texture4(4, "texture4"),
- texture5(5, "texture5"),
- texture6(6, "texture6"),
- texture7(7, "texture7"),
- texture8(8, "texture8"),
- texture9(9, "texture9"),
- texture10(10, "texture10"),
- texture11(11, "texture11"),
- texture12(12, "texture12");
- private static final BlockTestEnum.EnumType[] META_LOOKUP = new BlockTestEnum.EnumType[values().length];
- private final int metadata;
- private final String name;
- private String unlocalizedName;
- private EnumType(int meta, String name)
- {
- this.metadata = meta;
- this.name = name;
- this.unlocalizedName = name;
- }
- public int getMetadata()
- {
- return this.metadata;
- }
- public String toString()
- {
- return this.name;
- }
- /**
- * Returns the matching EnumType for the given metadata.
- */
- public static BlockTestEnum.EnumType byMetadata(int meta)
- {
- if (meta < 0 || meta >= META_LOOKUP.length)
- {
- meta = 0;
- }
- return META_LOOKUP[meta];
- }
- public String getName()
- {
- return this.name;
- }
- public String getUnlocalizedName()
- {
- return this.unlocalizedName;
- }
- static
- {
- for (BlockTestEnum.EnumType blocksandstone$enumtype : values())
- {
- META_LOOKUP[blocksandstone$enumtype.getMetadata()] = blocksandstone$enumtype;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment