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 have a custom inventory and some extended properties and when I equip an item in the slot in the custom inventory, it renders an accessory onto the player like armor, but the only problem I have is that when on a server, it doesn't show the accessory to other players. I assume I will need packets.

  • Author

So I taken a look at how vanilla does this with the armor, and I took a look at S04PacketEntityEquipment and NetHandlerPlayClient#handleEntityEquipment, now what I am wondering is how within my packet would I go about getting an entity from its ID, since it is handled client side?

Nope.

 

Every entity has entityId. It is always the same on client and server (server sets client's entityId on spawn).

You need to send packet from server to client with: player.entityId, itemStack, slotId.

On client you read them, world.getEntityById(message.entityId) and then set player's client side inventory to received itemStack in some slotId.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I am aware that the id is the same on both sides, better wording would have been, where should I get the World from inside the packet.

  • Author

So, upon trying, inside the packet:

EntityPlayer player = Minecraft.getMinecraft().theWorld.getEntityById(id);

and trying to use the variable in any way returns null.

Are you getting "id" field from message passed to receive method?

 

Post full code.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

After a bit of debugging, and looking at the code, I realized I missed the dumbest thing, I forgot to assign the entityId to the entityId in the packet in the constructor... so it was only returning 0, but fixed it, and it is now working.

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.