Posted March 4, 20187 yr 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 March 4, 20187 yr by Heeee
March 4, 20187 yr Author Just now, diesieben07 said: There isn't. What are you trying to achieve (from the player's perspective, not how you intend to program it)? 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
March 4, 20187 yr Author Just now, 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. 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
March 4, 20187 yr Author Just now, 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. 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
March 4, 20187 yr Author Just now, 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. Ohh I see... But what's the nbt tag called, so I can look it up?
March 4, 20187 yr Author 1 minute ago, diesieben07 said: Which NBT tag are you talking about? One to remove the possibility to remove item repair :L Like the setNoRepair, just permanetly. Is there even anything like that?
March 4, 20187 yr Author 6 minutes ago, 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. With "GameRegistry.findItem..." and then adding setNoRepair to all of the tools? Or would I go about that?
March 4, 20187 yr Author 5 minutes ago, diesieben07 said: findItem is once again from an old version of Forge. Please update. Use ForgeRegistries.ITEMS to interact with the item registry. 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.