Posted June 4, 20178 yr I am getting a crash report from my own mod in my dev environment. It's saying something about the fact that I have registered the same block twice, but I can clearly see that it is two different blocks in my code. Github project: https://github.com/xXJamieXx/myTweaks Crash report: https://pastebin.com/ayq8Aifp
June 4, 20178 yr Your repository is terribly arranged. Why is the Init package not inside the com.xXJamie_Xx.myTweaks package? Also, do you own xXJamie_Xx.com? Now then, lets look at this method This method is called twice. Can you find the problem? I'll give you a hint. private static void registerBlock(Block block) { GameRegistry.register(townCentre); //COUGH, COUGH Edited June 4, 20178 yr by Draco18s 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.
June 4, 20178 yr Author 1 hour ago, Draco18s said: private static void registerBlock(Block block) { GameRegistry.register(townCentre); //COUGH, COUGH Excuse my lack of knowledge (I'm fairly new to modding), I can't see the issue here. Edited June 4, 20178 yr by xXJamie_Xx
June 4, 20178 yr No? You can't? How about I in-line that method. //copy 1, was registerBlock(townCentre); GameRegistry.register(townCentre); //COUGH #1 ItemBlock itemtowncentre = new ItemBlock(townCentre); itemtowncentre.setRegistryName(townCentre.getRegistryName()); GameRegistry.register(itemtowncentre); GameRegistry.register(house); ItemBlock itemhouse = new ItemBlock(townCentre); itemhouse.setRegistryName(townCentre.getRegistryName()); GameRegistry.register(itemhouse); //copy 2, was registerBlock(house); GameRegistry.register(townCentre); //COUGH #2 ItemBlock itemtowncentre = new ItemBlock(house); itemtowncentre.setRegistryName(house.getRegistryName()); GameRegistry.register(itemtowncentre); GameRegistry.register(house); ItemBlock itemhouse = new ItemBlock(house); itemhouse.setRegistryName(house.getRegistryName()); GameRegistry.register(itemhouse); Can you find where a block is being registered twice, now? 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.
June 4, 20178 yr Author 1 hour ago, Draco18s said: No? You can't? How about I in-line that method. //copy 1, was registerBlock(townCentre); GameRegistry.register(townCentre); //COUGH #1 ItemBlock itemtowncentre = new ItemBlock(townCentre); itemtowncentre.setRegistryName(townCentre.getRegistryName()); GameRegistry.register(itemtowncentre); GameRegistry.register(house); ItemBlock itemhouse = new ItemBlock(townCentre); itemhouse.setRegistryName(townCentre.getRegistryName()); GameRegistry.register(itemhouse); //copy 2, was registerBlock(house); GameRegistry.register(townCentre); //COUGH #2 ItemBlock itemtowncentre = new ItemBlock(house); itemtowncentre.setRegistryName(house.getRegistryName()); GameRegistry.register(itemtowncentre); GameRegistry.register(house); ItemBlock itemhouse = new ItemBlock(house); itemhouse.setRegistryName(house.getRegistryName()); GameRegistry.register(itemhouse); Can you find where a block is being registered twice, now? So you are saying that there is 2 of these: GameRegistry.register(townCentre); //COUGH #1 ItemBlock itemtowncentre = new ItemBlock(townCentre); itemtowncentre.setRegistryName(townCentre.getRegistryName()); GameRegistry.register(itemtowncentre); GameRegistry.register(townCentre); //COUGH #2 ItemBlock itemtowncentre = new ItemBlock(house); itemtowncentre.setRegistryName(house.getRegistryName()); GameRegistry.register(itemtowncentre); Yet I only see one.
June 4, 20178 yr Within your private registerBlock method, you register your townCentre block and your house block. You call the registerBlock method twice. Both times you call it, it tries to register townCentre and house.
June 4, 20178 yr Author 1 hour ago, Jay Avery said: Within your private registerBlock method, you register your townCentre block and your house block. You call the registerBlock method twice. Both times you call it, it tries to register townCentre and house. No. I only use this line once: private static void registerBlock(Block block) {
June 4, 20178 yr No, you call it twice: public static void register() { registerBlock(townCentre); registerBlock(house); }
June 4, 20178 yr Author 1 hour ago, Jay Avery said: No, you call it twice: public static void register() { registerBlock(townCentre); registerBlock(house); } Yeah, to register both blocks.
June 4, 20178 yr No, you still don't realise what I'm saying. The method registerBlock, within itself, already registers both blocks. You've written it that way. Inside registerBlock, you have lines GameRegistry.register(townCentre) and GameRegistry.register(house). That means that every time you call the registerBlock method, no matter what parameters are passed to it, both of those lines get executed. When you call registerBlock(townCentre), those two lines get executed. When you call registerBlock(house), those two lines get executed.
June 4, 20178 yr Author 1 hour ago, Jay Avery said: No, you still don't realise what I'm saying. The method registerBlock, within itself, already registers both blocks. You've written it that way. Inside registerBlock, you have lines GameRegistry.register(townCentre) and GameRegistry.register(house). That means that every time you call the registerBlock method, no matter what parameters are passed to it, both of those lines get executed. When you call registerBlock(townCentre), those two lines get executed. When you call registerBlock(house), those two lines get executed. I see. So I commented out these lines: //GameRegistry.register(townCentre); //GameRegistry.register(house); But the game crashes still. (with the same error)
June 4, 20178 yr It can't be the same error, because when you comment out those lines completely you no longer register either of your blocks at all.
June 4, 20178 yr Author 1 hour ago, Jay Avery said: It can't be the same error, because when you comment out those lines completely you no longer register either of your blocks at all. It may be different but from first glance it looks very similar at least. https://pastebin.com/7J2LvPFD
June 4, 20178 yr That error says that the ItemBlock is being registered twice. That's because you have a slightly different version of the same mistake in registering your items in registerBlock. Within that method, you twice create a new ItemBlock from the passed Block parameter, and register it under the Block parameter's name. You give the variables different names but that doesn't change the fact that you're doing the same thing twice. Edited June 4, 20178 yr by Jay Avery
June 4, 20178 yr Author 1 hour ago, Jay Avery said: That error says that the ItemBlock is being registered twice. That's because you have a slightly different version of the same mistake in registering your items in registerBlock. Within that method, you twice create a new ItemBlock from the passed Block parameter, and register it under the Block parameter's name. You give the variables different names but that doesn't change the fact that you're doing the same thing twice. ModBlocks.java: package com.xXJamie_Xx.myTweaks.init; import com.xXJamie_Xx.myTweaks.blocks.Blockhouse; import com.xXJamie_Xx.myTweaks.blocks.BlocktownCentre; import com.xXJamie_Xx.myTweaks.items.ItemScroll; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModBlocks { //Passive/Economical Buildings public static Block townCentre; public static Block house; public static Block farm; public static Block market; public static Block mine; //Aggressive/Military Buildings public static Block barracks; public static Block stable; public static Block artilleryFoundry; public static void init() { townCentre = new BlocktownCentre(); house = new Blockhouse(); } public static void register() { registerBlock(townCentre); registerBlock(house); } private static void registerBlock(Block block) { //GameRegistry.register(townCentre); ItemBlock itemtowncentre = new ItemBlock(townCentre); itemtowncentre.setRegistryName(block.getRegistryName()); GameRegistry.register(itemtowncentre); //GameRegistry.register(house); ItemBlock itemhouse = new ItemBlock(house); itemhouse.setRegistryName(block.getRegistryName()); GameRegistry.register(itemhouse); } public static void registerRenders() { registerRender(townCentre); registerRender(house); } private static void registerRender(Block block) { } } Crash Report: https://pastebin.com/yJPwrsE8
June 4, 20178 yr Go learn Java. If you had the most basic Java knowledge (or any programming language for that matter), your mistake would be painfully obvious. In your registerBlock method, you call GameRegistry.register for 1) your town center block 2) your town center item 3) your house block 4) your house item. So in this method, you're registering all four objects. In your register method, you call the reigsterBlock method twice, once with the argument townCentre and the other time with the argument house. This would result in each of the GameRegistry.register calls occurring twice, so every object would be registered twice. As for how to fix it, learn Java. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
June 4, 20178 yr 30 minutes ago, xXJamie_Xx said: ModBlocks.java: package com.xXJamie_Xx.myTweaks.init; import com.xXJamie_Xx.myTweaks.blocks.Blockhouse; import com.xXJamie_Xx.myTweaks.blocks.BlocktownCentre; import com.xXJamie_Xx.myTweaks.items.ItemScroll; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModBlocks { //Passive/Economical Buildings public static Block townCentre; public static Block house; public static Block farm; public static Block market; public static Block mine; //Aggressive/Military Buildings public static Block barracks; public static Block stable; public static Block artilleryFoundry; public static void init() { townCentre = new BlocktownCentre(); house = new Blockhouse(); } public static void register() { registerBlock(townCentre); registerBlock(house); } private static void registerBlock(Block block) { //GameRegistry.register(townCentre); ItemBlock itemtowncentre = new ItemBlock(townCentre); itemtowncentre.setRegistryName(block.getRegistryName()); GameRegistry.register(itemtowncentre); //GameRegistry.register(house); ItemBlock itemhouse = new ItemBlock(house); itemhouse.setRegistryName(block.getRegistryName()); GameRegistry.register(itemhouse); } public static void registerRenders() { registerRender(townCentre); registerRender(house); } private static void registerRender(Block block) { } } Crash Report: https://pastebin.com/yJPwrsE8 I explained the problem, it hasn't changed. shadowfacts has explained (again) what is wrong, but you don't seem to be understanding it. It seems like you are struggling with some fairly fundamental aspects of object-oriented programming, and how methods and parameters work. There's not much more I can think of to say that will explain what's wrong other than re-writing your code for you - which I'm not going to do (because you'll immediately be back here as soon as you need to change something, if you don't understand the code you're using). Edited June 4, 20178 yr by Jay Avery
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.