From f4daa14bd55cc48bf0c9c8d74a0d09d03e746ecf Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sat, 29 Jan 2022 16:03:13 +0100 Subject: [PATCH] a --- src/main/java/pl/minecon724/giants/Main.java | 8 ++++++-- src/main/resources/config.yml | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/pl/minecon724/giants/Main.java b/src/main/java/pl/minecon724/giants/Main.java index 87572ab..36eb06f 100644 --- a/src/main/java/pl/minecon724/giants/Main.java +++ b/src/main/java/pl/minecon724/giants/Main.java @@ -37,6 +37,8 @@ public class Main extends JavaPlugin implements Listener { boolean headRotations; double chance; double attackDamage; + double attackReach; + double expandUp; long refreshDelay; Map effects = new HashMap(); @@ -50,6 +52,8 @@ public class Main extends JavaPlugin implements Listener { ai = config.getBoolean("ai"); chance = config.getDouble("chance"); attackDamage = config.getDouble("attackDamage"); + attackReach = config.getDouble("attackReach"); + expandUp = config.getDouble("expandUp"); for (Object s : config.getList("effects")) { try { String[] parts = ((String) s).split(":"); @@ -73,8 +77,8 @@ public class Main extends JavaPlugin implements Listener { new BukkitRunnable() { @Override public void run() { - for (Entity e : giants) { - Collection nearby = e.getWorld().getNearbyEntities(e.getBoundingBox(), n -> (n instanceof Player)); + for (Entity e : giants) { + Collection nearby = e.getWorld().getNearbyEntities(e.getBoundingBox().expand(attackReach, expandUp, attackReach), n -> (n instanceof Player)); for (Entity p : nearby) { ((LivingEntity) p).damage(attackDamage, e); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2c480a7..1756919 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -4,7 +4,8 @@ attackDamage: 1.0 chance: 0.02 # Attack delay in ticks, smaller values will lag the server more hitDelay: 20 -# if too high the entity will hit through walls +# 0 - attack only entities touching the giant, if too high the entity will hit through walls +# fun fact: you can use negative values attackReach: 2 # Additional potion effects # type:amplifier @@ -15,4 +16,5 @@ effects: # No need to change this headRotations: true -refreshDelay: 40 \ No newline at end of file +refreshDelay: 20 +expandUp: 0 \ No newline at end of file