Jump to content

Serialising blocks & items references in 1.7


Kinniken

Recommended Posts

Hi,

 

I've started working on updating Millénaire to 1.7. Just a question regarding the new system of dropping item and block ids: how does that work for saving and transmitting references to blocks and items? Should I still use ids for that? That's what ItemStack seems to be doing in its readFromNBT method. Is there a guarantee that for the same world ids will be persistent across clients (in MP- and across saves and reloads?

 

Thanks

 

K.

Link to comment
Share on other sites

Serialization to IDs is pretty much garenteed to be consistant with FML's ID management system. When a Client connects to the server it is given the table of names<->ids and syncs it's internal table with that.

And same thing happens when loading a world, the world contains that table, and the client syncs with it.

So yes, serializing to IDs in network communication should be fine.

Serializing to ids on the world save should also be okay as long as the end user doesn't do something to screw up the mapping table that FML adds.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Sounds good, that's what I was hoping.

 

The one thing ID-wise that I was doing that no longer seems possible though is for Millénaire content makers to "register" new blocks and items for use by Millénaire via text files, by giving the id and a name for the item/block. Is there any other way to identity an item or block from an other mod?

Link to comment
Share on other sites

You interact with other mods by there block name that they use to register there block.

Example: minecraft:dirt minecraft:sandstone

You can query the block registry by name as shown in the net.minecraft.init.Blocks class.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

I might be missing something obvious, but is there a way to get the item/block name (the minecraft:sandstone one) from the block or item object? It doesn't seem to get stored in the object itself and it does not always match getUnlocalizedName().

 

BTW, the new gradle setup is excellent. Very easy to setup and clean dev environment.

Link to comment
Share on other sites

Well, I guess I'll make my own reference table then.

 

I have an other question regarding the life-cycle of the items and blocks objects - are they stable throughout a Minecraft run? With Minecraft only updating the ids if switching to a world that has a different ID config?

 

I'm asking because I'm in the process of switching the references in my Millénaire objects loaded at startup from using ids to using direct references to the items and blocks. Should that be normally safe across worlds? Or should I avoid doing things like this at startup and instead move it to the world loading events?

Link to comment
Share on other sites

After all mods are loaded and initialized, yes, it should be completely safe across the rest of MC's run.

That is, unless a modder screws it up, in which case we can't do anything.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

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.