mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
1271 lines
50 KiB
Diff
1271 lines
50 KiB
Diff
From 3ad2b56f69e8fe52b9820dd5366d30389a202651 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
|
|
|
|
---
|
|
.../server/ControllerLookDolphin.java | 4 +-
|
|
.../java/net/minecraft/server/Entity.java | 10 ++-
|
|
.../net/minecraft/server/EntityAgeable.java | 2 +-
|
|
.../net/minecraft/server/EntityChicken.java | 2 +-
|
|
.../net/minecraft/server/EntityDolphin.java | 17 +++-
|
|
.../net/minecraft/server/EntityDrowned.java | 6 +-
|
|
.../net/minecraft/server/EntityEndermite.java | 2 +-
|
|
.../java/net/minecraft/server/EntityFish.java | 20 +++--
|
|
.../minecraft/server/EntityGiantZombie.java | 1 +
|
|
.../net/minecraft/server/EntityGuardian.java | 26 +++++--
|
|
.../net/minecraft/server/EntityHorse.java | 2 +-
|
|
.../minecraft/server/EntityHorseAbstract.java | 4 +-
|
|
.../server/EntityHorseChestedAbstract.java | 10 ++-
|
|
.../minecraft/server/EntityHorseSkeleton.java | 6 +-
|
|
.../minecraft/server/EntityHorseZombie.java | 6 +-
|
|
.../net/minecraft/server/EntityHuman.java | 14 +++-
|
|
.../minecraft/server/EntityInsentient.java | 54 ++++++++++++-
|
|
.../net/minecraft/server/EntityLiving.java | 24 ++++--
|
|
.../net/minecraft/server/EntityLlama.java | 36 ++++++++-
|
|
.../net/minecraft/server/EntityPhantom.java | 31 ++++++--
|
|
.../java/net/minecraft/server/EntityPig.java | 33 ++++----
|
|
.../net/minecraft/server/EntityRabbit.java | 2 +-
|
|
.../net/minecraft/server/EntitySlime.java | 2 +-
|
|
.../net/minecraft/server/EntitySnowman.java | 1 +
|
|
.../net/minecraft/server/EntitySquid.java | 46 +++++++++++
|
|
.../server/EntityTameableAnimal.java | 6 ++
|
|
.../net/minecraft/server/EntityTypes.java | 4 +
|
|
.../purpur/controller/ControllerLookWASD.java | 74 ++++++++++++++++++
|
|
.../purpur/controller/ControllerMoveWASD.java | 77 +++++++++++++++++++
|
|
.../controller/ControllerMoveWASDFlying.java | 58 ++++++++++++++
|
|
.../controller/ControllerMoveWASDWater.java | 42 ++++++++++
|
|
.../craftbukkit/entity/CraftLivingEntity.java | 10 +++
|
|
32 files changed, 560 insertions(+), 72 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/ControllerMoveWASDFlying.java
|
|
create mode 100644 src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDWater.java
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ControllerLookDolphin.java b/src/main/java/net/minecraft/server/ControllerLookDolphin.java
|
|
index 454627f65..df3d6cf28 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;
|
|
|
|
@@ -10,7 +10,7 @@ public class ControllerLookDolphin extends ControllerLook {
|
|
}
|
|
|
|
@Override
|
|
- public void a() {
|
|
+ public void tick() { // Purpur
|
|
if (this.d) {
|
|
this.d = false;
|
|
this.a.aM = this.a(this.a.aM, this.h() + 20.0F, this.b);
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 74f00b376..777e6ee3c 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -78,6 +78,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
protected CraftEntity bukkitEntity;
|
|
|
|
PlayerChunkMap.EntityTracker tracker; // Paper
|
|
+ public PlayerChunkMap.EntityTracker getTracker() { return tracker; } // Purpur
|
|
Throwable addedToWorldStack; // Paper - entity debug
|
|
public CraftEntity getBukkitEntity() {
|
|
if (bukkitEntity == null) {
|
|
@@ -101,6 +102,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
private int id;
|
|
public boolean i; public final boolean blocksEntitySpawning() { return this.i; } // Paper - OBFHELPER
|
|
public final List<Entity> passengers;
|
|
+ private EntityHuman rider; public EntityHuman getRider() { return rider; } // Purpur
|
|
protected int j;
|
|
private Entity vehicle;
|
|
public boolean attachedToPlayer;
|
|
@@ -134,7 +136,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
public double H;
|
|
public double I;
|
|
public double J;
|
|
- public float K;
|
|
+ public float K; public float getStepHeight() { return K; } public void setStepHeight(float stepHeight) { this.K = stepHeight; } // Purpur - OBFHELPER
|
|
public boolean noclip;
|
|
public float M;
|
|
protected final Random random;
|
|
@@ -2067,6 +2069,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
// Spigot end
|
|
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) {
|
|
this.passengers.add(0, entity);
|
|
+ this.rider = (EntityHuman) entity; // Purpur
|
|
} else {
|
|
this.passengers.add(entity);
|
|
}
|
|
@@ -2105,6 +2108,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.j = 60;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityAgeable.java b/src/main/java/net/minecraft/server/EntityAgeable.java
|
|
index e87754ef3..553245ebe 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityAgeable.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityAgeable.java
|
|
@@ -70,7 +70,7 @@ public abstract class EntityAgeable extends EntityCreature {
|
|
|
|
return true;
|
|
} else {
|
|
- return false;
|
|
+ return super.a(entityhuman, enumhand); // Purpur
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityChicken.java b/src/main/java/net/minecraft/server/EntityChicken.java
|
|
index a374c3051..9af1c2a09 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityChicken.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityChicken.java
|
|
@@ -65,7 +65,7 @@ public class EntityChicken extends EntityAnimal {
|
|
}
|
|
|
|
this.bz += this.bE * 2.0F;
|
|
- if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 0) {
|
|
+ if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 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);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityDolphin.java b/src/main/java/net/minecraft/server/EntityDolphin.java
|
|
index d1f3f7f43..2558e1e01 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityDolphin.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityDolphin.java
|
|
@@ -524,7 +524,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;
|
|
|
|
@@ -533,8 +533,21 @@ public class EntityDolphin extends EntityWaterAnimal {
|
|
this.i = entitydolphin;
|
|
}
|
|
|
|
+ // Purpur start
|
|
@Override
|
|
- public void a() {
|
|
+ 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.setMot(this.i.getMot().add(0.0D, 0.005D, 0.0D));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void tick() {
|
|
+ // Purpur end
|
|
if (this.i.isInWater()) {
|
|
this.i.setMot(this.i.getMot().add(0.0D, 0.005D, 0.0D));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityDrowned.java b/src/main/java/net/minecraft/server/EntityDrowned.java
|
|
index 817769764..f949c75d4 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityDrowned.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityDrowned.java
|
|
@@ -205,7 +205,7 @@ public class EntityDrowned extends EntityZombie implements IRangedEntity {
|
|
this.bz = flag;
|
|
}
|
|
|
|
- static class d extends ControllerMove {
|
|
+ static class d extends net.pl3x.purpur.controller.ControllerMoveWASD { // Purpur
|
|
|
|
private final EntityDrowned i;
|
|
|
|
@@ -215,7 +215,7 @@ public class EntityDrowned extends EntityZombie implements IRangedEntity {
|
|
}
|
|
|
|
@Override
|
|
- public void a() {
|
|
+ public void tick() { // Purpur
|
|
EntityLiving entityliving = this.i.getGoalTarget();
|
|
|
|
if (this.i.eg() && this.i.isInWater()) {
|
|
@@ -248,7 +248,7 @@ public class EntityDrowned extends EntityZombie implements IRangedEntity {
|
|
this.i.setMot(this.i.getMot().add(0.0D, -0.008D, 0.0D));
|
|
}
|
|
|
|
- super.a();
|
|
+ super.tick(); // Purpur
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityEndermite.java b/src/main/java/net/minecraft/server/EntityEndermite.java
|
|
index 10b0f9653..9425a7998 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityEndermite.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityEndermite.java
|
|
@@ -18,7 +18,7 @@ public class EntityEndermite extends EntityMonster {
|
|
this.goalSelector.a(3, new PathfinderGoalRandomStrollLand(this, 1.0D));
|
|
this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
|
|
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
|
|
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
|
|
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // Purpur - decompile error?
|
|
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java
|
|
index a28fbdf1e..36229a2c4 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFish.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFish.java
|
|
@@ -75,11 +75,7 @@ public abstract class EntityFish extends EntityWaterAnimal {
|
|
protected void initPathfinder() {
|
|
super.initPathfinder();
|
|
this.goalSelector.a(0, new PathfinderGoalPanic(this, 1.25D));
|
|
- PathfinderGoalSelector pathfindergoalselector = this.goalSelector;
|
|
- Predicate predicate = IEntitySelector.f;
|
|
-
|
|
- predicate.getClass();
|
|
- pathfindergoalselector.a(2, new PathfinderGoalAvoidTarget<>(this, EntityHuman.class, 8.0F, 1.6D, 1.4D, predicate::test));
|
|
+ this.goalSelector.a(2, new PathfinderGoalAvoidTarget<>(this, EntityHuman.class, 8.0F, 1.6D, 1.4D, IEntitySelector.f::test)); // Purpur - decompile error?
|
|
this.goalSelector.a(4, new EntityFish.b(this));
|
|
}
|
|
|
|
@@ -91,7 +87,7 @@ public abstract class EntityFish extends EntityWaterAnimal {
|
|
@Override
|
|
public void e(Vec3D vec3d) {
|
|
if (this.de() && this.isInWater()) {
|
|
- this.a(0.01F, vec3d);
|
|
+ this.a(getRider() == null ? 0.1F : getSpeed(), vec3d); // Purpur
|
|
this.move(EnumMoveType.SELF, this.getMot());
|
|
this.setMot(this.getMot().a(0.9D));
|
|
if (this.getGoalTarget() == null) {
|
|
@@ -162,7 +158,7 @@ public abstract class EntityFish extends EntityWaterAnimal {
|
|
return SoundEffects.ENTITY_FISH_SWIM;
|
|
}
|
|
|
|
- static class a extends ControllerMove {
|
|
+ static class a extends net.pl3x.purpur.controller.ControllerMoveWASDWater { // Purpur
|
|
|
|
private final EntityFish i;
|
|
|
|
@@ -171,8 +167,16 @@ public abstract class EntityFish extends EntityWaterAnimal {
|
|
this.i = entityfish;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ public void tick(EntityHuman rider) {
|
|
+ super.tick(rider);
|
|
+ this.i.setMot(this.i.getMot().add(0.0D, 0.005D, 0.0D));
|
|
+ }
|
|
+
|
|
@Override
|
|
- public void a() {
|
|
+ public void tick() {
|
|
+ // Purpur end
|
|
if (this.i.a(TagsFluid.WATER)) {
|
|
this.i.setMot(this.i.getMot().add(0.0D, 0.005D, 0.0D));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
index bcbade19e..19b8312f2 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
@@ -6,6 +6,7 @@ public class EntityGiantZombie extends EntityMonster {
|
|
super(entitytypes, world);
|
|
// Purpur start
|
|
this.safeFallDistance = 10.0F;
|
|
+ setStepHeight(2.0F);
|
|
// Purpur end
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityGuardian.java b/src/main/java/net/minecraft/server/EntityGuardian.java
|
|
index 335416d96..6599bce9a 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityGuardian.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityGuardian.java
|
|
@@ -22,8 +22,14 @@ public class EntityGuardian extends EntityMonster {
|
|
super(entitytypes, world);
|
|
this.f = 10;
|
|
this.moveController = new EntityGuardian.ControllerMoveGuardian(this);
|
|
- this.c = this.random.nextFloat();
|
|
- this.d = this.c;
|
|
+ // 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);
|
|
+ }
|
|
+ };
|
|
+ // Purpur end
|
|
}
|
|
|
|
@Override
|
|
@@ -77,6 +83,7 @@ public class EntityGuardian extends EntityMonster {
|
|
return (Boolean) this.datawatcher.get(EntityGuardian.b);
|
|
}
|
|
|
|
+ private void setMovingFlag(boolean movingFlag) { r(movingFlag); } // Purpur - OBFHELPER
|
|
private void r(boolean flag) {
|
|
this.datawatcher.set(EntityGuardian.b, flag);
|
|
}
|
|
@@ -302,7 +309,7 @@ public class EntityGuardian extends EntityMonster {
|
|
@Override
|
|
public void e(Vec3D vec3d) {
|
|
if (this.de() && this.isInWater()) {
|
|
- this.a(0.1F, vec3d);
|
|
+ this.a(getRider() == null ? 0.1F : getSpeed(), vec3d); // Purpur
|
|
this.move(EnumMoveType.SELF, this.getMot());
|
|
this.setMot(this.getMot().a(0.9D));
|
|
if (!this.dY() && this.getGoalTarget() == null) {
|
|
@@ -314,7 +321,7 @@ public class EntityGuardian extends EntityMonster {
|
|
|
|
}
|
|
|
|
- static class ControllerMoveGuardian extends ControllerMove {
|
|
+ static class ControllerMoveGuardian extends net.pl3x.purpur.controller.ControllerMoveWASDWater { // Purpur
|
|
|
|
private final EntityGuardian i;
|
|
|
|
@@ -324,7 +331,16 @@ public class EntityGuardian extends EntityMonster {
|
|
}
|
|
|
|
@Override
|
|
- public void a() {
|
|
+ // Purpur start
|
|
+ public void tick(EntityHuman rider) {
|
|
+ super.tick(rider);
|
|
+ this.i.setMot(this.i.getMot().add(0.0D, 0.005D, 0.0D));
|
|
+ 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().n()) {
|
|
Vec3D vec3d = new Vec3D(this.b - this.i.locX, this.c - this.i.locY, this.d - this.i.locZ);
|
|
double d0 = vec3d.f();
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java
|
|
index 401f00561..d689e1173 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHorse.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
|
|
@@ -201,7 +201,7 @@ public class EntityHorse extends EntityHorseAbstract {
|
|
}
|
|
}
|
|
|
|
- if (this.isBaby()) {
|
|
+ if (false && this.isBaby()) { // Purpur - allow riding babies
|
|
return super.a(entityhuman, enumhand);
|
|
} else {
|
|
this.g(entityhuman);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHorseAbstract.java b/src/main/java/net/minecraft/server/EntityHorseAbstract.java
|
|
index 686bca4f2..3cc908955 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHorseAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHorseAbstract.java
|
|
@@ -81,7 +81,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven
|
|
}
|
|
|
|
public boolean isTamed() {
|
|
- return this.r(2);
|
|
+ return this.r(2) || isBaby(); // Purpur - allow riding babies
|
|
}
|
|
|
|
@Nullable
|
|
@@ -280,6 +280,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven
|
|
return true;
|
|
}
|
|
|
|
+ public boolean isSaddled() { return eq(); } // Purpur - OBFHELPER
|
|
public boolean eq() {
|
|
return this.r(4);
|
|
}
|
|
@@ -600,6 +601,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven
|
|
|
|
}
|
|
|
|
+ public void makeMad() { eu(); } // Purpur - OBFHELPER
|
|
public void eu() {
|
|
this.eB();
|
|
SoundEffect soundeffect = this.getSoundAngry();
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
|
|
index e61d8f07d..17819fc92 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
|
|
@@ -152,8 +152,12 @@ public abstract class EntityHorseChestedAbstract extends EntityHorseAbstract {
|
|
return true;
|
|
}
|
|
|
|
- this.eu();
|
|
- 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()) {
|
|
@@ -178,7 +182,7 @@ public abstract class EntityHorseChestedAbstract extends EntityHorseAbstract {
|
|
}
|
|
}
|
|
|
|
- if (this.isBaby()) {
|
|
+ if (false && this.isBaby()) { // Purpur - allow riding babies
|
|
return super.a(entityhuman, enumhand);
|
|
} else {
|
|
this.g(entityhuman);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHorseSkeleton.java b/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
|
|
index b96726456..b60bb4d17 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
|
|
@@ -156,16 +156,16 @@ public class EntityHorseSkeleton extends EntityHorseAbstract {
|
|
return super.a(entityhuman, enumhand);
|
|
} else if (!this.isTamed()) {
|
|
return false;
|
|
- } else if (this.isBaby()) {
|
|
+ } else if (false && this.isBaby()) { // Purpur - allow riding babies
|
|
return super.a(entityhuman, enumhand);
|
|
- } else if (entityhuman.isSneaking()) {
|
|
+ } else if (!this.isBaby() && entityhuman.isSneaking()) { // Purpur - don't open inventory on babies
|
|
this.e(entityhuman);
|
|
return true;
|
|
} else if (this.isVehicle()) {
|
|
return super.a(entityhuman, enumhand);
|
|
} else {
|
|
if (!itemstack.isEmpty()) {
|
|
- if (itemstack.getItem() == Items.SADDLE && !this.eq()) {
|
|
+ if (!this.isBaby() && itemstack.getItem() == Items.SADDLE && !this.isSaddled()) { // Purpur - don't open inventory on babies
|
|
this.e(entityhuman);
|
|
return true;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHorseZombie.java b/src/main/java/net/minecraft/server/EntityHorseZombie.java
|
|
index 1160929e1..d94063885 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHorseZombie.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHorseZombie.java
|
|
@@ -53,16 +53,16 @@ public class EntityHorseZombie extends EntityHorseAbstract {
|
|
return super.a(entityhuman, enumhand);
|
|
} else if (!this.isTamed()) {
|
|
return false;
|
|
- } else if (this.isBaby()) {
|
|
+ } else if (false && this.isBaby()) { // Purpur - allow riding babies
|
|
return super.a(entityhuman, enumhand);
|
|
- } else if (entityhuman.isSneaking()) {
|
|
+ } else if (!this.isBaby() && entityhuman.isSneaking()) { // Purpur - don't open inventory on babies
|
|
this.e(entityhuman);
|
|
return true;
|
|
} else if (this.isVehicle()) {
|
|
return super.a(entityhuman, enumhand);
|
|
} else {
|
|
if (!itemstack.isEmpty()) {
|
|
- if (!this.eq() && itemstack.getItem() == Items.SADDLE) {
|
|
+ if (!this.isBaby() && itemstack.getItem() == Items.SADDLE && !this.isSaddled()) { // Purpur - don't open inventory on babies
|
|
this.e(entityhuman);
|
|
return true;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index 4bea5f1ea..ac13282a1 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -347,9 +347,21 @@ 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
|
|
+
|
|
@Override
|
|
public void passengerTick() {
|
|
- 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 5cc08ca7c..ca4e9d0dd 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
@@ -63,8 +63,11 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
this.bL = -1.0F;
|
|
this.goalSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null);
|
|
this.targetSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null);
|
|
- this.lookController = new ControllerLook(this);
|
|
- this.moveController = new ControllerMove(this);
|
|
+ // 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
|
|
this.bt = new ControllerJump(this);
|
|
this.c = this.o();
|
|
this.navigation = this.b(world);
|
|
@@ -492,6 +495,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
this.bb = f;
|
|
}
|
|
|
|
+ public void setSpeed(float speed) { o(speed); } // Purpur - OBFHELPER
|
|
@Override
|
|
public void o(float f) {
|
|
super.o(f);
|
|
@@ -1057,7 +1061,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
}
|
|
|
|
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
|
- return false;
|
|
+ return tryRide(entityhuman, enumhand); // Purpur
|
|
}
|
|
|
|
public boolean dH() {
|
|
@@ -1355,4 +1359,48 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
public boolean a(Item item) {
|
|
return this.getItemInMainHand().getItem() == item || this.getItemInOffHand().getItem() == item;
|
|
}
|
|
+
|
|
+ // 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 (this instanceof EntityTameableAnimal) {
|
|
+ EntityTameableAnimal tameable = (EntityTameableAnimal) this;
|
|
+ if (tameable.isTamed() && !tameable.isOwner(entityhuman)) {
|
|
+ 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/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 0cb8c6cbc..27375059f 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -87,10 +87,10 @@ public abstract class EntityLiving extends Entity {
|
|
protected float aX;
|
|
protected int aY; protected int getKillCount() { return this.aY; } // Paper - OBFHELPER
|
|
public float lastDamage;
|
|
- protected boolean jumping;
|
|
- public float bb;
|
|
- public float bc;
|
|
- public float bd;
|
|
+ protected boolean jumping; public boolean isJumping() { return jumping; } // Purpur - OBFHELPER
|
|
+ public float bb; public float getStrafe() { return bb; } public void setStrafe(float strafe) { bb = strafe; } // Purpur - OBFHELPER
|
|
+ public float bc; public float getVertical() { return bc; } public void setVertical(float vertical) { bc = vertical; } // Purpur - OBFHELPER
|
|
+ public float bd; public float getForward() { return bd; } public void setForward(float forward) { bd = forward; } // Purpur - OBFHELPER
|
|
public float be;
|
|
protected int bf;
|
|
protected double bg;
|
|
@@ -369,9 +369,18 @@ public abstract class EntityLiving extends Entity {
|
|
return this.isBaby() ? 0.5F : 1.0F;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ protected boolean canBeRiddenInWater = false;
|
|
+
|
|
+ public void setCanBeRiddenInWater(boolean canBeRiddenInWater) {
|
|
+ this.canBeRiddenInWater = canBeRiddenInWater;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
+ public boolean canBeRiddenInWater() { return be(); } // Purpur - OBFHELPER
|
|
@Override
|
|
public boolean be() {
|
|
- return false;
|
|
+ return canBeRiddenInWater; // Purpur
|
|
}
|
|
|
|
protected void cn() {
|
|
@@ -2027,7 +2036,7 @@ public abstract class EntityLiving extends Entity {
|
|
return 0.42F;
|
|
}
|
|
|
|
- protected void jump() {
|
|
+ public void jump() { // Purpur - protected -> public
|
|
float f;
|
|
|
|
if (this.hasEffect(MobEffects.JUMP)) {
|
|
@@ -2256,10 +2265,12 @@ public abstract class EntityLiving extends Entity {
|
|
return this.onGround ? this.da() * (0.21600002F / (f * f * f)) : this.aO;
|
|
}
|
|
|
|
+ public float getSpeed() { return da(); } // Purpur - OBFHELPER
|
|
public float da() {
|
|
return this.bD;
|
|
}
|
|
|
|
+ public void setSpeed(float speed) { o(speed); } // Purpur - OBFHELPER
|
|
public void o(float f) {
|
|
this.bD = f;
|
|
}
|
|
@@ -2735,6 +2746,7 @@ public abstract class EntityLiving extends Entity {
|
|
this.aM = f;
|
|
}
|
|
|
|
+ public void setRenderYawOffset(float renderYawOffset) { l(renderYawOffset); } // Purpur - OBFHELPER
|
|
@Override
|
|
public void l(float f) {
|
|
this.aK = f;
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLlama.java b/src/main/java/net/minecraft/server/EntityLlama.java
|
|
index f8a8da637..cfb80b34c 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLlama.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLlama.java
|
|
@@ -16,6 +16,28 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
|
|
|
|
public EntityLlama(EntityTypes<? extends EntityLlama> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
+ // 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();
|
|
+ }
|
|
+ }
|
|
+ };
|
|
+ // Purpur end
|
|
}
|
|
|
|
public void setStrength(int i) {
|
|
@@ -371,6 +393,18 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
|
|
}
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ public boolean isLeashed() {
|
|
+ return (getRider() != null && isSaddled()) || super.isLeashed();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Entity getLeashHolder() {
|
|
+ return (getRider() != null && isSaddled()) ? getRider() : super.getLeashHolder();
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public void eG() {
|
|
if (this.bN != null) {
|
|
this.bN.bO = null;
|
|
@@ -385,7 +419,7 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
|
|
}
|
|
|
|
public boolean eH() {
|
|
- return this.bO != null;
|
|
+ return (getRider() != null && isSaddled()) || this.bO != null; // Purpur
|
|
}
|
|
|
|
public boolean eI() {
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
index 6aa116f4b..033d8e05a 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
@@ -22,6 +22,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
this.f = 5;
|
|
this.moveController = new EntityPhantom.g(this);
|
|
this.lookController = new EntityPhantom.f(this);
|
|
+ this.canBeRiddenInWater = false; // Purpur
|
|
}
|
|
|
|
@Override
|
|
@@ -106,7 +107,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
|
|
@Override
|
|
public void movementTick() {
|
|
- if (this.isAlive() && this.dS()) {
|
|
+ if (this.isAlive() && getRider() == null && this.isInDaylight()) { // Purpur - do not set fire if being ridden
|
|
this.setOnFire(8);
|
|
}
|
|
|
|
@@ -605,14 +606,23 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
}
|
|
|
|
- class f extends ControllerLook {
|
|
+ class f extends net.pl3x.purpur.controller.ControllerLookWASD { // Purpur
|
|
|
|
public f(EntityInsentient entityinsentient) {
|
|
super(entityinsentient);
|
|
}
|
|
|
|
@Override
|
|
- public void a() {}
|
|
+ // Purpur start
|
|
+ public void tick(EntityHuman rider) {
|
|
+ setYawPitch(rider.yaw, -rider.pitch * 0.75F);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void tick() {
|
|
+ // do nothing
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
|
|
class d extends EntityAIBodyControl {
|
|
@@ -628,7 +638,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
}
|
|
|
|
- class g extends ControllerMove {
|
|
+ class g extends net.pl3x.purpur.controller.ControllerMoveWASDFlying { // Purpur
|
|
|
|
private float j = 0.1F;
|
|
|
|
@@ -636,8 +646,19 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
super(entityinsentient);
|
|
}
|
|
|
|
+ // Purpur start
|
|
@Override
|
|
- public void a() {
|
|
+ public void tick(EntityHuman rider) {
|
|
+ if (!EntityPhantom.this.onGround) {
|
|
+ // phantom is always in motion when flying
|
|
+ // TODO - FIX THIS - rider.setForward(1.0F);
|
|
+ }
|
|
+ super.tick(rider);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void tick() {
|
|
+ // Purpur end
|
|
if (EntityPhantom.this.positionChanged) {
|
|
EntityPhantom.this.yaw += 180.0F;
|
|
this.j = 0.1F;
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java
|
|
index 616075569..e51054b23 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPig.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPig.java
|
|
@@ -111,27 +111,22 @@ public class EntityPig extends EntityAnimal {
|
|
|
|
@Override
|
|
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
|
- if (!super.a(entityhuman, enumhand)) {
|
|
- ItemStack itemstack = entityhuman.b(enumhand);
|
|
-
|
|
- if (itemstack.getItem() == Items.NAME_TAG) {
|
|
- itemstack.a(entityhuman, (EntityLiving) this, enumhand);
|
|
- return true;
|
|
- } else if (this.hasSaddle() && !this.isVehicle()) {
|
|
- if (!this.world.isClientSide) {
|
|
- entityhuman.startRiding(this);
|
|
- }
|
|
-
|
|
- return true;
|
|
- } else if (itemstack.getItem() == Items.SADDLE) {
|
|
- itemstack.a(entityhuman, (EntityLiving) this, enumhand);
|
|
- return true;
|
|
- } else {
|
|
- return false;
|
|
- }
|
|
- } else {
|
|
+ // Purpur start - reorder logic so super is last (so tryRide is last)
|
|
+ ItemStack itemstack = entityhuman.b(enumhand);
|
|
+ if (itemstack.getItem() == Items.NAME_TAG) {
|
|
+ itemstack.a(entityhuman, this, enumhand);
|
|
+ return true;
|
|
+ }
|
|
+ if (hasSaddle() && !isVehicle()) {
|
|
+ entityhuman.startRiding(this);
|
|
+ return true;
|
|
+ }
|
|
+ if (itemstack.getItem() == Items.SADDLE) {
|
|
+ itemstack.a(entityhuman, this, enumhand);
|
|
return true;
|
|
}
|
|
+ return super.a(entityhuman, enumhand);
|
|
+ // Purpur end
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/server/EntityRabbit.java b/src/main/java/net/minecraft/server/EntityRabbit.java
|
|
index f6fa87158..bd0679e74 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityRabbit.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityRabbit.java
|
|
@@ -59,7 +59,7 @@ public class EntityRabbit extends EntityAnimal {
|
|
}
|
|
|
|
@Override
|
|
- protected void jump() {
|
|
+ public void jump() { // Purpur - protected -> public
|
|
super.jump();
|
|
double d0 = this.moveController.c();
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
|
|
index e28c0673d..f88cd9e94 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySlime.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
|
|
@@ -316,7 +316,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
}
|
|
|
|
@Override
|
|
- protected void jump() {
|
|
+ public void jump() { // Purpur - protected -> public
|
|
Vec3D vec3d = this.getMot();
|
|
|
|
this.setMot(vec3d.x, 0.41999998688697815D, vec3d.z);
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
index c13dfc6cc..fca5fde34 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
@@ -74,6 +74,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) {
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java
|
|
index 77c0ed42f..a7434fbe1 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySquid.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySquid.java
|
|
@@ -174,6 +174,7 @@ public class EntitySquid extends EntityWaterAnimal {
|
|
return this.locY > this.world.spigotConfig.squidSpawnRangeMin && this.locY < maxHeight; // Spigot // Paper
|
|
}
|
|
|
|
+ public void setMovementVector(float x, float y, float z) { a(x, y, z); } // Purpur - OBFHELPER
|
|
public void a(float f, float f1, float f2) {
|
|
this.bH = f;
|
|
this.bI = f1;
|
|
@@ -258,6 +259,39 @@ public class EntitySquid extends EntityWaterAnimal {
|
|
|
|
@Override
|
|
public void e() {
|
|
+ // Purpur start
|
|
+ EntityHuman rider = this.b.getRider();
|
|
+ if (rider != null) {
|
|
+ EntitySquid squid = this.b;
|
|
+ if (rider.isJumping()) {
|
|
+ squid.onSpacebar();
|
|
+ }
|
|
+ float forward = rider.getForward();
|
|
+ float strafe = rider.getStrafe();
|
|
+ float speed = (float) squid.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue() * 5F;
|
|
+ if (forward < 0.0F) {
|
|
+ speed *= -0.5;
|
|
+ }
|
|
+ org.bukkit.util.Vector dir = rider.getBukkitEntity().getEyeLocation().getDirection().normalize().multiply(speed / 20.0F);
|
|
+ if (strafe != 0.0F) {
|
|
+ if (forward == 0.0F) {
|
|
+ dir.setY(0);
|
|
+ rotateVectorAroundY(dir, strafe > 0.0F ? -90 : 90);
|
|
+ } else if (forward < 0.0F) {
|
|
+ rotateVectorAroundY(dir, strafe > 0.0F ? 45 : -45);
|
|
+ } else {
|
|
+ rotateVectorAroundY(dir, strafe > 0.0F ? -45 : 45);
|
|
+ }
|
|
+ }
|
|
+ if (forward != 0.0F || strafe != 0.0F) {
|
|
+ squid.setMovementVector((float) dir.getX(), (float) dir.getY(), (float) dir.getZ());
|
|
+ } else {
|
|
+ squid.setMovementVector(0.0F, 0.0F, 0.0F);
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
int i = this.b.cv();
|
|
|
|
if (i > 100) {
|
|
@@ -272,5 +306,17 @@ public class EntitySquid extends EntityWaterAnimal {
|
|
}
|
|
|
|
}
|
|
+
|
|
+ // Purpur start
|
|
+ private void rotateVectorAroundY(org.bukkit.util.Vector vector, double degrees) {
|
|
+ double rad = Math.toRadians(degrees);
|
|
+ double cos = Math.cos(rad);
|
|
+ double sine = Math.sin(rad);
|
|
+ double x = vector.getX();
|
|
+ double z = vector.getZ();
|
|
+ vector.setX(cos * x - sine * z);
|
|
+ vector.setZ(sine * x + cos * z);
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTameableAnimal.java b/src/main/java/net/minecraft/server/EntityTameableAnimal.java
|
|
index 70bf06b94..2f41d8ade 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTameableAnimal.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTameableAnimal.java
|
|
@@ -127,6 +127,12 @@ public abstract class EntityTameableAnimal extends EntityAnimal {
|
|
this.datawatcher.set(EntityTameableAnimal.bA, Optional.ofNullable(uuid));
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public boolean isOwner(EntityHuman entityhuman) {
|
|
+ return entityhuman != null && entityhuman.getUniqueID() == getOwnerUUID();
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public void tame(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 fb0c6bce0..4979f77b7 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
@@ -262,6 +262,10 @@ public class EntityTypes<T extends Entity> {
|
|
}
|
|
|
|
// Purpur start
|
|
+ public String getName() {
|
|
+ return IRegistry.ENTITY_TYPE.getKey(this).getKey();
|
|
+ }
|
|
+
|
|
public String getTranslatedName() {
|
|
return getNameComponent().getString();
|
|
}
|
|
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 000000000..99e184d36
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java
|
|
@@ -0,0 +1,74 @@
|
|
+package net.pl3x.purpur.controller;
|
|
+
|
|
+import net.minecraft.server.ControllerLook;
|
|
+import net.minecraft.server.EntityHuman;
|
|
+import net.minecraft.server.EntityInsentient;
|
|
+import net.minecraft.server.MathHelper;
|
|
+import net.minecraft.server.PacketPlayOutEntity;
|
|
+
|
|
+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.yaw = normalizeYaw(yaw + yawOffset);
|
|
+ entity.lastYaw = entity.yaw;
|
|
+ entity.setRenderYawOffset(entity.yaw);
|
|
+ entity.setHeadRotation(entity.yaw);
|
|
+ entity.pitch = normalizePitch(pitch + pitchOffset);
|
|
+
|
|
+ entity.getTracker().broadcast(new PacketPlayOutEntity
|
|
+ .PacketPlayOutEntityLook(entity.getId(),
|
|
+ (byte) MathHelper.d(entity.yaw * 256.0F / 360.0F),
|
|
+ (byte) MathHelper.d(entity.pitch * 256.0F / 360.0F),
|
|
+ entity.onGround));
|
|
+ }
|
|
+
|
|
+ public void setOffsets(float yaw, float pitch) {
|
|
+ yawOffset = yaw;
|
|
+ pitchOffset = pitch;
|
|
+ }
|
|
+
|
|
+ public float normalizeYaw(float yaw) {
|
|
+ yaw %= 360.0f;
|
|
+ if (yaw >= 180.0f) {
|
|
+ yaw -= 360.0f;
|
|
+ } else if (yaw < -180.0f) {
|
|
+ yaw += 360.0f;
|
|
+ }
|
|
+ return yaw;
|
|
+ }
|
|
+
|
|
+ public float normalizePitch(float pitch) {
|
|
+ if (pitch > 90.0f) {
|
|
+ pitch = 90.0f;
|
|
+ } else if (pitch < -90.0f) {
|
|
+ pitch = -90.0f;
|
|
+ }
|
|
+ return 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 000000000..d64a66274
|
|
--- /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 yawOffset = 0;
|
|
+ if (strafe != 0) {
|
|
+ if (forward == 0) {
|
|
+ yawOffset += strafe > 0 ? -90 : 90;
|
|
+ forward = Math.abs(strafe * 2);
|
|
+ } else {
|
|
+ yawOffset += strafe > 0 ? -30 : 30;
|
|
+ strafe /= 2;
|
|
+ if (forward < 0) {
|
|
+ yawOffset += strafe > 0 ? -110 : 110;
|
|
+ forward *= -1;
|
|
+ }
|
|
+ }
|
|
+ } else if (forward < 0) {
|
|
+ yawOffset -= 180;
|
|
+ forward *= -1;
|
|
+ }
|
|
+
|
|
+ ((ControllerLookWASD) entity.getControllerLook()).setOffsets(yawOffset, 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/ControllerMoveWASDFlying.java b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDFlying.java
|
|
new file mode 100644
|
|
index 000000000..1a5a0c04c
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDFlying.java
|
|
@@ -0,0 +1,58 @@
|
|
+package net.pl3x.purpur.controller;
|
|
+
|
|
+import net.minecraft.server.EntityHuman;
|
|
+import net.minecraft.server.EntityInsentient;
|
|
+import net.minecraft.server.GenericAttributes;
|
|
+
|
|
+public class ControllerMoveWASDFlying extends ControllerMoveWASD {
|
|
+ protected final float groundSpeedModifier;
|
|
+ private final double maxY;
|
|
+ private int tooHighCooldown = 0;
|
|
+
|
|
+ public ControllerMoveWASDFlying(EntityInsentient entity) {
|
|
+ this(entity, 1.0F, 256D);
|
|
+ }
|
|
+
|
|
+ public ControllerMoveWASDFlying(EntityInsentient entity, float groundSpeedModifier, double maxY) {
|
|
+ super(entity);
|
|
+ this.groundSpeedModifier = groundSpeedModifier;
|
|
+ this.maxY = maxY;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void tick(EntityHuman rider) {
|
|
+ float forward = Math.max(0.0F, rider.getForward());
|
|
+ float vertical = forward == 0.0F ? 0.0F : -(rider.pitch / 45.0F);
|
|
+ float strafe = rider.getStrafe();
|
|
+
|
|
+ if (rider.isJumping()) {
|
|
+ //RidableSpacebarEvent event = new RidableSpacebarEvent(ridable);
|
|
+ //Bukkit.getPluginManager().callEvent(event);
|
|
+ //if (!event.isCancelled() && !event.isHandled()) {
|
|
+ entity.onSpacebar();
|
|
+ //}
|
|
+ }
|
|
+
|
|
+ if (entity.locY >= maxY || --tooHighCooldown > 0) {
|
|
+ tooHighCooldown = 60;
|
|
+ entity.setMot(entity.getMot().add(0.0D, -0.05D, 0.0D));
|
|
+ vertical = 0.0F;
|
|
+ }
|
|
+
|
|
+ float speed = (float) (e = entity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
|
|
+
|
|
+ if (entity.onGround) {
|
|
+ speed *= groundSpeedModifier; // TODO = fix this!
|
|
+ }
|
|
+
|
|
+ entity.setNoGravity(forward > 0);
|
|
+
|
|
+ entity.setSpeed(speed);
|
|
+ entity.setVertical(vertical);
|
|
+ entity.setStrafe(strafe);
|
|
+ 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 000000000..74ff48259
|
|
--- /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 640faccfd..2390baa75 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -697,5 +697,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
public void setSafeFallDistance(float safeFallDistance) {
|
|
getHandle().safeFallDistance = safeFallDistance;
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public boolean canBeRiddenInWater() {
|
|
+ return getHandle().canBeRiddenInWater();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCanBeRiddenInWater(boolean canBeRiddenInWater) {
|
|
+ getHandle().setCanBeRiddenInWater(canBeRiddenInWater);
|
|
+ }
|
|
// Purpur end
|
|
}
|
|
--
|
|
2.20.1
|
|
|