Pathplanning #399
@ -42,7 +42,10 @@ 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.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -74,7 +77,7 @@ public abstract class AI {
|
||||
|
||||
entity = (LivingEntity) Config.world.spawnEntity(Config.SpecSpawn, EntityType.VILLAGER);
|
||||
entity.setCustomName(user.getUserName());
|
||||
entity.setAI(false);
|
||||
((Villager)entity).setAware(false);
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
|
||||
ais.put(entity.getUniqueId(), this);
|
||||
@ -112,7 +115,7 @@ public abstract class AI {
|
||||
}
|
||||
|
||||
protected void chat(String message) {
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, entity.getName() + "» " + message);
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + "» " + message);
|
||||
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
|
||||
}
|
||||
|
||||
@ -122,13 +125,13 @@ public abstract class AI {
|
||||
if(Fight.getUnrotated() == team)
|
||||
return new Vector(
|
||||
location.getX() - extend.getMinX(),
|
||||
location.getY() - extend.getMinY(),
|
||||
location.getY() - team.getSchemRegion().getMinY(),
|
||||
location.getZ() - extend.getMinZ()
|
||||
);
|
||||
else
|
||||
return new Vector(
|
||||
extend.getMaxX() - location.getX(),
|
||||
location.getY() - extend.getMinY(),
|
||||
location.getY() - team.getSchemRegion().getMinY(),
|
||||
extend.getMaxZ() - location.getZ()
|
||||
);
|
||||
}
|
||||
@ -199,13 +202,12 @@ public abstract class AI {
|
||||
queue.add(new Action(2) {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!entity.isOnGround())
|
||||
return;
|
||||
|
||||
Location location = entity.getLocation();
|
||||
Location target = translate(pos, false);
|
||||
if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1 || Math.abs(location.getZ() - target.getZ()) > 1)
|
||||
if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1.2 || Math.abs(location.getZ() - target.getZ()) > 1) {
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target))
|
||||
return;
|
||||
@ -268,14 +270,14 @@ public abstract class AI {
|
||||
return new Location(
|
||||
Config.world,
|
||||
pos.getX() + extend.getMinX(),
|
||||
pos.getY() + extend.getMinY(),
|
||||
pos.getY() + team.getSchemRegion().getMinY(),
|
||||
pos.getZ() + extend.getMinZ()
|
||||
);
|
||||
else
|
||||
return new Location(
|
||||
Config.world,
|
||||
extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0),
|
||||
pos.getY() + extend.getMinY(),
|
||||
pos.getY() + team.getSchemRegion().getMinY(),
|
||||
extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0)
|
||||
);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class LixfelPathplanner {
|
||||
}
|
||||
|
||||
private static Vector toBukkit(BlockVector3 vector) {
|
||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||
return new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
|
||||
}
|
||||
|
||||
private final List<Vector> walkable = new ArrayList<>();
|
||||
@ -70,12 +70,16 @@ public class LixfelPathplanner {
|
||||
|
||||
BlockType belowMaterial = getBlockType(clipboard, below);
|
||||
BlockVector3 above = vector.add(0, 1, 0);
|
||||
if(
|
||||
(belowMaterial.getMaterial().isSolid() || belowMaterial.getId().equals("minecraft:ladder")) &&
|
||||
nonsolid(clipboard, vector) &&
|
||||
(!region.contains(above) || nonsolid(clipboard, above))
|
||||
)
|
||||
walkable.add(toBukkit(vector.subtract(min)));
|
||||
if(nonsolid(clipboard, vector)) {
|
||||
if(
|
||||
(belowMaterial.getMaterial().isSolid() || belowMaterial.getId().equals("minecraft:ladder")) &&
|
||||
(!region.contains(above) || nonsolid(clipboard, above))
|
||||
)
|
||||
walkable.add(toBukkit(vector.subtract(min)));
|
||||
} else {
|
||||
if(!region.contains(above))
|
||||
walkable.add(toBukkit(above.subtract(min)));
|
||||
}
|
||||
});
|
||||
|
||||
for(Vector vector : walkable) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren