Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6189

Persistent data disappears when calling setFacingDirection on an item frame

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-2740d5a-890130b (MC: 1.16.3) (Implementing API version 1.16.3-R0.1-SNAPSHOT)
    • Yes

      When Hanging#setFacingDirection is called on a spawned ItemFrame, all custom metadata is removed. I've used git-Paper-229 to run this example internally but I've confirmed the same behavior is on git-Spigot-2740d5a-890130b as well (see version info).

      Location relativeLocation = targetBlock.getRelative(attachToSide).getLocation();
      ItemFrame itemFrame = (ItemFrame) targetBlock.getWorld().spawnEntity(relativeLocation, EntityType.ITEM_FRAME);
      
      setPersistentData(itemFrame, "before_facing");
      
      if (spawnWithFacing) {
          itemFrame.setFacingDirection(attachToSide);
      }
      
      itemFrame.setInvulnerable(false);
      itemFrame.setFixed(false);
      
      setPersistentData(itemFrame, "after_facing");
      
      itemFrame.setItem(new ItemStack(Material.GLISTERING_MELON_SLICE));
      

      When inspecting the NBT of the spawned entity that had not its facing direction set, here's the result:

      {Paper.SpawnReason:"CUSTOM",BukkitValues:{"itemframebugdemo:data":"after_facing"},Invisible:0b,Bukkit.updateLevel:2,ItemDropChance:1.0f,Item:{id:"minecraft:glistering_melon_slice",Count:1b},ItemRotation:0b,OnGround:0b,Air:300s,UUID:[I;934245344,-378451563,-1533531567,-229749185],Invulnerable:0b,Spigot.ticksLived:77,Paper.Origin:[-78.5d,63.5d,9.96875d],Fixed:0b,FallDistance:0.0f,WorldUUIDLeast:-7680800385441158204L,Motion:[0.0d,0.0d,0.0d],Facing:2b,Rotation:[180.0f,0.0f],TileZ:9,Fire:-1s,Pos:[-78.5d,63.5d,9.96875d],WorldUUIDMost:8230340146961074430L,PortalCooldown:0,TileY:63,TileX:-79}
      

      If the facing direction was set, the NBT tags are as follows:

      {Paper.SpawnReason:"DEFAULT",Invisible:0b,Bukkit.updateLevel:2,ItemDropChance:1.0f,Item:{id:"minecraft:glistering_melon_slice",Count:1b},ItemRotation:0b,OnGround:0b,Air:300s,UUID:[I;-741504061,744834135,-1387863996,-282977806],Invulnerable:0b,Spigot.ticksLived:90,Paper.Origin:[-78.5d,64.03125d,10.5d],Fixed:0b,FallDistance:0.0f,WorldUUIDLeast:-7680800385441158204L,Motion:[0.0d,0.0d,0.0d],Facing:1b,Rotation:[0.0f,-90.0f],TileZ:10,Fire:-1s,Pos:[-78.5d,64.03125d,10.5d],WorldUUIDMost:8230340146961074430L,PortalCooldown:0,TileY:64,TileX:-79}
      

      Note how the Paper.SpawnReason was changed as well as the BukkitValues persistent tag was removed, but the item frame properties (what item is inside) stay the same.

      I've attached the demo plugin that demonstrates this issue. You can find the source code here: https://github.com/bo3tools/spigot-itemframe-bug-demo

            Unassigned Unassigned
            asdfg asdfg
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: