Posted June 20, 201510 yr 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.
June 20, 201510 yr One way to save string Arrays to NBT is use a Standard compound, set one integer Holding the length and then writing with a loop The compound,using String.valueOf(i) as key. But there might be better ways to do so
June 20, 201510 yr Author 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.
June 20, 201510 yr 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
June 20, 201510 yr Author 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.
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.