SteamWar/FightSystem
Archiviert
13
1

Add Repeater, Comparator and Lectern to interact method #398

Zusammengeführt
Lixfel hat 2 Commits von psirobot-ai nach master 2023-09-02 17:31:40 +02:00 zusammengeführt

Datei anzeigen

@ -35,10 +35,13 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Note; import org.bukkit.Note;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Lectern;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable; import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable; 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.NoteBlock;
import org.bukkit.block.data.type.Repeater;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; 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) { protected void move(Vector pos) {
queue.add(new Action(2) { queue.add(new Action(2) {
@Override @Override
@ -200,6 +224,9 @@ public abstract class AI {
} else if (data instanceof Openable) { } else if (data instanceof Openable) {
Openable openable = (Openable) data; Openable openable = (Openable) data;
openable.setOpen(!openable.isOpen()); 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) { } else if (data instanceof Powerable) {
Material type = block.getType(); Material type = block.getType();
Powerable powerable = (Powerable) data; Powerable powerable = (Powerable) data;