mojira.dev
MC-229598

Command Block in repeat mode using Summon command with invalid NBT data causes massive amounts of TPS lag

General Description

I used the following command inside a command block in repeat mode:

summon minecraft:axolotl ~2 ~ ~ {Age: -100000,Variant: -1}

When I placed a redstone block next to the command block I noticed a slowdown in the world and looking at the graphs in the F3 menu, I saw a massive spike in the TPS. When the redstone block was removed, I noticed the graph 'catching up' and afterwards everything returned to normal. Screenshots and a screen recording of this occurrence are attached*.

 

I later changed the command to make the NBT valid again:

summon minecraft:axolotl ~2 ~ ~ {Age: -100000,Variant:2}

This worked as expected: after placing the redstone block, a lot of Axolotls spawned, all of variant 2, and no lag was to be observed in both the world en the TPS graph.

Steps to reproduce

  1. Place a command block in the world

  2. Set the command block to repeat mode and insert the following command:

  • summon minecraft:axolotl ~2 ~ ~ {Age: -100000,Variant: -1}

       3. Activate the command block

 

*Video is encoded using libx265, in case you're having trouble loading the file

Attachments

Comments 8

I'm sorry for editing the post so much, the formatting kept breaking for some reason

[media]

I am definitely getting some lag trying to do this, but not nearly as much as you are.

That's very interesting... I see you are in a superflat world where I was in an normal world and I was wondering if that made a difference. So I tried the command again, also in a superflat world this time and I seem to get massive amounts of lag there as well, way more than you seem to be getting

I ran a performance metrics debug test while this lag spike occurred and I've attached the resulting zip file 

[media]

Can confirm in 1.17.1. I have an idea of why this happens; I think the main issue is not being able to spawn an axolotl with a non-existent variant.

Unlike tropical fish, which spawn even with non-existent variants, axolotls with non-existent variants are not able to be spawned. If you test typing

/summon minecraft:tropical_fish ~2 ~ ~ {Variant:-1}

, it will be successful. However, typing

/summon minecraft:axolotl ~2 ~ ~ {Variant:-1}

will fail to spawn the axolotl.

Aditionally, the game log is spammed with warn messages saying Exception loading entity caused by java.lang.ArrayIndexOutOfBoundsException: Index [variant number] out of bounds for length 5 at bfa.a, which I assume is net.minecraft.world.entity.animal.axolotl.Axolotl:readAdditionalSaveData(net.minecraft.nbt.CompoundTag) according to the Mojang deobfuscation map.

So my hypothesis is (I don't know much about code, I'm basing myself only in the log) that the game stores the valid NBT data (in this case, Variant) as an array of the 5 variants of axolotl, but the function to read said data does not prevent it from getting a value that does not exist in the array. The tropical fish must have something like this, because if I type in an absurdly high number as the variant and get the Variant NBT after it is spawned, it shows up as 0. This probably means that the Variant is set to 0 if it is not valid.

Can confirm in 21w42a.

I am no longer able to reproduce this in 1.20.2. This seems to have been fixed at some point (there is still some lag, but that's just caused by the amount of axolotls rather than the command block failing to spawn them). Resolving as Cannot Reproduce.

BoredStudent

(Unassigned)

Confirmed

(Unassigned)

command-block, lag, nbt, summon, tickLAG, tickspeed

1.17, 1.17.1 Pre-release 1, 1.17.1, 21w42a, 1.19

Retrieved