Fix ridable rabbits

This commit is contained in:
William Blake Galbreath
2020-01-17 02:50:09 -06:00
parent f841e39dae
commit 97e1a38a6e

View File

@@ -0,0 +1,164 @@
From 53b6b1ac2ba2d1d5c3ccec7242be7a45b37ea137 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 16 Jan 2020 22:44:07 -0600
Subject: [PATCH] test
---
.../minecraft/server/EntityInsentient.java | 2 +-
.../net/minecraft/server/EntityRabbit.java | 57 ++++++++++++++++++-
.../purpur/controller/ControllerMoveWASD.java | 2 +-
3 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index b223044f5..c98203603 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -29,7 +29,7 @@ public abstract class EntityInsentient extends EntityLiving {
protected int f;
protected ControllerLook lookController;
protected ControllerMove moveController;
- protected ControllerJump bq;
+ protected ControllerJump bq; public ControllerJump getJumpController() { return bq; } // Purpur - OBFHELPER
private final EntityAIBodyControl c;
protected NavigationAbstract navigation;
public PathfinderGoalSelector goalSelector;
diff --git a/src/main/java/net/minecraft/server/EntityRabbit.java b/src/main/java/net/minecraft/server/EntityRabbit.java
index 35b8e182c..2e89745ce 100644
--- a/src/main/java/net/minecraft/server/EntityRabbit.java
+++ b/src/main/java/net/minecraft/server/EntityRabbit.java
@@ -44,6 +44,14 @@ public class EntityRabbit extends EntityAnimal {
@Override
protected float dp() {
+ // Purpur start
+ if (getRider() != null) {
+ if (getForward() < 0) {
+ setSpeed(getForward() * 2F);
+ }
+ return actualJump ? 0.5F : 0.3F;
+ }
+ // Purpur end
if (!this.positionChanged && (!this.moveController.b() || this.moveController.e() <= this.locY() + 0.5D)) {
PathEntity pathentity = this.navigation.k();
@@ -94,6 +102,7 @@ public class EntityRabbit extends EntityAnimal {
}
+ public void startJumping() { eq(); } // Purpur - OBFHELPER
public void eq() {
this.setJumping(true);
this.bz = 10;
@@ -108,6 +117,12 @@ public class EntityRabbit extends EntityAnimal {
@Override
public void mobTick() {
+ // Purpur start
+ if (getRider() != null) {
+ handleJumping();
+ return;
+ }
+ // Purpur end
if (this.bB > 0) {
--this.bB;
}
@@ -158,6 +173,39 @@ public class EntityRabbit extends EntityAnimal {
this.bA = this.onGround;
}
+ // Purpur start
+ private boolean wasOnGround;
+ private boolean actualJump;
+
+ private void handleJumping() {
+ if (onGround) {
+ ControllerJumpRabbit jumpController = (ControllerJumpRabbit) getJumpController();
+ if (!wasOnGround) {
+ setJumping(false);
+ jumpController.setCanJump(false);
+ }
+ if (!jumpController.isJumping()) {
+ if (moveController.b()) { // isUpdating
+ startJumping();
+ }
+ } else if (!jumpController.canJump()) {
+ jumpController.setCanJump(true);
+ }
+ }
+ wasOnGround = onGround;
+ }
+
+ @Override
+ public boolean onSpacebar() {
+ if (onGround) {
+ actualJump = true;
+ jump();
+ actualJump = false;
+ }
+ return true;
+ }
+ // Purpur end
+
@Override
public void aE() {}
@@ -477,7 +525,7 @@ public class EntityRabbit extends EntityAnimal {
}
}
- static class ControllerMoveRabbit extends ControllerMove {
+ static class ControllerMoveRabbit extends net.pl3x.purpur.controller.ControllerMoveWASD { // Purpur
private final EntityRabbit i;
private double j;
@@ -488,14 +536,14 @@ public class EntityRabbit extends EntityAnimal {
}
@Override
- public void a() {
+ public void tick() { // Purpur
if (this.i.onGround && !this.i.jumping && !((EntityRabbit.ControllerJumpRabbit) this.i.bq).c()) {
this.i.i(0.0D);
} else if (this.b()) {
this.i.i(this.j);
}
- super.a();
+ super.tick(); // Purpur
}
@Override
@@ -522,14 +570,17 @@ public class EntityRabbit extends EntityAnimal {
this.c = entityrabbit;
}
+ public boolean isJumping() { return c(); } // Purpur - OBFHELPER
public boolean c() {
return this.a;
}
+ public boolean canJump() { return d(); } // Purpur - OBFHELPER
public boolean d() {
return this.d;
}
+ public void setCanJump(boolean canJump) { a(canJump); } // Purpur - OBFHELPER
public void a(boolean flag) {
this.d = flag;
}
diff --git a/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java
index d64a66274..cc2956f17 100644
--- a/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java
+++ b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java
@@ -16,7 +16,7 @@ public class ControllerMoveWASD extends ControllerMove {
// isUpdating
@Override
public boolean b() {
- return entity.getRider() != null || super.b();
+ return entity.getRider() != null ? f != 0 || g != 0 : super.b();
}
// tick
--
2.24.0