I did try to check if the picking item is exactly Blaze Rod. Any picked up item is descibed like so:
What I want to pick up:
Item: net.minecraft.item.Item@7ef60c02
StackSize: 1
Meta: 1xitem.blazeRod@0 (stack.toString())
What I'm actually picking up:
Item: net.minecraft.item.ItemAir@2e1291a4
StackSize: 0
Meta: 0xtile.air@0 (stack.toString())
I did override method like so:
@SubscribeEvent
public void pickItem(ItemPickupEvent event) {.......}
When the ItemStack is stashed into the player's inventory, it's stack size is set to 0, making it into the empty ItemStack (air).
Try using EntityItemPickupEvent instead, it's called before the item is put in the player's inventory. I'm not sure what the intended purpose of PlayerEvent.ItemPickupEvent is.
In 1.10.2 it worked fine.
PlayerEvent.ItemPickupEvent could be deprecated or have some kind of description.
I tested it further and it will always give You Air (like You said) so it could be deleted.
EntityItemPickupEvent works nice in 1.11
Not sure why the fml event even exists anymore
I think we can close this issue.
This can stay open until we decide what to do with PlayerEvent.ItemPickupEvent.
Looking at the code, it has a slightly different purpose and can actually be updated to work correctly, if we move it down a few lines.
EntityItemPickupEvent is fired when a player collides with an item entity; ItemPickupEvent is fired when the item is picked up. I have used the first one to prevent specific items from picking up and used the second one to count how many items the player has in inventory of that type. I don't know what changed it behavior to produce an air itemstack, but there is a workaround if someone wants to get the same behavior as before - check whether EntityItemPickupEvent is cancelled; if not, then proceed with your algorithm (counting items in my case), if yes, then do nothing.
Actually, the entity item becomes correct after entityIn.onItemPickup(this, i); line, so maybe it's worth to try moving the FML hook under it.
It's "broken" because of the if-statement just after the EntityItemPickupEvent event is fired:
if (this.delayBeforeCanPickup <= 0 && (this.owner == null || lifespan - this.age <= 200 || this.owner.equals(entityIn.getName())) && (hook == 1 || i <= 0 || entityIn.inventory.addItemStackToInventory(itemstack)))
Check out that last conditional. Take a WILD GUESS as to what it does. That's right, it adds the item stack to the player's inventory and calls itemStackIn.setCount(0); making it an empty stack.
This still seems to be an issue.
Is there any change coming? The ability to see not only _when_ something enters the inventory, but _what_ it is, seems necessary.
use the forge version of the event in the meantime (EntityItemPickupEvent or something similar)
EntityItemPickupEvent fires when an attempt to put something in the inventory happens. If the inventory is full and the item isn't picked up, it will still fire.
So, can someone move
https://github.com/MinecraftForge/MinecraftForge/blob/c8efe29d61f849d7adbd58d8236a5c563e6562ef/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch#L109
above this:
https://github.com/MinecraftForge/MinecraftForge/blob/c8efe29d61f849d7adbd58d8236a5c563e6562ef/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch#L107
and see if the issue was fixed?
@AlexiyOrlov What should probably happen instead is to clone the original item stack and pass the clone to the event. The item's already been picked up and so the event is just a notification of that (can't be canceled or changed) so a clone stack is fine.
The idea is to NOT fire the pickup event until after its actually picked up, So no don't move it above the line.
@Draco18s that would be reasonable.
No one else was doing it, so I did.
Can this be closed now?
Most helpful comment
No one else was doing it, so I did.