Jump to content

Recommended Posts

Posted (edited)

Heeeyy! I need to trigger something everytime you move (drag and drop) an Item inside your Inventory :L

Can someone help me? Is there an event like that?

 

Or maybe if that's not possible an event that triggers when you put an item inside a crafting grid (2x2 / 3x3) ? :L

Edited by Heeee
Posted
  On 3/4/2018 at 10:04 PM, diesieben07 said:

There isn't.

What are you trying to achieve (from the player's perspective, not how you intend to program it)?

Expand  

I saw an thread about removing item repair. So I thought because the nbt tags keep on reseting for me,

it would be possible to update the nbt tags everytime you put such an item inside a crafting grid :L

Posted
  On 3/4/2018 at 10:09 PM, diesieben07 said:

If your NBT tags "keep resetting" then you are doing something wrong. Don't try to hack around the problem, fix the problem.

 

Post your code.

Expand  

public void PlayerInteractEvent(PlayerInteractEvent event)
{
    if ((event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) || (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR))
    {
        if (event.entityPlayer.getHeldItem().getItem() instanceof ItemTool)
        {
            if (event.entityPlayer.getHeldItem().getItem().isRepairable())
            {
                event.entityPlayer.getHeldItem().getItem().setNoRepair();
            }
        }
    }
}

 

It works fine, but everytime I restart my game (restart not leaving the world and rejoining) it keeps reseting :L

Posted
  On 3/4/2018 at 10:14 PM, diesieben07 said:

You seem to be using a very outdated version of Forge. The version of PlayerInteractEvent you are using was last used with 1.8.x. Please update to a more modern version of Minecraft as a first step.

Expand  

Oh damn it! Posted an old copy of the code, I already updated. Sorry 'bout that.

Anyway the part with the " event.entityPlayer.getHeldItem().getItem().setNoRepair();" is the same :L

Posted
  On 3/4/2018 at 10:18 PM, diesieben07 said:
  • setNoRepair has nothing to do with NBT.
  • setNoRepair is an per-item flag, which is supposed to be set at startup. You cannot dynamically set it.
Expand  

Ohh I see... But what's the nbt tag called, so I can look it up?

Posted
  On 3/4/2018 at 10:28 PM, diesieben07 said:

setNoRepair is permanent, per Item. You should call it in preInit if you want to do it for items that are not yours.

Expand  

With "GameRegistry.findItem..." and then adding setNoRepair to all of the tools? Or would I go about that?

Posted
  On 3/4/2018 at 10:37 PM, diesieben07 said:

findItem is once again from an old version of Forge. Please update.

Use ForgeRegistries.ITEMS to interact with the item registry.

Expand  

That was something I copied from another (apparently old) thread.

But I managed to it in preInit! So thanks for helping c:

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



×
×
  • Create New...

Important Information

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