Jump to content

Data Storage


Black

Recommended Posts

Good Afternoon,

 

I have a question for the people quite at home with minecraft & forge code.

 

My mod contains, among other, a tree and wood items for every mob in the game, whether that mob is from a mod or not, as long as it has a spawnegg.

So as an example, the creeper has a log, plank, leaf, sapling, stair, slab, button, craftingbench etc that belongs to him.

These items have certain qualities depending on which mob they belong to, such as blastresistance, a redstone signal only when that mob walks over them etc.

The textures are blended layers(with opengl) coloured by the primary and secondary colours of the mobs spawnegg.

And naturally since it needs to be modular and for efficiency's sake every particular block is merely a subblock from its base(E.g. BaseSapling, BasePlank).

(Yes, I realise, this is quite a silly premise but it is a fun project since there are a lot of things to flesh it out with like tree grafting, biomes etc.)

 

In any case, you might have heard me coming from a long mile, but the metadata is insufficient to store the itemdamage from the egg(which is the same as the mob id).

I need that to give the block its correct characteristics.

Now I'm certainly not new to OOP, although I am to minecraft modding, so I wasn't really bothered with that.

I am currently at the point where I have to implement it or I won't be able to move forward and I came up with a few solutions, the one prettier or uglier than the other.

I am wondering however, if there are alternative solutions or methods that implement my solutions in a better way. I have looked through the code quite extensively but I have yet to find anything of the sort. (I might just have overlooked something though, that is always possible).

 

Solutions:

 

- Make of the block a tile entity, the easiest solution but also the most wasteful. I only need to store the blocks coordinates and a single number so to make blocks    that can be plentiful in the word entities (e.g. the player can build his house out of it, there can be entire biomes) is saying goodbye to any frames per second you ever had. And since I also have a lot of other blocks being tile entities or models with polygons above the 200 I'd rather not do this.

- Create one tile entity for all the blocks and save that tile entity in the first block of its kind created. The downside is that that chunk always need to be loaded then and you need to migrate the data if that block is broken.

- The same as above but this time save it in the spawnchunks. The chunks are allready loaded but the chunks need to have a block that is either of that kind or override another block. And once again the problem of it having the chance of being broken.

- Save the data in the chunk of the block. The problem being here that the way chunks save data is by its blocks and the same limitations with the metadata persist.

- Override parts of the save classes so that they save the four numbers for each block in the level.dat and read it again when the game loads into a hashmap.

There are no tile entities here but adjusting the level.dat would be quite a messy procedure.

- Do the same as the above however save the data to a separate file next to level.dat

The downside here is that the data is separate from the rest of the game(and can be forgotten or deleted) but it is a very easy implementation.

- Bind an itemstack to the block to read the itemdamage. This however doubles the amount of things.

 

Pardon the lack of a decent list but the buttons to add them here to add quotes, lists, code etc have never worked for me and I don't know the forumcode to add lists.

 

So let me repeat my question. Does forge or minecraft implement one the methods above that make this a lot easier or do they have an alternative for storing 4 variables (or two if you add xyz in one string).

 

And yes, I do know a lot of sighs will escape your mouths, I do not care.

 

I thank you beforehand and hope that you will understand the above text.

 

Friendly greetings,

Black

Link to comment
Share on other sites

Well, it certainly was worth asking this here. I had totally forgotten that you could make tileentities non-ticking.

It is still a bit wasteful though, albeit there is probably little difference between saving it this way against another except the fact that it needs to save the fact that the block is a tileentity. It allready saves the coordinates so the only thing left to save is the entityid.

But like you said, perhaps, just as a separate structure, the actual bytes gained aren't really worth it.

I'll have a look into the ChunkDataEvent though, who knows what could come out of it.

 

Thank you for your help.

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.