Posted April 19, 201312 yr In the following method in GameRegistry class, in the second attempt at getting a constructor with signature of (int, Block), due to the imports in this class, the Block refers to cpw.mods.fml.common.Mod.Block annotation (class) rather than the intended net.minecraft.block.Block. To remedy the problem, a fully qualified class (with package) should be used in the code, the same it is used in signature of the method itself for first parameter. public static void registerBlock(net.minecraft.block.Block block, Class<? extends ItemBlock> itemclass, String name, String modId) { if (Loader.instance().isInState(LoaderState.CONSTRUCTING)) { FMLLog.warning("The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.", Loader.instance().activeModContainer()); } try { assert block != null : "registerBlock: block cannot be null"; assert itemclass != null : "registerBlock: itemclass cannot be null"; int blockItemId = block.field_71990_ca - 256; Constructor<? extends ItemBlock> itemCtor; Item i; try { itemCtor = itemclass.getConstructor(int.class); i = itemCtor.newInstance(blockItemId); } catch (NoSuchMethodException e) { itemCtor = itemclass.getConstructor(int.class, Block.class); i = itemCtor.newInstance(blockItemId, block); } GameRegistry.registerItem(i,name, modId); } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "Caught an exception during block registration"); throw new LoaderException(e); } blockRegistry.put(Loader.instance().activeModContainer(), (BlockProxy) block); }
April 19, 201312 yr Author In the following method in GameRegistry class, in the second attempt at getting a constructor with signature of (int, Block), due to the imports in this class, the Block refers to cpw.mods.fml.common.Mod.Block annotation (class) rather than the intended net.minecraft.block.Block. To remedy the problem, a fully qualified class (with package) should be used in the code, the same it is used in signature of the method itself for first parameter. public static void registerBlock(net.minecraft.block.Block block, Class<? extends ItemBlock> itemclass, String name, String modId) { if (Loader.instance().isInState(LoaderState.CONSTRUCTING)) { FMLLog.warning("The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.", Loader.instance().activeModContainer()); } try { assert block != null : "registerBlock: block cannot be null"; assert itemclass != null : "registerBlock: itemclass cannot be null"; int blockItemId = block.field_71990_ca - 256; Constructor<? extends ItemBlock> itemCtor; Item i; try { itemCtor = itemclass.getConstructor(int.class); i = itemCtor.newInstance(blockItemId); } catch (NoSuchMethodException e) { itemCtor = itemclass.getConstructor(int.class, Block.class); i = itemCtor.newInstance(blockItemId, block); } GameRegistry.registerItem(i,name, modId); } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "Caught an exception during block registration"); throw new LoaderException(e); } blockRegistry.put(Loader.instance().activeModContainer(), (BlockProxy) block); }
April 20, 201312 yr File an issue at the bt if you havent already. https://github.com/MinecraftForge/MinecraftForge/issues Read the EAQ before posting! OR ELSE! This isn't building better software, its trying to grab a place in the commit list of a highly visible github project. www.forgeessentials.com Don't PM me, I don't check this account unless I have to.
April 20, 201312 yr File an issue at the bt if you havent already. https://github.com/MinecraftForge/MinecraftForge/issues Read the EAQ before posting! OR ELSE! This isn't building better software, its trying to grab a place in the commit list of a highly visible github project. www.forgeessentials.com Don't PM me, I don't check this account unless I have to.
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.