
NBT Filter creates an ItemStack with empty tag when transfering items with cold cache
Raverbury opened this issue ยท 0 comments
LaserIO version
1.6.8
Minecraft Version
1.20.1
(Neo)Forge Version
47.2.1
Modpack & Version
No response
Do you have optifine installed?
No
Describe the issue
NBT Filter can sometimes create ItemStack with an empty NBT tag. Those items do not stack with normal items without an NBT tag.
Steps to reproduce
- Launch Minecraft with only LaserIO 1.6.8 installed (optionally Storage Drawer version 1.20.1-12.9.13 to better demonstrate this behavior).
- Create a new world in creative (flat Redstone Ready world preferred).
- Put down a Barrel (can be any other inventory but I choose a Barrel to distinguish from output container), a Laser Node and a Chest or any drawer that has >= 2 slots right next to each other so that the Laser Node is between the 2 inventories with no gap. All 3 are in the same chunk and the direction they span do not matter.
- Get an NBT Filter, add the "Damage" tag to it with a Bow or something that has durability. Set the filter to Deny mode.
- Get 2 Item Cards, change 1 to Extract mode and put the NBT Filter in that card. Other settings do not matter, but setting Transfer Amount to 8 is recommended to speed things up. I have checked that this behavior also occurs with Transfer Amount set to 1.
- Put the Extracting Item Card into the Laser Node on the side facing the Barrel. Put the other default Item Card on the side facing the Chest/Drawer.
- Get 2 stacks of arrows, open the Barrel and put both into it. Wait for the Laser Node to transfer everything into the Chest/Drawer.
- If using a Chest, run "/data get block <the coordinates of the Chest/Drawer>". The command should show "... has the following block data: {x: 6, y: 56, Items: [{Slot: 0b, id: "minecraft:arrow", Count: 64b, tag: {}}, {Slot: 1b, id: "minecraft:arrow", Count: 64b}], z: 8, id: "minecraft:chest"}". Note the "tag: {}" on the first element in Items array and the absence of it on the second element. Here you can open the Chest and fiddle with the transferred items and try to stack some arrows from the first ItemStack with some from the second ItemStack, but they do not stack. Alternatively, if using a Drawer, you should be able to tell there's a problem right away since the Drawer has arrows occupying 2 slots instead of 1. Running the same command on the Drawer will give a similar result in that there are 2 arrow stacks/slots in the Drawer, one with "tag: {}" and one without.
- If you now replace the Chest/Drawer with a new one and transfer 2 stacks of arrow again without touching anything else, this behavior does not occur and everything works normally. To re-trigger the behavior in step 8, access the extracting Item Card, take out the NBT Filter and put it back in again.
Expected behaviour
Item transfer using NBT Filter does not sometimes create unstackable ItemStack with empty tag.
Screenshots
I have opted to screen record instead since a video is probably better and it also requires less file uploads, do excuse my lower resolution though: https://www.youtube.com/watch?v=IaBwVWqGRqc
Log files
No response
Additional information
I haven't dug around too much but I suspect it's due to this piece of code. If it's indeed the cause then I think a solution would be to check based on ItemStack#hasTag separately before calling ItemStack#getOrCreateTag.