Jump to content

Thermal Expansion API Help


TheSparkst3r

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

    • Hi, my name is Gatis. Mostly all I do is play minecraft on Hypixel server. I play Skyblock where almost every player has installed QOL mods. They are nice and work nice but recently the grind I'm on requires not wasting time on boosts and if I'm watching something I usually miss it. Let me explain better. So there is "Mining speed boost" when it's ready message appears in chat. Mod I've been using allows to copy chat message, paste it in mod and next time same message appears it flashes big notification message on screen that speed boost is ready. The thing is somehow I still miss the notification. SO, I want to create mod that can detect that message and make more noticable notification (ex. bigger) or even stop me from moving for 10 sec if I don't use it instantly. I have no knowledge about java I have prepared intellij with forge on 1.8.9 I'm just left with this:                 package com.example.examplemod;                  import net.minecraft.init.Blocks;                import net.minecraftforge.fml.common.Mod;                import net.minecraftforge.fml.common.Mod.EventHandler;                import net.minecraftforge.fml.common.event.FMLInitializationEvent;                 @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)               public class GatisMOD              {                           public static final String MODID = "GatisMOD"; \                           public static final String VERSION = "1.0";                            @EventHandler                          public void init(FMLInitializationEvent event)                          {                                      // some example code                                      System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());                          } }     I've watched many video, mostly they show how to setup everything but how to create, prepare file and later (export I guess) export to import in mods folder to use they don't I'd appreciate any help, maybe someone would explain some things to me. In future I have plans to make other feature but I guess not for now.
    • I don't think embeddium and rubidium can be used together. Try removing one of them.
    • I have been attempting to troubleshoot my personal modpack created on Curseforge for 1.18.2 Forge but I keep getting the Exit Code: 1 crash upon launching the game. When I open the debug.log I find the error for "Duplicate mods found" which simply isn't the case as there isn't a single mod with the same name. Most files are for the correct version as far as I can tell so I think there may be mods that are conflicting and the game is confusing them as "Duplicates". (Or I simply didn't check the versions correctly. Debug.log file paste: https://paste.ee/p/pQwZo#s=0 I don't normally frequent forums and don't normally ask for help online but guidance would be greatly appreciated. I can provide any other info needed  
  • Topics

×
×
  • Create New...

Important Information

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