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