Posted January 4, 20196 yr Hello, I have been struggling to resolve an "Attempted to set registry name with existing registry name! New: striketheblightmod:planks Old: striketheblightmod:planks" error. Basically, I have a BlockPlank class to register two plank variants using an EnumHandler. I would like to ask if anyone can help find out what's wrong as I couldn't find the culprit. more error details: Caused by: java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: striketheblightmod:planks Old: striketheblightmod:planks at net.minecraftforge.registries.IForgeRegistryEntry$Impl.setRegistryName(IForgeRegistryEntry.java:71) at net.minecraftforge.registries.IForgeRegistryEntry$Impl.setRegistryName(IForgeRegistryEntry.java:79) at striketheblight.striketheblightmod.blocks.BlockPlank.<init>(BlockPlank.java:41) at striketheblight.striketheblightmod.init.BlockList.<clinit>(BlockList.java:38) ... 23 more BlockPlank public class BlockPlank extends Block implements IHasModel, IMetaName { public static final PropertyEnum<EnumHandler.EnumType> VARIANT = PropertyEnum.<EnumHandler.EnumType>create("variant", EnumHandler.EnumType.class); private String name; public BlockPlank(String name) { super(Material.WOOD); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(Main.modTab); setSoundType(SoundType.WOOD); setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, EnumHandler.EnumType.WILLOW)); this.name = name; BlockList.BLOCKS.add(this); ItemList.ITEMS.add(new ItemBlockVariants(this.setRegistryName(this.getRegistryName()))); // line 41 } @Override public int damageDropped(IBlockState state) { return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta(); } @Override public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) { for(EnumHandler.EnumType blockplank$enumtype : EnumHandler.EnumType.values()) { items.add(new ItemStack(this, 1, blockplank$enumtype.getMeta())); } } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(VARIANT, EnumHandler.EnumType.byMetadata(meta)); } @Override public int getMetaFromState(IBlockState state) { return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta(); } @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 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, EnumHandler.EnumType.values()[i].getName() + "_planks", "inventory"); } } } EnumHandler: public class EnumHandler { public static enum EnumType implements IStringSerializable{ WILLOW(0, "willow"), REDWOOD(1, "redwood"); 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 String getUnlocalizedName() { return this.unlocalizedName; } public int getMeta() { return this.meta; } @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; } } } } line 38 in BlockList (other people call the class BlockInit): public static final Block PLANKS = new BlockPlank("planks"); ItemBlockVariants: public class ItemBlockVariants extends ItemBlock{ public ItemBlockVariants(Block block) { super(block); setHasSubtypes(true); setMaxDamage(0); } @Override public int getMetadata(int damage) { return damage; } @Override public String getUnlocalizedName(ItemStack stack) { return ((IMetaName)this.block).getSpecialName(stack) + "_" + super.getUnlocalizedName(); //e.g.: willow_planks } } I usually resolve errors on my own but this one has me pondering for a while ^^ Thanks in advance, Kris Edited January 6, 20196 yr by pH7 edited lines of error into the code 'Everyone is a genius, But if you judge a fish by its ability to climb trees, it will live its whole life believing that it is stupid.' -Albert Einstein ---------------------------------------------------------- If Arthas's horse is named "Invincible", then why can I clearly see him?
January 4, 20196 yr 1 hour ago, pH7 said: IHasModel Kill this with fire. You do not need this. All this interface does is make you implement the same code over and over and over again. ALL items need models. All of them. And none of the information necessary to register that model is private. Just loop through your block and item lists in your model registry event. Anyway, you haven't provided enough code to identify the problem. 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.
January 4, 20196 yr 6 hours ago, pH7 said: public static final Block PLANKS = new BlockPlank("planks"); Also don't use a static initializer to register blocks/items.
January 6, 20196 yr Author I have since stopped using IHasModel. That was not the issue, but I managed to sort it out. Basically: ItemList.ITEMS.add(new ItemBlockVariants(this.setRegistryName(this.getRegistryName()))); // line 41 should have been: ItemList.ITEMS.add(new ItemBlockVariants(this).setRegistryName(this.getRegistryName())); // line 41 Damn syntax mistakes causing trouble ? This thread can now be closed. Thanks for the advice. 'Everyone is a genius, But if you judge a fish by its ability to climb trees, it will live its whole life believing that it is stupid.' -Albert Einstein ---------------------------------------------------------- If Arthas's horse is named "Invincible", then why can I clearly see him?
January 6, 20196 yr 2 minutes ago, pH7 said: I have since stopped using IHasModel. That was not the issue, but I managed to sort it out. Basically: ItemList.ITEMS.add(new ItemBlockVariants(this.setRegistryName(this.getRegistryName()))); // line 41 should have been: ItemList.ITEMS.add(new ItemBlockVariants(this).setRegistryName(this.getRegistryName())); // line 41 Damn syntax mistakes causing trouble ? This thread can now be closed. Thanks for the advice. Threads don't get "closed" really, just edit the title and add [SOLVED] just fyi All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
January 6, 20196 yr 15 hours ago, hiotewdew said: Threads don't get "closed" really, just edit the title and add [SOLVED] just fyi Or don't. You don't have to do it. Its not a forum rule, just a thing some people do because they think its helpful. 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.
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.