Sponge icon indicating copy to clipboard operation
Sponge copied to clipboard

MobSpawnerData#possibleEntitiesToSpawn is empty

Open Eufranio opened this issue 5 years ago • 1 comments

I am currently running

  • SpongeForge version: stable-7
  • Java version: 1.8.0_121
  • Operating System: Windows 10

Issue Description When getting the value of Keys.SPAWNER_ENTITIES from a MobSpawner TileEntity, which leads to MobSpawnerData#possibleEntitiesToSpawn, the returned WeightedCollectionValue is empty:

image

I tested it by spawning a Skeleton spawner via /setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnData:{id:"Skeleton"}} then checking it's data via event.getTargetBlock().getLocation().get().getTileEntity().get().get(Keys.SPAWNER_ENTITIES).

Eufranio avatar Feb 19 '20 14:02 Eufranio

I searched a bit in MobSpawnerBaseLogic and found that setting SpawnPotentials instead of SpawnData works fine: /setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnPotentials:[{Entity:{id:"Skeleton"}}]}

The reason is that SpawnData forces the entity to spawn if SpawnPotentials is empty/unspecified, but since Sponge directly gets the potentialSpawns field of the spawner logic (which is empty for spawners made with your command), then it will return an empty collection. Note that nextEntityToSpawn() will still return the skeleton archetype.

RedNesto avatar Apr 14 '20 18:04 RedNesto