Posted December 8, 20222 yr I'm working on a mod which should allow the player to capture the souls of dead LivingEntities. When LivingEntity dies a SoulEntity should be created that flies towards the player, similar to how experience orbs work. So I created a SoulEntity class which extends Entity. But I'm having problems with the Packet required for the 'getAddEntityPacket()' method. I created my custom Packet class simliar to the ClientboundAddExperienceOrbPacket. But I'm having trouble with the 'handle(ClientGamePacketListener p_131523_)' method. In the ClientboundAddExperienceOrbPacket the handling is done by the ClientGamePacketListener argument: public void handle(ClientGamePacketListener p_131523_) { p_131523_.handleAddExperienceOrb(this); } But as ClientGamePacketListener is a vanilla interface I'm not certain how I can add my own handle method to it. I'm having trouble finding documentation on this subject as most tutorials only explain the creation of LivingEntities, which don't require a custom 'getAddEntityPacket()' method. As I'm rather new to modding I'm not really sure what to do.
December 9, 20222 yr You shouldn't need to override the method unless you are sending additional information with the entity, and for that you can just refer to the docs and setting the packet to NetworkHooks#getEntitySpawningPacket.
December 10, 20222 yr Author As 'getAddEntityPacket()' is an abstract method of the Entity class it gives me an error if it isn't implemented. Anyways I just used the same code which is used in the LivingEntity class, which seems to work fine. @Override public Packet<?> getAddEntityPacket() { return new ClientboundAddEntityPacket(this); } Still thank you very much for the answer! The docs will most certainly get useful in the future.
December 10, 20222 yr 7 hours ago, TheScaryParrot said: As 'getAddEntityPacket()' is an abstract method of the Entity class it gives me an error if it isn't implemented. What version are you using? Afaik, that shouldn't be the case.
December 11, 20222 yr Author I'm using forge-1.19.2-43.1.57 and my SoulEntity extends 'net.minecraft.world.entity.Entity'
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.