Posted December 6, 20213 yr Hi, I created a simple steel lighter item, which has a item property "open" with "1.0" or "0.0" to display two different models, see: https://github.com/MarkusBordihn/BOs-Steel-Armor-Tools-Weapons/blob/main/src/main/resources/assets/steel_armor_tools_weapons/models/item/steel_lighter.json This works fine, but I want to change the state in the case the steel lighter is currently selected in the hotbar or not. I tried the LivingEquipmentChangeEvent which offers exactly the needed functionality, see: https://github.com/MarkusBordihn/BOs-Steel-Armor-Tools-Weapons/blob/main/src/main/java/de/markusbordihn/steelarmortoolsweapons/client/equipment/EquipmentChange.java But it seems that the ItemStack from this event is different from the ItemStack which is used for the ItemProperties.register(...), even both should be client side only. What I tried so far: Using itemStack.getOrCreateTag().putBoolean(...) and itemStack.getOrCreateTag().getBoolean(...) Using a hashmap with <itemStack, boolean> Using a local variable (current version) A debug of the hashmap with <itemStack, boolean> shows that the itemStack within the ItemProperties.register(...) is different from the itemStack in LivingEquipmentChangeEvent. So I wonder if there is a alternative event / approach I could use in this case or any other client only item state which I could share between these two events. Edited December 6, 20213 yr by Kaworru
December 6, 20213 yr Author 4 hours ago, diesieben07 said: Check whether the LivingEntity you get is not null and if the ItemStack being rendered is == to LivingEntity#getMainHandItem. Thanks. Works like a charm. Example for the record: ItemProperties.register(ModItems.STEEL_LIGHTER.get(), new ResourceLocation(Constants.MOD_ID, "open"), (itemStack, clientLevel, livingEntity, id) -> { return (livingEntity == null || !itemStack.is(ModItems.STEEL_LIGHTER.get()) || livingEntity.getMainHandItem().isEmpty() || itemStack != livingEntity.getMainHandItem()) ? 0.0F : 1.0F; });
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.