This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
So, when a certain event triggered, i want to modify the attack damage of the item the player is holding.
I tried a lot but all didn't work
also here is my current code
@SubscribeEvent public static void hmm(BlockEvent.BreakEvent e) { EntityPlayer p = e.getPlayer(); ItemStack stack = p.getHeldItemMainhand(); Item item = stack.getItem(); EntityEquipmentSlot slot = EntityEquipmentSlot.MAINHAND; String key = SharedMonsterAttributes.ATTACK_DAMAGE.getName(); AttributeModifier value = new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "weapon", 10, 0); Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create(); multimap.put(key, value); item.getAttributeModifiers(slot, stack).putAll(multimap); }
If you know this well please help me!
The issue here is that getAttributeModifiers is called to get the modifiers for the item, so calling it and adding to the list does nothing (it creates a new list each time it is called).
Uncrafting Table (1.15.2): https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/wip-mods/3032965-uncrafting-table
Ruins of Humanity (mod, no longer being developed): https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/wip-mods/2898701-1-12-2-wip-early-alpha-ruins-of-humanity
so what i should change the code to?
So, when a certain event triggered, i want to modify the attack damage of the item the player is holding.
I tried a lot but all didn't work
also here is my current code
If you know this well please help me!
The issue here is that getAttributeModifiers is called to get the modifiers for the item, so calling it and adding to the list does nothing (it creates a new list each time it is called).
Uncrafting Table (1.15.2): https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/wip-mods/3032965-uncrafting-table
Ruins of Humanity (mod, no longer being developed): https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/wip-mods/2898701-1-12-2-wip-early-alpha-ruins-of-humanity
so what i should change the code to?