Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

  • 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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.