Manchou Posted September 20, 2012 Posted September 20, 2012 I wanted to share custom data with the client for my mobs. I first tried to send a custom packet but then I found this : http://www.minecraftforge.net/forum/index.php/topic,1410.msg12341.html#msg12341 So I made my Entity implement IEntityAdditionalSpawnData : /** * @author Manchou * */ public class EntityDarwinCreature extends EntityAnimal implements IEntityAdditionalSpawnData { private long genome; /** * @param par1World */ public EntityDarwinCreature(World world) { super(world); this.texture = "/net/darwin/darwinCreature.png"; genome = 0; } // specific code @Override public void writeSpawnData(ByteArrayDataOutput data) { data.writeLong(genome); System.out.println("writeSpawnData "+genome); } @Override public void readSpawnData(ByteArrayDataInput data) { genome = data.readLong(); System.out.println("readSpawnData "+genome); } public void setGenome(long genome) { this.genome = genome; } } And well, the methods write/readSpawnData() are never called. I tried to make them spawn with an monsterPlacer and with a spawn rule: EntityRegistry.addSpawn(EntityDarwinCreature.class, 20, 10, 10, EnumCreatureType.creature, new BiomeGenBase[]{desert, beach, iceMountains, icePlains, taiga, taigaHills, desertHills, forest, forestHills, plains, extremeHills, extremeHillsEdge, jungle, jungleHills}); The mob spawns but the data is not shared. Quote
Manchou Posted September 21, 2012 Author Posted September 21, 2012 I send my variable "genome" on each onUpdate() call. And well, it works. But it's a useless flood of packets. Why the methods of IEntityAdditionalSpawnData are not called? Did I do something wrong? Is it a bug? Quote
DarkGuardsman Posted September 21, 2012 Posted September 21, 2012 use dataWatchers like the VillagerMob does it a simple way to keep things updated and is sent with all other mob data. Quote http://i577.photobucket.com/albums/ss215/bobstrong/ModBannerMed.png[/img]
LexManos Posted September 21, 2012 Posted September 21, 2012 I see your spawn registration, but I dont see your entity registration. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
Manchou Posted September 22, 2012 Author Posted September 22, 2012 You mean that? EntityRegistry.registerGlobalEntityID(EntityDarwinCreature.class, "Creature", ModLoader.getUniqueEntityId(), 0x880000, 0x00FF00); Quote
LexManos Posted September 22, 2012 Posted September 22, 2012 Was referring to the tracking registration, but also dont use any ModLoader.* stuff, keep yourself as ModLoader free as possible. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
Manchou Posted October 3, 2012 Author Posted October 3, 2012 use dataWatchers like the VillagerMob does it a simple way to keep things updated and is sent with all other mob data. Thank you. That was what I need and more! Was referring to the tracking registration, but also dont use any ModLoader.* stuff, keep yourself as ModLoader free as possible. Dunno what's the tracking registration. I don't find how to have the method called, and as said above, I have another, better solution. I know I shouldn't use ModLoader anymore and that's what I mostly do. But what's the method in Forge API to get a unique entity id? Quote
OvermindDL1 Posted October 6, 2012 Posted October 6, 2012 Not needed. In Forge Entities are per-mod, so just name them distinct in your own mod. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.