Jump to content

Won´t check Chestplate slot


darkexplosiveqwx

Recommended Posts

I am coding my own Mod with an Elytra Item

and in My ElytraJumpC2SPacket.java i want to check if the player is wearing  my custom Elytra

with this line of code 

            if(player.getInventory().armor.get(1) != ModItems.BAT_ELYTRA.get().getDefaultInstance() || player.getInventory().armor.get(1) != ModItems.ARMORED_BAT_ELYTRA.get().getDefaultInstance()) return;

Full Code on GitHub

 In the game it doesn´t works

 I am using Forge 1.19.2 - 43.1.52(the latest)

Edited by darkexplosiveqwx
forgot something
Link to comment
Share on other sites

You need to learn the different between reference == and value e.g. Object.equals() equality checks.

Examples where reference equality works in Minecraft are things that go in registries, e.g. Block, Item, EntityType, etc.

Examples where you need value equality are most other things, ItemStack, Entity, etc. because they have many instances.

The code you want looks something like:

Quote

        player.getItemBySlot(EquipmentSlot.CHEST).is(EXAMPLE_ITEM.get())

Look at the ItemStack class for other value equality checks.

NOTE how Item == Item is acceptable, but ItemStack == ItemStack is not.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

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.