use of net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC in project Citizens2 by CitizensDev.
the class NMSImpl method updateAI.
public static void updateAI(LivingEntity entity) {
if (entity instanceof Mob) {
Mob handle = (Mob) entity;
handle.getSensing().tick();
handle.getNavigation().tick();
handle.getMoveControl().tick();
handle.getLookControl().tick();
handle.getJumpControl().tick();
} else if (entity instanceof EntityHumanNPC) {
((EntityHumanNPC) entity).updateAI();
}
}
use of net.citizensnpcs.nms.v1_13_R2.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.getChunkProvider().chunkMap.G.get(player.getEntityId());
if (entry == null)
return;
PlayerlistTracker replace = new PlayerlistTracker(server.getChunkProvider().chunkMap, entry);
server.getChunkProvider().chunkMap.G.put(player.getEntityId(), replace);
if (getHandle(player) instanceof EntityHumanNPC) {
((EntityHumanNPC) getHandle(player)).setTracked(replace);
}
}
use of net.citizensnpcs.nms.v1_13_R2.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();
}
}
use of net.citizensnpcs.nms.v1_13_R2.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_13_R2.entity.EntityHumanNPC in project Citizens2 by CitizensDev.
the class PlayerControllerMove method c.
@Override
public void c() {
this.a.ba = 0F;
if (this.f) {
this.f = false;
double dX = this.b - this.a.locX;
double dZ = this.d - this.a.locZ;
double dY = this.c - this.a.locY;
double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.025)
return;
float f = (float) Math.toDegrees(Math.atan2(dZ, dX)) - 90.0F;
this.a.yaw = a(this.a.yaw, f, 90.0F);
NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
speed.setValue(0.1D * this.e);
float movement = (float) (this.e * speed.getValue()) * 10;
this.a.k(movement);
this.a.ba = movement;
if (shouldSlimeJump() || ((dY >= NMS.getStepHeight(a.getBukkitEntity())) && dXZ < 0.4)) {
this.h = cg();
this.h /= 3;
if (this.a instanceof EntityHumanNPC) {
((EntityHumanNPC) this.a).getControllerJump().a();
} else {
((EntityInsentient) this.a).getControllerJump().a();
}
}
}
}
Aggregations