From 35449c060371a45215b16ccf9b8d5a64167ab39b Mon Sep 17 00:00:00 2001 From: rattatwinko Date: Sat, 6 Sep 2025 22:34:57 +0200 Subject: [PATCH] fixed the windcharge function, works good now --- .../org/rattatwinko/mace/MaceEventListener.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rattatwinko/mace/MaceEventListener.java b/src/main/java/org/rattatwinko/mace/MaceEventListener.java index 3e14db9..0abb517 100644 --- a/src/main/java/org/rattatwinko/mace/MaceEventListener.java +++ b/src/main/java/org/rattatwinko/mace/MaceEventListener.java @@ -74,7 +74,6 @@ public class MaceEventListener implements Listener { if (!plugin.isMaceItem(item)) return; event.setCancelled(true); - // remove if does not work attemptWindCharge(player); } @@ -100,6 +99,7 @@ public class MaceEventListener implements Listener { // Strict cooldown check Long lastUse = windChargeCooldowns.get(playerId); + if (lastUse != null && (now - lastUse) < windCooldown * 1000L) { int remaining = (int) ((windCooldown * 1000L - (now - lastUse)) / 1000L); player.sendActionBar(Component.text("§cWind Charge cooldown: " + remaining + "s")); @@ -107,6 +107,18 @@ public class MaceEventListener implements Listener { return; // Block spawn completely } + // apply a knockback effect to nearby entittys + for (Entity entity : player.getNearbyEntities(5, 5, 5)) { + if (entity instanceof LivingEntity && !entity.equals(player)) { + Vector knockback = entity.getLocation().toVector() + .subtract(player.getLocation().toVector()) + .normalize() + .multiply(0.5) + .setY(0.3); + entity.setVelocity(knockback); + } + } + // Immediately mark the cooldown to prevent spamming windChargeCooldowns.put(playerId, now); @@ -129,6 +141,7 @@ public class MaceEventListener implements Listener { if (secondsLeft <= 0) { windChargeCooldowns.remove(playerId); cancel(); + player.playSound(player.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.5f, 0.5f); return; } player.sendActionBar(Component.text("§aWind Charge cooldown: " + secondsLeft + "s"));