mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-11 21:56:55 +00:00
adjust ward to actualy work out of the box
This commit is contained in:
@@ -139,7 +139,7 @@ public class WardEnchant implements EnchantioEnchant {
|
||||
configurationSection,
|
||||
"activeSlots",
|
||||
List.of(
|
||||
"OFF_HAND"
|
||||
"OFFHAND"
|
||||
)
|
||||
)),
|
||||
EnchantioConfig.getInt(configurationSection, "cooldownTicks", 40),
|
||||
|
||||
@@ -39,11 +39,10 @@ public class WardListener implements Listener {
|
||||
if (item == null) return;
|
||||
if (!(EnchantioConfig.ENCHANTS.get(WardEnchant.KEY) instanceof WardEnchant wardEnchant)) return;
|
||||
if (entity instanceof HumanEntity humanEntity) {
|
||||
if (humanEntity.getCooldown(item.getType()) > 0) return;
|
||||
if (humanEntity.getCooldown(item) > 0) return;
|
||||
if (wardEnchant.getCooldownTicks() > 0) {
|
||||
humanEntity.setCooldown(item, wardEnchant.getCooldownTicks());
|
||||
}
|
||||
item.damage((int) Math.ceil(event.getFinalDamage()), humanEntity);
|
||||
} else {
|
||||
if (wardEnchant.getCooldownTicks() > 0) {
|
||||
// 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;
|
||||
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);
|
||||
event.setDamage(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user