Files
Purpur/patches/server/0007-Integrate-ridables.patch
2019-05-04 21:02:38 -05:00

1617 lines
64 KiB
Diff

From 99ec119821250b8f08e990bf5ee8b9e9271332c8 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Tue, 30 Apr 2019 19:17:21 -0500
Subject: [PATCH] Integrate ridables
---
.../net/minecraft/server/ControllerJump.java | 1 +
.../server/ControllerLookDolphin.java | 4 +-
.../java/net/minecraft/server/Entity.java | 13 ++++
.../net/minecraft/server/EntityChicken.java | 17 +++-
.../java/net/minecraft/server/EntityCow.java | 14 ++++
.../net/minecraft/server/EntityCreeper.java | 14 ++++
.../net/minecraft/server/EntityDolphin.java | 28 ++++++-
.../net/minecraft/server/EntityDrowned.java | 38 ++++++++-
.../net/minecraft/server/EntityEnderman.java | 15 ++++
.../net/minecraft/server/EntityEndermite.java | 15 ++++
.../java/net/minecraft/server/EntityFish.java | 28 ++++++-
.../net/minecraft/server/EntityGuardian.java | 36 ++++++++-
.../net/minecraft/server/EntityHorse.java | 10 ++-
.../minecraft/server/EntityHorseAbstract.java | 4 +-
.../server/EntityHorseChestedAbstract.java | 18 +++--
.../minecraft/server/EntityHorseDonkey.java | 3 +
.../net/minecraft/server/EntityHorseMule.java | 3 +
.../minecraft/server/EntityHorseSkeleton.java | 15 ++--
.../minecraft/server/EntityHorseZombie.java | 12 +--
.../net/minecraft/server/EntityHuman.java | 14 +++-
.../minecraft/server/EntityInsentient.java | 39 ++++++++++
.../net/minecraft/server/EntityIronGolem.java | 15 ++++
.../net/minecraft/server/EntityLiving.java | 21 ++++-
.../net/minecraft/server/EntityLlama.java | 37 ++++++++-
.../minecraft/server/EntityMushroomCow.java | 14 ++++
.../net/minecraft/server/EntityOcelot.java | 14 ++++
.../java/net/minecraft/server/EntityPig.java | 25 ++++++
.../net/minecraft/server/EntityPolarBear.java | 15 ++++
.../net/minecraft/server/EntitySheep.java | 14 ++++
.../minecraft/server/EntitySilverfish.java | 15 ++++
.../server/EntitySkeletonAbstract.java | 15 ++++
.../net/minecraft/server/EntitySnowman.java | 15 ++++
.../net/minecraft/server/EntitySpider.java | 15 ++++
.../server/EntityTameableAnimal.java | 6 ++
.../net/minecraft/server/EntityTypes.java | 6 ++
.../java/net/minecraft/server/EntityWolf.java | 14 ++++
.../net/minecraft/server/EntityZombie.java | 15 ++++
.../purpur/controller/ControllerLookWASD.java | 46 +++++++++++
.../purpur/controller/ControllerMoveWASD.java | 77 +++++++++++++++++++
.../controller/ControllerMoveWASDWater.java | 42 ++++++++++
.../craftbukkit/entity/CraftLivingEntity.java | 12 +++
41 files changed, 734 insertions(+), 40 deletions(-)
create mode 100644 src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java
create mode 100644 src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java
create mode 100644 src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDWater.java
diff --git a/src/main/java/net/minecraft/server/ControllerJump.java b/src/main/java/net/minecraft/server/ControllerJump.java
index 489beed2..041f0763 100644
--- a/src/main/java/net/minecraft/server/ControllerJump.java
+++ b/src/main/java/net/minecraft/server/ControllerJump.java
@@ -9,6 +9,7 @@ public class ControllerJump {
this.b = entityinsentient;
}
+ public void jump() { a(); } // Purpur - OBFHELPER
public void a() {
this.a = true;
}
diff --git a/src/main/java/net/minecraft/server/ControllerLookDolphin.java b/src/main/java/net/minecraft/server/ControllerLookDolphin.java
index 8397aacb..92432ee6 100644
--- a/src/main/java/net/minecraft/server/ControllerLookDolphin.java
+++ b/src/main/java/net/minecraft/server/ControllerLookDolphin.java
@@ -1,6 +1,6 @@
package net.minecraft.server;
-public class ControllerLookDolphin extends ControllerLook {
+public class ControllerLookDolphin extends net.pl3x.purpur.controller.ControllerLookWASD { // Purpur
private final int h;
@@ -9,7 +9,7 @@ public class ControllerLookDolphin extends ControllerLook {
this.h = i;
}
- public void a() {
+ public void tick() { // Purpur
if (this.d) {
this.d = false;
double d0 = this.e - this.a.locX;
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 89a8bbe3..caa07f8b 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -96,6 +96,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
private int id;
public boolean j; public boolean blocksEntitySpawning() { return j; } // Paper - OBFHELPER
public final List<Entity> passengers;
+ private EntityHuman rider; // Purpur
protected int k;
private Entity vehicle;
public boolean attachedToPlayer;
@@ -2115,6 +2116,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return this.k <= 0;
}
+ // Purpur start
+ public EntityHuman getRider() {
+ return rider;
+ }
+ // Purpur end
+
public void ejectPassengers() {
for (int i = this.passengers.size() - 1; i >= 0; --i) {
((Entity) this.passengers.get(i)).stopRiding();
@@ -2167,6 +2174,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// Spigot end
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) {
this.passengers.add(0, entity);
+ this.rider = (EntityHuman) entity; // Purpur
} else {
this.passengers.add(entity);
}
@@ -2205,6 +2213,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return false;
}
// Spigot end
+ // Purpur start
+ if (passengers.get(0) == rider) {
+ rider = null;
+ }
+ // Purpur end
this.passengers.remove(entity);
entity.k = 60;
}
diff --git a/src/main/java/net/minecraft/server/EntityChicken.java b/src/main/java/net/minecraft/server/EntityChicken.java
index 070a9e7b..cf3730b3 100644
--- a/src/main/java/net/minecraft/server/EntityChicken.java
+++ b/src/main/java/net/minecraft/server/EntityChicken.java
@@ -18,6 +18,11 @@ public class EntityChicken extends EntityAnimal {
this.setSize(0.4F, 0.7F);
this.bI = this.random.nextInt(6000) + 6000;
this.a(PathType.WATER, 0.0F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -62,7 +67,7 @@ public class EntityChicken extends EntityAnimal {
}
this.bC += this.bH * 2.0F;
- if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bI <= 0) {
+ if (!this.isBaby() && !this.isChickenJockey() && --this.bI <= 0 && getRider() == null) { // Purpur
this.a(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
this.forceDrops = true; // CraftBukkit
this.a((IMaterial) Items.EGG);
@@ -72,6 +77,16 @@ public class EntityChicken extends EntityAnimal {
}
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
+
public void c(float f, float f1) {}
protected SoundEffect D() {
diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java
index efd2a0ee..231ade5c 100644
--- a/src/main/java/net/minecraft/server/EntityCow.java
+++ b/src/main/java/net/minecraft/server/EntityCow.java
@@ -11,6 +11,11 @@ public class EntityCow extends EntityAnimal {
protected EntityCow(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
this.setSize(0.9F, 1.4F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
public EntityCow(World world) {
@@ -62,6 +67,15 @@ public class EntityCow extends EntityAnimal {
private int mushroomsFed = 0; // Purpur
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ private boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java
index 945a75dd..588bba0a 100644
--- a/src/main/java/net/minecraft/server/EntityCreeper.java
+++ b/src/main/java/net/minecraft/server/EntityCreeper.java
@@ -22,6 +22,11 @@ public class EntityCreeper extends EntityMonster {
public EntityCreeper(World world) {
super(EntityTypes.CREEPER, world);
this.setSize(0.6F, 1.7F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -175,6 +180,15 @@ public class EntityCreeper extends EntityMonster {
// CraftBukkit end
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ private boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.FLINT_AND_STEEL) {
diff --git a/src/main/java/net/minecraft/server/EntityDolphin.java b/src/main/java/net/minecraft/server/EntityDolphin.java
index 8bf15a68..5ef1796b 100644
--- a/src/main/java/net/minecraft/server/EntityDolphin.java
+++ b/src/main/java/net/minecraft/server/EntityDolphin.java
@@ -18,6 +18,7 @@ public class EntityDolphin extends EntityWaterAnimal {
this.setSize(0.9F, 0.6F);
this.moveController = new EntityDolphin.a(this);
this.lookController = new ControllerLookDolphin(this, 10);
+ this.canBeRiddenInWater = true; // Purpur
this.p(true);
}
@@ -199,6 +200,15 @@ public class EntityDolphin extends EntityWaterAnimal {
}
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ protected boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (!itemstack.isEmpty() && itemstack.getItem().a(TagsItem.FISHES)) {
@@ -487,7 +497,7 @@ public class EntityDolphin extends EntityWaterAnimal {
}
}
- static class a extends ControllerMove {
+ static class a extends net.pl3x.purpur.controller.ControllerMoveWASDWater { // Purpur
private final EntityDolphin i;
@@ -496,7 +506,21 @@ public class EntityDolphin extends EntityWaterAnimal {
this.i = entitydolphin;
}
- public void a() {
+ // Purpur start
+ @Override
+ public void tick(EntityHuman rider) {
+ if (this.i.getAirTicks() < 150) {
+ // if drowning override player WASD controls to find air
+ tick();
+ } else {
+ super.tick(rider);
+ this.i.motY += 0.005D;
+ }
+ }
+
+ @Override
+ public void tick() {
+ // Purpur end
if (this.i.isInWater()) {
this.i.motY += 0.005D;
}
diff --git a/src/main/java/net/minecraft/server/EntityDrowned.java b/src/main/java/net/minecraft/server/EntityDrowned.java
index 0e2b5ee7..522f7d61 100644
--- a/src/main/java/net/minecraft/server/EntityDrowned.java
+++ b/src/main/java/net/minecraft/server/EntityDrowned.java
@@ -6,14 +6,47 @@ import javax.annotation.Nullable;
public class EntityDrowned extends EntityZombie implements IRangedEntity {
- private boolean bC;
+ private boolean bC; public boolean isSwimmingUp() { return this.bC; } // Purpur - OBFHELPER
protected final NavigationGuardian a;
protected final Navigation b;
public EntityDrowned(World world) {
super(EntityTypes.DROWNED, world);
this.Q = 1.0F;
- this.moveController = new EntityDrowned.e(this);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this) {
+ @Override
+ public void tick() {
+ EntityDrowned drowned = EntityDrowned.this;
+ EntityLiving target = drowned.getGoalTarget();
+ if (drowned.isSwimmingUpOrTargetIsInWater() && drowned.isInWater()) {
+ if (target != null && target.locY > drowned.locY || drowned.isSwimmingUp()) {
+ drowned.motY += 0.002D;
+ }
+ if (h != Operation.MOVE_TO || drowned.getNavigation().p()) {
+ drowned.setSpeed(0.0F);
+ return;
+ }
+ double x = b - drowned.locX;
+ double y = c - drowned.locY;
+ double z = d - drowned.locZ;
+ y /= (double) MathHelper.sqrt(x * x + y * y + z * z);
+ drowned.yaw = a(drowned.yaw, (float) (MathHelper.c(z, x) * 57.2957763671875D) - 90.0F, 90.0F);
+ drowned.setRenderYawOffset(drowned.yaw);
+ float speed = (float) (e * drowned.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
+ drowned.setSpeed(drowned.getSpeed() + (speed - drowned.getSpeed()) * 0.125F);
+ drowned.motY += (double) drowned.getSpeed() * y * 0.1D;
+ drowned.motX += (double) drowned.getSpeed() * x * 0.005D;
+ drowned.motZ += (double) drowned.getSpeed() * z * 0.005D;
+ } else {
+ if (!drowned.onGround) {
+ drowned.motY -= 0.008D;
+ }
+ super.tick();
+ }
+ }
+ };
+ // Purpur end
this.a(PathType.WATER, 0.0F);
this.a = new NavigationGuardian(this, world);
this.b = new Navigation(this, world);
@@ -123,6 +156,7 @@ public class EntityDrowned extends EntityZombie implements IRangedEntity {
return !this.isSwimming();
}
+ public boolean isSwimmingUpOrTargetIsInWater() { return dI(); } // Purpur - OBFHELPER
private boolean dI() {
if (this.bC) {
return true;
diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java
index 94504044..7ac728ba 100644
--- a/src/main/java/net/minecraft/server/EntityEnderman.java
+++ b/src/main/java/net/minecraft/server/EntityEnderman.java
@@ -21,6 +21,11 @@ public class EntityEnderman extends EntityMonster {
this.setSize(0.6F, 2.9F);
this.Q = 1.0F;
this.a(PathType.WATER, -1.0F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -243,6 +248,16 @@ public class EntityEnderman extends EntityMonster {
return LootTables.C;
}
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
+
public void setCarried(@Nullable IBlockData iblockdata) {
this.datawatcher.set(EntityEnderman.c, Optional.ofNullable(iblockdata));
}
diff --git a/src/main/java/net/minecraft/server/EntityEndermite.java b/src/main/java/net/minecraft/server/EntityEndermite.java
index 9a22e202..8e8d4cbc 100644
--- a/src/main/java/net/minecraft/server/EntityEndermite.java
+++ b/src/main/java/net/minecraft/server/EntityEndermite.java
@@ -11,6 +11,11 @@ public class EntityEndermite extends EntityMonster {
super(EntityTypes.ENDERMITE, world);
this.b_ = 3;
this.setSize(0.4F, 0.3F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -128,4 +133,14 @@ public class EntityEndermite extends EntityMonster {
public EnumMonsterType getMonsterType() {
return EnumMonsterType.ARTHROPOD;
}
+
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java
index 5da2d72a..ecfcbe31 100644
--- a/src/main/java/net/minecraft/server/EntityFish.java
+++ b/src/main/java/net/minecraft/server/EntityFish.java
@@ -7,6 +7,10 @@ public abstract class EntityFish extends EntityWaterAnimal implements IAnimal {
public EntityFish(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
this.moveController = new EntityFish.a(this);
+ // Purpur start
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
public float getHeadHeight() {
@@ -73,7 +77,7 @@ public abstract class EntityFish extends EntityWaterAnimal implements IAnimal {
public void a(float f, float f1, float f2) {
if (this.cP() && this.isInWater()) {
- this.a(f, f1, f2, 0.01F);
+ this.a(f, f1, f2, getRider() == null ? 0.1F : getSpeed()); // Purpur
this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ);
this.motX *= 0.8999999761581421D;
this.motY *= 0.8999999761581421D;
@@ -101,6 +105,15 @@ public abstract class EntityFish extends EntityWaterAnimal implements IAnimal {
}
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ protected boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.WATER_BUCKET && this.isAlive()) {
@@ -145,7 +158,7 @@ public abstract class EntityFish extends EntityWaterAnimal implements IAnimal {
return SoundEffects.ENTITY_FISH_SWIM;
}
- static class a extends ControllerMove {
+ static class a extends net.pl3x.purpur.controller.ControllerMoveWASDWater { // Purpur
private final EntityFish i;
@@ -154,7 +167,16 @@ public abstract class EntityFish extends EntityWaterAnimal implements IAnimal {
this.i = entityfish;
}
- public void a() {
+ // Purpur start
+ @Override
+ public void tick(EntityHuman rider) {
+ super.tick(rider);
+ this.i.motY += 0.005D;
+ }
+
+ @Override
+ public void tick() {
+ // Purpur end
if (this.i.a(TagsFluid.WATER)) {
this.i.motY += 0.005D;
}
diff --git a/src/main/java/net/minecraft/server/EntityGuardian.java b/src/main/java/net/minecraft/server/EntityGuardian.java
index 072236ec..e04cb7c0 100644
--- a/src/main/java/net/minecraft/server/EntityGuardian.java
+++ b/src/main/java/net/minecraft/server/EntityGuardian.java
@@ -22,6 +22,15 @@ public class EntityGuardian extends EntityMonster {
this.b_ = 10;
this.setSize(0.85F, 0.85F);
this.moveController = new EntityGuardian.ControllerMoveGuardian(this);
+ // Purpur start
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this) {
+ @Override
+ public void setYawPitch(float yaw, float pitch) {
+ super.setYawPitch(yaw, pitch * 0.35F);
+ }
+ };
+ this.canBeRiddenInWater = true;
+ // Purpur end
this.a = this.random.nextFloat();
this.b = this.a;
}
@@ -75,6 +84,7 @@ public class EntityGuardian extends EntityMonster {
return (Boolean) this.datawatcher.get(EntityGuardian.bF);
}
+ private void setMovingFlag(boolean movingFlag) { a(movingFlag); } // Purpur - OBFHELPER
private void a(boolean flag) {
this.datawatcher.set(EntityGuardian.bF, flag);
}
@@ -282,7 +292,7 @@ public class EntityGuardian extends EntityMonster {
public void a(float f, float f1, float f2) {
if (this.cP() && this.isInWater()) {
- this.a(f, f1, f2, 0.1F);
+ this.a(f, f1, f2, getRider() == null ? 0.1F : getSpeed()); // Purpur
this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ);
this.motX *= 0.8999999761581421D;
this.motY *= 0.8999999761581421D;
@@ -296,7 +306,17 @@ public class EntityGuardian extends EntityMonster {
}
- static class ControllerMoveGuardian extends ControllerMove {
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
+
+ static class ControllerMoveGuardian extends net.pl3x.purpur.controller.ControllerMoveWASDWater { // Purpur
private final EntityGuardian i;
@@ -305,7 +325,17 @@ public class EntityGuardian extends EntityMonster {
this.i = entityguardian;
}
- public void a() {
+ // Purpur start
+ @Override
+ public void tick(EntityHuman rider) {
+ super.tick(rider);
+ this.i.motY += 0.005D;
+ this.i.setMovingFlag(this.i.getForward() > 0.0F); // control tail speed
+ }
+
+ @Override
+ public void tick() {
+ // Purpur end
if (this.h == ControllerMove.Operation.MOVE_TO && !this.i.getNavigation().p()) {
double d0 = this.b - this.i.locX;
double d1 = this.c - this.i.locY;
diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java
index 1b9425f3..ff7f1a61 100644
--- a/src/main/java/net/minecraft/server/EntityHorse.java
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
@@ -191,12 +191,14 @@ public class EntityHorse extends EntityHorseAbstract {
}
}
- if (this.isBaby()) {
- return super.a(entityhuman, enumhand);
- } else {
+ // Purpur start - allow riding babies
+ //if (this.isBaby()) {
+ // return super.a(entityhuman, enumhand);
+ //} else {
this.g(entityhuman);
return true;
- }
+ //}
+ // Purpur end
}
}
diff --git a/src/main/java/net/minecraft/server/EntityHorseAbstract.java b/src/main/java/net/minecraft/server/EntityHorseAbstract.java
index 95327763..3e80c82d 100644
--- a/src/main/java/net/minecraft/server/EntityHorseAbstract.java
+++ b/src/main/java/net/minecraft/server/EntityHorseAbstract.java
@@ -80,7 +80,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven
}
public boolean isTamed() {
- return this.p(2);
+ return this.p(2) || isBaby(); // Purpur
}
@Nullable
@@ -300,6 +300,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven
return true;
}
+ public boolean isSaddled() { return dV(); } // Purpur - OBFHELPER
public boolean dV() {
return this.p(4);
}
@@ -611,6 +612,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven
}
+ public void makeMad() { dZ(); } // Purpur - OBFHELPER
public void dZ() {
this.dH();
SoundEffect soundeffect = this.dB();
diff --git a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
index 6eddc2a8..7fa0c8fc 100644
--- a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
+++ b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
@@ -146,8 +146,12 @@ public abstract class EntityHorseChestedAbstract extends EntityHorseAbstract {
return true;
}
- this.dZ();
- return true;
+ // Purpur start - don't make babies mad
+ if (!this.isBaby()) {
+ this.makeMad();
+ return true;
+ }
+ // Purpur end
}
if (!this.isCarryingChest() && itemstack.getItem() == Blocks.CHEST.getItem()) {
@@ -172,12 +176,14 @@ public abstract class EntityHorseChestedAbstract extends EntityHorseAbstract {
}
}
- if (this.isBaby()) {
- return super.a(entityhuman, enumhand);
- } else {
+ // Purpur start - allow riding babies
+ //if (this.isBaby()) {
+ // return super.a(entityhuman, enumhand);
+ //} else {
this.g(entityhuman);
return true;
- }
+ //}
+ // Purpur end
}
}
diff --git a/src/main/java/net/minecraft/server/EntityHorseDonkey.java b/src/main/java/net/minecraft/server/EntityHorseDonkey.java
index 65c40e72..cd0828cc 100644
--- a/src/main/java/net/minecraft/server/EntityHorseDonkey.java
+++ b/src/main/java/net/minecraft/server/EntityHorseDonkey.java
@@ -6,6 +6,9 @@ public class EntityHorseDonkey extends EntityHorseChestedAbstract {
public EntityHorseDonkey(World world) {
super(EntityTypes.DONKEY, world);
+ // Purpur start
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
@Nullable
diff --git a/src/main/java/net/minecraft/server/EntityHorseMule.java b/src/main/java/net/minecraft/server/EntityHorseMule.java
index d17c3e81..874ea280 100644
--- a/src/main/java/net/minecraft/server/EntityHorseMule.java
+++ b/src/main/java/net/minecraft/server/EntityHorseMule.java
@@ -6,6 +6,9 @@ public class EntityHorseMule extends EntityHorseChestedAbstract {
public EntityHorseMule(World world) {
super(EntityTypes.MULE, world);
+ // Purpur start
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
@Nullable
diff --git a/src/main/java/net/minecraft/server/EntityHorseSkeleton.java b/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
index 0a092acd..05c963c3 100644
--- a/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
+++ b/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
@@ -10,6 +10,9 @@ public class EntityHorseSkeleton extends EntityHorseAbstract {
public EntityHorseSkeleton(World world) {
super(EntityTypes.SKELETON_HORSE, world);
+ // Purpur start
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void initAttributes() {
@@ -142,18 +145,20 @@ public class EntityHorseSkeleton extends EntityHorseAbstract {
if (itemstack.getItem() instanceof ItemMonsterEgg) {
return super.a(entityhuman, enumhand);
- } else if (!this.isTamed()) {
+ // Purpur start - allow riding babies
+ } else if (!this.isTamed() && !this.isBaby()) {
return false;
- } else if (this.isBaby()) {
- return super.a(entityhuman, enumhand);
- } else if (entityhuman.isSneaking()) {
+ //} else if (this.isBaby()) {
+ // return super.a(entityhuman, enumhand);
+ // Purpur end
+ } else if (entityhuman.isSneaking() && !this.isBaby()) { // Purpur - don't open inventory on babies
this.c(entityhuman);
return true;
} else if (this.isVehicle()) {
return super.a(entityhuman, enumhand);
} else {
if (!itemstack.isEmpty()) {
- if (itemstack.getItem() == Items.SADDLE && !this.dV()) {
+ if (!this.isBaby() && itemstack.getItem() == Items.SADDLE && !this.isSaddled()) { // Purpur - don't open inventory on babies
this.c(entityhuman);
return true;
}
diff --git a/src/main/java/net/minecraft/server/EntityHorseZombie.java b/src/main/java/net/minecraft/server/EntityHorseZombie.java
index a1873f55..9dac0c25 100644
--- a/src/main/java/net/minecraft/server/EntityHorseZombie.java
+++ b/src/main/java/net/minecraft/server/EntityHorseZombie.java
@@ -49,18 +49,20 @@ public class EntityHorseZombie extends EntityHorseAbstract {
if (itemstack.getItem() instanceof ItemMonsterEgg) {
return super.a(entityhuman, enumhand);
- } else if (!this.isTamed()) {
+ // Purpur start - allow riding babies
+ } else if (!this.isTamed() && !this.isBaby()) {
return false;
- } else if (this.isBaby()) {
- return super.a(entityhuman, enumhand);
- } else if (entityhuman.isSneaking()) {
+ //} else if (this.isBaby()) {
+ // return super.a(entityhuman, enumhand);
+ // Purpur end
+ } else if (entityhuman.isSneaking() && !this.isBaby()) { // Purpur - don't open inventory on babies
this.c(entityhuman);
return true;
} else if (this.isVehicle()) {
return super.a(entityhuman, enumhand);
} else {
if (!itemstack.isEmpty()) {
- if (!this.dV() && itemstack.getItem() == Items.SADDLE) {
+ if (!this.isBaby() && itemstack.getItem() == Items.SADDLE && !this.isSaddled()) { // Purpur - don't open inventory on babies
this.c(entityhuman);
return true;
}
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index fdbe9a2a..3fbfa6d7 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -372,8 +372,20 @@ public abstract class EntityHuman extends EntityLiving {
this.activeContainer = this.defaultContainer;
}
+ // Purpur start
+ boolean mounting = false;
+
+ @Override
+ public void setSneaking(boolean sneaking) {
+ if (this.mounting && !sneaking) {
+ this.mounting = false;
+ }
+ super.setSneaking(sneaking);
+ }
+ // Purpur end
+
public void aH() {
- if (!this.world.isClientSide && this.isSneaking() && this.isPassenger()) {
+ if (this.isSneaking() && this.isPassenger() && !this.mounting) { // Purpur
this.stopRiding();
this.setSneaking(false);
} else {
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index d1ec201d..ae9d0585 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -515,6 +515,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.bh = f;
}
+ public void setSpeed(float speed) { o(speed); } // Purpur - OBFHELPER
public void o(float f) {
super.o(f);
this.r(f);
@@ -1310,4 +1311,42 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
+
+ // Purpur start
+ public boolean hasRidePermission(EntityHuman entityhuman) {
+ return entityhuman.getBukkitEntity().hasPermission("allow.ride." + getEntityType().getName());
+ }
+
+ public boolean tryRide(EntityHuman entityhuman, EnumHand enumhand) {
+ if (enumhand != EnumHand.MAIN_HAND) {
+ return false;
+ }
+ if (!entityhuman.isSneaking()) {
+ return false;
+ }
+ if (!passengers.isEmpty() || entityhuman.isPassenger()) {
+ return false;
+ }
+ if (!hasRidePermission(entityhuman)) {
+ entityhuman.getBukkitEntity().sendMessage("You cannot mount that mob");
+ return false;
+ }
+ return mountTo(entityhuman);
+ }
+
+ public boolean mountTo(EntityHuman entityhuman) {
+ entityhuman.mounting = true;
+ entityhuman.yaw = this.yaw;
+ entityhuman.pitch = this.pitch;
+ if (entityhuman.startRiding(this)) {
+ entityhuman.setJumping(false); // fixes jump on mount
+ return true;
+ }
+ return entityhuman.mounting = false;
+ }
+
+ public boolean onSpacebar() {
+ return false;
+ }
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/server/EntityIronGolem.java b/src/main/java/net/minecraft/server/EntityIronGolem.java
index ae269270..8140fa12 100644
--- a/src/main/java/net/minecraft/server/EntityIronGolem.java
+++ b/src/main/java/net/minecraft/server/EntityIronGolem.java
@@ -14,6 +14,11 @@ public class EntityIronGolem extends EntityGolem {
public EntityIronGolem(World world) {
super(EntityTypes.IRON_GOLEM, world);
this.setSize(1.4F, 2.7F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -190,4 +195,14 @@ public class EntityIronGolem extends EntityGolem {
return iblockdata1.q() && SpawnerCreature.a(iblockdata2, iblockdata2.s()) && SpawnerCreature.a(iblockdata, FluidTypes.EMPTY.i()) && iworldreader.getCubes(this, this.getBoundingBox()) && iworldreader.a_(this, this.getBoundingBox());
}
+
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 4d5459d2..d44ac353 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -90,9 +90,9 @@ public abstract class EntityLiving extends Entity {
protected int be; protected int getKillCount() { return this.be; } // Paper - OBFHELPER
public float lastDamage;
protected boolean bg;
- public float bh;
- public float bi;
- public float bj;
+ public float bh; public float getStrafe() { return bh; } public void setStrafe(float strafe) { bh = strafe; } // Purpur - OBFHELPER
+ public float bi; public float getVertical() { return bi; } public void setVertical(float vertical) { bi = vertical; } // Purpur - OBFHELPER
+ public float bj; public float getForward() { return bj; } public void setForward(float forward) { bj = forward; } // Purpur - OBFHELPER
public float bk;
protected int bl;
protected double bm;
@@ -346,8 +346,16 @@ public abstract class EntityLiving extends Entity {
return false;
}
+ // Purpur start
+ protected boolean canBeRiddenInWater = false;
+
+ public void setCanBeRiddenInWater(boolean canBeRiddenInWater) {
+ this.canBeRiddenInWater = canBeRiddenInWater;
+ }
+
+ public boolean canBeRiddenInWater() { return aY(); }
public boolean aY() {
- return false;
+ return canBeRiddenInWater;
}
protected void cb() {
@@ -1838,6 +1846,7 @@ public abstract class EntityLiving extends Entity {
return 0.42F;
}
+ public void jump() { cH(); } // Purpur - OBFHELPER
protected void cH() {
this.motY = (double) this.cG();
if (this.hasEffect(MobEffects.JUMP)) {
@@ -2082,10 +2091,12 @@ public abstract class EntityLiving extends Entity {
this.aK += this.aJ;
}
+ public float getSpeed() { return cK(); } // Purpur - OBFHELPER
public float cK() {
return this.bI;
}
+ public void setSpeed(float speed) { o(speed); } // Purpur - OBFHELPER
public void o(float f) {
this.bI = f;
}
@@ -2499,6 +2510,7 @@ public abstract class EntityLiving extends Entity {
this.fallDistance = 0.0F;
}
+ public void setJumping(boolean jumping) { o(jumping); } public boolean isJumping() { return bg; } // Purpur - OBFHELPER
public void o(boolean flag) {
this.bg = flag;
}
@@ -2546,6 +2558,7 @@ public abstract class EntityLiving extends Entity {
this.aS = f;
}
+ public void setRenderYawOffset(float renderYawOffset) { k(renderYawOffset); } // Purpur - OBFHELPER
public void k(float f) {
this.aQ = f;
}
diff --git a/src/main/java/net/minecraft/server/EntityLlama.java b/src/main/java/net/minecraft/server/EntityLlama.java
index 82a32c61..12b68665 100644
--- a/src/main/java/net/minecraft/server/EntityLlama.java
+++ b/src/main/java/net/minecraft/server/EntityLlama.java
@@ -18,6 +18,29 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
public EntityLlama(World world) {
super(EntityTypes.LLAMA, world);
this.setSize(0.9F, 1.87F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this) {
+ @Override
+ protected void tick(EntityHuman rider) {
+ if (EntityLlama.this.isSaddled()) {
+ super.tick(rider);
+ } else {
+ super.tick();
+ }
+ }
+ };
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this) {
+ @Override
+ protected void tick(EntityHuman rider) {
+ if (EntityLlama.this.isSaddled()) {
+ super.tick(rider);
+ } else {
+ super.tick();
+ }
+ }
+ };
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
public void setStrength(int i) {
@@ -346,6 +369,18 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
}
}
+ // Purpur start
+ @Override
+ public boolean isLeashed() {
+ return getRider() != null || super.isLeashed();
+ }
+
+ @Override
+ public Entity getLeashHolder() {
+ return getRider() != null ? getRider() : super.getLeashHolder();
+ }
+ // Purpur end
+
public void ek() {
if (this.bQ != null) {
this.bQ.bR = null;
@@ -360,7 +395,7 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
}
public boolean el() {
- return this.bR != null;
+ return getRider() != null || this.bR != null; // Purpur
}
public boolean inCaravan() { return this.em(); } // Paper - OBFHELPER
diff --git a/src/main/java/net/minecraft/server/EntityMushroomCow.java b/src/main/java/net/minecraft/server/EntityMushroomCow.java
index 4a74145b..a7277d84 100644
--- a/src/main/java/net/minecraft/server/EntityMushroomCow.java
+++ b/src/main/java/net/minecraft/server/EntityMushroomCow.java
@@ -14,9 +14,23 @@ public class EntityMushroomCow extends EntityCow {
super(EntityTypes.MOOSHROOM, world);
this.setSize(0.9F, 1.4F);
this.bF = Blocks.MYCELIUM;
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ public boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BOWL && this.getAge() >= 0 && !entityhuman.abilities.canInstantlyBuild) {
diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java
index 13c84bda..bee1532a 100644
--- a/src/main/java/net/minecraft/server/EntityOcelot.java
+++ b/src/main/java/net/minecraft/server/EntityOcelot.java
@@ -15,6 +15,11 @@ public class EntityOcelot extends EntityTameableAnimal {
public EntityOcelot(World world) {
super(EntityTypes.OCELOT, world);
this.setSize(0.6F, 0.7F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -122,6 +127,15 @@ public class EntityOcelot extends EntityTameableAnimal {
}
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return (!isTamed() && isOwner(entityhuman)) || tryRide(entityhuman, enumhand);
+ }
+
+ public boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (this.isTamed()) {
diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java
index d1689dc3..50efffcf 100644
--- a/src/main/java/net/minecraft/server/EntityPig.java
+++ b/src/main/java/net/minecraft/server/EntityPig.java
@@ -19,6 +19,11 @@ public class EntityPig extends EntityAnimal {
public EntityPig(World world) {
super(EntityTypes.PIG, world);
this.setSize(0.9F, 0.9F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -99,6 +104,15 @@ public class EntityPig extends EntityAnimal {
}
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ public boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
if (!super.a(entityhuman, enumhand)) {
ItemStack itemstack = entityhuman.b(enumhand);
@@ -114,6 +128,17 @@ public class EntityPig extends EntityAnimal {
} else if (itemstack.getItem() == Items.SADDLE) {
itemstack.a(entityhuman, (EntityLiving) this, enumhand);
return true;
+ // Purpur start - get saddle back
+ } else if (hasSaddle() && entityhuman.isSneaking() && itemstack.getItem() == Items.AIR) {
+ setSaddle(false);
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ ItemStack saddle = new ItemStack(Items.SADDLE);
+ if (!entityhuman.inventory.pickup(saddle)) {
+ entityhuman.drop(saddle, false);
+ }
+ }
+ return true;
+ // Purpur end
} else {
return false;
}
diff --git a/src/main/java/net/minecraft/server/EntityPolarBear.java b/src/main/java/net/minecraft/server/EntityPolarBear.java
index dbb534c9..77de1a7d 100644
--- a/src/main/java/net/minecraft/server/EntityPolarBear.java
+++ b/src/main/java/net/minecraft/server/EntityPolarBear.java
@@ -15,6 +15,11 @@ public class EntityPolarBear extends EntityAnimal {
public EntityPolarBear(World world) {
super(EntityTypes.POLAR_BEAR, world);
this.setSize(1.3F, 1.4F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
public EntityAgeable createChild(EntityAgeable entityageable) {
@@ -130,6 +135,16 @@ public class EntityPolarBear extends EntityAnimal {
return 0.98F;
}
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
+
public GroupDataEntity prepare(DifficultyDamageScaler difficultydamagescaler, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) {
if (groupdataentity instanceof EntityPolarBear.b) {
if (((EntityPolarBear.b) groupdataentity).a) {
diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java
index c35d1eef..78ce8211 100644
--- a/src/main/java/net/minecraft/server/EntitySheep.java
+++ b/src/main/java/net/minecraft/server/EntitySheep.java
@@ -67,6 +67,11 @@ public class EntitySheep extends EntityAnimal {
public EntitySheep(World world) {
super(EntityTypes.SHEEP, world);
this.setSize(0.9F, 1.3F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -150,6 +155,15 @@ public class EntitySheep extends EntityAnimal {
}
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ public boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java
index ba40e03f..8f30ad66 100644
--- a/src/main/java/net/minecraft/server/EntitySilverfish.java
+++ b/src/main/java/net/minecraft/server/EntitySilverfish.java
@@ -10,6 +10,11 @@ public class EntitySilverfish extends EntityMonster {
public EntitySilverfish(World world) {
super(EntityTypes.SILVERFISH, world);
this.setSize(0.4F, 0.3F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -106,6 +111,16 @@ public class EntitySilverfish extends EntityMonster {
return EnumMonsterType.ARTHROPOD;
}
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
+
static class PathfinderGoalSilverfishHideInBlock extends PathfinderGoalRandomStroll {
private EnumDirection h;
diff --git a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
index 6e2ee04c..f62dfecf 100644
--- a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
+++ b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
@@ -24,6 +24,11 @@ public abstract class EntitySkeletonAbstract extends EntityMonster implements IR
super(entitytypes, world);
this.setSize(0.6F, 1.99F);
this.dz();
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -197,4 +202,14 @@ public abstract class EntitySkeletonAbstract extends EntityMonster implements IR
public void s(boolean flag) {
this.datawatcher.set(EntitySkeletonAbstract.a, flag);
}
+
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java
index 277ef077..0a7c8872 100644
--- a/src/main/java/net/minecraft/server/EntitySnowman.java
+++ b/src/main/java/net/minecraft/server/EntitySnowman.java
@@ -13,6 +13,11 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
public EntitySnowman(World world) {
super(EntityTypes.SNOW_GOLEM, world);
this.setSize(0.7F, 1.9F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -66,6 +71,7 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
return;
}
+ if (getRider() != null) return; // Purpur - don't leave snow trail when being ridden
IBlockData iblockdata = Blocks.SNOW.getBlockData();
for (int l = 0; l < 4; ++l) {
@@ -105,6 +111,15 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
}
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+
+ public boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
if (this.hasPumpkin()) { if (itemstack.getItem() == Items.SHEARS) { // Purpur
diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java
index 9ef1c9ba..8ac330dc 100644
--- a/src/main/java/net/minecraft/server/EntitySpider.java
+++ b/src/main/java/net/minecraft/server/EntitySpider.java
@@ -10,6 +10,11 @@ public class EntitySpider extends EntityMonster {
protected EntitySpider(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
this.setSize(1.4F, 0.9F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
public EntitySpider(World world) {
@@ -106,6 +111,16 @@ public class EntitySpider extends EntityMonster {
this.datawatcher.set(EntitySpider.a, b0);
}
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
+
@Nullable
public GroupDataEntity prepare(DifficultyDamageScaler difficultydamagescaler, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) {
Object object = super.prepare(difficultydamagescaler, groupdataentity, nbttagcompound);
diff --git a/src/main/java/net/minecraft/server/EntityTameableAnimal.java b/src/main/java/net/minecraft/server/EntityTameableAnimal.java
index 5262ede2..d3d4c5df 100644
--- a/src/main/java/net/minecraft/server/EntityTameableAnimal.java
+++ b/src/main/java/net/minecraft/server/EntityTameableAnimal.java
@@ -123,6 +123,12 @@ public abstract class EntityTameableAnimal extends EntityAnimal implements Entit
this.datawatcher.set(EntityTameableAnimal.bD, Optional.ofNullable(uuid));
}
+ // Purpur start
+ public boolean isOwner(EntityHuman entityhuman) {
+ return entityhuman != null && entityhuman.getUniqueID() == getOwnerUUID();
+ }
+ // Purpur end
+
public void c(EntityHuman entityhuman) {
this.setTamed(true);
this.setOwnerUUID(entityhuman.getUniqueID());
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
index 24ca3511..2356b879 100644
--- a/src/main/java/net/minecraft/server/EntityTypes.java
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
@@ -253,6 +253,12 @@ public class EntityTypes<T extends Entity> {
return this.aS;
}
+ // Purpur start
+ public String getName() {
+ return IRegistry.ENTITY_TYPE.getKey(this).getKey();
+ }
+ // Purpur end
+
public String d() {
if (this.aW == null) {
this.aW = SystemUtils.a("entity", IRegistry.ENTITY_TYPE.getKey(this));
diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java
index 46d8e0a1..1edba183 100644
--- a/src/main/java/net/minecraft/server/EntityWolf.java
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
@@ -24,6 +24,11 @@ public class EntityWolf extends EntityTameableAnimal {
super(EntityTypes.WOLF, world);
this.setSize(0.6F, 0.85F);
this.setTamed(false);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
protected void n() {
@@ -245,6 +250,15 @@ public class EntityWolf extends EntityTameableAnimal {
}
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur start - processInteract
+ if (processInteract(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return (!isTamed() && isOwner(entityhuman)) || tryRide(entityhuman, enumhand);
+ }
+
+ public boolean processInteract(EntityHuman entityhuman, EnumHand enumhand) {
+ // Purpur end
ItemStack itemstack = entityhuman.b(enumhand);
Item item = itemstack.getItem();
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
index bf2bed00..8d8ef643 100644
--- a/src/main/java/net/minecraft/server/EntityZombie.java
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
@@ -37,6 +37,11 @@ public class EntityZombie extends EntityMonster {
this.bG = new PathfinderGoalBreakDoor(this);
this.bK = -1.0F;
this.setSize(0.6F, 1.95F);
+ // Purpur start
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
+ this.canBeRiddenInWater = true;
+ // Purpur end
}
public EntityZombie(World world) {
@@ -454,6 +459,16 @@ public class EntityZombie extends EntityMonster {
return itemstack.getItem() == Items.EGG && this.isBaby() && this.isPassenger() ? false : super.d(itemstack);
}
+ // Purpur start - processInteract
+ @Override
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
+ if (super.a(entityhuman, enumhand)) {
+ return true; // vanilla action handled
+ }
+ return tryRide(entityhuman, enumhand);
+ }
+ // Purpur end
+
@Nullable
public GroupDataEntity prepare(DifficultyDamageScaler difficultydamagescaler, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) {
Object object = super.prepare(difficultydamagescaler, groupdataentity, nbttagcompound);
diff --git a/src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java b/src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java
new file mode 100644
index 00000000..851ab80e
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java
@@ -0,0 +1,46 @@
+package net.pl3x.purpur.controller;
+
+import net.minecraft.server.ControllerLook;
+import net.minecraft.server.EntityHuman;
+import net.minecraft.server.EntityInsentient;
+
+public class ControllerLookWASD extends ControllerLook {
+ protected final EntityInsentient entity;
+ private float yawOffset = 0;
+ private float pitchOffset = 0;
+
+ public ControllerLookWASD(EntityInsentient entity) {
+ super(entity);
+ this.entity = entity;
+ }
+
+ // tick
+ @Override
+ public void a() {
+ if (entity.getRider() != null) {
+ tick(entity.getRider());
+ } else {
+ tick();
+ }
+ }
+
+ protected void tick() {
+ super.a(); // tick
+ }
+
+ protected void tick(EntityHuman rider) {
+ setYawPitch(rider.yaw, rider.pitch);
+ }
+
+ public void setYawPitch(float yaw, float pitch) {
+ entity.lastYaw = entity.yaw = (yaw + yawOffset) % 360.0F;
+ entity.setRenderYawOffset(entity.lastYaw);
+ entity.setHeadRotation(entity.lastYaw);
+ entity.pitch = (pitch + pitchOffset) % 360.0F;
+ }
+
+ public void setOffsets(float yaw, float pitch) {
+ yawOffset = yaw;
+ pitchOffset = pitch;
+ }
+}
diff --git a/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java
new file mode 100644
index 00000000..4f7dec9b
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java
@@ -0,0 +1,77 @@
+package net.pl3x.purpur.controller;
+
+import net.minecraft.server.ControllerMove;
+import net.minecraft.server.EntityHuman;
+import net.minecraft.server.EntityInsentient;
+import net.minecraft.server.GenericAttributes;
+
+public class ControllerMoveWASD extends ControllerMove {
+ protected final EntityInsentient entity;
+
+ public ControllerMoveWASD(EntityInsentient entity) {
+ super(entity);
+ this.entity = entity;
+ }
+
+ // isUpdating
+ @Override
+ public boolean b() {
+ return entity.getRider() != null || super.b();
+ }
+
+ // tick
+ @Override
+ public void a() {
+ if (entity.getRider() != null) {
+ tick(entity.getRider());
+ } else {
+ tick();
+ }
+ }
+
+ protected void tick() {
+ super.a(); // tick
+ }
+
+ protected void tick(EntityHuman rider) {
+ float forward = rider.getForward() * 0.5F;
+ float strafe = rider.getStrafe() * 0.25F;
+
+ if (forward <= 0.0F) {
+ forward *= 0.5F;
+ }
+
+ float yaw = rider.yaw;
+ if (strafe != 0) {
+ if (forward == 0) {
+ yaw += strafe > 0 ? -90 : 90;
+ forward = Math.abs(strafe * 2);
+ } else {
+ yaw += strafe > 0 ? -30 : 30;
+ strafe /= 2;
+ if (forward < 0) {
+ yaw += strafe > 0 ? -110 : 110;
+ forward *= -1;
+ }
+ }
+ } else if (forward < 0) {
+ yaw -= 180;
+ forward *= -1;
+ }
+
+ ((ControllerLookWASD) entity.getControllerLook()).setOffsets(yaw - rider.yaw, 0);
+
+ if (rider.isJumping()) {
+ //RidableSpacebarEvent event = new RidableSpacebarEvent(entity);
+ if (/*event.callEvent() && !event.isHandled() &&*/ !entity.onSpacebar() && entity.onGround) {
+ entity.jump();
+ }
+ }
+
+ entity.setSpeed((float) (e = entity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue()));
+ entity.setForward(forward);
+
+ f = entity.getForward();
+ g = entity.getStrafe();
+ }
+}
diff --git a/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDWater.java b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDWater.java
new file mode 100644
index 00000000..74ff4825
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDWater.java
@@ -0,0 +1,42 @@
+package net.pl3x.purpur.controller;
+
+import net.minecraft.server.EntityHuman;
+import net.minecraft.server.EntityInsentient;
+import net.minecraft.server.GenericAttributes;
+
+public class ControllerMoveWASDWater extends ControllerMoveWASD {
+ public ControllerMoveWASDWater(EntityInsentient entity) {
+ super(entity);
+ }
+
+ @Override
+ protected void tick(EntityHuman rider) {
+ float forward = rider.getForward();
+ float strafe = rider.getStrafe() * 0.5F; // strafe slower by default
+ float vertical = -(rider.pitch / 90);
+
+ if (forward == 0.0F) {
+ // strafe slower if not moving forward
+ strafe *= 0.5F;
+ // do not move vertically if not moving forward
+ vertical = 0.0F;
+ } else if (forward < 0.0F) {
+ // water animals can't swim backwards
+ forward = 0.0F;
+ vertical = 0.0F;
+ }
+
+ if (rider.isJumping()) {
+ entity.onSpacebar();
+ }
+
+ entity.setSpeed((float) (e = entity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue()) * 0.1F);
+
+ entity.setForward(forward);
+ entity.setStrafe(strafe);
+ entity.setVertical(vertical);
+
+ f = entity.getForward();
+ g = entity.getStrafe();
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index d6a4bc64..7cfd33a7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -633,4 +633,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return getHandle().isHandRaised();
}
// Paper end
+
+ // Purpur start
+ @Override
+ public boolean canBeRiddenInWater() {
+ return getHandle().canBeRiddenInWater();
+ }
+
+ @Override
+ public void setCanBeRiddenInWater(boolean canBeRiddenInWater) {
+ getHandle().setCanBeRiddenInWater(canBeRiddenInWater);
+ }
+ // Purpur end
}
--
2.20.1