Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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.

Posted

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.

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.

×
×
  • Create New...

Important Information

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