Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-262998

Lectern don't update with mcfunction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.19.4, 1.20 Pre-release 6
    • None
    • Unconfirmed
    • (Unassigned)

      Hello, after hours of struggling because I thought my system was poorly designed, I realized there was a very specific Minecraft bug. I provided a datapack ready to use to reproduce the bug if necessary.
      The "lectern" command:
      /setblock ~ ~ ~ lectern[has_book=true]{Book:{id:"minecraft:written_book",Count:1b,tag:{title:"",author:"",pages:['{"score":{"name":"@p","objective":"test"}}']}}} replace
      Here, it displays the score of the nearest player, and it works fine. If you destroy and replace it in the same location, it will update the score.
      But for some obscure reason, in the mcfunctions, if you destroy and then replace the block lectern , the lectern will retain the NBT of the first lectern.
      As a result, I created a map that uses the mechanics of lecterns to store scores in books, but my map doesn't work because of this bug.
      However, when you use the /data modify block command, it updates the chunk/data, and then it will work.

      In Loop

      tag @e[type=item] add check
      setblock 0 0 0 lectern[has_book=true]{Book:{id:"minecraft:written_book",Count:1b,tag:{title:"",author:"",pages:['{"score":{"name":"@p","objective":"test"}}']}}} destroy
      tp @e[type=item] @p
      scoreboard players add @p test 1
      

      In setup

      scoreboard objectives add test dummy
      forceload remove all
      setworldspawn 0 0 0
      tp @a 45111 100 44512121
      gamerule doTileDrops false
      scoreboard objectives setdisplay sidebar test
      

      So with this code, you should have a book with your current score every tick, but you'll notice that you always have the same book...
      For my personal use, I solved the issue by placing an empty lectern and then filling it with data modify...
      Instead of placing it directly with the correct NBT because it doesn't work.

            Unassigned Unassigned
            MrBurdy Alexis MrBurdy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: