ConsumeAmmo Skill not working for offhand
The consumeammo skill only works for items held in your main hand, and not for items held in your offhand, helmet, etc. Essentially I am making an item that gives an effect when the player is hit, and it has to be reloaded with charges, that are consumed. Below are debug logs from from when the item is held in my main hand, vs offhand. I think the root of the cause has to do with the "No ammo tracker found" line. I have also included the item and skills I used, modified from the wiki.
Item triggered in main hand
[i] Parsing Weapon for Doctor_JohnSmith
|----- + SkillMechanic metaskill is usable!
|----- Executing SkillMechanic metaskill with power 1 (line: null)
|------- : EntityTargeter found 1 targets
+--- + Applying entity target filters
|----- Returning 1 targets
|------- : SkillMechanic is a META mechanic. Executing...
|----- ! Skill usable!
~----------- Executing MetaSkill (et: 1) -> shield_activate
+--- Running Skill shield_activate Async from MetaSkillMechanic
+--- + Evaluating SkillMechanic null
|----- + SkillMechanic CustomMechanic:consumeAmmo is usable!
|----- Executing SkillMechanic CustomMechanic:consumeAmmo with power 1 (line: null)
|------- : EntityTargeter found 1 targets
+--- + Applying entity target filters
|----- Returning 1 targets
|------- : SkillMechanic is a CUSTOM mechanic
|------- : SkillMechanic runnable with no targets. Executing...
~----------- Attempting to use ammo...
|----- Executing skill after consuming ammo
+--- + Evaluating SkillMechanic null
|----- + SkillMechanic potion is usable!
|----- Executing SkillMechanic potion with power 1 (line: null)
|----- Mechanic is ITargetedEntitySkill
|------- : SkillMechanic is an ENTITY skill. Executing...
+--- + Evaluating SkillMechanic null
|----- + SkillMechanic sendactionmessage is usable!
|----- Executing SkillMechanic sendactionmessage with power 1 (line: null)
|----- Mechanic is ITargetedEntitySkill
|------- : SkillMechanic is an ENTITY skill. Executing...
Item triggered in offhand
[i] Updating Armor (Delayed)
[i] Updating Armor
[i] Parsing Weapon for Doctor_JohnSmith
|----- + SkillMechanic metaskill is usable!
|----- Executing SkillMechanic metaskill with power 1 (line: null)
|------- : EntityTargeter found 1 targets
+--- + Applying entity target filters
|----- Returning 1 targets
|------- : SkillMechanic is a META mechanic. Executing...
|----- ! Skill usable!
~----------- Executing MetaSkill (et: 1) -> shield_activate
+--- Running Skill shield_activate Async from MetaSkillMechanic
+--- + Evaluating SkillMechanic null
|----- + SkillMechanic CustomMechanic:consumeAmmo is usable!
|----- Executing SkillMechanic CustomMechanic:consumeAmmo with power 1 (line: null)
|------- : EntityTargeter found 1 targets
+--- + Applying entity target filters
|----- Returning 1 targets
|------- : SkillMechanic is a CUSTOM mechanic
|------- : SkillMechanic runnable with no targets. Executing...
~----------- No ammo tracker found
+--- + Evaluating SkillMechanic null
|----- + SkillMechanic sendactionmessage is usable!
|----- Executing SkillMechanic sendactionmessage with power 1 (line: null)
|----- Mechanic is ITargetedEntitySkill
|------- : SkillMechanic is an ENTITY skill. Executing...
magic_powder:
ID: GUNPOWDER
Model: 666001
Display: Magic Powder
Recipes:
SHAPED:
Type: SHAPED
Amount: 1
Ingredients:
- redstone | lapis_lazuli | redstone
- lapis_lazuli | redstone | lapis_lazuli
- redstone | lapis_lazuli | redstone
Lore:
magic_shield_generator:
Id: BLAZE_ROD
# Model: 10
Display: 'Magic Shield Generator'
Ammo:
Enabled: TRUE
ConsumeOnUse: true
Bullet: magic_powder
ClipSize: 5
AmmoPerItem: 1
Lore:
- "&7Ammunition 5 / 5"
Skills:
- skill{s=shield_activate} @self ~onDamaged
- reloadammo{sync=false;
onReload=TestGun-Reload;
onFail=TestGun-Reload-Fail;
onFull=TestGun-Reload-Full} @self ~onSwing
shield_activate:
# Conditions:
# - wearing{slot=OFFHAND;m=magic_shield_generator} true
Skills:
- consumeammo{amount=1; onNoAmmo=magic_shield_generator_no_charge; onUse=magic_shield_generator_use} @self
- am{m="&c&lOut of Charges"}
magic_shield_generator_no_charge:
Skills:
- am{m="&c&lOut of Charges"}
magic_shield_generator_use:
Skills:
- potion{type=ABSORPTION;duration=200;level=0}
TestGun-Reload:
Skills:
- actionmessage{m="&e&lRELOADING"} @self
- potion{type=SLOW_DIGGING;level=20;d=40}
- delay 1
- playanimation{audience=SELF;animation=0} @self
- delay 40
- potion{type=FAST_DIGGING;level=99}
TestGun-Reload-Fail:
Skills:
- actionmessage{m="&4&lOUT OF AMMO"} @self
- sound{s=item.flintandsteel.use;p=.1}
TestGun-Reload-Full:
Skills:
- actionmessage{m="&e&oAMMO FULL"} @self
- sound{s=item.flintandsteel.use;p=.1}
This error also happens when I right click with the item, not sure why
[21:35:39 ERROR]: [MythicMobs] [EVENTS] Exception thrown whilst handling event: org.bukkit.event.player.PlayerInteractEvent
[21:35:39 WARN]: java.lang.NullPointerException: Cannot invoke "java.util.Queue.iterator()" because "mechanics" is null
[21:35:39 WARN]: at MythicCrucible-2.0.0.jar//io.lumine.mythiccrucible.profiles.Profile.runSkills(Profile.java:284)
[21:35:39 WARN]: at MythicCrucible-2.0.0.jar//io.lumine.mythiccrucible.profiles.Profile.runSkills(Profile.java:262)
[21:35:39 WARN]: at MythicCrucible-2.0.0.jar//io.lumine.mythiccrucible.skills.SkillEventListeners.onTriggerInteract(SkillEventListeners.java:368)
[21:35:39 WARN]: at MythicMobs-5.6.1.jar//io.lumine.mythic.bukkit.utils.Delegates$ConsumerToBiConsumerSecond.accept(Delegates.java:144)
[21:35:39 WARN]: at MythicMobs-5.6.1.jar//io.lumine.mythic.bukkit.utils.events.functional.single.EventListener.execute(EventListener.java:131)
[21:35:39 WARN]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81)
[21:35:39 WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[21:35:39 WARN]: at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54)
[21:35:39 WARN]: at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126)
[21:35:39 WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615)
[21:35:39 WARN]: at org.bukkit.craftbukkit.v1_20_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:594)
[21:35:39 WARN]: at org.bukkit.craftbukkit.v1_20_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:550)
[21:35:39 WARN]: at org.bukkit.craftbukkit.v1_20_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:545)
[21:35:39 WARN]: at org.bukkit.craftbukkit.v1_20_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:541)
[21:35:39 WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1993)
[21:35:39 WARN]: at net.minecraft.network.protocol.game.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:32)
[21:35:39 WARN]: at net.minecraft.network.protocol.game.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:8)
[21:35:39 WARN]: at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:54)
[21:35:39 WARN]: at net.minecraft.server.TickTask.run(TickTask.java:18)
[21:35:39 WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.d(IAsyncTaskHandler.java:149)
[21:35:39 WARN]: at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(IAsyncTaskHandlerReentrant.java:24)
[21:35:39 WARN]: at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1465)
[21:35:39 WARN]: at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:194)
[21:35:39 WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.x(IAsyncTaskHandler.java:123)
[21:35:39 WARN]: at net.minecraft.server.MinecraftServer.bl(MinecraftServer.java:1442)
[21:35:39 WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1365)
[21:35:39 WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.c(IAsyncTaskHandler.java:133)
[21:35:39 WARN]: at net.minecraft.server.MinecraftServer.w_(MinecraftServer.java:1343)
[21:35:39 WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1232)
[21:35:39 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319)
[21:35:39 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)