Posted February 25, 201411 yr Currently I have a GUI that sends a packet to the server with an item name, and then the server is supposed to get the item and do something. How would I get an item from just a name? I don't want to use IDs because they'll probably be removed completely I think. Kain
February 25, 201411 yr Author Dug a little deeper, found out how (I think). GameData.itemRegistry.get(name) Kain
February 25, 201411 yr They are very unlikely to remove IDs; integers are just too handy of a storage method to get rid of entirely, though most users will never know they are there anymore. That was the point of moving to a registration system, but the game itself still tracks everything by ID, so you should be safe doing so as well. http://i.imgur.com/NdrFdld.png[/img]
February 25, 201411 yr The point to be made here is, never hard-code any IDs from now on. PERIOD. Ever. If you get an ID temporarily (from a call to the registry for example), expect it to be fine for this session only. Do not ever store it persistently or load it from persistent store and expect it to mean anything. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
February 25, 201411 yr As long as you get the ID from the registry in the first place, it should be safe to store that for example in an NBT tag, since that's exactly what happens when you write an ItemStack to NBT anyway. The game will refuse to load or at least give you warning messages if any of the items / blocks have changed from the id to string mappings that get stored with the world save. Otherwise, how do you think Minecraft is storing the data itself? Certainly not as complex objects, and it wouldn't make any sense if the ids that were stored in your world save meant nothing the next time you load, as all the items and blocks in the game would be corrupt. http://i.imgur.com/NdrFdld.png[/img]
February 25, 201411 yr I should have been clearer, I guess. By "persistent store" I meant, any file system outside of the inner minecraft communication system of world storage. Now I repeat the important part: Never hard-code IDs in the newer version of minecraft. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
February 25, 201411 yr Ah, sorry, I misunderstood your post. Yeah, what he said ^^ http://i.imgur.com/NdrFdld.png[/img]
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.