Jump to content

Recommended Posts

Posted

So here is a question. I have an item and I want the item to do different things based on its NBT data (if this is the best way to do it). I want the player to be able to change that NBT Data with a keypress. So the default item when you create it/craft it sets up an NBT field and sets it to like 1 and when you right click puts resistance on you becasue that field is one. This will make it very simple to just use a switch to determine which ability to cast since the NBT will be an int field.  

 

The player then can press the "M" key or whatever and change the item being held's NBT data field to like 2 and this will make it so when you right click the item it will cast Fire Resistance or something to that effect. So is this method the best way to do this? Or is their a better way to do it? Plus I'm imagining packets would need to be involved so that the game knows "When player presses <KEYBIND> change the NBT Data" right? 

Posted

You need to use packets. The server doesn't know dick about keybinds and the client's NBT data gets overwitten by the server's copy.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Got it and applied it. Seems to work fine on both a server test environment and regular singleplayer environment. Found it easier to have a keybind press pass the player and their hand to a function that alters the NBT data of the item the player is holding

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.