Skip to content

Commit

Permalink
Allow NPCs to push other entities
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Feb 20, 2022
1 parent 65c7e7c commit 626b6d6
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void apply(Team team, boolean nameVisibility) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ public void k_() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ public void playerTick() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ public void playerTick() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ public void playerTick() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ public void playerTick() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ public void playerTick() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ public void playerTick() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ public void doTick() {
setLastHurtByMob((LivingEntity) null);
}
}
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
pushEntities();
}
tickEffects();
this.animStepO = this.animStep;
this.yBodyRotO = this.yBodyRot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ public void doTick() {
}
}

if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
pushEntities();
}

tickEffects();
this.animStepO = this.animStep;
this.yBodyRotO = this.yBodyRot;
Expand Down Expand Up @@ -375,9 +379,7 @@ public boolean isNavigating() {

@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() {
Expand Down Expand Up @@ -509,8 +511,8 @@ public void travel(Vec3 vec3d) {

public void updateAI() {
controllerMove.tick();
controllerLook.a();
controllerJump.b();
controllerLook.tick();
controllerJump.tick();
}

private void updatePackets(boolean navigating) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public PlayerControllerJump(EntityHumanNPC entityinsentient) {
this.b = entityinsentient;
}

public void b() {
public void tick() {
this.b.setJumping(this.a);
this.a = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PlayerLookControl(EntityHumanNPC entityinsentient) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ public void l() {
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;
Expand Down

0 comments on commit 626b6d6

Please sign in to comment.