Posted April 20, 20196 yr Hi, I have just created some ores using variants and the blocks work just fine, no errors in the Logs but what I place the block it only registers the variant with the meta of 0. here is my Enum class: public class EnumHandler { public static enum EnumType implements IStringSerializable { //un to 16 variants COPPER(1, "copper"), ALUMINIUM(0, "aluminium"); private static final EnumType[] META_LOOKUP = new EnumType[values().length]; private final int meta; private final String name, unlocalizedName; private EnumType(int meta, String name) { this(meta, name, name); } private EnumType(int meta, String name, String unlocalizedName) { this.meta = meta; this.name = name; this.unlocalizedName = unlocalizedName; } @Override public String getName() { return this.name; } public int getMeta() { return this.meta; } public String getUnlocalizedName() { return this.unlocalizedName; } @Override public String toString() { return this.name; } public static EnumType byMetaData(int meta) { return META_LOOKUP[meta]; } static { for(EnumType enumType : values()) { META_LOOKUP[enumType.getMeta()] = enumType; } } } } Here is my BlockOres class: public class BlockOres extends Block implements IHasModel, IMetaName{ public static final PropertyEnum<EnumHandler.EnumType> VARIANT = PropertyEnum.<EnumHandler.EnumType>create("variant", EnumHandler.EnumType.class); private String name, dimension; public BlockOres(String name, String dimension) { super(Material.ROCK); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(CreativeTabs.BUILDING_BLOCKS); setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, EnumHandler.EnumType.COPPER )); setHarvestLevel("pickaxe", 2); 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++) { MainPixelmon.proxy.registerVariantRenderer(Item.getItemFromBlock(this), i, "ore_" + this.dimension + "_" + EnumHandler.EnumType.values()[i].getName(), "inventory"); } } } If anyone can help me I would be very gratefull! Thank you Edited April 20, 20196 yr by Thegametutor101
April 20, 20196 yr With 1.13 just around the corner, it is no longer advised to use variants like this. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 20, 20196 yr Author 38 minutes ago, Draco18s said: With 1.13 just around the corner, it is no longer advised to use variants like this. So what do you recommend?
April 21, 20196 yr 1. You could just use different blocks. 2. Stop using IHasModel. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
April 21, 20196 yr Author 26 minutes ago, DavidM said: 1. You could just use different blocks. 2. Stop using IHasModel. 1. I can just make a regular block without variants to make an ore generate? 2. If you don't mind me asking...why does it not work? It is registering each item variant with Quote public void registerModels() Edited April 21, 20196 yr by Thegametutor101
April 21, 20196 yr 11 minutes ago, Thegametutor101 said: I can just make a regular block without variants to make an ore generate? You could make each ore a different block. I'm not sure whether this is encouraged though. 12 minutes ago, Thegametutor101 said: If you don't mind me asking...why does it not work? IHasModel works, but it is pointless. Every block and item has a model; there is no point for implementing an interface to do so, just iterate through everything and register the model for everything. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
April 21, 20196 yr Author 1 minute ago, DavidM said: IHasModel works, but it is pointless. Every block and item has a model; there is no point for implementing an interface to do so, just iterate through everything and register the model for everything. I don't understand what you mean by Iterating through everything... I'm really sorry I'm completely new to all of this
April 21, 20196 yr Everything that IHasModel does can be done better in a lot less code. https://gist.github.com/Cadiboo/3f5cdb785affc069af2fa5fdf2d70358 About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
April 21, 20196 yr Author 4 minutes ago, Cadiboo said: Everything that IHasModel does can be done better in a lot less code. https://gist.github.com/Cadiboo/3f5cdb785affc069af2fa5fdf2d70358 Ok I will try implementing this into my code, thank you
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.