Immersive Railroading

Immersive Railroading

3M Downloads

Empty tag compounds polluting items in player inventory

littlej541 opened this issue ยท 1 comments

commented

Describe the bug
This bug is similar to #786 in problem and solution. That PR is waiting on an update to UMC otherwise I'd probably make a PR for this as well. The rail blueprint item causes items in the player's inventory to be contaminated with empty tag compounds that break stacking with other items of the same type. The items in question are the blocks selected for the rail bed and rail fill. It happens to every stack of that item type in the player's inventory. This only happens outside of creative mode because rails don't consume items when placed in creative and so don't go through the sequence required. The exact that causes this issue arises through this sequence:

  1. ItemTrackBlueprint::OnBlockClicked calls RailInfo::build
  2. RailInfo::build calls RailInfo::checkMaterials
  3. RailInfo::checkMaterials calls ItemGauge::has on ItemStacks of the rail bed and rail fill material
  4. ItemGauge::has calls ItemStack::getTagCompound on the ItemStacks from above

getTagCompound() is the root cause of the issue. When getTagCompound() is called, if the tag compound for the item is null, as it is for many items, it creates an empty tag compound for it. This may be desired elsewhere but it causes a problem in this situation.

How to reproduce
Steps to reproduce the unwanted behavior:

  1. Be outside of creative mode
  2. Get a track blueprint
  3. Set rail fill and/or bed to something other than air
  4. Build the track
  5. Get new blocks of the same type use for the rail fill/bed
  6. These new blocks will not stack with the old unless another track section is built with the same blocks as fill/bed, causing them to be given empty tag compounds as well

Expected behavior
Items without tag compounds should not acquire them randomly, and should remain null to preserve stacking capabilities.

System Information

  • IR-Version: 1.7.3_1.12.2
  • Forge-Version: 1.12.2-14.23.4.2705, 1.12.2-14.23.5.2854

Additional context
The easy fix would be to store the result to be returned in ItemGauge::has, clear the tag compound set after calling ItemStack::getTagCompound with ItemStack::clearTagCompound if it was supposed to be null, then return the stored result.

commented

I am pretty sure d7ca08a inadvertently fixed this. Closing as it will be in the next release.

Thanks for the super detailed report!