Hello everyone! I am new to forge and I starting following a tutorial for this and I need help on my first mod. So what i am trying to do here is to add a cooldown after right clicking. I've done the RightClickItem event and it works correctly however every solution I see uses Spigot or Bukkit and I think thats only for Plugins can Anyone help please?
Heres the code I have for my event. thanks in advance!
@SubscribeEvent
public static void Beastmode(PlayerInteractEvent.RightClickItem event) {
PlayerEntity player = event.getPlayer();
if (event.getEntityLiving().getHeldItemMainhand().getItem() == RegistryHandler.WOLFBLOOD_SWORD.get()) {
player.addPotionEffect(new EffectInstance(Effects.SPEED, 10 * 20));
player.addPotionEffect(new EffectInstance(Effects.STRENGTH, 10 * 20, 1));
}
}
}
You can add a cooldown to an item by via the CooldownTracker like this:
player.getCooldownTracker().setCooldown(your item, cooldown duration in ticks);
Also, since the wolfblood sword is your custom item, I recommend overriding your items onItemRightClick() instead of using the RightClickItem event. You can check out the EnderPearlItem to see how vanilla does it.
Hello everyone! I am new to forge and I starting following a tutorial for this and I need help on my first mod. So what i am trying to do here is to add a cooldown after right clicking. I've done the RightClickItem event and it works correctly however every solution I see uses Spigot or Bukkit and I think thats only for Plugins can Anyone help please?
Heres the code I have for my event. thanks in advance!
You can add a cooldown to an item by via the CooldownTracker like this:
Also, since the wolfblood sword is your custom item, I recommend overriding your items onItemRightClick() instead of using the RightClickItem event. You can check out the EnderPearlItem to see how vanilla does it.
Hope this helps!
it works perfectly!
Thank you so much for the help, I've been looking everywhere for a solution but I was only finding a solution for bukkit/spigot
No problem, glad I could be of help!