Jump to content

Difficulties with custom Entity Packets


TheScaryParrot

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.