Jump to content

Recommended Posts

Posted

Im new to Forge modding and wanted to make a mod as a self project.

Im trying to test if the player is holding a specific item when an event happens but it seems to not be doing anything.

 

if(player.getItemInHand(InteractionHand.MAIN_HAND).equals(new ItemStack(ItemInit.SOUL_POUCH_ARTIFACT.get()))){

     player.sendSystemMessage(Component.literal("Test"));

}

 

I know the event works because it runs fine without the if statement.

Thanks.

Posted

Try

if(player.getItemInHand(InteractionHand.MAIN_HAND).getItem() == ItemInit.SOUL_POUCH_ARTIFACT.get()) {
     player.sendSystemMessage(Component.literal("Test"));
}
Posted
9 minutes ago, dee12452 said:

Try

if(player.getItemInHand(InteractionHand.MAIN_HAND).getItem() == ItemInit.SOUL_POUCH_ARTIFACT.get()) {
     player.sendSystemMessage(Component.literal("Test"));
}

Yeah it worked ty!!

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.