From 071b76a4ce75953df73c7b91aacac1ab6efd0dfa Mon Sep 17 00:00:00 2001 From: PsiRobot Date: Sat, 2 Sep 2023 15:20:33 +0000 Subject: [PATCH 1/2] Add Repeater, Comparator and Lectern to interact method --- .../src/de/steamwar/fightsystem/ai/AI.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java index 9f51c74..8280599 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java @@ -35,10 +35,13 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Note; import org.bukkit.block.Block; +import org.bukkit.block.Lectern; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Openable; import org.bukkit.block.data.Powerable; +import org.bukkit.block.data.type.Comparator; import org.bukkit.block.data.type.NoteBlock; +import org.bukkit.block.data.type.Repeater; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -170,6 +173,27 @@ public abstract class AI { }); } + protected void interact(Vector pos, int n) { + queue.add(new Action(1) { + @Override + public void run() { + Location location = translate(pos, true); + if (interactionDistanceViolation(location)) + return; + Block block = location.getBlock(); + BlockData data = block.getBlockData(); + if (data instanceof Repeater) { + Repeater repeater = (Repeater) data; + repeater.setDelay(n); + } else if (data instanceof Lectern) { + Lectern lectern = (Lectern) data; + lectern.setPage(n); + } + block.setBlockData(data); + } + }); + } + protected void move(Vector pos) { queue.add(new Action(2) { @Override @@ -200,6 +224,9 @@ public abstract class AI { } else if (data instanceof Openable) { Openable openable = (Openable) data; openable.setOpen(!openable.isOpen()); + } else if (data instanceof Comparator) { + Comparator comparator = (Comparator) data; + comparator.setMode(Comparator.Mode.values()[1 - comparator.getMode().ordinal()]); } else if (data instanceof Powerable) { Material type = block.getType(); Powerable powerable = (Powerable) data; @@ -217,8 +244,6 @@ public abstract class AI { block.setBlockData(powerable); }, type.name().endsWith("STONE_BUTTON") ? 20 : 30); } - - powerable.setPowered(!isPowered); } block.setBlockData(data); } -- 2.39.2 From 2ed5f5000dc2ddb8141ba5250ba2703b63ad790d Mon Sep 17 00:00:00 2001 From: PsiRobot Date: Sat, 2 Sep 2023 15:28:34 +0000 Subject: [PATCH 2/2] Fixed previous commmit --- FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java index 8280599..96d9df9 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java @@ -244,6 +244,8 @@ public abstract class AI { block.setBlockData(powerable); }, type.name().endsWith("STONE_BUTTON") ? 20 : 30); } + + powerable.setPowered(!isPowered); } block.setBlockData(data); } -- 2.39.2