Industrial Foregoing

Industrial Foregoing

95M Downloads

[1.20] Taking a Black Hole Unit out of a Black Hole Controller and placing it loses NBT data

notcake opened this issue ยท 0 comments

commented

Industrial Foregoing Version: 3.5.15

Titanium Version: 3.8.27

Reproduction Steps

  1. Start with an empty Black Hole Unit inside a Black Hole Controller.
  2. Insert an item with NBT data into the Black Hole Controller.
  3. Take the Black Hole Unit out of the Black Hole Controller and place it into the world.
  4. The NBT data of the stored item has been lost.

BLHBlockItemHandlerItemStack doesn't set the hasNBT flag when accepting items with NBT tags.

private void setStack(ItemStack stack) {
CompoundTag tag = getTag();
if (tag == null) {
CompoundTag compoundNBT = new CompoundTag();
compoundNBT.put("BlockEntityTag", new CompoundTag());
this.stack.setTag(compoundNBT);
}
this.stack.getTag().getCompound("BlockEntityTag").put("blStack", stack.serializeNBT());
}

BlackHoleUnitTile then wipes the item's NBT if the hasNBT flag isn't set.

public void serverTick(Level level, BlockPos pos, BlockState state, BlackHoleUnitTile blockEntity) {
super.serverTick(level, pos, state, blockEntity);
if (isServer()) {
if (!this.hasNBT && this.blStack.hasTag()) {
ItemStack stack = this.blStack.copy();
stack.setTag(null);
this.setStack(stack);
}
}
}