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

Hello, I am working on something that lets me change an item's NBT when it is being crafted with (A transmutation stone).

I have this method:

    @SubscribeEvent
    public void ItemCraftedEvent(PlayerEvent.ItemCraftedEvent e)
    {
        // If the item crafted is the transmutation stone
        if (e.crafting.getItem() instanceof BasicTransmutationStone)
        {
            e.crafting.stackTagCompound = new NBTTagCompound();
            e.crafting.stackTagCompound.setString("owner", e.player.getDisplayName());
            e.crafting.stackTagCompound.setInteger("uses", 128);
            return;
        }
        // If the item being used in crafting is the transmutation stone
        for (int i = 0; i < e.craftMatrix.getSizeInventory(); i++)
        {
            if (e.craftMatrix.getStackInSlot(i).getItem() instanceof BasicTransmutationStone)
            {
                if (e.craftMatrix.getStackInSlot(i).stackTagCompound != null)
                {
                    e.craftMatrix.getStackInSlot(i).stackTagCompound.setInteger("uses", e.craftMatrix.getStackInSlot(i).stackTagCompound.getInteger("uses") - 1);
                    if (e.craftMatrix.getStackInSlot(i).stackTagCompound.getInteger("uses") < 1)
                    {
                        e.craftMatrix.setInventorySlotContents(i, null);
                        return;
                    }
                }
            }
        }
    }

When I try to craft the transmutation stone, it does not crash!

When I try to craft with a transmutation stone, it crashes.

The crash log is identical:

---- Minecraft Crash Report ----
// You should try our sister game, Minceraft!

Time: 10/1/14 1:58 PM
Description: Updating screen events

java.lang.NullPointerException: Updating screen events
at com.ilan321.transmutation.ref.CraftingHandler.ItemCraftedEvent(CraftingHandler.java:29)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_CraftingHandler_ItemCraftedEvent_ItemCraftedEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at cpw.mods.fml.common.FMLCommonHandler.firePlayerCraftingEvent(FMLCommonHandler.java:569)
at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:128)
at net.minecraft.inventory.Container.slotClick(Container.java:349)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:482)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:678)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:420)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:346)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:315)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1730)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1038)
at net.minecraft.client.Minecraft.run(Minecraft.java:961)
at net.minecraft.client.main.Main.main(Main.java:164)
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)
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 GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:55)
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.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

 

What am I doing wrong here?

 

  • Author

That is not the problem. The

e.crafting

block is for when the player is crafting a transmutation stone. My problem is when the player crafts with the transmutation stone, for example 'stone + 1 iron = 4 ender pearl'. That is when it crashes.

 

Edit: ah nvm, it works now. I added the null check for the second block and it works. Thanks! :)

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.