Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null nbt tag is being applied to items in black hole unit #19

Closed
DoomSquirter opened this issue Jul 24, 2017 · 1 comment
Closed

null nbt tag is being applied to items in black hole unit #19

DoomSquirter opened this issue Jul 24, 2017 · 1 comment

Comments

@DoomSquirter
Copy link

see other issue on farscapes github:
Beyond-Reality/Beyond-Realty-Farscapes#38

over a week ago, I had verified that the BHU that contained wood from my farm had the null nbt removed and that all new wood coming in (and existing) would not have the extra (NBT: (0) tags) added to it.

I have > 400k of spruce wood in this bhu and it has not emptied in the last week.

I noticed yesterday that now it does have the null nbt tag on it, meaning, all spruce being exported from that BHU will not stack with any normal spruce that has no nbt tags.

I feel fairly confident the issue's occurring to the BHU itself. It does seem that anything that gets put into a BHU is subject to the null nbt tag.

@Shadows-of-Fire
Copy link

That's caused by basically, well, this entire method: https://github.com/Buuz135/Industrial-Foregoing/blob/master/src/main/java/com/buuz135/industrial/tile/misc/BlackHoleUnitTile.java#L150
@Buuz135 you don't need to check compound.hasKey unless you need another fallback that isn't the default. All NBTTagCompound get methods are nonnull and have a fallback.
IE, this compound.hasKey(NBT_META) ? compound.getInteger(NBT_META) : 0 can just be compound.getInteger(NBT_META) with the same effect.

Either way, on to the reason there's the blank itemstack tag:
In readFromNbt, you check
if (compound.hasKey(NBT_ITEM_NBT)) stack.setTagCompound(compound.getCompoundTag(NBT_ITEM_NBT));
But, this is always true, since you do tagCompound.setTag(NBT_ITEM_NBT, stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound());
in writeToNbt.

This may be best to continue doing in writeToNbt, but this line should change in readFromNbt
if (compound.hasKey(NBT_ITEM_NBT)) stack.setTagCompound(compound.getCompoundTag(NBT_ITEM_NBT));
should become
NBTTagCompound nbttag = compound.getCompoundTag(NBT_ITEM_NBT);
if(!nbttag.hasNoTags()) stack.setTagCompound(nbttag);

@Buuz135 Buuz135 closed this as completed in af502b6 Sep 9, 2017
blizzard4591 pushed a commit to blizzard4591/Industrial-Foregoing that referenced this issue Jan 13, 2018
(cherry picked from commit af502b6)

# Conflicts:
#	gradle.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants