So I want to search a player's whole inventory for a specific item client-side. I have the following class:
net.minecraft.client.entity.EntityOtherPlayerMP
Which extends off of some other classes, like
net.minecraft.entity.player.EntityPlayer
And I can use the inventory (InventoryPlayer) property from that class to get the player's inventory. I tried two things and I don't really get the correct results:
1. hasItem:
import net.minecraft.item.Item;
// ...
// entity is an instance of EntityOtherPlayerMP
// inventory is InventoryPlayer
entity.inventory.hasItem(Item.getItemByID(1));
// This only returns true when the entity is holding a stone block (ID 1)
// Expected result: returns true regardless if the player is holding a stone block or not.
2. inventory.mainInventory:
// ...
// like before, entity is an instance of EntityOtherPlayerMP, and inventory is InventoryPlayer...
entity.inventory.mainInventory;
// mainInventory is just supposed to be a ItemStack[]
// Returns an array of null, 36 nulls. [null, null, null, ...]
Does this mean that no, client-side you cannot get another player's (full) inventory, or am I doing something wrong?
So I want to search a player's whole inventory for a specific item client-side. I have the following class:
Which extends off of some other classes, like
And I can use the inventory (InventoryPlayer) property from that class to get the player's inventory. I tried two things and I don't really get the correct results:
1. hasItem:
2. inventory.mainInventory:
Does this mean that no, client-side you cannot get another player's (full) inventory, or am I doing something wrong?
m
You cannot, only visible items like the hand and armour are sent to the other players.