Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.isageek.joethornton.Orientation;
- import net.minecraft.server.ControllerMove;
- import net.minecraft.server.MathHelper;
- public class SafeControllerMove extends ControllerMove {
- // Hiding variable a from ControllerMove
- private SafePlayer a;
- private double b;
- private double c;
- private double d;
- private float e;
- private boolean f = false;
- public SafeControllerMove(SafePlayer safeplayer) {
- super(safeplayer);
- this.a = safeplayer;
- this.b = safeplayer.locX;
- this.c = safeplayer.locY;
- this.d = safeplayer.locZ;
- }
- @Override
- public boolean a() {
- return this.f;
- }
- @Override
- public float b() {
- return this.e;
- }
- @Override
- public void a(double d0, double d1, double d2, float f) {
- this.b = d0;
- this.c = d1;
- this.d = d2;
- this.e = f;
- this.f = true;
- }
- @Override
- public void c() {
- this.a.e(0.0F);
- if (this.f) {
- this.f = false;
- int i = MathHelper.floor(this.a.boundingBox.b + 0.5D);
- double d0 = this.b - this.a.locX;
- double d1 = this.d - this.a.locZ;
- double d2 = this.c - (double) i;
- double d3 = d0 * d0 + d2 * d2 + d1 * d1;
- if (d3 >= 2.500000277905201E-7D) {
- float f = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
- this.a.setYaw(this.a(this.a.yaw, f, 30.0F));
- this.a.d(this.e);
- if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D) {
- this.a.getControllerJump().a();
- }
- }
- }
- }
- private float a(float f, float f1, float f2) {
- float f3;
- for (f3 = f1 - f; f3 < -180.0F; f3 += 360.0F) {
- ;
- }
- while (f3 >= 180.0F) {
- f3 -= 360.0F;
- }
- if (f3 > f2) {
- f3 = f2;
- }
- if (f3 < -f2) {
- f3 = -f2;
- }
- return f + f3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement