Jedispencer21 Posted January 25, 2016 Share Posted January 25, 2016 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. Quote Link to comment Share on other sites More sharing options...
Jedispencer21 Posted January 25, 2016 Author Share Posted January 25, 2016 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? Quote Link to comment Share on other sites More sharing options...
Ernio Posted January 26, 2016 Share Posted January 26, 2016 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. Quote 1.7.10 is no longer supported by forge, you are on your own. Link to comment Share on other sites More sharing options...
Jedispencer21 Posted January 26, 2016 Author Share Posted January 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
Choonster Posted January 26, 2016 Share Posted January 26, 2016 On the client there's only one World : Minecraft#theWorld . Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
Jedispencer21 Posted January 26, 2016 Author Share Posted January 26, 2016 So, upon trying, inside the packet: EntityPlayer player = Minecraft.getMinecraft().theWorld.getEntityById(id); and trying to use the variable in any way returns null. Quote Link to comment Share on other sites More sharing options...
Ernio Posted January 26, 2016 Share Posted January 26, 2016 Are you getting "id" field from message passed to receive method? Post full code. Quote 1.7.10 is no longer supported by forge, you are on your own. Link to comment Share on other sites More sharing options...
Jedispencer21 Posted January 26, 2016 Author Share Posted January 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
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.