What I am trying to accomplish is if a player picks up a specific mod item, it gives them an achievement. I know how to add the achievement however I need to test what item it is that was picked up. I attempted
When I check the item being picked up and print it in game, the item being picked up is always displayed as 0xtileair@0?
Minecraft.getMinecraft().player.sendChatMessage("Picked up " + event.pickedUp.getEntityItem());
It's possible it's only handled server side. Try print out a log on the server side and see what you get.
I've used this before in 1.10.2 and it worked but I always handle things like this server side anyway, so I've never seen what happens when you try to use this event on the client side.
EDIT:
FYI "0xtileair@0" is an empty stack. In MC 1.11+ ItemStacks can never be null, and so an empty ItemStack is simply one containing 0 air blocks. There's the static field ItemStack.EMPTY which can be used for this.
It's possible it's only handled server side. Try print out a log on the server side and see what you get.
I've used this before in 1.10.2 and it worked but I always handle things like this server side anyway, so I've never seen what happens when you try to use this event on the client side.
EDIT:
FYI "0xtileair@0" is an empty stack. In MC 1.11+ ItemStacks can never be null, and so an empty ItemStack is simply one containing 0 air blocks. There's the static field ItemStack.EMPTY which can be used for this.
I attempted to make the method server side by adding
@SideOnly(Side.SERVER)
however that made it so the method was not executed at all (verified by message not being printed to console via System.out.println() ). Aside from that, how would I print a server log?
I attempted to make the method server side by adding
@SideOnly(Side.SERVER)
however that made it so the method was not executed at all (verified by message not being printed to console via System.out.println() ). Aside from that, how would I print a server log?
Thanks for the FYI regarding the empty stack.
Noooooo no no no no. NO.
Don't ever use the @SideOnly annotation unless you really know what it's doing, or a method you're overriding already uses it. That annotation will make whatever you attach it to only exist on that side.
Use World.isRemote to check for what side the code is running on. That variable is a boolean, and will be true when on the client side.
Within Forge 1.11 what was the PlayerPickupItemEvent replaced with?
PlayerEvent.ItemPickupEvent
Sorry for the delay in my response, thank you!
Also, I know that ItemSmeltedEvent has , what is it for the pick up event? Sadly does not exist?
What I am trying to accomplish is if a player picks up a specific mod item, it gives them an achievement. I know how to add the achievement however I need to test what item it is that was picked up. I attempted however that does not work.
Use EntityItem#getEntityItem. All you needed to do was look for the method in the class.
When I check the item being picked up and print it in game, the item being picked up is always displayed as 0xtileair@0?
It's possible it's only handled server side. Try print out a log on the server side and see what you get.
I've used this before in 1.10.2 and it worked but I always handle things like this server side anyway, so I've never seen what happens when you try to use this event on the client side.
EDIT:
FYI "0xtileair@0" is an empty stack. In MC 1.11+ ItemStacks can never be null, and so an empty ItemStack is simply one containing 0 air blocks. There's the static field ItemStack.EMPTY which can be used for this.
I attempted to make the method server side by adding
however that made it so the method was not executed at all (verified by message not being printed to console via System.out.println() ). Aside from that, how would I print a server log?
Thanks for the FYI regarding the empty stack.
Noooooo no no no no. NO.
Don't ever use the @SideOnly annotation unless you really know what it's doing, or a method you're overriding already uses it. That annotation will make whatever you attach it to only exist on that side.
Use World.isRemote to check for what side the code is running on. That variable is a boolean, and will be true when on the client side.