Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am trying to make a recipe with TE hardened Glass

And I've tried this

private void addCrafting() {
	if (ModsExist.teExists) {


		ItemStack glass = ItemRegistry.getItem("ItemBlockHardenedGlass", 1);
		ItemStack dye = new ItemStack(Item.dyePowder, 1, 1);
		ItemStack sil = new ItemStack(BasicItems.SiliconChip);
		GameRegistry.addRecipe(new ItemStack(this, 4), new Object[]{
			" G ", " D ", " S ", 
			'G', glass, 'D', dye, 'S', sil
		});



	}

And the ItemRegistry.getItem() in the TE API

    private static final Map<String, ItemStack> registry = new TreeMap<String, ItemStack>();

    /**
     * Returns an ItemStack containing the item that corresponds to the provided name.
     * 
     * @param name
     *            Name of the item.
     * @param qty
     *            Requested quantity of the item.
     */
    public static ItemStack getItem(String name, int qty) {

        ItemStack result = registry.get(name);
        if (result != null) {
            result = result.copy();
            result.stackSize = qty;
        }
        return result;
    }

 

 

As far as i know ItemRegistry.getItem(); Takes a string as a name of an item which I think is "ItemBlockHardenedGlass" and an integer for item count and create a new ItemStack of HardenedGlass, that i can use in the crafting recipe.

But instead i get an NPE

java.lang.NullPointerException
at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:200)
at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:259)
at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:254)
at anotherWorld.common.basicItems.ItemRedLED.addCrafting(ItemRedLED.java:32)
at anotherWorld.common.basicItems.ItemRedLED.<init>(ItemRedLED.java:18)
at anotherWorld.common.basicItems.BasicItems.addItems(BasicItems.java:23)
at anotherWorld.common.onLoad.onLoading(onLoad.java:11)
at anotherWorld.common.AnotherWorld.load(AnotherWorld.java:53)
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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:487)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
at com.google.common.eventbus.EventBus.post(EventBus.java:268)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:153)
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.EventHandler.handleEvent(EventHandler.java:69)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
at com.google.common.eventbus.EventBus.post(EventBus.java:268)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:86)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:676)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:207)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:456)
at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)
at net.minecraft.client.Minecraft.run(Minecraft.java:744)
at java.lang.Thread.run(Unknown Source)

And I'm sure that my mod loads after TE so it shouldn't be that it cant find the method, my only ideas is that that isnt the name of the block. But there is no listing of the blocks, or im using completely the wrong method to do what I want.

Also if i substitute the hardened glass for say an arrow or an item from my mod. It works fine :( So i dont know

Anyway if you know what im doing wrong, please tell me! :)

I'm Sparkst3r, that kid who makes Sphax textures.

Well hi there. :D

if I were you I would try asking either on their forum or irc channel ;).

 

 

 

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Since it's an NPE it should be easy to find by using the debugger inn an IDE of your choice.

Set a break point at this location: at anotherWorld.common.basicItems.ItemRedLED.addCrafting(ItemRedLED.java:32)

And see what happends when the 32nd line of ItemRedLED gets executed.

 

 

I'm not sure what line it is inn your add.Crafting method but I bet that one of the parameters you pass to the calls for ItemStack contains a refference to an object which == null

If you guys dont get it.. then well ya.. try harder...

  • Author

After looking around the API i found a method that printed out all the items registered in the registry. And it contained some of the basic blocks and items but hardened glass wasn't there so I'm guessing i was requesting a non existent block and that caused the NPE

Also if you want to look at my mod, it's on Github. I'm pretty new to modding, so my ways around doing things aren't exactly elegant. I would imagine Lex would cringe at my code if he saw it! :P Please poke me with a stick if I've made a stupid mistake too! :P

https://github.com/Sparkst3r/Another-World

Plus I'm only 14 and haven't had much experience yet! :P

Anyway thanks for your help :)

I'm Sparkst3r, that kid who makes Sphax textures.

Well hi there. :D

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.