Hello.
I want to summon an entity by code, so I saw vanilla’s SummonCommand#spawnEntity and the main flow is here :
{
Entity entity = EntityType.loadEntityRecursive(compoundtag, serverlevel, (e) -> {
e.moveTo(x, y, z, yRot, xRot);
return e;
});
((Mob)entity).finalizeSpawn(commandSourceStack.getLevel(), commandSourceStack.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData)null, (CompoundTag)null);
}
I guess I need compoundtag and ServerLevel object(=commandSourceStack.getLevel()).
CompoundTag compoundtag = new CompoundTag();
compoundtag.putString("id", "minecraft:chicken”); // right?
ServerLevel serverlevel … ???
How can I get them? Or is there another way?
Thanks in advance.