Posted September 2, 20169 yr I have method that is called on only the server side that result player.inventory.addItemStackToInventory(item) be called if all conditions are meet, but because it is only called on the server side the client does not update util you click in the slot it put in. If there away to invoke this update, right after player.inventory.addItemStackToInventory(item) is called.
September 2, 20169 yr Send packet from server to client with ItemStack and slotID and on client put ItemStack in that slot. 1.7.10 is no longer supported by forge, you are on your own.
September 2, 20169 yr Call Container#detectAndSendChanges on EntityPlayer#inventoryContainer to sync the player's inventory to their client. If you make a large amount of changes to an inventory, consider calling EntityPlayerMP#sendContainerToPlayer instead. This sends a single packet with the whole inventory instead of sending an individual packet for each slot that changed. 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.
September 3, 20169 yr Author So i am guessing player.inventory.addItemStackToInventory(item) player.inventory.detectAndSendChanges() not being at my development environment although it end yo being something more like this if (player.inventory.addItemStackToInventory(item)) { player.inventory.detectAndSendChanges() } else{ playerMP.worldObj.spawnEntityInWorld(new EntityItem(playerMP.worldObj, playerMP.posX, playerMP.posY, playerMP.posZ, item)); }
September 3, 20169 yr Call Container#detectAndSendChanges on EntityPlayer#inventoryContainer to sync the player's inventory to their client. EntityPlayer#inventory is an InventoryPlayer , not a Container . Use ItemHandlerHelper.giveItemToPlayer to give an item to a player or drop it at their feet if there wasn't room for it in their inventory. 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.
September 5, 20169 yr Author So got this and it works if (player.inventory.addItemStackToInventory(rewrad)){ player.inventoryContainer.detectAndSendChanges(); } else{ playerMP.worldObj.spawnEntityInWorld(new EntityItem(playerMP.worldObj, playerMP.posX, playerMP.posY, playerMP.posZ, rewrad)); } but will look into ItemHandlerHelper.giveItemToPlayer when i get an chance.
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.