use of net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.
the class NMSImpl method replaceTrackerEntry.
@Override
public void replaceTrackerEntry(Player player) {
ServerLevel server = (ServerLevel) NMSImpl.getHandle(player).level;
TrackedEntity entry = server.getChunkSource().chunkMap.entityMap.get(player.getEntityId());
if (entry == null)
return;
PlayerlistTracker replace = new PlayerlistTracker(server.getChunkSource().chunkMap, entry);
server.getChunkSource().chunkMap.entityMap.put(player.getEntityId(), replace);
if (getHandle(player) instanceof EntityHumanNPC) {
((EntityHumanNPC) getHandle(player)).setTracked(replace);
}
}
use of net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.
the class PlayerPathfinder method findPath.
public Path findPath(PathNavigationRegion var0, EntityHumanNPC 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(var0.getProfiler(), var6, var7, var3, var4, var5);
this.nodeEvaluator.done();
return var8;
}
use of net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.
the class NMSImpl method look.
@Override
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) {
Entity handle = NMSImpl.getHandle(entity);
if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
Location fromLocation = entity.getLocation(FROM_LOCATION);
double xDiff, yDiff, zDiff;
xDiff = to.getX() - fromLocation.getX();
yDiff = to.getY() - fromLocation.getY();
zDiff = to.getZ() - fromLocation.getZ();
double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
if (zDiff < 0.0)
yaw += Math.abs(180 - yaw) * 2;
if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
} else {
yaw = yaw - 90;
}
if (headOnly) {
setHeadYaw(entity, (float) yaw);
} else {
look(entity, (float) yaw, (float) pitch);
}
return;
}
if (handle instanceof EntityInsentient) {
((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), 10, ((EntityInsentient) handle).bQ());
while (((EntityInsentient) handle).aK >= 180F) {
((EntityInsentient) handle).aK -= 360F;
}
while (((EntityInsentient) handle).aK < -180F) {
((EntityInsentient) handle).aK += 360F;
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getNPC().getOrAddTrait(SmoothRotationTrait.class).rotateToFace(to);
}
}
use of net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.
the class NMSImpl method setShouldJump.
@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null)
return;
if (handle instanceof EntityInsentient) {
ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
controller.a();
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).setShouldJump();
}
}
use of net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.
the class NMSImpl method updatePathfindingRange.
@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
return;
EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
if (!(en instanceof EntityInsentient)) {
if (en instanceof EntityHumanNPC) {
((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
}
return;
}
if (PATHFINDING_RANGE == null)
return;
EntityInsentient handle = (EntityInsentient) en;
NavigationAbstract navigation = handle.getNavigation();
try {
AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
inst.setValue(pathfindingRange);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
Aggregations