HalestormXV Posted February 22, 2018 Posted February 22, 2018 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? Quote
Draco18s Posted February 23, 2018 Posted February 23, 2018 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. Quote 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.
HalestormXV Posted February 23, 2018 Author Posted February 23, 2018 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 Quote
Recommended Posts
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.