I have a function that swaps out a Knowledge Book as an item entity for a custom entity using data modify.
If I run "/function #minecraft:tick" via the chat console it works fine.
When running automatically, the function is called but the same command either fails or is skipped (hard to say).
I have attached the datapack.
Setup:
Drop a Knowledge Book within 6 blocks of the player
Give the player the tag giveSeedBook
Expected Result:
Item entity is modified to be a written book, with a custom texture, called "Seed Book"
Current Result:
Item entity is unmodified unless "/function bettercrops:seed_book/give/detect_knowledge_book" or "/function #minecraft:tick" is run via the chat console or an Impulse Command Block.
Attachments
Comments 5
Just updated initial call to use the following:
execute as @a[tag=giveSeedBook] at @s run function bettercrops:seed_book/give/detect_knowledge_book
Even added it to the command for redundancy.
execute at @s store success score @s itemFound run data modify entity @e[type=item,nbt={Item:{id:"minecraft:knowledge_book"}},sort=nearest,limit=1,distance=..6] Item set value {id:"minecraft:written_book",Count:1b,tag:{CustomModelData:12885930,title:"Seed Book",author:"",pages:['{"text":" "}']}}
Same issue.
Did you save? Did you reload? Are you sure you're not esiting a copy? Note, that this site is not a help desk. I've been working with data packs since 1.13 snapshots and my packs have always functioned with #tick, even today in both 1.20.1 and 1.20.2-rc1 there's no problems. That means there is something wrong in your data pack.
In either case, cannot reproduce.
I always /reload after every change and I know it's making updates.
Note: I came out of the world completely and went back in and now it's functioning fine.
Can't reproduce it now.
Not a bug. The command to replace item entities within 6 blocks is not run at the player, only as the player.
Always tripple check your setup before reporting it as a bug.
note lack of "at" or "positioned".