Posted June 3, 201510 yr I have been trying to make it that my ore would drop a gem, but when i start the client in eclipse, it instantly closes. The code that i used: public Item getItemDropped(int meta, Random rand, int fortune) { return TutorialItems.gem_1; } TutorialItems is my class that has my items, gem_1 is the item. Thank you in advance.
June 3, 201510 yr Not enough code. Need Main class and proxies most likely (block and item init). Use @Override annotation. If the client crashes right away (during launch) it's not fault of this particular method. Error is elsewhere. 1.7.10 is no longer supported by forge, you are on your own.
June 3, 201510 yr Author I have all of those classes, but your right for saying there problems not there, once i commented out everything, the game still wouldn't start. The error message: b---- Minecraft Crash Report ---- // Oops. Time: 6/3/15 4:17 PM Description: Initializing game http://www.minecraftforge.net/forum/Themes/default/images/bbc/spoiler.gifjava.lang.NullPointerException: Initializing game at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:270) at net.minecraftforge.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:236) at net.minecraftforge.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:231) at com.Babuska.init.TutorialBlocks.recipe(TutorialBlocks.java:63) at com.Babuska.TutorialMod.preInit(TutorialMod.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:447) at net.minecraft.client.Minecraft.run(Minecraft.java:356) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) Hope the detailed walkthrow isn't needed. what i did before trying to change the block drops was make a crafting recipe, and it perfectly worked. after that i tried to change what drops when you break a block. And thats where it went all wrong, now even if i comment out everything i did after the recipe, it still wont launch. Heres the code that the recipe is in: http://www.minecraftforge.net/forum/Themes/default/images/bbc/spoiler.gifpackage com.Babuska.init; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.registry.GameRegistry; import com.Babuska.References; import com.Babuska.blocks.BlockTest; import com.Babuska.material.MaterialTest; public class TutorialBlocks { public static Block test_1; public static Block test_block; public static Block test_2; public static Block test_3; public static void init() { test_1 = new BlockTest(Material.iron).setUnlocalizedName("test_1"); test_block = new BlockTest(Material.iron).setUnlocalizedName("test_block"); test_2 = new BlockTest(Material.iron).setUnlocalizedName("test_2"); test_3 = new BlockTest(Material.iron).setUnlocalizedName("test_3"); } public static void register() { GameRegistry.registerBlock(test_1, test_1.getUnlocalizedName().substring(5)); GameRegistry.registerBlock(test_block, test_block.getUnlocalizedName().substring(5)); GameRegistry.registerBlock(test_2, test_2.getUnlocalizedName().substring(5)); GameRegistry.registerBlock(test_3, test_3.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(test_1); registerRender(test_block); registerRender(test_2); registerRender(test_3); } public static void registerRender(Block block) { Item item = Item.getItemFromBlock(block); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } public static void recipe() { GameRegistry.addRecipe(new ItemStack(test_2), new Object[]{"RRR", " S ", " S ", 'R', TutorialItems.gem_1, 'S', Items.stick}); } }
June 3, 201510 yr Hi You might find these links helpful to track down your bug http://www.terryanderson.ca/debugging/run.html http://www.vogella.com/tutorials/EclipseDebugging/article.html In this case - at com.Babuska.init.TutorialBlocks.recipe(TutorialBlocks.java:63) your items or blocks probably aren't initialised which you call addRecipe (they are still null) -TGG
June 3, 201510 yr Author After some testing, i found that when i try to craft some items it instantly crashes. do i have to do something more to define it? for instance if i try to craft or use in crafting gem_1, its doesnt even load minecraft, if i use test_item it crashes when i try and craft it, and when i craft my test_2 item it for some reason works? am i missing something complicated or very obvious?
June 3, 201510 yr Author package com.Babuska; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import com.Babuska.init.TutorialBlocks; import com.Babuska.init.TutorialItems; import com.Babuska.proxy.CommonProxy; @Mod(modid = References.MOD_ID, name = References.MOD_NAME, version = References.VERSION) public class TutorialMod { @SidedProxy(clientSide = References.CLIENT_PROXY_CLASS, serverSide = References.SERVER_PROXY_CLASS) public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event){ TutorialBlocks.init(); TutorialBlocks.register(); TutorialBlocks.recipe(); TutorialItems.init(); TutorialItems.register(); } @EventHandler public void init(FMLInitializationEvent event){ proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event){ } }
June 3, 201510 yr Author Thank you now all i need to do is figure out why the block drops dont work. i used a code that was for 1.7.10. Does this still work? package com.Babuska.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import com.Babuska.init.TutorialItems; public class BlockTest extends Block { public BlockTest(Material materialIn) { super(materialIn); this.setHardness(2.0F); this.setHarvestLevel("pickaxe", 1); //dmd 3, iron 2, stone 1, wood 0, } //public Item getItemDropped(int meta, Random rand, int fortune) //{ // return TutorialItems.gem_1; //} //@Override //public int quantityDropped(Random rand){ // return 6; //} }
June 3, 201510 yr Author Wow, as always im impressed how much these little things like order mean :DD thanks a lot to people who helped
June 3, 201510 yr Author Everything works, just the block doesnt drop what i want, the quantity works thow
June 3, 201510 yr Author It works thank you One last thing, and then i guess ill go away for like 2 weeks, so people get a break from my questions The pickaxe that i made has no texture in game, i guess the only thing diferent with it is that i used in my items: public class TutorialItems { public static Item test_item; public static Item gem_1; public static Item gem_pickaxe; public static final Item.ToolMaterial gemToolMaterial = EnumHelper.addToolMaterial("gemToolMaterial", 2, 512, 7.0F, 2.0F, 10); public static void init(){ test_item = new Item().setUnlocalizedName("test_item"); gem_1 = new Item().setUnlocalizedName("gem_1"); gem_pickaxe = new ItemGemPickaxe(gemToolMaterial).setUnlocalizedName("gem_pickaxe"); } public static void register() { GameRegistry.registerItem(test_item, test_item.getUnlocalizedName().substring(5)); //"tile.test_item" GameRegistry.registerItem(gem_1, gem_1.getUnlocalizedName().substring(5)); GameRegistry.registerItem(gem_pickaxe, gem_pickaxe.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(test_item); registerRender(gem_1); registerRender(gem_pickaxe); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } } and in the actual ItemGemPickaxe class: import net.minecraft.item.ItemPickaxe; public class ItemGemPickaxe extends ItemPickaxe { public ItemGemPickaxe(ToolMaterial material) { super(material); } } i have the .json.
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.