copygirl / BetterStorage

A Minecraft mod aimed at offering more storage options.
http://copy.mcft.net/mc/BetterStorage/
MIT License
57 stars 33 forks source link

Bug #316 fix #319

Closed VascoUP closed 7 years ago

VascoUP commented 7 years ago

Hi,

We tried to fix bug #316, though we're not sure the problem was fixed, instead of avoided, since we couldn't find it's source. But at least it shouldn't crash anymore.

Thank you!

copygirl commented 7 years ago

This indeed resolves the crash, but probably causes broken presents to lose their color in those cases. I suppose this would be two ways to fix the issue:

Use StackUtils, which makes sure the stack's tag compound exists

StackUtils.set(stack, (byte)colorInner, TAG_COLOR_INNER);
StackUtils.set(stack, (byte)colorOuter, TAG_COLOR_OUTER);
StackUtils.set(stack, skojanzaMode, TAG_SKOJANZA_MODE); // Unsure about bools being supported.
if (nameTag != null)
    StackUtils.set(stack, nameTag, TAG_NAMETAG);
StackUtils.remove(stack, "display", "color");
StackUtils.set(stack, "color", color);

Create and assign the compound if it is null

NBTTagCompound compound = stack.getTagCompound();
if (compound == null)
    stack.setTagCompound(compound = new NBTTagCompound());
compound.setByte(TAG_COLOR_INNER, (byte)colorInner);
// Etc...

(untested!)

Due to the large commit history, lots of other files being changed, the faulty fix (all 3 I could fix with some work) and most importantly this version of the mod being discontinued, I won't accept the PR as is.

I really appreciate your work on continuing the project. Thank you!