mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 14:19:49 +00:00
Full Imports and Code Format Optimization
This commit is contained in:
1 parent
250edf099c
commit
6815f579a7
1192 files changed
+60344
-62167
No files matched your search
@@ -9,14 +9,14 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class EntityAILook extends EntityAIBase{
|
||||
public class EntityAILook extends EntityAIBase {
|
||||
private final EntityNPCInterface npc;
|
||||
private int idle = 0;
|
||||
private double lookX;
|
||||
private double lookZ;
|
||||
boolean rotatebody;
|
||||
|
||||
public EntityAILook(EntityNPCInterface npc){
|
||||
public EntityAILook(EntityNPCInterface npc) {
|
||||
this.npc = npc;
|
||||
this.setMutexBits(AiMutex.LOOK);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class EntityAILook extends EntityAIBase{
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
public boolean shouldExecute() {
|
||||
return !npc.isAttacking() && npc.getNavigator().noPath() && !npc.isPlayerSleeping() && npc.isEntityAlive();
|
||||
}
|
||||
|
||||
@@ -33,68 +33,67 @@ public class EntityAILook extends EntityAIBase{
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
rotatebody = npc.ais.standingType == EnumStandingType.RotateBody || npc.ais.standingType == EnumStandingType.HeadRotation;
|
||||
public void startExecuting() {
|
||||
rotatebody = npc.ais.standingType == EnumStandingType.RotateBody || npc.ais.standingType == EnumStandingType.HeadRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
@Override
|
||||
public void resetTask(){
|
||||
rotatebody = false;
|
||||
public void resetTask() {
|
||||
rotatebody = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
@Override
|
||||
public void updateTask(){
|
||||
if(npc.ais.standingType == EnumStandingType.Stalking){
|
||||
EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16);
|
||||
if(player == null)
|
||||
rotatebody = true;
|
||||
else
|
||||
npc.getLookHelper().setLookPositionWithEntity(player, 10F, npc.getVerticalFaceSpeed());
|
||||
}
|
||||
if(npc.isInteracting()){
|
||||
Iterator<EntityLivingBase> ita = npc.interactingEntities.iterator();
|
||||
EntityLivingBase closest = null;
|
||||
double closestDistance = 12;
|
||||
while(ita.hasNext()){
|
||||
EntityLivingBase entity = ita.next();
|
||||
double distance = entity.getDistanceSqToEntity(npc);
|
||||
if(distance < closestDistance){
|
||||
closestDistance = entity.getDistanceSqToEntity(npc);
|
||||
closest = entity;
|
||||
}
|
||||
else if(distance > 12)
|
||||
ita.remove();
|
||||
}
|
||||
if(closest != null){
|
||||
npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed());
|
||||
return;
|
||||
}
|
||||
public void updateTask() {
|
||||
if (npc.ais.standingType == EnumStandingType.Stalking) {
|
||||
EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16);
|
||||
if (player == null)
|
||||
rotatebody = true;
|
||||
else
|
||||
npc.getLookHelper().setLookPositionWithEntity(player, 10F, npc.getVerticalFaceSpeed());
|
||||
}
|
||||
if (npc.isInteracting()) {
|
||||
Iterator<EntityLivingBase> ita = npc.interactingEntities.iterator();
|
||||
EntityLivingBase closest = null;
|
||||
double closestDistance = 12;
|
||||
while (ita.hasNext()) {
|
||||
EntityLivingBase entity = ita.next();
|
||||
double distance = entity.getDistanceSqToEntity(npc);
|
||||
if (distance < closestDistance) {
|
||||
closestDistance = entity.getDistanceSqToEntity(npc);
|
||||
closest = entity;
|
||||
} else if (distance > 12)
|
||||
ita.remove();
|
||||
}
|
||||
if (closest != null) {
|
||||
npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(rotatebody){
|
||||
if(idle == 0 && npc.getRNG().nextFloat() < 0.02F){
|
||||
double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble();
|
||||
if(npc.ais.standingType == EnumStandingType.HeadRotation)
|
||||
var1 = Math.PI / 180 * npc.ais.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble();
|
||||
this.lookX = Math.cos(var1);
|
||||
this.lookZ = Math.sin(var1);
|
||||
this.idle = 20 + this.npc.getRNG().nextInt(20);
|
||||
}
|
||||
if(idle > 0){
|
||||
idle--;
|
||||
npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed());
|
||||
}
|
||||
}
|
||||
if (rotatebody) {
|
||||
if (idle == 0 && npc.getRNG().nextFloat() < 0.02F) {
|
||||
double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble();
|
||||
if (npc.ais.standingType == EnumStandingType.HeadRotation)
|
||||
var1 = Math.PI / 180 * npc.ais.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble();
|
||||
this.lookX = Math.cos(var1);
|
||||
this.lookZ = Math.sin(var1);
|
||||
this.idle = 20 + this.npc.getRNG().nextInt(20);
|
||||
}
|
||||
if (idle > 0) {
|
||||
idle--;
|
||||
npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed());
|
||||
}
|
||||
}
|
||||
|
||||
if(npc.ais.standingType == EnumStandingType.NoRotation){
|
||||
npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation;
|
||||
}
|
||||
if (npc.ais.standingType == EnumStandingType.NoRotation) {
|
||||
npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user