deenkayros Posted March 5, 2015 Posted March 5, 2015 Hi, How can I change the current slot selected in hotbar? (not the held item) Thanks in advance ... Quote
deenkayros Posted March 5, 2015 Author Posted March 5, 2015 I can't find the player method "playerNetServerHandler" Quote
deenkayros Posted March 5, 2015 Author Posted March 5, 2015 a) It's a field, not a method. b) You need a server-side player (EntityPlayerMP). You can safely cast EntityPlayer to that if you are on the server thread (check with world.isRemote). Thank You, now works!!! BUT I'm already on server side and I still need to cast the EntityPlayerMP, here my code: @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { if (!event.player.worldObj.isRemote) { for (int s = 0; s < 9; ++s) { if (event.player.inventory.getStackInSlot(s) != null) { if (event.player.inventory.getStackInSlot(s).getItem() == MyItem) { event.player.inventory.currentItem = s; EntityPlayerMP playerMP = (EntityPlayerMP) event.player; playerMP.inventory.currentItem = s; playerMP.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(playerMP.inventory.currentItem)); } } } } Also I mean, if I need to send the package anyway? Quote
deenkayros Posted March 5, 2015 Author Posted March 5, 2015 I mean the packet ... but nevermind Quote
CCmoder Posted March 5, 2015 Posted March 5, 2015 maybe you can try this: EntityPlayer me=(EntityPlayer)world.playerEntities.get(0); me.inventory.currentItem=0;//or other number in 0-8 sorry,my english is not well Quote
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.