Jump to content

1.7.2 - There is a bug on the crafting recipes code and I can't see where it is


pta2002

Recommended Posts

Hey, I am almost ending my mod and it was working fine when I run Minecraft to see if the craftable enchanted items where working (They worked) and then I decided to add one more item. I put it there, all fine but when I run the game, it crashed with the error: NullPointerException. All the times I got this error, I fixed it (always in the crafting). I removed all the shaped crafting code and Minecraft launched. I put the code back and I removed the recipe I added for the item I created. But this time, it crashed. I tried to see where the error is, since Eclipse wasn't showing me any error icon, but I didn't found it.

Do, I'm asking you if you can tell me what's wrong in the crafting code.

Here it is:

 

GameRegistry.addRecipe(new ItemStack(EmeraldHoe,1), new Object[] {"EE"," S "," S ",'E', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldAxe,1), new Object[] {"EE ","ES "," S ",'E', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldAxe,1), new Object[] {" EE"," SE"," S ",'E', Items.emerald, 'S', Items.stick});

    ItemStack stack = new ItemStack(NetherSword,1);

    stack.addEnchantment(Enchantment.fireAspect, 10);

    GameRegistry.addRecipe(stack,

    "X",

    "X",

    "B",'X', NetherIngot, 'B', Items.blaze_rod);

    GameRegistry.addRecipe(new ItemStack(FusionGem,1), new Object[] {" D ","SEO"," E ",'D', Items.diamond,'S', SapphireGem,'E', Items.emerald,'O', Blocks.obsidian});

    GameRegistry.addRecipe(new ItemStack(EmeraldPick,1), new Object[] {"XXX"," S "," S ", 'X', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldShovel,1), new Object[] {"X","S","S",'X', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldSword,1), new Object[] {"X","X","S",'X', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(ObsidianShovel,1), new Object[] {

    "X","S","S",'X', Blocks.obsidian, 'S', Items.stick

    });

    ItemStack itemstack = new ItemStack(MegaPick, 1);

    itemstack.addEnchantment(Enchantment.efficiency, 2);

    GameRegistry.addRecipe(itemstack, "EOS", " F "," X ",'E', EmeraldPick,'O', ObsidianPick,'S', SapphirePick,'F', FusionGem,'X', Items.stick);

    GameRegistry.addRecipe(new ItemStack(ObsidianHoe,1), new Object[] {

    "XX","S","S",'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianAxe,1), new Object[] {

    "XX ","XS "," S ",'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianAxe,1), new Object[] {

    " XX"," SX"," S ",'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianPick,1), new Object[] {

    "XXX"," S ","S", 'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianSword,1), new Object[] {

    "X","X","S", 'X', Blocks.obsidian, 'S', Items.stick

    });

   

   

    GameRegistry.addRecipe(new ItemStack(SapphireBlock, 1), new Object[] {

   

    "XXX",

    "XXX",

    "XXX",'X', SapphireGem

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), new Object[] {

   

    "XX ",

    "XS ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), new Object[] {

   

    " XX",

    " SX",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), new Object[] {

    "XX ",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), new Object[] {

    " XX",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphirePick, 1), new Object[] {

    "XXX",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), new Object[] {

    "X  ",

    "S  ",

    "S  ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), new Object[] {

    " X ",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), new Object[] {

    "  X",

    "  S",

    "  S", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), new Object[] {

    "X  ",

    "X  ",

    "S  ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), new Object[] {

    " X ",

    " X ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), new Object[] {

    "  X",

    "  X",

    "  S", 'X', SapphireGem, 'S', Items.stick

    });

Link to comment
Share on other sites

For the love of god, you don't need 'new Object[]{'

Thats compiler spam just makes your code UGLY.

 

Anyways your issue is that one of moe of the Items you're using to inialize your ItemStacks is Null at the time you're making the recipe. Check your order of code and see if your item init code runs before this code.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Here it is: (WTF? // I'm sorry, Dave? Who is Dave?

---- Minecraft Crash Report ----

// I'm sorry, Dave.

 

Time: 08-06-2014 16:17

Description: Initializing game

 

java.lang.StringIndexOutOfBoundsException: String index out of range: 8

at java.lang.String.charAt(String.java:658)

at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232)

at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:233)

at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:228)

at com.pta.plusmod.PlusMod.<init>(PlusMod.java:165)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at java.lang.Class.newInstance(Class.java:374)

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:486)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:491)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)

at net.minecraft.client.Minecraft.run(Minecraft.java:892)

at net.minecraft.client.main.Main.main(Main.java:112)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at java.lang.String.charAt(String.java:658)

at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232)

at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:233)

at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:228)

at com.pta.plusmod.PlusMod.<init>(PlusMod.java:165)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at java.lang.Class.newInstance(Class.java:374)

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:486)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:491)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)

 

-- Initialization --

Details:

Stacktrace:

at net.minecraft.client.Minecraft.run(Minecraft.java:892)

at net.minecraft.client.main.Main.main(Main.java:112)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

-- System Details --

Details:

Minecraft Version: 1.7.2

Operating System: Windows 8 (x86) version 6.2

Java Version: 1.7.0_51, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation

Memory: 928241096 bytes (885 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.03 FML v7.2.209.1112 Minecraft Forge 10.12.1.1112 4 mods loaded, 4 mods active

mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{7.2.209.1112} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1112.jar) Unloaded->Constructed

Forge{10.12.1.1112} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1112.jar) Unloaded->Constructed

PlusMod{1.0} [PlusMod] (bin) Unloaded->Errored

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: Intel® HD Graphics GL version 4.0.0 - Build 10.18.10.3308, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: ~~ERROR~~ NullPointerException: null

Anisotropic Filtering: Off (1)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm using Modrinth as a launcher for a forge modpack on 1.20.1, and can't diagnose the issue on the crash log myself. Have tried repairing the Minecraft instillation as well as removing a few mods that have been problematic for me in the past to no avail. Crash log is below, if any further information is necessary let me know. Thank you! https://paste.ee/p/k6xnS
    • Hey folks. I am working on a custom "Mecha" entity (extended from LivingEntity) that the player builds up from blocks that should get modular stats depending on the used blocks. e.g. depending on what will be used for the legs, the entity will have a different jump strength. However, something unexpected is happening when trying to override a few of LivingEntity's functions and using my new own "Mecha" specific fields: instead of their actual instance-specific value, the default value is used (0f for a float, null for an object...) This is especially strange as when executing with the same entity from a point in the code specific to the mecha entity, the correct value is used. Here are some code snippets to better illustrate what I mean: /* The main Mecha class, cut down for brevity */ public class Mecha extends LivingEntity { protected float jumpMultiplier; //somewhere later during the code when spawning the entity, jumpMultiplier is set to something like 1.5f //changing the access to public didn't help @Override //Overridden from LivingEntity, this function is only used in the jumpFromGround() function, used in the aiStep() function, used in the LivingEntity tick() function protected float getJumpPower() { //something is wrong with this function //for some reason I can't correctly access the fields and methods from the instanciated entity when I am in one of those overridden protected functions. this is very annoying LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 0f return this.jumpMultiplier * super.getJumpPower(); } //The code above does not operate properly. Written as is, the entity will not jump, and adding debug logs shows that when executing the code, the value of this.jumpMultiplier is 0f //in contrast, it will be the correct value when done here: @Override public void tick() { super.tick(); //inherited LivingEntity logic //Custom logic LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 1.5f } } My actual code is slightly different, as the jumpMuliplier is stored in another object (so I am calling "this.legModule.getJumpPower()" instead of the float), but even using a simple float exactly like in the code above didn't help. When running my usual code, the object I try to use is found to be null instead, leading to a crash from a nullPointerException. Here is the stacktrace of said crash: The full code can be viewed here. I have found a workaround in the case of jump strength, but have already found the same problem for another parameter I want to do, and I do not understand why the code is behaving as such, and I would very much like to be able to override those methods as intended - they seemed to work just fine like that for vanilla mobs... Any clues as to what may be happening here?
    • Please delete post. Had not noticed the newest edition for 1.20.6 which resolves the issue.
    • https://paste.ee/p/GTgAV Here's my debug log, I'm on 1.18.2 with forge 40.2.4 and I just want to get it to work!! I cant find any mod names in the error part and I would like some help from the pros!! I have 203 mods at the moment.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.