-
-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double sending of command messages with LINEAR execution
- Loading branch information
Showing
3 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerBodyControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package net.citizensnpcs.nms.v1_16_R3.util; | ||
|
||
import net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC; | ||
import net.minecraft.server.v1_16_R3.EntityInsentient; | ||
import net.minecraft.server.v1_16_R3.MathHelper; | ||
|
||
public class PlayerBodyControl { | ||
private final EntityHumanNPC a; | ||
private int b; | ||
private float c; | ||
|
||
public PlayerBodyControl(EntityHumanNPC var0) { | ||
this.a = var0; | ||
} | ||
|
||
public void a() { | ||
if (f()) { | ||
this.a.aA = this.a.yaw; | ||
c(); | ||
this.c = this.a.aC; | ||
this.b = 0; | ||
return; | ||
} | ||
if (e()) | ||
if (Math.abs(this.a.aC - this.c) > 15.0F) { | ||
System.out.println("BIG DX"); | ||
this.b = 0; | ||
this.c = this.a.aC; | ||
b(); | ||
} else { | ||
this.b++; | ||
if (this.b > 10) | ||
d(); | ||
} | ||
} | ||
|
||
private void b() { | ||
this.a.aA = MathHelper.b(this.a.aA, this.a.aC, 10); | ||
this.a.yaw = this.a.aA; | ||
} | ||
|
||
private void c() { | ||
this.a.aC = MathHelper.b(this.a.aC, this.a.aA, 10); | ||
} | ||
|
||
private void d() { | ||
int var0 = this.b - 10; | ||
float var1 = MathHelper.a(var0 / 10.0F, 0.0F, 1.0F); | ||
float var2 = 40 * (1.0F - var1); | ||
this.a.aA = MathHelper.b(this.a.aA, this.a.aC, var2); | ||
} | ||
|
||
private boolean e() { | ||
return (this.a.getPassengers().isEmpty() || !(this.a.getPassengers().get(0) instanceof EntityInsentient)); | ||
} | ||
|
||
private boolean f() { | ||
double var0 = this.a.locX() - this.a.lastX; | ||
double var2 = this.a.locZ() - this.a.lastZ; | ||
return (var0 * var0 + var2 * var2 > 2.500000277905201E-7D); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters