adjust ward to actualy work out of the box

This commit is contained in:
2025-05-15 17:58:30 +02:00
parent 2c7950ccb2
commit 38cec2de08
2 changed files with 3 additions and 4 deletions
@@ -139,7 +139,7 @@ public class WardEnchant implements EnchantioEnchant {
configurationSection, configurationSection,
"activeSlots", "activeSlots",
List.of( List.of(
"OFF_HAND" "OFFHAND"
) )
)), )),
EnchantioConfig.getInt(configurationSection, "cooldownTicks", 40), EnchantioConfig.getInt(configurationSection, "cooldownTicks", 40),
@@ -39,11 +39,10 @@ public class WardListener implements Listener {
if (item == null) return; if (item == null) return;
if (!(EnchantioConfig.ENCHANTS.get(WardEnchant.KEY) instanceof WardEnchant wardEnchant)) return; if (!(EnchantioConfig.ENCHANTS.get(WardEnchant.KEY) instanceof WardEnchant wardEnchant)) return;
if (entity instanceof HumanEntity humanEntity) { if (entity instanceof HumanEntity humanEntity) {
if (humanEntity.getCooldown(item.getType()) > 0) return; if (humanEntity.getCooldown(item) > 0) return;
if (wardEnchant.getCooldownTicks() > 0) { if (wardEnchant.getCooldownTicks() > 0) {
humanEntity.setCooldown(item, wardEnchant.getCooldownTicks()); humanEntity.setCooldown(item, wardEnchant.getCooldownTicks());
} }
item.damage((int) Math.ceil(event.getFinalDamage()), humanEntity);
} else { } else {
if (wardEnchant.getCooldownTicks() > 0) { if (wardEnchant.getCooldownTicks() > 0) {
// non-human entities don't support cooldowns, so simulate it with a timestamp // non-human entities don't support cooldowns, so simulate it with a timestamp
@@ -52,8 +51,8 @@ public class WardListener implements Listener {
if (lastWard != null && Instant.now().toEpochMilli() - lastWard < 50L * wardEnchant.getCooldownTicks()) return; if (lastWard != null && Instant.now().toEpochMilli() - lastWard < 50L * wardEnchant.getCooldownTicks()) return;
pdc.set(wardKey, PersistentDataType.LONG, Instant.now().toEpochMilli()); pdc.set(wardKey, PersistentDataType.LONG, Instant.now().toEpochMilli());
} }
item.damage((int) Math.ceil(event.getFinalDamage()), entity);
} }
item.damage((int) Math.ceil(event.getFinalDamage()), entity);
entity.getWorld().playSound(entity, wardEnchant.getBlockSound(), SoundCategory.MASTER, 1, 1); entity.getWorld().playSound(entity, wardEnchant.getBlockSound(), SoundCategory.MASTER, 1, 1);
event.setDamage(0); event.setDamage(0);
} }