Jump to content

[1.8][SOLVED] Implementing NBTTagStringArray.


Ernio

Recommended Posts

Looking at it from outside - seems easy - just extend NBTBase and make your read/write streams.

 

Looking at the inside - NBT types are hard-coded and even worse - are actually used in few places.

protected static NBTBase createNewByType(byte id)

 

What I want to ask - how would I approach making such array? I was thinking about overriding "createNewByType" + using #writeUTF8StringToBuffer (or something like that, forgot name).

 

Will that work? Maybe someone has such thing in utility? (on my way to check out SevenCommons).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I know "ways", I am just looking to implement best way (without using useless tagKeys).

 

Instead of:

{List:[0:{Thingy:"String",},1:{Thingy:"String",},2:{Thingy:"String",},],}

There will be: (obviously not realistic example)

{List:[lenght, String, String, String,],}

 

Btw. if anyone is interested why - when ItemStack has tons of strings in it and is used VERY often (super common item, there is more of it than e.g iron ingots) it actually matters if you are sending almost half the data less.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Why not just use a NBTList with type String?

As for the issue when 'sending less data' should not be an issue, things are compressed when needed.

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

Why not just use a NBTList with type String?

 

If by NBTList you ment NBTTagList - I just relized that NBTTagString(string) is also an NBTTag.

 

Before:

NBTTagList strings = new NBTTagList();

NBTTagCompound nbt;
for (String s : stringsToAdd)
{
nbt = new NBTTagCompound()
nbt.setString("S", s);
strings.appendTag(nbt);
}

 

Now:

NBTTagList strings = new NBTTagList();

NBTTagString string;
for (String s : stringsToAdd)
{
string = new NBTTagString(s)
strings.appendTag(string);
}

 

This closes thread - SOLVED.

 

Thanks for pointing it out!

 

1.7.10 is no longer supported by forge, you are on your own.

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.