Allow NPCs to push other entities

This commit is contained in:
fullwall 2022-02-20 21:21:50 +08:00
parent 65c7e7c28c
commit 626b6d6b42
13 changed files with 37 additions and 8 deletions

View File

@ -72,7 +72,7 @@ public class ScoreboardTrait extends Trait {
if (SUPPORT_COLLIDABLE_SETOPTION && npc.data().has(NPC.COLLIDABLE_METADATA)) {
try {
team.setOption(Option.COLLISION_RULE,
(boolean) npc.data().get(NPC.COLLIDABLE_METADATA) ? OptionStatus.ALWAYS : OptionStatus.NEVER);
npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA) ? OptionStatus.ALWAYS : OptionStatus.NEVER);
} catch (NoSuchMethodError e) {
SUPPORT_COLLIDABLE_SETOPTION = false;
} catch (NoClassDefFoundError e) {

View File

@ -302,6 +302,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;

View File

@ -367,6 +367,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;

View File

@ -393,6 +393,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;

View File

@ -368,6 +368,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;

View File

@ -372,6 +372,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;

View File

@ -373,6 +373,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;

View File

@ -403,6 +403,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;

View File

@ -214,6 +214,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
setLastHurtByMob((LivingEntity) null);
}
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
pushEntities();
}
tickEffects();
this.animStepO = this.animStep;
this.yBodyRotO = this.yBodyRot;

View File

@ -218,6 +218,10 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
}
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
pushEntities();
}
tickEffects();
this.animStepO = this.animStep;
this.yBodyRotO = this.yBodyRot;
@ -375,9 +379,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
@Override
public boolean isPushable() {
return npc == null ? super.isPushable()
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
: !npc.isProtected();
return npc == null ? super.isPushable() : npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA, !npc.isProtected());
}
private void moveOnCurrentHeading() {
@ -509,8 +511,8 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
public void updateAI() {
controllerMove.tick();
controllerLook.a();
controllerJump.b();
controllerLook.tick();
controllerJump.tick();
}
private void updatePackets(boolean navigating) {

View File

@ -10,7 +10,7 @@ public class PlayerControllerJump {
this.b = entityinsentient;
}
public void b() {
public void tick() {
this.b.setJumping(this.a);
this.a = false;
}

View File

@ -21,7 +21,7 @@ public class PlayerLookControl {
this.control = new PlayerBodyControl(this.a);
}
public void a() {
public void tick() {
if (!this.a.getNavigation().isDone()) {
// TODO: use Citizens AI?
// this.a.yHeadRot = Mth.rotateIfNecessary(this.a.yHeadRot, this.a.yBodyRot, 75);

View File

@ -311,6 +311,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
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;