Redecompile 1.20.2 minecraft pathfinder

This commit is contained in:
fullwall 2023-12-01 23:43:58 +08:00
parent 7a676e3420
commit a1e4255771
22 changed files with 222 additions and 220 deletions

View File

@ -18,7 +18,7 @@ public class BoundingBoxExaminer implements BlockExaminer {
public BoundingBoxExaminer(Entity entity) { public BoundingBoxExaminer(Entity entity) {
if (entity != null) { if (entity != null) {
height = NMS.getHeight(entity); height = NMS.getBoundingBoxHeight(entity);
width = NMS.getWidth(entity); width = NMS.getWidth(entity);
} }
} }

View File

@ -24,6 +24,7 @@ import net.citizensnpcs.api.command.CommandConfigurable;
import net.citizensnpcs.api.command.CommandContext; import net.citizensnpcs.api.command.CommandContext;
import net.citizensnpcs.api.event.NPCRightClickEvent; import net.citizensnpcs.api.event.NPCRightClickEvent;
import net.citizensnpcs.api.exception.NPCLoadException; import net.citizensnpcs.api.exception.NPCLoadException;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.persistence.Persist; import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait; import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName; import net.citizensnpcs.api.trait.TraitName;
@ -294,10 +295,11 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
} }
handle.setVelocity(vel); handle.setVelocity(vel);
if (newSpeed > oldSpeed && speed < maxSpeed) if (newSpeed > oldSpeed && speed < maxSpeed) {
return (float) Math.min(maxSpeed, speed + (maxSpeed - speed) / 50.0D); return (float) Math.min(maxSpeed, speed + (maxSpeed - speed) / 50.0D);
else } else {
return (float) Math.max(0, speed - speed / 50.0D); return (float) Math.max(0, speed - speed / 50.0D);
}
} }
public class GroundController implements MovementController { public class GroundController implements MovementController {
@ -320,23 +322,17 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
@Override @Override
public void run(Player rider) { public void run(Player rider) {
boolean onGround = NMS.isOnGround(npc.getEntity()); boolean onGround = NMS.isOnGround(npc.getEntity());
float speedMod = npc.getNavigator().getDefaultParameters() float impulse = npc.getNavigator().getDefaultParameters()
.modifiedSpeed(onGround ? GROUND_SPEED : AIR_SPEED); .modifiedSpeed(onGround ? GROUND_SPEED : AIR_SPEED);
if (!Util.isHorse(npc.getEntity().getType())) { if (!Util.isHorse(npc.getEntity().getType())) {
// use minecraft horse physics speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, impulse,
speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, speedMod,
Setting.MAX_CONTROLLABLE_GROUND_SPEED.asDouble()); Setting.MAX_CONTROLLABLE_GROUND_SPEED.asDouble());
} }
boolean shouldJump = NMS.shouldJump(rider); if (onGround && jumpTicks <= 0 && NMS.shouldJump(rider)) {
if (shouldJump) { npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(JUMP_VELOCITY));
if (onGround && jumpTicks == 0) { jumpTicks = 10;
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(JUMP_VELOCITY));
jumpTicks = 10;
}
} else {
jumpTicks = 0;
} }
jumpTicks = Math.max(0, jumpTicks - 1); jumpTicks--;
setMountedYaw(npc.getEntity()); setMountedYaw(npc.getEntity());
} }
@ -454,18 +450,10 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
.newEnumMap(EntityType.class); .newEnumMap(EntityType.class);
static { static {
registerControllerType(EntityType.BAT, PlayerInputAirController.class); for (EntityType type : EntityType.values()) {
registerControllerType(EntityType.BLAZE, PlayerInputAirController.class); if (Util.isAlwaysFlyable(type)) {
registerControllerType(EntityType.ENDER_DRAGON, PlayerInputAirController.class); registerControllerType(type, 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) {
} }
registerControllerType(EntityType.UNKNOWN, LookAirController.class); registerControllerType(EntityType.UNKNOWN, LookAirController.class);
} }

View File

@ -49,7 +49,7 @@ import net.citizensnpcs.util.Util;
public class HologramTrait extends Trait { public class HologramTrait extends Trait {
private Location currentLoc; private Location currentLoc;
private BiFunction<String, Player, String> customHologramSupplier; private BiFunction<String, Player, String> customHologramSupplier;
private double lastEntityHeight = 0; private double lastEntityBbHeight = 0;
private boolean lastNameplateVisible; private boolean lastNameplateVisible;
@Persist @Persist
private double lineHeight = -1; private double lineHeight = -1;
@ -117,7 +117,7 @@ public class HologramTrait extends Trait {
if (viewRange != -1) { if (viewRange != -1) {
hologramNPC.data().set(NPC.Metadata.TRACKING_RANGE, viewRange); 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); Matcher itemMatcher = ITEM_MATCHER.matcher(line);
if (itemMatcher.matches()) { if (itemMatcher.matches()) {
@ -144,12 +144,12 @@ public class HologramTrait extends Trait {
} }
}); });
} }
lastEntityHeight = getEntityHeight(); lastEntityBbHeight = getEntityBbHeight();
return hologramNPC; return hologramNPC;
} }
private double getEntityHeight() { private double getEntityBbHeight() {
return NMS.getHeight(npc.getEntity()); return NMS.getBoundingBoxHeight(npc.getEntity());
} }
private double getHeight(int lineNumber) { private double getHeight(int lineNumber) {
@ -275,7 +275,13 @@ public class HologramTrait extends Trait {
} }
if (!npc.isSpawned()) if (!npc.isSpawned())
return; 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++) { for (int i = 0; i < lines.size(); i++) {
lines.get(i).spawnNPC(getHeight(i)); lines.get(i).spawnNPC(getHeight(i));
} }
@ -318,7 +324,8 @@ public class HologramTrait extends Trait {
Location npcLoc = npc.getStoredLocation(); Location npcLoc = npc.getStoredLocation();
boolean updatePosition = Setting.HOLOGRAM_ALWAYS_UPDATE_POSITION.asBoolean() boolean updatePosition = Setting.HOLOGRAM_ALWAYS_UPDATE_POSITION.asBoolean()
|| currentLoc.getWorld() != npcLoc.getWorld() || currentLoc.distance(npcLoc) >= 0.001 || 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; boolean updateName = false;
if (t++ >= Setting.HOLOGRAM_UPDATE_RATE.asTicks() + Util.getFastRandom().nextInt(3) /* add some jitter */) { 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) { if (updatePosition) {
currentLoc = npcLoc.clone(); currentLoc = npcLoc.clone();
lastEntityHeight = getEntityHeight(); lastEntityBbHeight = getEntityBbHeight();
} }
if (nameLine != null && nameLine.hologram.isSpawned()) { if (nameLine != null && nameLine.hologram.isSpawned()) {
if (updatePosition && !useDisplayEntities) { 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) { if (updateName) {
nameLine.setText(npc.getRawName()); nameLine.setText(npc.getRawName());
@ -355,7 +363,7 @@ public class HologramTrait extends Trait {
continue; continue;
} }
if (updatePosition && !useDisplayEntities) { 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); hologramNPC.teleport(tp, TeleportCause.PLUGIN);
} }
if (useDisplayEntities && hologramNPC.getEntity().getVehicle() == null) { if (useDisplayEntities && hologramNPC.getEntity().getVehicle() == null) {

View File

@ -110,18 +110,17 @@ public abstract class AbstractBlockBreaker extends BlockBreaker {
} }
if (entity.getWorld().getBlockAt(x, y, z).isEmpty()) if (entity.getWorld().getBlockAt(x, y, z).isEmpty())
return BehaviorStatus.SUCCESS; return BehaviorStatus.SUCCESS;
else {
int tickDifference = currentTick - startDigTick; int tickDifference = currentTick - startDigTick;
float damage = getDamage(tickDifference); float damage = getDamage(tickDifference);
if (damage >= 1F) { if (damage >= 1F) {
configuration.blockBreaker().accept(entity.getWorld().getBlockAt(x, y, z), getItemStack()); configuration.blockBreaker().accept(entity.getWorld().getBlockAt(x, y, z), getItemStack());
return BehaviorStatus.SUCCESS; return BehaviorStatus.SUCCESS;
} }
int modifiedDamage = (int) (damage * 10.0F); int modifiedDamage = (int) (damage * 10.0F);
if (modifiedDamage != currentDamage) { if (modifiedDamage != currentDamage) {
setBlockDamage(modifiedDamage); setBlockDamage(modifiedDamage);
currentDamage = modifiedDamage; currentDamage = modifiedDamage;
}
} }
return BehaviorStatus.RUNNING; return BehaviorStatus.RUNNING;
} }

View File

@ -54,9 +54,9 @@ import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.BoundingBox; import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.api.util.EntityDim; import net.citizensnpcs.api.util.EntityDim;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.MirrorTrait; import net.citizensnpcs.trait.MirrorTrait;
import net.citizensnpcs.trait.PacketNPC; import net.citizensnpcs.trait.PacketNPC;
@ -462,8 +462,8 @@ public class NMS {
return BRIDGE.getHeadYaw(entity); return BRIDGE.getHeadYaw(entity);
} }
public static double getHeight(Entity entity) { public static double getBoundingBoxHeight(Entity entity) {
return BRIDGE.getHeight(entity); return BRIDGE.getBoundingBoxHeight(entity);
} }
public static float getHorizontalMovement(org.bukkit.entity.Entity bukkitEntity) { public static float getHorizontalMovement(org.bukkit.entity.Entity bukkitEntity) {

View File

@ -82,7 +82,9 @@ public interface NMSBridge {
public float getHeadYaw(Entity entity); public float getHeadYaw(Entity entity);
public double getHeight(Entity entity); public default double getBoundingBoxHeight(Entity entity) {
return entity.getHeight();
}
public float getHorizontalMovement(Entity entity); public float getHorizontalMovement(Entity entity);

View File

@ -13,9 +13,9 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.citizensnpcs.api.npc.AbstractNPC;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.PacketNPC; import net.citizensnpcs.trait.PacketNPC;
@ -37,6 +37,7 @@ public class PlayerUpdateTask extends BukkitRunnable {
for (Entity entity : PLAYERS_PENDING_REMOVE) { for (Entity entity : PLAYERS_PENDING_REMOVE) {
uuids.remove(entity.getUniqueId()); uuids.remove(entity.getUniqueId());
} }
PLAYERS_PENDING_REMOVE.clear();
} }
for (Entity entity : PLAYERS_PENDING_ADD) { for (Entity entity : PLAYERS_PENDING_ADD) {
NPC next = ((NPCHolder) entity).getNPC(); NPC next = ((NPCHolder) entity).getNPC();
@ -58,14 +59,13 @@ public class PlayerUpdateTask extends BukkitRunnable {
rm.entity.remove(); rm.entity.remove();
} }
if (next.hasTrait(PacketNPC.class)) { if (next.hasTrait(PacketNPC.class)) {
players.add(new PlayerTick(entity, () -> ((CitizensNPC) next).update())); players.add(new PlayerTick(entity, () -> ((AbstractNPC) next).update()));
} else { } else {
players.add(new PlayerTick(entity, NMS.playerTicker((Player) entity))); players.add(new PlayerTick(entity, NMS.playerTicker((Player) entity)));
} }
uuids.add(entity.getUniqueId()); uuids.add(entity.getUniqueId());
} }
PLAYERS_PENDING_ADD.clear(); PLAYERS_PENDING_ADD.clear();
PLAYERS_PENDING_REMOVE.clear();
for (PlayerTick player : players) { for (PlayerTick player : players) {
player.run(); player.run();

View File

@ -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.TippedArrowController;
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController; import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.npc.EntityControllers; import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.BossBarTrait;
@ -480,7 +480,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public double getHeight(org.bukkit.entity.Entity entity) { public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length; return getHandle(entity).length;
} }

View File

@ -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.TippedArrowController;
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController; import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.npc.EntityControllers; import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.BossBarTrait;
@ -500,7 +500,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public double getHeight(org.bukkit.entity.Entity entity) { public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length; return getHandle(entity).length;
} }

View File

@ -504,11 +504,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).aP; return getHandle((LivingEntity) entity).aP;
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -527,11 +527,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).aS; return getHandle((LivingEntity) entity).aS;
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -569,11 +569,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).aM; return getHandle((LivingEntity) entity).aM;
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -584,11 +584,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).aK; return getHandle((LivingEntity) entity).aK;
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -600,11 +600,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).getHeadRotation(); return getHandle((LivingEntity) entity).getHeadRotation();
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -612,11 +612,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot(); return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -618,11 +618,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot(); return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -658,11 +658,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot(); return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -8,6 +8,7 @@ import com.google.common.collect.ImmutableSet;
import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.Settings.Setting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.SectionPos;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth; 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.PathNavigationRegion;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; 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.BlockPathTypes;
import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.Node;
import net.minecraft.world.level.pathfinder.NodeEvaluator; import net.minecraft.world.level.pathfinder.NodeEvaluator;
import net.minecraft.world.level.pathfinder.Path; import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.level.pathfinder.PathFinder; import net.minecraft.world.level.pathfinder.PathFinder;
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
public class EntityNavigation extends PathNavigation { public class EntityNavigation extends PathNavigation {
@ -61,7 +64,6 @@ public class EntityNavigation extends PathNavigation {
this.nodeEvaluator = new EntityNodeEvaluator(); this.nodeEvaluator = new EntityNodeEvaluator();
this.nodeEvaluator.setCanPassDoors(true); this.nodeEvaluator.setCanPassDoors(true);
this.pathFinder = new EntityPathfinder(this.nodeEvaluator, Setting.MAXIMUM_VISITED_NODES.asInt()); this.pathFinder = new EntityPathfinder(this.nodeEvaluator, Setting.MAXIMUM_VISITED_NODES.asInt());
this.setRange(24);
} }
@Override @Override
@ -142,26 +144,32 @@ public class EntityNavigation extends PathNavigation {
@Override @Override
public Path createPath(BlockPos var0, int var1) { public Path createPath(BlockPos var0, int var1) {
BlockPos var2; LevelChunk var2 = this.level.getChunkSource().getChunkNow(SectionPos.blockToSectionCoord(var0.getX()),
if (this.level.getBlockState(var0).isAir()) { SectionPos.blockToSectionCoord(var0.getZ()));
for (var2 = var0.below(); var2.getY() > this.level.getMinBuildHeight() if (var2 == null) {
&& this.level.getBlockState(var2).isAir(); var2 = var2.below()) { 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()) if (!var2.getBlockState(var0).isSolid()) {
return supercreatePath(var2.above(), var1); return supercreatePath(var0, var1);
} else {
while (var2.getY() < this.level.getMaxBuildHeight() && this.level.getBlockState(var2).isAir()) { for (var3 = var0.above(); var3.getY() < this.level.getMaxBuildHeight()
var2 = var2.above(); && 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 @Override
protected void doStuckDetection(Vec3 var0) { protected void doStuckDetection(Vec3 var0) {
if (this.tick - this.lastStuckCheck > 100) { 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; this.isStuck = true;
stop(); this.stop();
} else { } else {
this.isStuck = false; this.isStuck = false;
} }
@ -228,35 +238,43 @@ public class EntityNavigation extends PathNavigation {
this.lastStuckCheckPos = var0; this.lastStuckCheckPos = var0;
} }
if (this.path != null && !this.path.isDone()) { if (this.path != null && !this.path.isDone()) {
BlockPos blockPos = this.path.getNextNodePos(); Vec3i var1 = this.path.getNextNodePos();
if (blockPos.equals(this.timeoutCachedNode)) { long var2 = this.level.getGameTime();
this.timeoutTimer += System.currentTimeMillis() - this.lastTimeoutCheck; if (var1.equals(this.timeoutCachedNode)) {
this.timeoutTimer += var2 - this.lastTimeoutCheck;
} else { } else {
this.timeoutCachedNode = blockPos; this.timeoutCachedNode = var1;
double var2 = var0.distanceTo(Vec3.atBottomCenterOf(this.timeoutCachedNode)); double var4 = var0.distanceTo(Vec3.atBottomCenterOf(this.timeoutCachedNode));
this.timeoutLimit = this.mob.getSpeed() > 0.0F ? var2 / this.mob.getSpeed() * 1000.0D : 0.0D; 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) { if (this.timeoutLimit > 0.0 && this.timeoutTimer > this.timeoutLimit * 3.0) {
timeoutPath(); this.timeoutPath();
} }
this.lastTimeoutCheck = System.currentTimeMillis(); this.lastTimeoutCheck = var2;
} }
} }
@Override @Override
protected void followThePath() { protected void followThePath() {
Vec3 var0 = getTempMobPos(); Vec3 var0 = this.getTempMobPos();
this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F
: 0.75F - this.mob.getBbWidth() / 2.0F; : 0.75F - this.mob.getBbWidth() / 2.0F;
BlockPos blockPos = this.path.getNextNodePos(); Vec3i var1 = this.path.getNextNodePos();
double var2 = Math.abs(this.mob.getX() - (blockPos.getX() + 0.5D)); double var2 = Math.abs(this.mob.getX() - (var1.getX() + 0.5));
double var4 = Math.abs(this.mob.getY() - blockPos.getY()); double var4 = Math.abs(this.mob.getY() - var1.getY());
double var6 = Math.abs(this.mob.getZ() - (blockPos.getZ() + 0.5D)); double var6 = Math.abs(this.mob.getZ() - (var1.getZ() + 0.5));
boolean var8 = var2 < this.maxDistanceToWaypoint && var6 < this.maxDistanceToWaypoint && var4 < 1.0D; boolean var8 = var2 < this.maxDistanceToWaypoint && var6 < this.maxDistanceToWaypoint && var4 < 1.0;
if (var8 || canCutCorner(this.path.getNextNode().type) && shouldTargetNextNodeInDirection(var0)) { if (var8 || this.canCutCorner(this.path.getNextNode().type) && this.shouldTargetNextNodeInDirection(var0)) {
this.path.advance(); 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 @Override
@ -308,10 +326,13 @@ public class EntityNavigation extends PathNavigation {
} }
protected boolean hasValidPathType(BlockPathTypes var0) { protected boolean hasValidPathType(BlockPathTypes var0) {
if ((var0 == BlockPathTypes.WATER) || (var0 == BlockPathTypes.LAVA)) if (var0 == BlockPathTypes.WATER) {
return false; return false;
else } else if (var0 == BlockPathTypes.LAVA) {
return false;
} else {
return var0 != BlockPathTypes.OPEN; return var0 != BlockPathTypes.OPEN;
}
} }
@Override @Override
@ -415,10 +436,6 @@ public class EntityNavigation extends PathNavigation {
this.maxVisitedNodesMultiplier = var0; this.maxVisitedNodesMultiplier = var0;
} }
public void setRange(float pathfindingRange) {
this.followRange.setBaseValue(pathfindingRange);
}
@Override @Override
public void setSpeedModifier(double var0) { public void setSpeedModifier(double var0) {
this.speedModifier = var0; this.speedModifier = var0;
@ -441,12 +458,26 @@ public class EntityNavigation extends PathNavigation {
if (this.path.getNextNodeIndex() + 1 >= this.path.getNodeCount()) if (this.path.getNextNodeIndex() + 1 >= this.path.getNodeCount())
return false; return false;
Vec3 var1 = Vec3.atBottomCenterOf(this.path.getNextNodePos()); Vec3 var1 = Vec3.atBottomCenterOf(this.path.getNextNodePos());
if (!var0.closerThan(var1, 2.0D)) if (!var0.closerThan(var1, 2.0)) {
return false; return false;
Vec3 var2 = Vec3.atBottomCenterOf(this.path.getNodePos(this.path.getNextNodeIndex() + 1)); } else if (this.canMoveDirectly(var0, this.path.getNextEntityPos(this.mob))) {
Vec3 var3 = var2.subtract(var1); return true;
Vec3 var4 = var0.subtract(var1); } else {
return var3.dot(var4) > 0.0D; 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 @Override
@ -476,26 +507,27 @@ public class EntityNavigation extends PathNavigation {
@Override @Override
public void tick() { public void tick() {
this.tick++; ++this.tick;
if (this.hasDelayedRecomputation) { if (this.hasDelayedRecomputation) {
recomputePath(); this.recomputePath();
} }
if (isDone()) if (!this.isDone()) {
return; Vec3 var0;
if (canUpdatePath()) { if (this.canUpdatePath()) {
followThePath(); this.followThePath();
} else if (this.path != null && !this.path.isDone()) { } else if (this.path != null && !this.path.isDone()) {
Vec3 vec31 = getTempMobPos(); var0 = this.getTempMobPos();
Vec3 vec32 = this.path.getNextEntityPos(this.mob); Vec3 var1 = this.path.getNextEntityPos(this.mob);
if (vec31.y > vec32.y && !this.mob.onGround() && Mth.floor(vec31.x) == Mth.floor(vec32.x) if (var0.y > var1.y && !this.mob.onGround() && Mth.floor(var0.x) == Mth.floor(var1.x)
&& Mth.floor(vec31.z) == Mth.floor(vec32.z)) { && Mth.floor(var0.z) == Mth.floor(var1.z)) {
this.path.advance(); 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() { private void timeoutPath() {

View File

@ -88,9 +88,9 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
Node var8 = null; Node var8 = null;
BlockPos.MutableBlockPos var9 = new BlockPos.MutableBlockPos(); BlockPos.MutableBlockPos var9 = new BlockPos.MutableBlockPos();
double var10 = this.getFloorLevel(var9.set(var0, var1, var2)); double var10 = this.getFloorLevel(var9.set(var0, var1, var2));
if (var10 - var4 > this.getMobJumpHeight()) if (var10 - var4 > this.getMobJumpHeight()) {
return null; return null;
else { } else {
BlockPathTypes var12 = this.getCachedBlockType(this.mob, var0, var1, var2); BlockPathTypes var12 = this.getCachedBlockType(this.mob, var0, var1, var2);
float var13 = this.mvmt.getPathfindingMalus(var12); float var13 = this.mvmt.getPathfindingMalus(var12);
double var14 = this.mob.getBbWidth() / 2.0; double var14 = this.mob.getBbWidth() / 2.0;
@ -102,6 +102,8 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
var8 = null; var8 = null;
} }
if (var12 == BlockPathTypes.WALKABLE || this.isAmphibious() && var12 == BlockPathTypes.WATER) { if (var12 == BlockPathTypes.WALKABLE || this.isAmphibious() && var12 == BlockPathTypes.WATER) {
return var8;
} else {
if ((var8 == null || var8.costMalus < 0.0F) && var3 > 0 if ((var8 == null || var8.costMalus < 0.0F) && var3 > 0
&& (var12 != BlockPathTypes.FENCE || this.canWalkOverFences()) && (var12 != BlockPathTypes.FENCE || this.canWalkOverFences())
&& var12 != BlockPathTypes.UNPASSABLE_RAIL && var12 != BlockPathTypes.TRAPDOOR && 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.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; return var8;
}
while (var1 > this.mob.level().getMinBuildHeight()) { while (var1 > this.mob.level().getMinBuildHeight()) {
--var1; --var1;
var12 = this.getCachedBlockType(this.mob, var0, var1, var2); var12 = this.getCachedBlockType(this.mob, var0, var1, var2);
if (var12 != BlockPathTypes.WATER) if (var12 != BlockPathTypes.WATER) {
return var8; return var8;
}
var8 = this.getNodeAndUpdateCostToMax(var0, var1, var2, var12, var8 = this.getNodeAndUpdateCostToMax(var0, var1, var2, var12,
this.mvmt.getPathfindingMalus(var12)); this.mvmt.getPathfindingMalus(var12));
} }
@ -143,20 +145,21 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
while (var12 == BlockPathTypes.OPEN) { while (var12 == BlockPathTypes.OPEN) {
--var1; --var1;
if (var1 < this.mob.level().getMinBuildHeight()) if (var1 < this.mob.level().getMinBuildHeight()) {
return this.getBlockedNode(var0, var17, var2); return this.getBlockedNode(var0, var17, var2);
}
if (var16++ >= this.mob.getMaxFallDistance()) if (var16++ >= this.mob.getMaxFallDistance()) {
return this.getBlockedNode(var0, var1, var2); return this.getBlockedNode(var0, var1, var2);
}
var12 = this.getCachedBlockType(this.mob, var0, var1, var2); var12 = this.getCachedBlockType(this.mob, var0, var1, var2);
var13 = this.mvmt.getPathfindingMalus(var12); var13 = this.mvmt.getPathfindingMalus(var12);
if (var12 != BlockPathTypes.OPEN && var13 >= 0.0F) { if (var12 != BlockPathTypes.OPEN && var13 >= 0.0F) {
var8 = this.getNodeAndUpdateCostToMax(var0, var1, var2, var12, var13); var8 = this.getNodeAndUpdateCostToMax(var0, var1, var2, var12, var13);
break; break;
} }
if (var13 < 0.0F) if (var13 < 0.0F) {
return this.getBlockedNode(var0, var1, var2); return this.getBlockedNode(var0, var1, var2);
}
} }
} }
if (doesBlockHavePartialCollision(var12) && var8 == null) { if (doesBlockHavePartialCollision(var12) && var8 == null) {
@ -165,8 +168,8 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase {
var8.type = var12; var8.type = var12;
var8.costMalus = var12.getMalus(); 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)) if (this.canStartAt(var1.set(var4.minX, var0, var4.minZ))
|| this.canStartAt(var1.set(var4.minX, var0, var4.maxZ)) || 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.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(var1);
}
} }
return this.getStartNode(new BlockPos(var3.getX(), var0, var3.getZ())); 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) { protected boolean isDiagonalValid(Node var0, Node var1, Node var2, Node var3) {
if (((var3 == null) || (var2 == null) || (var1 == null)) || var3.closed) if (var3 != null && var2 != null && var1 != null) {
return false; if (var3.closed) {
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; 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; return false;
}
} }
protected boolean isNeighborValid(Node var0, Node var1) { protected boolean isNeighborValid(Node var0, Node var1) {

View File

@ -8,7 +8,6 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -39,26 +38,35 @@ public class EntityPathfinder extends PathFinder {
this.maxVisitedNodes = var1; this.maxVisitedNodes = var1;
} }
public Path findPath(PathNavigationRegion var0, LivingEntity var1, Set<BlockPos> var2, float range, int reachRange, public Path findPath(PathNavigationRegion var0, LivingEntity var1, Set<BlockPos> var2, float var3, int var4,
float maxVisitedNodesMultiplier) { float var5) {
this.openSet.clear(); this.openSet.clear();
this.nodeEvaluator.prepare(var0, var1); this.nodeEvaluator.prepare(var0, var1);
Node var6 = this.nodeEvaluator.getStart(); Node var6 = this.nodeEvaluator.getStart();
Map<Target, BlockPos> var7 = var2.stream().collect( if (var6 == null)
Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity())); return null;
Path var8 = findPath(null, var6, var7, range, reachRange, maxVisitedNodesMultiplier);
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(); this.nodeEvaluator.done();
return var8; return var8;
} }
@Override @Override
public Path findPath(PathNavigationRegion var0, Mob var1, Set<BlockPos> var2, float var3, int var4, float var5) { public Path findPath(PathNavigationRegion var0, Mob var1, Set<BlockPos> var2, float var3, int var4, float var5) {
this.openSet.clear(); this.openSet.clear();
this.nodeEvaluator.prepare(var0, var1); this.nodeEvaluator.prepare(var0, var1);
Node var6 = this.nodeEvaluator.getStart(); Node var6 = this.nodeEvaluator.getStart();
Map<Target, BlockPos> var7 = var2.stream().collect( if (var6 == null)
Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity())); return null;
Path var8 = findPath(null, var6, var7, var3, var4, var5);
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(); this.nodeEvaluator.done();
return var8; return var8;
} }
@ -71,25 +79,25 @@ public class EntityPathfinder extends PathFinder {
var1.f = var1.h; var1.f = var1.h;
this.openSet.clear(); this.openSet.clear();
this.openSet.insert(var1); this.openSet.insert(var1);
Set var7 = ImmutableSet.of(); Set<Target> var7 = ImmutableSet.of();
int var8 = 0; int var8 = 0;
Set<Target> var9 = Sets.newHashSetWithExpectedSize(var6.size()); Set<Target> var9 = Sets.newHashSetWithExpectedSize(var6.size());
int maxVisitedNodesScaled = (int) (this.maxVisitedNodes * var5); int var10 = (int) (this.maxVisitedNodes * var5);
while (!this.openSet.isEmpty()) { while (!this.openSet.isEmpty()) {
++var8; ++var8;
if (var8 >= maxVisitedNodesScaled) { if (var8 >= var10) {
break; break;
} }
Node var11 = this.openSet.pop(); Node var11 = this.openSet.pop();
var11.closed = true; var11.closed = true;
Iterator var13i = var6.iterator(); Iterator var13 = var6.iterator();
while (var13i.hasNext()) { while (var13.hasNext()) {
Target var13 = (Target) var13i.next(); Target var13t = (Target) var13.next();
if (var11.distanceManhattan(var13) <= reachRange) { if (var11.distanceManhattan(var13t) <= reachRange) {
var13.setReached(); var13t.setReached();
var9.add(var13); var9.add(var13t);
} }
} }
if (!var9.isEmpty()) { if (!var9.isEmpty()) {
@ -98,8 +106,8 @@ public class EntityPathfinder extends PathFinder {
if (!(var11.distanceTo(var1) >= range)) { if (!(var11.distanceTo(var1) >= range)) {
int var12 = this.nodeEvaluator.getNeighbors(this.neighbors, var11); int var12 = this.nodeEvaluator.getNeighbors(this.neighbors, var11);
for (int var13 = 0; var13 < var12; ++var13) { for (int i = 0; i < var12; ++i) {
Node var14 = this.neighbors[var13]; Node var14 = this.neighbors[i];
float var15 = this.distance(var11, var14); float var15 = this.distance(var11, var14);
var14.walkedDistance = var11.walkedDistance + var15; var14.walkedDistance = var11.walkedDistance + var15;
float var16 = var11.g + var15 + var14.costMalus; float var16 = var11.g + var15 + var14.costMalus;
@ -120,7 +128,7 @@ public class EntityPathfinder extends PathFinder {
Optional<Path> var11 = !var9.isEmpty() Optional<Path> var11 = !var9.isEmpty()
? var9.stream().map(var1x -> this.reconstructPath(var1x.getBestNode(), var2.get(var1x), true)).min( ? var9.stream().map(var1x -> this.reconstructPath(var1x.getBestNode(), var2.get(var1x), true)).min(
Comparator.comparingInt(Path::getNodeCount)) Comparator.comparingInt(Path::getNodeCount))
: getFallbackDestinations(var2, var6).findFirst(); : getFallbackDestinations(var2, var6);
/*var6.stream().map((var1x) -> { /*var6.stream().map((var1x) -> {
return this.reconstructPath(var1x.getBestNode(), (BlockPos)var2.get(var1x), false); return this.reconstructPath(var1x.getBestNode(), (BlockPos)var2.get(var1x), false);
}).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount))*/ }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount))*/
@ -140,11 +148,11 @@ public class EntityPathfinder extends PathFinder {
return var2; 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()) 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)) 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) { private Path reconstructPath(Node var0, BlockPos var1, boolean var2) {

View File

@ -635,11 +635,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot(); return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
} }
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())

View File

@ -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.ThrownExpBottleController;
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.WitherSkullController; import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.WitherSkullController;
import net.citizensnpcs.npc.EntityControllers; import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.util.EmptyChannel; import net.citizensnpcs.util.EmptyChannel;
@ -434,7 +434,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public double getHeight(org.bukkit.entity.Entity entity) { public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length; return getHandle(entity).length;
} }