entityBaseTick should update some variables

This commit is contained in:
fullwall 2022-03-10 03:12:43 +08:00
parent bd26f30361
commit 908e678135
11 changed files with 9 additions and 144 deletions

View File

@ -281,6 +281,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
super.k_();
return;
}
super.U();
boolean navigating = npc.getNavigator().isNavigating();
if (!navigating && getBukkitEntity() != null
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
@ -297,20 +298,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
moveOnCurrentHeading();
}
NMSImpl.updateAI(this);
this.aD = this.aE;
this.aK = this.aL;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
cs();
}
tickPotionEffects();
this.ba = this.aZ;
this.aP = this.aO;
this.aR = this.aQ;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
@Override

View File

@ -362,20 +362,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
moveOnCurrentHeading();
}
NMSImpl.updateAI(this);
this.aC = this.aD;
this.aJ = this.aK;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
ct();
}
tickPotionEffects();
this.aZ = this.aY;
this.aO = this.aN;
this.aQ = this.aP;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
public void setMoveDestination(double x, double y, double z, double speed) {

View File

@ -388,20 +388,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
moveOnCurrentHeading();
}
NMSImpl.updateAI(this);
this.aC = this.aD;
this.aJ = this.aK;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
cB();
}
tickPotionEffects();
this.aZ = this.aY;
this.aO = this.aN;
this.aQ = this.aP;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
public void setMoveDestination(double x, double y, double z, double speed) {

View File

@ -363,20 +363,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
moveOnCurrentHeading();
}
NMSImpl.updateAI(this);
this.aF = this.aG;
this.aM = this.aN;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
cN();
}
tickPotionEffects();
this.bc = this.bb;
this.aR = this.aQ;
this.aT = this.aS;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
public void setMoveDestination(double x, double y, double z, double speed) {

View File

@ -368,19 +368,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
moveOnCurrentHeading();
}
NMSImpl.updateAI(this);
this.aB = this.aC;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
collideNearby();
}
tickPotionEffects();
this.aW = this.aV;
this.aL = this.aK;
this.aN = this.aM;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
public void setMoveDestination(double x, double y, double z, double speed) {

View File

@ -369,19 +369,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
NMSImpl.updateAI(this);
this.az = this.aA;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
collideNearby();
}
tickPotionEffects();
this.aU = this.aT;
this.aJ = this.aI;
this.aL = this.aK;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
public void setMoveDestination(double x, double y, double z, double speed) {

View File

@ -399,19 +399,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
NMSImpl.updateAI(this);
this.ar = this.as;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
collideNearby();
}
tickPotionEffects();
this.aM = this.aL;
this.aB = this.aA;
this.aD = this.aC;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
public void setMoveDestination(double x, double y, double z, double speed) {

View File

@ -60,7 +60,6 @@ import net.minecraft.stats.ServerStatsCounter;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
@ -195,34 +194,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
this.onGround = false;
}
if (this.hurtTime > 0)
this.hurtTime--;
if (isDeadOrDying()) {
tickDeath();
}
if (this.lastHurtByPlayerTime > 0) {
this.lastHurtByPlayerTime--;
} else {
this.lastHurtByPlayer = null;
}
if (this.lastHurtByMob != null) {
if (!this.lastHurtByMob.isAlive()) {
setLastHurtByMob((LivingEntity) null);
} else if (this.tickCount - this.lastHurtByMobTimestamp > 100) {
setLastHurtByMob((LivingEntity) null);
}
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
pushEntities();
}
tickEffects();
this.animStepO = this.animStep;
this.yBodyRotO = this.yBodyRot;
this.yHeadRotO = this.yHeadRot;
this.yRotO = getYRot();
this.xRotO = getXRot();
}
@Override

View File

@ -61,7 +61,6 @@ import net.minecraft.stats.ServerStatsCounter;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
@ -196,38 +195,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
this.onGround = false;
}
if (this.hurtTime > 0) {
this.hurtTime--;
}
if (isDeadOrDying()) {
tickDeath();
}
if (this.lastHurtByPlayerTime > 0) {
this.lastHurtByPlayerTime--;
} else {
this.lastHurtByPlayer = null;
}
if (this.lastHurtByMob != null) {
if (!this.lastHurtByMob.isAlive()) {
setLastHurtByMob((LivingEntity) null);
} else if (this.tickCount - this.lastHurtByMobTimestamp > 100) {
setLastHurtByMob((LivingEntity) null);
}
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
pushEntities();
}
tickEffects();
this.animStepO = this.animStep;
this.yBodyRotO = this.yBodyRot;
this.yHeadRotO = this.yHeadRot;
this.yRotO = getYRot();
this.xRotO = getXRot();
}
@Override

View File

@ -287,6 +287,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
super.l();
return;
}
super.K();
boolean navigating = npc.getNavigator().isNavigating();
if (!navigating && getBukkitEntity() != null
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
@ -303,23 +304,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
moveOnCurrentHeading();
}
NMSImpl.updateAI(this);
if (!this.world.isClientSide) {
b(0, this.fireTicks > 0);
}
this.ay = this.az;
this.aE = this.aF;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
bL();
}
bi();
this.aU = this.aT;
this.aJ = this.aI;
this.aL = this.aK;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
}
private void moveOnCurrentHeading() {

View File

@ -213,6 +213,7 @@ public class NMSImpl implements NMSBridge {
PlayerAnimation.ARM_SWING.play(humanHandle.getBukkitEntity());
return;
}
AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
int i = 0;