mojira.dev
MC-92282

Mob spawner block_entity_data does not copy SpawnData data to missing SpawnPotentials

When using /setblock to create a spawner with only "SpawnData" supplied, that data is automatically copied into "SpawnPotentials" such that the same entity will always spawn.

For example, the following /setblock command shows the intended behavior:

/setblock ~ ~ ~ spawner{SpawnData:{entity:{id:zombie}}}

A rough example of what the spawner's data becomes, indicating that the list of entities to spawn is only that which was defined in SpawnData:

{SpawnData:{entity:{id:"minecraft:zombie"}},SpawnPotentials:[{weight:1,data:{entity:{id:"minecraft:zombie"}}}]}

However, the block_entity_data component does not cause this copy to happen. Instead, given the following /give command (which is expected to have the exact same result as /setblock when placed):

/give @s spawner[block_entity_data={id:spawner,SpawnData:{entity:{id:zombie}}}]

The data becomes:

{SpawnData:{entity:{id:"minecraft:zombie"}},SpawnPotentials:[]}

The difference being that the SpawnPotentials did not copy the zombie over like it does with /setblock.

Related issues

MC-100058 Mob Spawner BUG MC-111814 Spawners turning back into pig spawners MC-112515 custom mob_spawner placed manually turn into pig spawner after 1 mob spawn. MC-121071 Given spawner MC-124783 Mob Spawner Deletes Initial Index without Checks MC-129586 Custom Mob Spawner MC-130509 Custom spawners resets to default (pig) state after spawning entity once MC-130551 Spawner resets to default (pig) state after spawning mobs once. MC-136186 BlockEntityTag & Spawner SpawnPotentials Issue MC-144379 Custom Spawners Revert to Pig Spawners MC-151352 Spawners transforming into pigs MC-153863 Spider Spawner changing spawning entity to pig MC-160816 Custom spawners turn into pig spawners after only 1 spawn MC-165724 Spawner Given With Commands Turns Into A Pig Spawner After Spawning The Mob MC-183946 Command created spawners turn back into pig spawners after spawning a mob once

Comments

migrated

Confirmed, but probably invalid because mob spawners are not supposed to be available in item form (MC-80597).

Irbis

redstonehelper, mob spawners as item are commonly used in servers, so disabling it would be bad for them. The bug you linked to is no longer counting mob spawner.
This bug is not invalid and in my opinion should be fixed.=]

migrated

redstonehelper: You could argue that the entire BlockEntityTag is invalid with that argument.

migrated

Yes, I could have.

SunCat

Confirmed for 1.9-pre2

Skylinerw

Confirmed fixed; BlockEntityTag now corresponds with behavior of /setblock (filling in SpawnPotentials automatically).

Skylinerw

Issue has resurfaced at some point between 16w32a and 1.11.

migrated

I've been messing with the latest snapshot (time of writing, so 17w17b) and noticed that this is still a problem. Was about to report when I found this issue. It's especially annoying for servers because using spawners is a lot less taxing than having to mess around with command blocks. Even better: spawners help to keep the game feel more natural.

migrated

I seem to be having this problem in 1.12 and 1.12.2 as well.

migrated

Confirmed for 1.13..

migrated

fix this the api was suppose to make it so you don't have to specify spawn potentials yet you have to here. confirmed for 1.13.1 pre 1

migrated

This problem has been resolved as far as I can tell.

If you place a spawner then it will default to spawning pigs. If you then set SpawnData as per example from the op:

/data merge block x y z {SpawnData:{id:"minecraft:zombie"}}

then it will change into a zombie spawner, spawn one (or more) zombies and then reset back to pigs. This is intended behavior because SpawnPotentials:[] (which hasn't changed) gets copied onto SpawnData. And 'potentials' was still set to pigs.

But if we use this command instead then the results will heavily change:

/data merge block x y z {SpawnPotentials:[{Entity:{id:"minecraft:zombie"},Weight:1}]}

First several pigs will spawn (which is intended because they were still specified in SpawnData) but after that the spawner will change into a zombie spawner and it will remain spawning zombies.

The same thing applies if you give yourself a spawner and only set SpawnPotentials: first it will spawn pigs, but then it will start spawning whatever entity you defined. This is fully as intended because SpawnData was never set (and thus is set to default).

Which makes me convinced that this bug has been resolved. I've never been able to use customized mob spawners in 1.12.2 but I can in 1.13.1

kumasasa

@unknown, the point is not to modify the data of an already placed spawner, but when placing a custom spawner the current SpawnData of the item should be copied into the (yet empty) SpawnPotentials of the yet placed block.

migrated

basically if it's a mob spawner they and don't have the tag on the itemstack they need to set it virtually before merging the nbt. Create a WeightedSpawnEntity(1,spawndataTag).toCompoundTag() and put it inside of a tag list. from there set that tag as spawnpotentials. When merging any additional data should get overridden by the 2d tag compound

Gatinh0

Remains an issue as of 09Oct18.

jredfox, sounds like you were explaining a work-around, but I don't follow. By tag list you referring to as an example minecraft/tags/blocks/example.json? Can you reply again in more detail? Would be much appreciated 😃

migrated

It's not a work around any data that could get merged via TileEntity nbt's tags that would also have to get synced over has to be applied. In this case spawnpotentials should be deleted before placement. 

Irbis

19w13a affected

migrated

1.14 and 1.14.1 are also affected

migrated

Edit: the bug as reported doesn't affect 1.14+ but unless you are in creative or are op on a server a custom spawner will always become a pig spawner.

It would be nice if this was changed.

I will post a feature request, because imo if a player has a way to get a custom spawner, then they should be able to place it.

 

CreeperMagnet_

I’m sorry to say, Valkon, but that’s never going to happen due to security exploits.

Players can easily save custom spawners that can spawn thousands of mobs a minute, or even command blocks, in their toolbars.

Then, with your feature request, they could place said spawners and cause massive destruction in another player’s server without OP.

TL;DR: No OP custom spawners are dangerous. Very dangerous.

migrated

CreeperMagnet, how is what you say possible? I don't get it.

If a player isn't op, then how do they get a spawner unless a server intentionally adds a method to give them one?

And if they do get one, how do they make it spawn thousands of mobs a minute unless they're given a spawner with higher rates? With default rates you'd need 50+ spawners to get even close to 1000 mobs per minute right?

It seems to me that even if non-op spawner placing was possible, it's still totally up to the server owners what they allow players to get their hands on - as it should be.

And if there are security exploits that allow non-op players to modify spawners to cause massive destruction, then those are bugs that should be fixed properly.

 

CreeperMagnet_

Players without OP can use creative mode’s saved toolbars. That is working as intended, and it will always be that way.

However, saved toolbars can be saved in any other world where the player has OP and can obtain spawners with modified NBT using /give—with modified spawnlimits, and delays so that it can spawn tickly, without a limit.

Then, if they were able to place these without OP, in any OTHER server, it would cause issues.

Being able to load toolbars without OP isn’t going to change. That’s a major purpose of toolbars, to be able to transfer items between worlds. However, the downside of this is non-OP players not being able to place custom spawners.

Would you rather be able to place some random spawners, or be able to keep your block palettes throughout worlds?

migrated

Ok I didn't know about that issue.
I don't play creative so have never really used a saved toolbar.

But isn't that issue part of a bigger exploit problem with saved toolbars that should be fixed properly?

Perhaps by not loading items you can't get via the creative inventory, or that's black listed on the server?
It's obviously not that simple I guess.

j_p_smith

Confirmed in 1.16. The first command no longer works; it should be:

/setblock ~ ~ ~ spawner{SpawnData:{id:zombie}}
Avoma

Can confirm in 21w05b.

Skylinerw

(Unassigned)

Confirmed

Platform

Low

Commands

Minecraft 15w45a, Minecraft 15w46a, Minecraft 15w47a, Minecraft 15w47b, Minecraft 15w47c, ..., 24w11a, 24w12a, 1.20.6, 1.21, 1.21.3

Minecraft 16w32a

Retrieved