mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-03-13 07:09:09 +01:00
Use new waterlogged methods
This commit is contained in:
parent
f5a56ba8f8
commit
9c8d26e73b
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -68,9 +69,10 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
@Override
|
||||
public float getCost(BlockSource source, PathPoint point) {
|
||||
Vector pos = point.getVector();
|
||||
Material in = source.getMaterialAt(pos);
|
||||
Material above = source.getMaterialAt(pos.setY(pos.getY() + 1));
|
||||
return params.avoidWater() && MinecraftBlockExaminer.isLiquid(in, above) ? 1F : 0F;
|
||||
return params.avoidWater() && (MinecraftBlockExaminer.isLiquid(above)
|
||||
|| MinecraftBlockExaminer.isLiquidOrInLiquid(pos.toLocation(source.getWorld()).getBlock())) ? 1F
|
||||
: 0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,7 +137,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
Location currLoc = npc.getEntity().getLocation(NPC_LOCATION);
|
||||
Vector destVector = new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
|
||||
/* Proper door movement - gets stuck on corners at times
|
||||
|
||||
|
||||
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
if (MinecraftBlockExaminer.isDoor(block.getType())) {
|
||||
Door door = (Door) block.getState().getData();
|
||||
@ -168,8 +170,9 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
params.speed());
|
||||
} else {
|
||||
Vector dir = destVector.subtract(npc.getEntity().getLocation().toVector()).normalize().multiply(0.2);
|
||||
Material in = npc.getEntity().getLocation().getBlock().getType();
|
||||
if (distance > 0 && dY >= 1 && xzDistance <= 2.75 || (dY >= 0.2 && MinecraftBlockExaminer.isLiquid(in))) {
|
||||
Block in = npc.getEntity().getLocation().getBlock();
|
||||
if (distance > 0 && dY >= 1 && xzDistance <= 2.75
|
||||
|| (dY >= 0.2 && MinecraftBlockExaminer.isLiquidOrInLiquid(in))) {
|
||||
dir.add(new Vector(0, 0.75, 0));
|
||||
}
|
||||
Util.faceLocation(npc.getEntity(), destVector.toLocation(npc.getEntity().getWorld()));
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.citizensnpcs.npc.ai;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -113,8 +112,9 @@ public class StraightLineNavigationStrategy extends AbstractPathStrategy {
|
||||
params.speed());
|
||||
} else {
|
||||
Vector dir = destVector.subtract(npc.getEntity().getLocation().toVector()).normalize().multiply(0.2);
|
||||
Material in = npc.getEntity().getLocation().getBlock().getType();
|
||||
if (distance > 0 && dY >= 1 && xzDistance <= 2.75 || (dY >= 0.2 && MinecraftBlockExaminer.isLiquid(in))) {
|
||||
Block in = npc.getEntity().getLocation().getBlock();
|
||||
if (distance > 0 && dY >= 1 && xzDistance <= 2.75
|
||||
|| (dY >= 0.2 && MinecraftBlockExaminer.isLiquidOrInLiquid(in))) {
|
||||
dir.add(new Vector(0, 0.75, 0));
|
||||
}
|
||||
Util.faceLocation(npc.getEntity(), destVector.toLocation(npc.getEntity().getWorld()));
|
||||
|
@ -105,7 +105,8 @@ public class Util {
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram() || npc.data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString().equals("false")) {
|
||||
if (npc.requiresNameHologram()
|
||||
|| npc.data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString().equals("false")) {
|
||||
NMS.setTeamNameTagVisible(team, false);
|
||||
}
|
||||
mode = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user