read & write spawn data properly for placing spawners option

This commit is contained in:
granny
2025-04-12 21:46:18 -07:00
parent c5bb590f88
commit ba521eb66d
2 changed files with 7 additions and 3 deletions

View File

@@ -32,7 +32,9 @@ public class SpawnerItem extends BlockItem {
if (mobTypeStringOptional.isPresent()) {
EntityType.byString(mobTypeStringOptional.get()).ifPresent(type -> spawner.getSpawner().setEntityId(type, level, level.random, pos));
} else if (customData.contains("Purpur.SpawnData")) {
customData.read("SpawnData", net.minecraft.world.level.SpawnData.CODEC).ifPresent(spawnData -> spawner.getSpawner().nextSpawnData = spawnData);
customData.getCompound("Purpur.SpawnData")
.flatMap(spawnerData -> spawnerData.read("SpawnData", net.minecraft.world.level.SpawnData.CODEC))
.ifPresent(spawnData -> spawner.getSpawner().nextSpawnData = spawnData);
}
}
}