Forge Version: 1.19.3 - 44.0.37
Hey, I've made a small mod with a nexus(just a blockentity) that spawns (monster)entitys. They should walk towards the nexus in order to destroy it.
Because there could be multiple nexuses, every spawned monster would need to know which nexus it was spawned by. In order to do that I thought I could just give every monster the nexus's BlockPos in nbt data.
The way I'm trying to do this is:
ModEntityTypes.NEXUS_ZOMBIE.get().spawn(level, (CompoundTag) new CompoundTag().put("NexusPos", NbtUtils.writeBlockPos(getBlockPos())), (Consumer<T>)null, spawnPosition, MobSpawnType.EVENT, false, false);
And then I get the nbt data of the spawned entity by using the command
/data get entity [ e.g. fef9ec95-4e46-4063-9221-6ff624c9e603]
ingame.
But the tag NexusPos is not present there:
I've dug a little into the spawn method which just forwards to EntityType.create. The create method only uses the compound tag to call Mob.finalizeSpawn, which does not use the compound tag.
I have a couple Questions
Is using nbt data for what I am trying to accomplish the right tool?
Is the compound tag argument ment to give the spawned entity it's nbt data? If not, how would I set the nbt data after or while spawning?
Is the way I am reading nbt via the command the correct way?
Do I have to manually sync changes to the nbt between the client and server?
If any more code is required to answer the question, just tell me :)
Thanks!