mojira.dev
MC-268109

Datapack functions delay block breaking

I am making datapack that creates new block called workbench. There is a function that happends when item frame cannot detect barrel on its position. It will kill item displays that have item with CustomModelData and will insert new nbt data to barrel item with specific name that dropped from the broken barrel. This happends normaly in creative mode or when I instantly break the barrel, but the longer I'm breking the barrel, the longer drop delay is. There is a screen recording and zip file of my datapack in the attachments. There are some unused files in the datapack, please pay them no mind. 

I also forgot to mention, when i was trying to debug it, it worked normaly when I removed part of the function where there was replacing item in the barrel. There were 27 parts of the functions (commented by "Slot 0", "Slot 1"...) which were summoning new item and inserting data from barrel into it and then replacing item in specific slot in the barrel with air. When I removed them, block delay was normal. Here is also the resourcepack if there is any need for it. If it is not a bug, please give me a tip how to fix it.

[media][media][media]

Attachments

Comments 3

Commands (and by extension functions) require processing power. Unoptimized functions will drain memory and slow down game tick speed. That's not a bug but an expected consequence. This is a problem with your pack, not the game. Lag is not a bug.

For reference, block breaking bugs out as the client does not lag, desyncing the mining progress, keep mining and the block breaks fine.

Any idea how to fix it? I made similiar datapack in the past, but I didn't have issue like that. How should I optimize it? And how is it caused by lag if I break it slowly, but when I break it fast, it breaks normaly.

  1. This place is not a help desk

  2. The desync with long mine times will be more noticable: if 20 ticks takes 1.1 seconds instead of 1, mining a block that takes 0.5 seconds to mine will have no noticable difference; mining a block that requires 10 seconds to mine will result in needing an extra 1 second of mining time.

MrRedi

(Unassigned)

Unconfirmed

(Unassigned)

1.20.4, 24w04a

Retrieved