Skip to content

Commit

Permalink
Use new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jun 19, 2022
1 parent 552d254 commit cd652db
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
@@ -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;

Expand Down Expand Up @@ -30,7 +31,7 @@ public float getCost(BlockSource source, PathPoint point) {
@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());
Expand Down
Expand Up @@ -3,7 +3,6 @@
import java.util.List;
import java.util.Map;

import org.bukkit.Material;
import org.bukkit.util.Vector;

import com.google.common.collect.Maps;
Expand Down Expand Up @@ -35,10 +34,8 @@ public List<PathPoint> getNeighbours(BlockSource source, PathPoint point) {
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);
Expand Down
Expand Up @@ -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());
Expand Down
Expand Up @@ -679,7 +679,7 @@ public int hashCode() {
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;
}
}
Expand Down

0 comments on commit cd652db

Please sign in to comment.