Use new methods

This commit is contained in:
fullwall 2022-06-19 12:05:18 +08:00
parent 552d25494b
commit cd652db2f7
4 changed files with 6 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package net.citizensnpcs.npc.ai;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
@ -30,7 +31,7 @@ public class BoundingBoxExaminer implements BlockExaminer {
@Override
public PassableState isPassable(BlockSource source, PathPoint point) {
Vector pos = point.getVector();
Material up = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() + 2, pos.getBlockZ());
Block up = source.getBlockAt(pos.getBlockX(), pos.getBlockY() + 2, pos.getBlockZ());
Material down = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
if (!MinecraftBlockExaminer.canStandIn(up) && MinecraftBlockExaminer.canStandOn(down)) {
BoundingBox above = source.getCollisionBox(pos.getBlockX(), pos.getBlockY() + 2, pos.getBlockZ());

View File

@ -3,7 +3,6 @@ package net.citizensnpcs.npc.ai;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import com.google.common.collect.Maps;
@ -35,10 +34,8 @@ public class FallingExaminer implements NeighbourGeneratorBlockExaminer {
if (!SpigotUtil.checkYSafe(pos.getBlockY() + 1, source.getWorld()))
return neighbours;
Material above = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() + 1, pos.getBlockZ());
Material below = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
Material in = source.getMaterialAt(pos);
if (!MinecraftBlockExaminer.canStandOn(below) && MinecraftBlockExaminer.canStandIn(above, in)) {
if (!MinecraftBlockExaminer
.canStandOn(source.getBlockAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ()))) {
Integer dist = fallen.get(point);
if (dist == null) {
neighbours.add(point);

View File

@ -34,7 +34,7 @@ public class MCNavigationStrategy extends AbstractPathStrategy {
MCNavigationStrategy(final NPC npc, Location dest, NavigatorParameters params) {
super(TargetType.LOCATION);
if (!MinecraftBlockExaminer.canStandIn(dest.getBlock().getType())) {
if (!MinecraftBlockExaminer.canStandIn(dest.getBlock())) {
dest = MinecraftBlockExaminer.findValidLocationAbove(dest, 2);
}
this.target = Util.getCenterLocation(dest.getBlock());

View File

@ -679,7 +679,7 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider {
public boolean verify(World world, Iterable<Vector> cached) {
for (Vector vector : cached) {
if (!MinecraftBlockExaminer
.validPosition(world.getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()))) {
.canStandOn(world.getBlockAt(vector.getBlockX(), vector.getBlockY() - 1, vector.getBlockZ()))) {
return false;
}
}