mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-21 14:51:23 +01:00
Redecompile 1.20.2 minecraft pathfinder
This commit is contained in:
parent
7a676e3420
commit
a1e4255771
@ -18,7 +18,7 @@ public class BoundingBoxExaminer implements BlockExaminer {
|
||||
|
||||
public BoundingBoxExaminer(Entity entity) {
|
||||
if (entity != null) {
|
||||
height = NMS.getHeight(entity);
|
||||
height = NMS.getBoundingBoxHeight(entity);
|
||||
width = NMS.getWidth(entity);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import net.citizensnpcs.api.command.CommandConfigurable;
|
||||
import net.citizensnpcs.api.command.CommandContext;
|
||||
import net.citizensnpcs.api.event.NPCRightClickEvent;
|
||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
@ -294,10 +295,11 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
}
|
||||
handle.setVelocity(vel);
|
||||
|
||||
if (newSpeed > oldSpeed && speed < maxSpeed)
|
||||
if (newSpeed > oldSpeed && speed < maxSpeed) {
|
||||
return (float) Math.min(maxSpeed, speed + (maxSpeed - speed) / 50.0D);
|
||||
else
|
||||
} else {
|
||||
return (float) Math.max(0, speed - speed / 50.0D);
|
||||
}
|
||||
}
|
||||
|
||||
public class GroundController implements MovementController {
|
||||
@ -320,23 +322,17 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
@Override
|
||||
public void run(Player rider) {
|
||||
boolean onGround = NMS.isOnGround(npc.getEntity());
|
||||
float speedMod = npc.getNavigator().getDefaultParameters()
|
||||
float impulse = npc.getNavigator().getDefaultParameters()
|
||||
.modifiedSpeed(onGround ? GROUND_SPEED : AIR_SPEED);
|
||||
if (!Util.isHorse(npc.getEntity().getType())) {
|
||||
// use minecraft horse physics
|
||||
speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, speedMod,
|
||||
speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, impulse,
|
||||
Setting.MAX_CONTROLLABLE_GROUND_SPEED.asDouble());
|
||||
}
|
||||
boolean shouldJump = NMS.shouldJump(rider);
|
||||
if (shouldJump) {
|
||||
if (onGround && jumpTicks == 0) {
|
||||
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(JUMP_VELOCITY));
|
||||
jumpTicks = 10;
|
||||
}
|
||||
} else {
|
||||
jumpTicks = 0;
|
||||
if (onGround && jumpTicks <= 0 && NMS.shouldJump(rider)) {
|
||||
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(JUMP_VELOCITY));
|
||||
jumpTicks = 10;
|
||||
}
|
||||
jumpTicks = Math.max(0, jumpTicks - 1);
|
||||
jumpTicks--;
|
||||
setMountedYaw(npc.getEntity());
|
||||
}
|
||||
|
||||
@ -454,18 +450,10 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
.newEnumMap(EntityType.class);
|
||||
|
||||
static {
|
||||
registerControllerType(EntityType.BAT, PlayerInputAirController.class);
|
||||
registerControllerType(EntityType.BLAZE, PlayerInputAirController.class);
|
||||
registerControllerType(EntityType.ENDER_DRAGON, PlayerInputAirController.class);
|
||||
registerControllerType(EntityType.GHAST, PlayerInputAirController.class);
|
||||
registerControllerType(EntityType.WITHER, PlayerInputAirController.class);
|
||||
try {
|
||||
registerControllerType(EntityType.valueOf("PARROT"), PlayerInputAirController.class);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
try {
|
||||
registerControllerType(EntityType.valueOf("PHANTOM"), PlayerInputAirController.class);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
if (Util.isAlwaysFlyable(type)) {
|
||||
registerControllerType(type, PlayerInputAirController.class);
|
||||
}
|
||||
}
|
||||
registerControllerType(EntityType.UNKNOWN, LookAirController.class);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ import net.citizensnpcs.util.Util;
|
||||
public class HologramTrait extends Trait {
|
||||
private Location currentLoc;
|
||||
private BiFunction<String, Player, String> customHologramSupplier;
|
||||
private double lastEntityHeight = 0;
|
||||
private double lastEntityBbHeight = 0;
|
||||
private boolean lastNameplateVisible;
|
||||
@Persist
|
||||
private double lineHeight = -1;
|
||||
@ -117,7 +117,7 @@ public class HologramTrait extends Trait {
|
||||
if (viewRange != -1) {
|
||||
hologramNPC.data().set(NPC.Metadata.TRACKING_RANGE, viewRange);
|
||||
}
|
||||
hologramNPC.spawn(currentLoc.clone().add(0, getEntityHeight() + heightOffset, 0));
|
||||
hologramNPC.spawn(currentLoc.clone().add(0, getEntityBbHeight() + heightOffset, 0));
|
||||
|
||||
Matcher itemMatcher = ITEM_MATCHER.matcher(line);
|
||||
if (itemMatcher.matches()) {
|
||||
@ -144,12 +144,12 @@ public class HologramTrait extends Trait {
|
||||
}
|
||||
});
|
||||
}
|
||||
lastEntityHeight = getEntityHeight();
|
||||
lastEntityBbHeight = getEntityBbHeight();
|
||||
return hologramNPC;
|
||||
}
|
||||
|
||||
private double getEntityHeight() {
|
||||
return NMS.getHeight(npc.getEntity());
|
||||
private double getEntityBbHeight() {
|
||||
return NMS.getBoundingBoxHeight(npc.getEntity());
|
||||
}
|
||||
|
||||
private double getHeight(int lineNumber) {
|
||||
@ -275,7 +275,13 @@ public class HologramTrait extends Trait {
|
||||
}
|
||||
if (!npc.isSpawned())
|
||||
return;
|
||||
|
||||
if (npc.requiresNameHologram() && lastNameplateVisible) {
|
||||
if (nameLine != null) {
|
||||
nameLine.removeNPC();
|
||||
}
|
||||
nameLine = new HologramLine(npc.getRawName(), false);
|
||||
nameLine.spawnNPC(0);
|
||||
}
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
lines.get(i).spawnNPC(getHeight(i));
|
||||
}
|
||||
@ -318,7 +324,8 @@ public class HologramTrait extends Trait {
|
||||
Location npcLoc = npc.getStoredLocation();
|
||||
boolean updatePosition = Setting.HOLOGRAM_ALWAYS_UPDATE_POSITION.asBoolean()
|
||||
|| currentLoc.getWorld() != npcLoc.getWorld() || currentLoc.distance(npcLoc) >= 0.001
|
||||
|| lastNameplateVisible != nameplateVisible || Math.abs(lastEntityHeight - getEntityHeight()) >= 0.05;
|
||||
|| lastNameplateVisible != nameplateVisible
|
||||
|| Math.abs(lastEntityBbHeight - getEntityBbHeight()) >= 0.05;
|
||||
boolean updateName = false;
|
||||
|
||||
if (t++ >= Setting.HOLOGRAM_UPDATE_RATE.asTicks() + Util.getFastRandom().nextInt(3) /* add some jitter */) {
|
||||
@ -329,11 +336,12 @@ public class HologramTrait extends Trait {
|
||||
|
||||
if (updatePosition) {
|
||||
currentLoc = npcLoc.clone();
|
||||
lastEntityHeight = getEntityHeight();
|
||||
lastEntityBbHeight = getEntityBbHeight();
|
||||
}
|
||||
if (nameLine != null && nameLine.hologram.isSpawned()) {
|
||||
if (updatePosition && !useDisplayEntities) {
|
||||
nameLine.hologram.teleport(npcLoc.clone().add(0, getEntityHeight(), 0), TeleportCause.PLUGIN);
|
||||
nameLine.hologram.teleport(npcLoc.clone().add(0, getEntityBbHeight(), 0),
|
||||
TeleportCause.PLUGIN);
|
||||
}
|
||||
if (updateName) {
|
||||
nameLine.setText(npc.getRawName());
|
||||
@ -355,7 +363,7 @@ public class HologramTrait extends Trait {
|
||||
continue;
|
||||
}
|
||||
if (updatePosition && !useDisplayEntities) {
|
||||
Location tp = npcLoc.clone().add(0, lastEntityHeight + getHeight(i), 0);
|
||||
Location tp = npcLoc.clone().add(0, lastEntityBbHeight + getHeight(i), 0);
|
||||
hologramNPC.teleport(tp, TeleportCause.PLUGIN);
|
||||
}
|
||||
if (useDisplayEntities && hologramNPC.getEntity().getVehicle() == null) {
|
||||
|
@ -110,18 +110,17 @@ public abstract class AbstractBlockBreaker extends BlockBreaker {
|
||||
}
|
||||
if (entity.getWorld().getBlockAt(x, y, z).isEmpty())
|
||||
return BehaviorStatus.SUCCESS;
|
||||
else {
|
||||
int tickDifference = currentTick - startDigTick;
|
||||
float damage = getDamage(tickDifference);
|
||||
if (damage >= 1F) {
|
||||
configuration.blockBreaker().accept(entity.getWorld().getBlockAt(x, y, z), getItemStack());
|
||||
return BehaviorStatus.SUCCESS;
|
||||
}
|
||||
int modifiedDamage = (int) (damage * 10.0F);
|
||||
if (modifiedDamage != currentDamage) {
|
||||
setBlockDamage(modifiedDamage);
|
||||
currentDamage = modifiedDamage;
|
||||
}
|
||||
|
||||
int tickDifference = currentTick - startDigTick;
|
||||
float damage = getDamage(tickDifference);
|
||||
if (damage >= 1F) {
|
||||
configuration.blockBreaker().accept(entity.getWorld().getBlockAt(x, y, z), getItemStack());
|
||||
return BehaviorStatus.SUCCESS;
|
||||
}
|
||||
int modifiedDamage = (int) (damage * 10.0F);
|
||||
if (modifiedDamage != currentDamage) {
|
||||
setBlockDamage(modifiedDamage);
|
||||
currentDamage = modifiedDamage;
|
||||
}
|
||||
return BehaviorStatus.RUNNING;
|
||||
}
|
||||
|
@ -54,9 +54,9 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.EntityDim;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.MirrorTrait;
|
||||
import net.citizensnpcs.trait.PacketNPC;
|
||||
@ -462,8 +462,8 @@ public class NMS {
|
||||
return BRIDGE.getHeadYaw(entity);
|
||||
}
|
||||
|
||||
public static double getHeight(Entity entity) {
|
||||
return BRIDGE.getHeight(entity);
|
||||
public static double getBoundingBoxHeight(Entity entity) {
|
||||
return BRIDGE.getBoundingBoxHeight(entity);
|
||||
}
|
||||
|
||||
public static float getHorizontalMovement(org.bukkit.entity.Entity bukkitEntity) {
|
||||
|
@ -82,7 +82,9 @@ public interface NMSBridge {
|
||||
|
||||
public float getHeadYaw(Entity entity);
|
||||
|
||||
public double getHeight(Entity entity);
|
||||
public default double getBoundingBoxHeight(Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
public float getHorizontalMovement(Entity entity);
|
||||
|
||||
|
@ -13,9 +13,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.citizensnpcs.api.npc.AbstractNPC;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.PacketNPC;
|
||||
|
||||
@ -37,6 +37,7 @@ public class PlayerUpdateTask extends BukkitRunnable {
|
||||
for (Entity entity : PLAYERS_PENDING_REMOVE) {
|
||||
uuids.remove(entity.getUniqueId());
|
||||
}
|
||||
PLAYERS_PENDING_REMOVE.clear();
|
||||
}
|
||||
for (Entity entity : PLAYERS_PENDING_ADD) {
|
||||
NPC next = ((NPCHolder) entity).getNPC();
|
||||
@ -58,14 +59,13 @@ public class PlayerUpdateTask extends BukkitRunnable {
|
||||
rm.entity.remove();
|
||||
}
|
||||
if (next.hasTrait(PacketNPC.class)) {
|
||||
players.add(new PlayerTick(entity, () -> ((CitizensNPC) next).update()));
|
||||
players.add(new PlayerTick(entity, () -> ((AbstractNPC) next).update()));
|
||||
} else {
|
||||
players.add(new PlayerTick(entity, NMS.playerTicker((Player) entity)));
|
||||
}
|
||||
uuids.add(entity.getUniqueId());
|
||||
}
|
||||
PLAYERS_PENDING_ADD.clear();
|
||||
PLAYERS_PENDING_REMOVE.clear();
|
||||
|
||||
for (PlayerTick player : players) {
|
||||
player.run();
|
||||
|
@ -167,9 +167,9 @@ import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
@ -480,7 +480,7 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
|
||||
return getHandle(entity).length;
|
||||
}
|
||||
|
||||
|
@ -182,9 +182,9 @@ import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
@ -500,7 +500,7 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
|
||||
return getHandle(entity).length;
|
||||
}
|
||||
|
||||
|
@ -504,11 +504,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((LivingEntity) entity).aP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -527,11 +527,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((LivingEntity) entity).aS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -569,11 +569,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((LivingEntity) entity).aM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -584,11 +584,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((LivingEntity) entity).aK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -600,11 +600,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((LivingEntity) entity).getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -612,11 +612,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -618,11 +618,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -658,11 +658,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -8,6 +8,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.Mth;
|
||||
@ -22,11 +23,13 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.PathNavigationRegion;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.level.pathfinder.Node;
|
||||
import net.minecraft.world.level.pathfinder.NodeEvaluator;
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.level.pathfinder.PathFinder;
|
||||
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class EntityNavigation extends PathNavigation {
|
||||
@ -61,7 +64,6 @@ public class EntityNavigation extends PathNavigation {
|
||||
this.nodeEvaluator = new EntityNodeEvaluator();
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
this.pathFinder = new EntityPathfinder(this.nodeEvaluator, Setting.MAXIMUM_VISITED_NODES.asInt());
|
||||
this.setRange(24);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -142,26 +144,32 @@ public class EntityNavigation extends PathNavigation {
|
||||
|
||||
@Override
|
||||
public Path createPath(BlockPos var0, int var1) {
|
||||
BlockPos var2;
|
||||
if (this.level.getBlockState(var0).isAir()) {
|
||||
for (var2 = var0.below(); var2.getY() > this.level.getMinBuildHeight()
|
||||
&& this.level.getBlockState(var2).isAir(); var2 = var2.below()) {
|
||||
LevelChunk var2 = this.level.getChunkSource().getChunkNow(SectionPos.blockToSectionCoord(var0.getX()),
|
||||
SectionPos.blockToSectionCoord(var0.getZ()));
|
||||
if (var2 == null) {
|
||||
return null;
|
||||
} else {
|
||||
BlockPos var3;
|
||||
if (var2.getBlockState(var0).isAir()) {
|
||||
for (var3 = var0.below(); var3.getY() > this.level.getMinBuildHeight()
|
||||
&& var2.getBlockState(var3).isAir(); var3 = var3.below()) {
|
||||
}
|
||||
if (var3.getY() > this.level.getMinBuildHeight()) {
|
||||
return supercreatePath(var3.above(), var1);
|
||||
}
|
||||
while (var3.getY() < this.level.getMaxBuildHeight() && var2.getBlockState(var3).isAir()) {
|
||||
var3 = var3.above();
|
||||
}
|
||||
var0 = var3;
|
||||
}
|
||||
if (var2.getY() > this.level.getMinBuildHeight())
|
||||
return supercreatePath(var2.above(), var1);
|
||||
|
||||
while (var2.getY() < this.level.getMaxBuildHeight() && this.level.getBlockState(var2).isAir()) {
|
||||
var2 = var2.above();
|
||||
if (!var2.getBlockState(var0).isSolid()) {
|
||||
return supercreatePath(var0, var1);
|
||||
} else {
|
||||
for (var3 = var0.above(); var3.getY() < this.level.getMaxBuildHeight()
|
||||
&& var2.getBlockState(var3).isSolid(); var3 = var3.above()) {
|
||||
}
|
||||
return supercreatePath(var3, var1);
|
||||
}
|
||||
var0 = var2;
|
||||
}
|
||||
if (!this.level.getBlockState(var0).isSolid())
|
||||
return supercreatePath(var0, var1);
|
||||
else {
|
||||
for (var2 = var0.above(); var2.getY() < this.level.getMaxBuildHeight()
|
||||
&& this.level.getBlockState(var2).isSolid(); var2 = var2.above()) {
|
||||
}
|
||||
return supercreatePath(var2, var1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,9 +226,11 @@ public class EntityNavigation extends PathNavigation {
|
||||
@Override
|
||||
protected void doStuckDetection(Vec3 var0) {
|
||||
if (this.tick - this.lastStuckCheck > 100) {
|
||||
if (var0.distanceToSqr(this.lastStuckCheckPos) < 2.25D) {
|
||||
float var1 = this.mob.getSpeed() >= 1.0F ? this.mob.getSpeed() : this.mob.getSpeed() * this.mob.getSpeed();
|
||||
float var2 = var1 * 100.0F * 0.25F;
|
||||
if (var0.distanceToSqr(this.lastStuckCheckPos) < var2 * var2) {
|
||||
this.isStuck = true;
|
||||
stop();
|
||||
this.stop();
|
||||
} else {
|
||||
this.isStuck = false;
|
||||
}
|
||||
@ -228,35 +238,43 @@ public class EntityNavigation extends PathNavigation {
|
||||
this.lastStuckCheckPos = var0;
|
||||
}
|
||||
if (this.path != null && !this.path.isDone()) {
|
||||
BlockPos blockPos = this.path.getNextNodePos();
|
||||
if (blockPos.equals(this.timeoutCachedNode)) {
|
||||
this.timeoutTimer += System.currentTimeMillis() - this.lastTimeoutCheck;
|
||||
Vec3i var1 = this.path.getNextNodePos();
|
||||
long var2 = this.level.getGameTime();
|
||||
if (var1.equals(this.timeoutCachedNode)) {
|
||||
this.timeoutTimer += var2 - this.lastTimeoutCheck;
|
||||
} else {
|
||||
this.timeoutCachedNode = blockPos;
|
||||
double var2 = var0.distanceTo(Vec3.atBottomCenterOf(this.timeoutCachedNode));
|
||||
this.timeoutLimit = this.mob.getSpeed() > 0.0F ? var2 / this.mob.getSpeed() * 1000.0D : 0.0D;
|
||||
this.timeoutCachedNode = var1;
|
||||
double var4 = var0.distanceTo(Vec3.atBottomCenterOf(this.timeoutCachedNode));
|
||||
this.timeoutLimit = this.mob.getSpeed() > 0.0F ? var4 / this.mob.getSpeed() * 20.0 : 0.0;
|
||||
}
|
||||
if (this.timeoutLimit > 0.0D && this.timeoutTimer > this.timeoutLimit * 3.0D) {
|
||||
timeoutPath();
|
||||
if (this.timeoutLimit > 0.0 && this.timeoutTimer > this.timeoutLimit * 3.0) {
|
||||
this.timeoutPath();
|
||||
}
|
||||
this.lastTimeoutCheck = System.currentTimeMillis();
|
||||
this.lastTimeoutCheck = var2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void followThePath() {
|
||||
Vec3 var0 = getTempMobPos();
|
||||
Vec3 var0 = this.getTempMobPos();
|
||||
this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F
|
||||
: 0.75F - this.mob.getBbWidth() / 2.0F;
|
||||
BlockPos blockPos = this.path.getNextNodePos();
|
||||
double var2 = Math.abs(this.mob.getX() - (blockPos.getX() + 0.5D));
|
||||
double var4 = Math.abs(this.mob.getY() - blockPos.getY());
|
||||
double var6 = Math.abs(this.mob.getZ() - (blockPos.getZ() + 0.5D));
|
||||
boolean var8 = var2 < this.maxDistanceToWaypoint && var6 < this.maxDistanceToWaypoint && var4 < 1.0D;
|
||||
if (var8 || canCutCorner(this.path.getNextNode().type) && shouldTargetNextNodeInDirection(var0)) {
|
||||
Vec3i var1 = this.path.getNextNodePos();
|
||||
double var2 = Math.abs(this.mob.getX() - (var1.getX() + 0.5));
|
||||
double var4 = Math.abs(this.mob.getY() - var1.getY());
|
||||
double var6 = Math.abs(this.mob.getZ() - (var1.getZ() + 0.5));
|
||||
boolean var8 = var2 < this.maxDistanceToWaypoint && var6 < this.maxDistanceToWaypoint && var4 < 1.0;
|
||||
if (var8 || this.canCutCorner(this.path.getNextNode().type) && this.shouldTargetNextNodeInDirection(var0)) {
|
||||
this.path.advance();
|
||||
}
|
||||
doStuckDetection(var0);
|
||||
this.doStuckDetection(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getGroundY(Vec3 var0) {
|
||||
BlockPos var1 = BlockPos.containing(var0);
|
||||
return this.level.getBlockState(var1.below()).isAir() ? var0.y
|
||||
: WalkNodeEvaluator.getFloorLevel(this.level, var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -308,10 +326,13 @@ public class EntityNavigation extends PathNavigation {
|
||||
}
|
||||
|
||||
protected boolean hasValidPathType(BlockPathTypes var0) {
|
||||
if ((var0 == BlockPathTypes.WATER) || (var0 == BlockPathTypes.LAVA))
|
||||
if (var0 == BlockPathTypes.WATER) {
|
||||
return false;
|
||||
else
|
||||
} else if (var0 == BlockPathTypes.LAVA) {
|
||||
return false;
|
||||
} else {
|
||||
return var0 != BlockPathTypes.OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -415,10 +436,6 @@ public class EntityNavigation extends PathNavigation {
|
||||
this.maxVisitedNodesMultiplier = var0;
|
||||
}
|
||||
|
||||
public void setRange(float pathfindingRange) {
|
||||
this.followRange.setBaseValue(pathfindingRange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpeedModifier(double var0) {
|
||||
this.speedModifier = var0;
|
||||
@ -441,12 +458,26 @@ public class EntityNavigation extends PathNavigation {
|
||||
if (this.path.getNextNodeIndex() + 1 >= this.path.getNodeCount())
|
||||
return false;
|
||||
Vec3 var1 = Vec3.atBottomCenterOf(this.path.getNextNodePos());
|
||||
if (!var0.closerThan(var1, 2.0D))
|
||||
if (!var0.closerThan(var1, 2.0)) {
|
||||
return false;
|
||||
Vec3 var2 = Vec3.atBottomCenterOf(this.path.getNodePos(this.path.getNextNodeIndex() + 1));
|
||||
Vec3 var3 = var2.subtract(var1);
|
||||
Vec3 var4 = var0.subtract(var1);
|
||||
return var3.dot(var4) > 0.0D;
|
||||
} else if (this.canMoveDirectly(var0, this.path.getNextEntityPos(this.mob))) {
|
||||
return true;
|
||||
} else {
|
||||
Vec3 var2 = Vec3.atBottomCenterOf(this.path.getNodePos(this.path.getNextNodeIndex() + 1));
|
||||
Vec3 var3 = var1.subtract(var0);
|
||||
Vec3 var4 = var2.subtract(var0);
|
||||
double var5 = var3.lengthSqr();
|
||||
double var7 = var4.lengthSqr();
|
||||
boolean var9 = var7 < var5;
|
||||
boolean var10 = var5 < 0.5;
|
||||
if (!var9 && !var10) {
|
||||
return false;
|
||||
} else {
|
||||
Vec3 var11 = var3.normalize();
|
||||
Vec3 var12 = var4.normalize();
|
||||
return var12.dot(var11) < 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -476,26 +507,27 @@ public class EntityNavigation extends PathNavigation {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.tick++;
|
||||
++this.tick;
|
||||
if (this.hasDelayedRecomputation) {
|
||||
recomputePath();
|
||||
this.recomputePath();
|
||||
}
|
||||
if (isDone())
|
||||
return;
|
||||
if (canUpdatePath()) {
|
||||
followThePath();
|
||||
} else if (this.path != null && !this.path.isDone()) {
|
||||
Vec3 vec31 = getTempMobPos();
|
||||
Vec3 vec32 = this.path.getNextEntityPos(this.mob);
|
||||
if (vec31.y > vec32.y && !this.mob.onGround() && Mth.floor(vec31.x) == Mth.floor(vec32.x)
|
||||
&& Mth.floor(vec31.z) == Mth.floor(vec32.z)) {
|
||||
this.path.advance();
|
||||
if (!this.isDone()) {
|
||||
Vec3 var0;
|
||||
if (this.canUpdatePath()) {
|
||||
this.followThePath();
|
||||
} else if (this.path != null && !this.path.isDone()) {
|
||||
var0 = this.getTempMobPos();
|
||||
Vec3 var1 = this.path.getNextEntityPos(this.mob);
|
||||
if (var0.y > var1.y && !this.mob.onGround() && Mth.floor(var0.x) == Mth.floor(var1.x)
|
||||
&& Mth.floor(var0.z) == Mth.floor(var1.z)) {
|
||||
this.path.advance();
|
||||
}
|
||||
}
|
||||
if (!this.isDone()) {
|
||||
var0 = this.path.getNextEntityPos(this.mob);
|
||||
this.mvmt.getMoveControl().setWantedPosition(var0.x, this.getGroundY(var0), var0.z, this.speedModifier);
|
||||
}
|
||||
}
|
||||
if (isDone())
|
||||
return;
|
||||
Vec3 var0 = this.path.getNextEntityPos(this.mob);
|
||||
mvmt.getMoveControl().setWantedPosition(var0.x, this.getGroundY(var0), var0.z, this.speedModifier);
|
||||
}
|
||||
|
||||
private void timeoutPath() {
|
||||
|
@ -88,9 +88,9 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
|
||||
Node var8 = null;
|
||||
BlockPos.MutableBlockPos var9 = new BlockPos.MutableBlockPos();
|
||||
double var10 = this.getFloorLevel(var9.set(var0, var1, var2));
|
||||
if (var10 - var4 > this.getMobJumpHeight())
|
||||
if (var10 - var4 > this.getMobJumpHeight()) {
|
||||
return null;
|
||||
else {
|
||||
} else {
|
||||
BlockPathTypes var12 = this.getCachedBlockType(this.mob, var0, var1, var2);
|
||||
float var13 = this.mvmt.getPathfindingMalus(var12);
|
||||
double var14 = this.mob.getBbWidth() / 2.0;
|
||||
@ -102,6 +102,8 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
|
||||
var8 = null;
|
||||
}
|
||||
if (var12 == BlockPathTypes.WALKABLE || this.isAmphibious() && var12 == BlockPathTypes.WATER) {
|
||||
return var8;
|
||||
} else {
|
||||
if ((var8 == null || var8.costMalus < 0.0F) && var3 > 0
|
||||
&& (var12 != BlockPathTypes.FENCE || this.canWalkOverFences())
|
||||
&& var12 != BlockPathTypes.UNPASSABLE_RAIL && var12 != BlockPathTypes.TRAPDOOR
|
||||
@ -124,15 +126,15 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
|
||||
}
|
||||
}
|
||||
if (!this.isAmphibious() && var12 == BlockPathTypes.WATER && !this.canFloat()) {
|
||||
if (this.getCachedBlockType(this.mob, var0, var1 - 1, var2) != BlockPathTypes.WATER)
|
||||
if (this.getCachedBlockType(this.mob, var0, var1 - 1, var2) != BlockPathTypes.WATER) {
|
||||
return var8;
|
||||
|
||||
}
|
||||
while (var1 > this.mob.level().getMinBuildHeight()) {
|
||||
--var1;
|
||||
var12 = this.getCachedBlockType(this.mob, var0, var1, var2);
|
||||
if (var12 != BlockPathTypes.WATER)
|
||||
if (var12 != BlockPathTypes.WATER) {
|
||||
return var8;
|
||||
|
||||
}
|
||||
var8 = this.getNodeAndUpdateCostToMax(var0, var1, var2, var12,
|
||||
this.mvmt.getPathfindingMalus(var12));
|
||||
}
|
||||
@ -143,20 +145,21 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
|
||||
|
||||
while (var12 == BlockPathTypes.OPEN) {
|
||||
--var1;
|
||||
if (var1 < this.mob.level().getMinBuildHeight())
|
||||
if (var1 < this.mob.level().getMinBuildHeight()) {
|
||||
return this.getBlockedNode(var0, var17, var2);
|
||||
|
||||
if (var16++ >= this.mob.getMaxFallDistance())
|
||||
}
|
||||
if (var16++ >= this.mob.getMaxFallDistance()) {
|
||||
return this.getBlockedNode(var0, var1, var2);
|
||||
|
||||
}
|
||||
var12 = this.getCachedBlockType(this.mob, var0, var1, var2);
|
||||
var13 = this.mvmt.getPathfindingMalus(var12);
|
||||
if (var12 != BlockPathTypes.OPEN && var13 >= 0.0F) {
|
||||
var8 = this.getNodeAndUpdateCostToMax(var0, var1, var2, var12, var13);
|
||||
break;
|
||||
}
|
||||
if (var13 < 0.0F)
|
||||
if (var13 < 0.0F) {
|
||||
return this.getBlockedNode(var0, var1, var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doesBlockHavePartialCollision(var12) && var8 == null) {
|
||||
@ -165,8 +168,8 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
|
||||
var8.type = var12;
|
||||
var8.costMalus = var12.getMalus();
|
||||
}
|
||||
return var8;
|
||||
}
|
||||
return var8;
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,8 +379,9 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
|
||||
if (this.canStartAt(var1.set(var4.minX, var0, var4.minZ))
|
||||
|| this.canStartAt(var1.set(var4.minX, var0, var4.maxZ))
|
||||
|| this.canStartAt(var1.set(var4.maxX, var0, var4.minZ))
|
||||
|| this.canStartAt(var1.set(var4.maxX, var0, var4.maxZ)))
|
||||
|| this.canStartAt(var1.set(var4.maxX, var0, var4.maxZ))) {
|
||||
return this.getStartNode(var1);
|
||||
}
|
||||
}
|
||||
return this.getStartNode(new BlockPos(var3.getX(), var0, var3.getZ()));
|
||||
}
|
||||
@ -398,19 +402,25 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
|
||||
}
|
||||
|
||||
protected boolean isDiagonalValid(Node var0, Node var1, Node var2, Node var3) {
|
||||
if (((var3 == null) || (var2 == null) || (var1 == null)) || var3.closed)
|
||||
return false;
|
||||
else if (var2.y <= var0.y && var1.y <= var0.y) {
|
||||
if (var1.type != BlockPathTypes.WALKABLE_DOOR && var2.type != BlockPathTypes.WALKABLE_DOOR
|
||||
&& var3.type != BlockPathTypes.WALKABLE_DOOR) {
|
||||
boolean var4 = var2.type == BlockPathTypes.FENCE && var1.type == BlockPathTypes.FENCE
|
||||
&& this.mob.getBbWidth() < 0.5;
|
||||
return var3.costMalus >= 0.0F && (var2.y < var0.y || var2.costMalus >= 0.0F || var4)
|
||||
&& (var1.y < var0.y || var1.costMalus >= 0.0F || var4);
|
||||
} else
|
||||
if (var3 != null && var2 != null && var1 != null) {
|
||||
if (var3.closed) {
|
||||
return false;
|
||||
} else
|
||||
} else if (var2.y <= var0.y && var1.y <= var0.y) {
|
||||
if (var1.type != BlockPathTypes.WALKABLE_DOOR && var2.type != BlockPathTypes.WALKABLE_DOOR
|
||||
&& var3.type != BlockPathTypes.WALKABLE_DOOR) {
|
||||
boolean var4 = var2.type == BlockPathTypes.FENCE && var1.type == BlockPathTypes.FENCE
|
||||
&& this.mob.getBbWidth() < 0.5;
|
||||
return var3.costMalus >= 0.0F && (var2.y < var0.y || var2.costMalus >= 0.0F || var4)
|
||||
&& (var1.y < var0.y || var1.costMalus >= 0.0F || var4);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isNeighborValid(Node var0, Node var1) {
|
||||
|
@ -8,7 +8,6 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -39,26 +38,35 @@ public class EntityPathfinder extends PathFinder {
|
||||
this.maxVisitedNodes = var1;
|
||||
}
|
||||
|
||||
public Path findPath(PathNavigationRegion var0, LivingEntity var1, Set<BlockPos> var2, float range, int reachRange,
|
||||
float maxVisitedNodesMultiplier) {
|
||||
public Path findPath(PathNavigationRegion var0, LivingEntity var1, Set<BlockPos> var2, float var3, int var4,
|
||||
float var5) {
|
||||
this.openSet.clear();
|
||||
this.nodeEvaluator.prepare(var0, var1);
|
||||
Node var6 = this.nodeEvaluator.getStart();
|
||||
Map<Target, BlockPos> var7 = var2.stream().collect(
|
||||
Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity()));
|
||||
Path var8 = findPath(null, var6, var7, range, reachRange, maxVisitedNodesMultiplier);
|
||||
if (var6 == null)
|
||||
return null;
|
||||
|
||||
Map<Target, BlockPos> var7 = var2.stream().collect(Collectors.toMap((var0x) -> {
|
||||
return this.nodeEvaluator.getGoal(var0x.getX(), var0x.getY(), var0x.getZ());
|
||||
}, Function.identity()));
|
||||
Path var8 = this.findPath(var0.getProfiler(), var6, var7, var3, var4, var5);
|
||||
this.nodeEvaluator.done();
|
||||
return var8;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Path findPath(PathNavigationRegion var0, Mob var1, Set<BlockPos> var2, float var3, int var4, float var5) {
|
||||
this.openSet.clear();
|
||||
this.nodeEvaluator.prepare(var0, var1);
|
||||
Node var6 = this.nodeEvaluator.getStart();
|
||||
Map<Target, BlockPos> var7 = var2.stream().collect(
|
||||
Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity()));
|
||||
Path var8 = findPath(null, var6, var7, var3, var4, var5);
|
||||
if (var6 == null)
|
||||
return null;
|
||||
|
||||
Map<Target, BlockPos> var7 = var2.stream().collect(Collectors.toMap((var0x) -> {
|
||||
return this.nodeEvaluator.getGoal(var0x.getX(), var0x.getY(), var0x.getZ());
|
||||
}, Function.identity()));
|
||||
Path var8 = this.findPath(var0.getProfiler(), var6, var7, var3, var4, var5);
|
||||
this.nodeEvaluator.done();
|
||||
return var8;
|
||||
}
|
||||
@ -71,25 +79,25 @@ public class EntityPathfinder extends PathFinder {
|
||||
var1.f = var1.h;
|
||||
this.openSet.clear();
|
||||
this.openSet.insert(var1);
|
||||
Set var7 = ImmutableSet.of();
|
||||
Set<Target> var7 = ImmutableSet.of();
|
||||
int var8 = 0;
|
||||
Set<Target> var9 = Sets.newHashSetWithExpectedSize(var6.size());
|
||||
int maxVisitedNodesScaled = (int) (this.maxVisitedNodes * var5);
|
||||
int var10 = (int) (this.maxVisitedNodes * var5);
|
||||
|
||||
while (!this.openSet.isEmpty()) {
|
||||
++var8;
|
||||
if (var8 >= maxVisitedNodesScaled) {
|
||||
if (var8 >= var10) {
|
||||
break;
|
||||
}
|
||||
Node var11 = this.openSet.pop();
|
||||
var11.closed = true;
|
||||
Iterator var13i = var6.iterator();
|
||||
Iterator var13 = var6.iterator();
|
||||
|
||||
while (var13i.hasNext()) {
|
||||
Target var13 = (Target) var13i.next();
|
||||
if (var11.distanceManhattan(var13) <= reachRange) {
|
||||
var13.setReached();
|
||||
var9.add(var13);
|
||||
while (var13.hasNext()) {
|
||||
Target var13t = (Target) var13.next();
|
||||
if (var11.distanceManhattan(var13t) <= reachRange) {
|
||||
var13t.setReached();
|
||||
var9.add(var13t);
|
||||
}
|
||||
}
|
||||
if (!var9.isEmpty()) {
|
||||
@ -98,8 +106,8 @@ public class EntityPathfinder extends PathFinder {
|
||||
if (!(var11.distanceTo(var1) >= range)) {
|
||||
int var12 = this.nodeEvaluator.getNeighbors(this.neighbors, var11);
|
||||
|
||||
for (int var13 = 0; var13 < var12; ++var13) {
|
||||
Node var14 = this.neighbors[var13];
|
||||
for (int i = 0; i < var12; ++i) {
|
||||
Node var14 = this.neighbors[i];
|
||||
float var15 = this.distance(var11, var14);
|
||||
var14.walkedDistance = var11.walkedDistance + var15;
|
||||
float var16 = var11.g + var15 + var14.costMalus;
|
||||
@ -120,7 +128,7 @@ public class EntityPathfinder extends PathFinder {
|
||||
Optional<Path> var11 = !var9.isEmpty()
|
||||
? var9.stream().map(var1x -> this.reconstructPath(var1x.getBestNode(), var2.get(var1x), true)).min(
|
||||
Comparator.comparingInt(Path::getNodeCount))
|
||||
: getFallbackDestinations(var2, var6).findFirst();
|
||||
: getFallbackDestinations(var2, var6);
|
||||
/*var6.stream().map((var1x) -> {
|
||||
return this.reconstructPath(var1x.getBestNode(), (BlockPos)var2.get(var1x), false);
|
||||
}).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount))*/
|
||||
@ -140,11 +148,11 @@ public class EntityPathfinder extends PathFinder {
|
||||
return var2;
|
||||
}
|
||||
|
||||
public Stream<Path> getFallbackDestinations(Map<Target, BlockPos> var1, Set<Target> var5) {
|
||||
public Optional<Path> getFallbackDestinations(Map<Target, BlockPos> var1, Set<Target> var5) {
|
||||
if (Setting.DISABLE_MC_NAVIGATION_FALLBACK.asBoolean())
|
||||
return Stream.empty();
|
||||
return Optional.empty();
|
||||
return var5.stream().map(var1x -> this.reconstructPath(var1x.getBestNode(), var1.get(var1x), false))
|
||||
.sorted(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount));
|
||||
.min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount));
|
||||
}
|
||||
|
||||
private Path reconstructPath(Node var0, BlockPos var1, boolean var2) {
|
||||
|
@ -635,11 +635,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
return entity.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
||||
if (!entity.getType().isAlive())
|
||||
|
@ -156,9 +156,9 @@ import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.TNTPrimedController;
|
||||
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.ThrownExpBottleController;
|
||||
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
@ -434,7 +434,7 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(org.bukkit.entity.Entity entity) {
|
||||
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
|
||||
return getHandle(entity).length;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user