fixed the windcharge function, works good now
This commit is contained in:
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user