-
[1.8.9][SOLVED]How to tell if an item is already in custom inventory?
@Override public boolean isItemValid(ItemStack itemstack) { if (itemstack.getItem() instanceof IBauble ){ for (int a = 0; a < inventory.INV_SIZE; a++) { if(itemstack.areItemStacksEqual(itemstack, inventory.getStackInSlot(a))){ if(inventory.getStackInSlot(a) != null){ return true; } } } } return false; } Thanks. Except now I cant put an item in the inventory at all.
-
[1.8.9][SOLVED]How to tell if an item is already in custom inventory?
From ItemStack Class @SideOnly(Side.CLIENT) public boolean getIsItemStackEqual(ItemStack p_179549_1_) { return this.isItemStackEqual(p_179549_1_); } private boolean isItemStackEqual(ItemStack other) { return this.stackSize != other.stackSize ? false : (this.item != other.item ? false : (this.itemDamage != other.itemDamage ? false : (this.stackTagCompound == null && other.stackTagCompound != null ? false : this.stackTagCompound == null || this.stackTagCompound.equals(other.stackTagCompound)))); } Nope http://pastebin.com/HkrTfcia
-
[1.8.9][SOLVED]How to tell if an item is already in custom inventory?
I want to make sure not more than one type of item can be placed in the inventory. Probably not like this because this crashes? @Override public boolean isItemValid(ItemStack itemstack) { if (itemstack.getItem() instanceof IBauble ){ for (int a = 0; a < inventory.INV_SIZE; a++) { if(itemstack.getIsItemStackEqual(inventory.getStackInSlot(a))){ return true; } } return false; } return false; }
-
[1.8.9][SOLVED]How to tell if an item is already in custom inventory?
I want to make sure you can only put one type of any item in my custom inventory. I know i need to use the isItemValid method but I don't know how to check if that item already exists in my inventory.
-
[1.8.9]How to tell when an item is removed from the players inventory?
Ok looks like I will have to take a different approach to this. Sorry I should have listened to you in the first place but I'm stubborn.
-
[1.8.9]How to tell when an item is removed from the players inventory?
Very good point. Not to mention every other mod that takes the item out of the players inventory. Is there anyway to tell when the items stacksize has been decreased?Otherwise I may have to use a different approach with this whole thing but for now il continue on. Well I thought it was a server client issue because throwing the item didn't stop my flight but i still took damage and so with this: @SubscribeEvent public void ItemTossEvent(ItemTossEvent event) { EntityPlayer player = event.player; if (event.entityItem.getEntityItem().getItem() == TatItems.itemBaublesBag) { ItemStack baublesbag = event.entityItem.getEntityItem(); InventoryBaublesBag inventorybaublesbag = (InventoryBaublesBag) BaublesBag.getInventory(baublesbag, player); for (int a = 0; a < inventorybaublesbag.inventory.length; a++) { if (inventorybaublesbag.getStackInSlot(a) != null && inventorybaublesbag.getStackInSlot(a).getItem() instanceof IBauble) { if(player.worldObj.isRemote){ System.out.println("client"); } if(!player.worldObj.isRemote){ System.out.println("server"); } ((IBauble) inventorybaublesbag.getStackInSlot(a).getItem()).onUnequipped(inventorybaublesbag.getStackInSlot(a), player); } } } } Putting the item outside the inventory prints both client and server whereas pressing "q" only prints server. So I think I am right in saying I need to send a packet from the server to the client then? Not an expert.
-
[1.8.9]How to tell when an item is removed from the players inventory?
- [1.8.9]How to tell when an item is removed from the players inventory?
So why doesn't it work?(it works for the throwing out of inventory but not for pressing Q)- [1.8.9]How to tell when an item is removed from the players inventory?
Cant I tell when the player presses the "toss key"?- [1.8.9]How to tell when an item is removed from the players inventory?
Yes I do that but their inventory is not an item inventory and so I need to make sure when the player dies (which ive done) or when the player tosses the item that the unequipped method is called.Becasue decrStackSize does not get called when this happens.- [1.8.9]How to tell when an item is removed from the players inventory?
Changed to PlayerTickEvent. Changed to .equals . onUnequiped is the method that is called when the bauble item is removed from the baubles inventory. I need to call is because I am basically making my own version of their inventory. If you haven't already: https://github.com/Azanor/Baubles- [1.8.9]How to tell when an item is removed from the players inventory?
If you are familiar with the mod baubles it is an api that allows you to add "rings" and "amulets". I am calling the methods that these items use when they need to be activated if they are in my custom inventory. But i need to turn these attributes off if the item inventory is removed from the players inventory. TickHandler public class TatEventHandler { @SubscribeEvent public void PlayerEvent(PlayerEvent event) { EntityPlayer player = event.entityPlayer; if (player instanceof EntityPlayer) { if (player.isDead) { for (int a = 0; a < player.inventory.mainInventory.length; a++) { if (player.inventory.getStackInSlot(a) == new ItemStack(TatItems.itemBaublesBag)) { ItemStack baublesbag = player.inventory.getStackInSlot(a); InventoryBaublesBag inventorybaublesbag = (InventoryBaublesBag) BaublesBag.getInventory(baublesbag, player); for (int b = 0; b < inventorybaublesbag.inventory.length; b++) { if (inventorybaublesbag.getStackInSlot(b) != null && inventorybaublesbag.getStackInSlot(b).getItem() instanceof IBauble) { ((IBauble) inventorybaublesbag.getStackInSlot(b).getItem()).onUnequipped(inventorybaublesbag.getStackInSlot(b), player); } } } } } } } @SubscribeEvent public void ItemTossEvent(ItemTossEvent event) { EntityPlayer player = event.player; if (event.entityItem.getEntityItem().getItem() == TatItems.itemBaublesBag) { ItemStack baublesbag = event.entityItem.getEntityItem(); InventoryBaublesBag inventorybaublesbag = (InventoryBaublesBag) BaublesBag.getInventory(baublesbag, player); for (int a = 0; a < inventorybaublesbag.inventory.length; a++) { if (inventorybaublesbag.getStackInSlot(a) != null && inventorybaublesbag.getStackInSlot(a).getItem() instanceof IBauble) { ((IBauble) inventorybaublesbag.getStackInSlot(a).getItem()).onUnequipped(inventorybaublesbag.getStackInSlot(a), player); } } } } }- [1.8.9]How to tell when an item is removed from the players inventory?
I have a custom inventory item that when particular items are in it it does something to the player but i need to stop that thing from happening when the item is removed from the player inventory.- [1.8.9]How to tell when an item is removed from the players inventory?
Hmm I'm not sure if you understand what I meant because I just used ItemTossEvent and that: * Event that is fired whenever a player tosses (Q) an item or drag-n-drops a * stack of items outside the inventory GUI screens. Canceling the event will * stop the items from entering the world, but will not prevent them being * removed from the inventory - and thus removed from the system. However the throwing outside the player gui works but the dropping on the ground only works on one side and i need it on both client and server.- [1.8.9]How to tell when an item is removed from the players inventory?
Ok. Can I tell if the item is removed by dropping it or if it is removed by picking up out the inventory? - [1.8.9]How to tell when an item is removed from the players inventory?
IPS spam blocked by CleanTalk.
Important Information
By using this site, you agree to our Terms of Use.