Immersive Melodies [Fabric/Forge]

Immersive Melodies [Fabric/Forge]

10M Downloads

Entity spawned with preconfigured NBT to hold a specific instrument, may have it replaced

SadSalmonTwT opened this issue ยท 0 comments

commented

Describe the bug
An entity spawned with nbt configuring an instrument and a melody, may have its instrument (and as such also its melody) replaced as per "mobInstrumentFactors" randomization chance.

To Reproduce
In 1.20.1

Command block in repeat mode:
/summon wither_skeleton ~ ~ ~ {HandItems:[{id:"immersive_melodies:handpan",Count:1b,tag:{melody:"immersive_melodies:melodies/castle.midi", playing: 1b,}}]}

Occasionally prune the correctly spawned:
/kill @e[type=minecraft:wither_skeleton,nbt={HandItems:[{id:"immersive_melodies:handpan",Count:1b,tag:{melody:"immersive_melodies:melodies/castle.midi", playing: 1b,}}]}]

In 1.21.1

Same but with:
/summon wither_skeleton ~ ~ ~ {HandItems:[{id:"immersive_melodies:handpan",Count:1b,components:{melody:"immersive_melodies:melody/castle.midi", playing: 1b,}}]}

Got no clue how to kill them tho, but the behaviour is the same.

Expected behavior
An entity already spawned with an instrument probably should not get it ever replaced.

Additional context
Admittedly the usecase of manually spawning entities with commands is rather obscure, but the same issue applies with other mods that stringify entities together with their nbt data for future respawning (various pokeballs etc.).

For context I wanted to build a sort of mob based jukebox. Which worked flawlesly, until said mobs started randomly switching instruments and melody when summoned from a pokeball.
Admittedly I fixed it by disabling "mobInstrumentFactors" for the mob type in question, but still.

I imagine an extra check to the shouldEquip function on whether the entity already holds one of the instruments would suffice?

If its at all worth the effort.