mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
2276 lines
93 KiB
Diff
2276 lines
93 KiB
Diff
From 06a7a4326ebb2250a3adac29b758fcf3bdd8da76 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
|
|
|
|
---
|
|
.../java/net/minecraft/server/BiomeBase.java | 26 ++-
|
|
.../net/minecraft/server/ControllerJump.java | 1 +
|
|
.../server/ControllerLookDolphin.java | 4 +-
|
|
.../java/net/minecraft/server/Entity.java | 16 +-
|
|
.../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 +++-
|
|
.../minecraft/server/EntityEnderCrystal.java | 49 +++++
|
|
.../net/minecraft/server/EntityEnderman.java | 15 ++
|
|
.../net/minecraft/server/EntityEndermite.java | 15 ++
|
|
.../java/net/minecraft/server/EntityFish.java | 28 ++-
|
|
.../minecraft/server/EntityGiantZombie.java | 36 +++-
|
|
.../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 ++
|
|
.../net/minecraft/server/EntityPhantom.java | 203 ++++++++++++++++--
|
|
.../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 ++
|
|
.../net/minecraft/server/EntitySquid.java | 57 +++++
|
|
.../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/ControllerMoveWASDFlying.java | 58 +++++
|
|
.../controller/ControllerMoveWASDWater.java | 42 ++++
|
|
.../craftbukkit/entity/CraftLivingEntity.java | 10 +
|
|
47 files changed, 1149 insertions(+), 55 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/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java
|
|
index 3496d423..e59ee303 100644
|
|
--- a/src/main/java/net/minecraft/server/BiomeBase.java
|
|
+++ b/src/main/java/net/minecraft/server/BiomeBase.java
|
|
@@ -196,6 +196,7 @@ public abstract class BiomeBase {
|
|
return this.aR != null;
|
|
}
|
|
|
|
+ protected void addMobSpawn(EnumCreatureType creaturetype, BiomeBase.BiomeMeta biomemeta) { a(creaturetype, biomemeta); } // Purpur - OBFHELPER
|
|
protected void a(EnumCreatureType enumcreaturetype, BiomeBase.BiomeMeta biomebase_biomemeta) {
|
|
((List) this.aZ.get(enumcreaturetype)).add(biomebase_biomemeta);
|
|
}
|
|
@@ -463,7 +464,30 @@ public abstract class BiomeBase {
|
|
a(166, "modified_wooded_badlands_plateau", new BiomeMesaPlateauMutated());
|
|
a(167, "modified_badlands_plateau", new BiomeMesaPlateauClearMutated());
|
|
Collections.addAll(BiomeBase.aG, new BiomeBase[] { Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.MOUNTAINS, Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS, Biomes.MUSHROOM_FIELDS, Biomes.MUSHROOM_FIELD_SHORE, Biomes.BEACH, Biomes.DESERT_HILLS, Biomes.WOODED_HILLS, Biomes.TAIGA_HILLS, Biomes.JUNGLE, Biomes.JUNGLE_HILLS, Biomes.JUNGLE_EDGE, Biomes.DEEP_OCEAN, Biomes.STONE_SHORE, Biomes.SNOWY_BEACH, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.WOODED_MOUNTAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.BADLANDS_PLATEAU});
|
|
- }
|
|
+
|
|
+ // Purpur start - add natural mob spawns (maybe find a better place for this?)
|
|
+ BiomeBase.addSpawn("plains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
|
|
+ BiomeBase.addSpawn("sunflower_plains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
|
|
+ BiomeBase.addSpawn("desert", EnumCreatureType.MONSTER, EntityTypes.GIANT, 2, 1, 1);
|
|
+ BiomeBase.addSpawn("desert_hills", EnumCreatureType.MONSTER, EntityTypes.GIANT, 2, 1, 1);
|
|
+ BiomeBase.addSpawn("desert_lakes", EnumCreatureType.MONSTER, EntityTypes.GIANT, 2, 1, 1);
|
|
+ BiomeBase.addSpawn("mountains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
|
|
+ BiomeBase.addSpawn("gravelly_mountains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
|
|
+ BiomeBase.addSpawn("modified_gravelly_mountains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
|
|
+ BiomeBase.addSpawn("savanna", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
|
|
+ BiomeBase.addSpawn("savanna_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
|
|
+ BiomeBase.addSpawn("shattered_savanna", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
|
|
+ BiomeBase.addSpawn("shattered_savanna_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
|
|
+ BiomeBase.addSpawn("badlands", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 1, 2);
|
|
+ BiomeBase.addSpawn("badlands_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 1, 2);
|
|
+ BiomeBase.addSpawn("eroded_badlands", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 1, 2);
|
|
+ BiomeBase.addSpawn("modified_badlands_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 2, 1);
|
|
+ }
|
|
+
|
|
+ private static void addSpawn(String biome, EnumCreatureType ct, EntityTypes et, int weight, int min_group, int max_group) {
|
|
+ IRegistry.BIOME.get(new MinecraftKey(biome)).addMobSpawn(ct, new BiomeBase.BiomeMeta(et, weight, min_group, max_group));
|
|
+ }
|
|
+ // Purpur end
|
|
|
|
private static void a(int i, String s, BiomeBase biomebase) {
|
|
IRegistry.BIOME.a(i, new MinecraftKey(s), biomebase);
|
|
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..0abe7a99 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;
|
|
@@ -135,7 +136,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
public double N;
|
|
public double O;
|
|
public double P;
|
|
- public float Q;
|
|
+ public float Q; public float getStepHeight() { return Q; } public void setStepHeight(float stepHeight) { this.Q = stepHeight; } // Purpur - OBFHELPER
|
|
public boolean noclip;
|
|
public float S;
|
|
protected Random random;
|
|
@@ -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;
|
|
}
|
|
@@ -2991,6 +3004,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
return null;
|
|
}
|
|
|
|
+ public List<Entity> getPassengers() { return bP(); } // Purpur - OBFHELPER
|
|
public List<Entity> bP() {
|
|
return (List) (this.passengers.isEmpty() ? Collections.emptyList() : Lists.newArrayList(this.passengers));
|
|
}
|
|
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/EntityEnderCrystal.java b/src/main/java/net/minecraft/server/EntityEnderCrystal.java
|
|
index 79bdb82b..020a0f2d 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityEnderCrystal.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityEnderCrystal.java
|
|
@@ -13,6 +13,12 @@ public class EntityEnderCrystal extends Entity {
|
|
private static final DataWatcherObject<Optional<BlockPosition>> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m);
|
|
private static final DataWatcherObject<Boolean> c = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.i);
|
|
public int a;
|
|
+ // Purpur start
|
|
+ private EntityPhantom targetPhantom;
|
|
+ private int phantomBeamTicks = 0;
|
|
+ private int phantomDamageCooldown = 0;
|
|
+ private int idleCooldown = 0;
|
|
+ // Purpur end
|
|
|
|
public EntityEnderCrystal(World world) {
|
|
super(EntityTypes.END_CRYSTAL, world);
|
|
@@ -52,7 +58,50 @@ public class EntityEnderCrystal extends Entity {
|
|
}
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ if (--idleCooldown > 0) {
|
|
+ return; // on cooldown
|
|
+ }
|
|
+
|
|
+ if (targetPhantom == null) {
|
|
+ for (EntityPhantom phantom : world.a(EntityPhantom.class, getBoundingBox().grow(16, 16, 16))) {
|
|
+ if (phantom.hasLineOfSight(this)) {
|
|
+ attackPhantom(phantom);
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ } else {
|
|
+ setBeamTarget(new BlockPosition(targetPhantom).add(0, -2, 0));
|
|
+ if (--phantomBeamTicks > 0 && targetPhantom.isAlive()) {
|
|
+ phantomDamageCooldown--;
|
|
+ if (targetPhantom.hasLineOfSight(this)) {
|
|
+ if (phantomDamageCooldown <= 0) {
|
|
+ phantomDamageCooldown = 20;
|
|
+ targetPhantom.damageEntity(DamageSource.c(this, this), 1.0F);
|
|
+ }
|
|
+ } else {
|
|
+ forgetPhantom(); // no longer in sight
|
|
+ }
|
|
+ } else {
|
|
+ forgetPhantom(); // attacked long enough
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void attackPhantom(EntityPhantom phantom) {
|
|
+ phantomDamageCooldown = 0;
|
|
+ phantomBeamTicks = 60;
|
|
+ targetPhantom = phantom;
|
|
+ }
|
|
+
|
|
+ private void forgetPhantom() {
|
|
+ targetPhantom = null;
|
|
+ setBeamTarget(null);
|
|
+ phantomBeamTicks = 0;
|
|
+ phantomDamageCooldown = 0;
|
|
+ idleCooldown = 60;
|
|
}
|
|
+ // Purpur end
|
|
|
|
protected void b(NBTTagCompound nbttagcompound) {
|
|
if (this.getBeamTarget() != null) {
|
|
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/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
index 053a880c..0786af8b 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
@@ -8,7 +8,11 @@ public class EntityGiantZombie extends EntityMonster {
|
|
super(EntityTypes.GIANT, world);
|
|
this.setSize(this.width * 6.0F, this.length * 6.0F);
|
|
// Purpur start
|
|
+ this.moveController = new net.pl3x.purpur.controller.ControllerMoveWASD(this);
|
|
+ this.lookController = new net.pl3x.purpur.controller.ControllerLookWASD(this);
|
|
+ this.canBeRiddenInWater = true;
|
|
this.safeFallDistance = 10.0F;
|
|
+ setStepHeight(2.0F);
|
|
// Purpur end
|
|
}
|
|
|
|
@@ -23,8 +27,38 @@ public class EntityGiantZombie extends EntityMonster {
|
|
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D);
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ protected void n() { // initPathfinder
|
|
+ this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
|
+ this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
|
|
+ this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D));
|
|
+ this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 16.0F));
|
|
+ this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
|
|
+ this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
|
|
+ this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, EntityHuman.class));
|
|
+ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
|
+ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillager.class, false));
|
|
+ this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
|
|
+ this.targetSelector.a(5, new PathfinderGoalNearestAttackableTarget<>(this, EntityTurtle.class, true));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public float cG() { // jump height
|
|
+ return 1.0F;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand) { // processInteract
|
|
+ if (super.a(entityhuman, enumhand)) {
|
|
+ return true; // vanilla action handled
|
|
+ }
|
|
+ return tryRide(entityhuman, enumhand);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
|
|
- return iworldreader.A(blockposition) - 0.5F;
|
|
+ return super.a(blockposition, iworldreader); // Purpur - fix light requirements for natural spawns
|
|
}
|
|
|
|
@Nullable
|
|
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 e211b95c..31e29b2e 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 13a3bd02..3058c6ce 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;
|
|
@@ -347,8 +347,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() {
|
|
@@ -1839,6 +1847,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)) {
|
|
@@ -2083,10 +2092,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;
|
|
}
|
|
@@ -2500,6 +2511,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;
|
|
}
|
|
@@ -2547,6 +2559,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 5e752b0c..8a54a6f2 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/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
index f576264a..8a5aed24 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
@@ -1,5 +1,7 @@
|
|
package net.minecraft.server;
|
|
|
|
+import net.pl3x.purpur.controller.ControllerLookWASD;
|
|
+
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import javax.annotation.Nullable;
|
|
@@ -7,9 +9,10 @@ import javax.annotation.Nullable;
|
|
public class EntityPhantom extends EntityFlying implements IMonster {
|
|
|
|
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityPhantom.class, DataWatcherRegistry.b);
|
|
- private Vec3D b;
|
|
- private BlockPosition c;
|
|
- private EntityPhantom.AttackPhase bC;
|
|
+ private Vec3D b; public Vec3D getOrbitOffset() { return this.b; } public void setOrbitOffset(Vec3D offset) { this.b = offset; } // Purpur - OBFHELPER
|
|
+ private BlockPosition c; public BlockPosition getOrbitPosition() { return this.c; } public void setOrbitPosition(BlockPosition position) { this.c = position; } // Purpur - OBFHELPER
|
|
+ private EntityPhantom.AttackPhase bC; public AttackPhase getPhase() { return this.bC; } public void setPhase(AttackPhase phase) { this.bC = phase; } // Purpur - OBFHELPER
|
|
+ private BlockPosition totemPosition; public BlockPosition getTotemPosition() { return this.totemPosition; } public void setTotemPosition(BlockPosition position) { this.totemPosition = position; } // Purpur
|
|
|
|
public EntityPhantom(World world) {
|
|
super(EntityTypes.PHANTOM, world);
|
|
@@ -20,6 +23,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
this.setSize(0.9F, 0.5F);
|
|
this.moveController = new EntityPhantom.g(this);
|
|
this.lookController = new EntityPhantom.f(this);
|
|
+ this.canBeRiddenInWater = false; // Purpur
|
|
}
|
|
|
|
protected EntityAIBodyControl o() {
|
|
@@ -27,8 +31,10 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
|
|
protected void n() {
|
|
+ this.goalSelector.a(0, new FindTotemGoal(this)); // Purpur
|
|
this.goalSelector.a(1, new EntityPhantom.c());
|
|
this.goalSelector.a(2, new EntityPhantom.i());
|
|
+ this.goalSelector.a(3, new OrbitTotemGoal(this)); // Purpur
|
|
this.goalSelector.a(3, new EntityPhantom.e());
|
|
this.targetSelector.a(1, new EntityPhantom.b());
|
|
}
|
|
@@ -103,7 +109,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
|
|
public void movementTick() {
|
|
- if (this.dq()) {
|
|
+ if (getRider() == null && this.dq()) { // Purpur - do not set fire if being ridden
|
|
this.setOnFire(8);
|
|
}
|
|
|
|
@@ -114,6 +120,25 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
super.mobTick();
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ protected void a(boolean wasRecentlyHit, int lootingModifier, DamageSource damagesource) { // dropLoot
|
|
+ boolean dropped = false;
|
|
+ if (killer == null && damagesource.getEntity() instanceof EntityEnderCrystal) {
|
|
+ if (random.nextInt(5) < 1) { // 1 out of 5 chance (20%)
|
|
+ dropped = a_(new ItemStack(Items.PHANTOM_MEMBRANE)) != null;
|
|
+ }
|
|
+ }
|
|
+ if (!dropped) {
|
|
+ super.a(wasRecentlyHit, lootingModifier, damagesource); // dropLoot
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public boolean isCirclingTotem() {
|
|
+ return totemPosition != null;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public GroupDataEntity prepare(DifficultyDamageScaler difficultydamagescaler, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) {
|
|
this.c = (new BlockPosition(this)).up(5);
|
|
this.setSize(0);
|
|
@@ -188,6 +213,138 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
// Paper end
|
|
|
|
+ // 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);
|
|
+ }
|
|
+
|
|
+ class FindTotemGoal extends PathfinderGoal {
|
|
+ private final EntityPhantom phantom;
|
|
+ private EntityEnderCrystal totem;
|
|
+ private PathfinderGoalNearestAttackableTarget.DistanceComparator comparator;
|
|
+
|
|
+ FindTotemGoal(EntityPhantom phantom) {
|
|
+ this.phantom = phantom;
|
|
+ comparator = new PathfinderGoalNearestAttackableTarget.DistanceComparator(phantom);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean a() { // shouldExecute
|
|
+ if (phantom.getRider() != null) {
|
|
+ return false;
|
|
+ }
|
|
+ double range = maxTargetRange();
|
|
+ List<EntityEnderCrystal> crystals = world.a(EntityEnderCrystal.class, phantom.getBoundingBox().grow(range, range, range));
|
|
+ if (crystals.isEmpty()) {
|
|
+ return false;
|
|
+ }
|
|
+ crystals.sort(comparator);
|
|
+ totem = crystals.get(0);
|
|
+ if (phantom.h(totem) > range * range) {
|
|
+ totem = null;
|
|
+ return false;
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean b() { // shouldContinueExecuting
|
|
+ if (phantom.getRider() != null) {
|
|
+ return false;
|
|
+ }
|
|
+ if (totem == null || !totem.isAlive()) {
|
|
+ return false;
|
|
+ }
|
|
+ double range = maxTargetRange();
|
|
+ return phantom.h(totem) <= (range * range) * 2;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void c() { // startExecuting
|
|
+ phantom.setTotemPosition(new BlockPosition(totem).add(0, phantom.getRandom().nextInt(10) + 10, 0));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void d() { // resetTask
|
|
+ totem = null;
|
|
+ phantom.setTotemPosition(null);
|
|
+ super.d();
|
|
+ }
|
|
+
|
|
+ private double maxTargetRange() {
|
|
+ AttributeInstance range = phantom.getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
|
|
+ return range == null ? 16.0D : range.getValue();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ class OrbitTotemGoal extends PathfinderGoal {
|
|
+ private final EntityPhantom phantom;
|
|
+ private float c;
|
|
+ private float radius;
|
|
+ private float verticalChange;
|
|
+ private float direction;
|
|
+
|
|
+ OrbitTotemGoal(EntityPhantom phantom) {
|
|
+ this.phantom = phantom;
|
|
+ a(1);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean a() { // shouldExecute
|
|
+ return phantom.getRider() == null && phantom.isCirclingTotem();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void c() { // startExecuting
|
|
+ this.radius = 5.0F + phantom.random.nextFloat() * 10.0F;
|
|
+ this.verticalChange = -4.0F + phantom.random.nextFloat() * 9.0F;
|
|
+ this.direction = phantom.random.nextBoolean() ? 1.0F : -1.0F;
|
|
+ updateOffset();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void e() { // tick
|
|
+ if (phantom.random.nextInt(350) == 0) {
|
|
+ this.verticalChange = -4.0F + phantom.random.nextFloat() * 9.0F;
|
|
+ }
|
|
+ if (phantom.random.nextInt(250) == 0) {
|
|
+ ++this.radius;
|
|
+ if (this.radius > 15.0F) {
|
|
+ this.radius = 5.0F;
|
|
+ this.direction = -this.direction;
|
|
+ }
|
|
+ }
|
|
+ if (phantom.random.nextInt(450) == 0) {
|
|
+ this.c = phantom.random.nextFloat() * 2.0F * 3.1415927F;
|
|
+ updateOffset();
|
|
+ }
|
|
+ if (phantom.b.c(phantom.locX, phantom.locY, phantom.locZ) < 4.0D) {
|
|
+ updateOffset();
|
|
+ }
|
|
+ if (phantom.b.y < phantom.locY && !phantom.world.isEmpty((new BlockPosition(phantom)).down(1))) {
|
|
+ this.verticalChange = Math.max(1.0F, this.verticalChange);
|
|
+ updateOffset();
|
|
+ }
|
|
+ if (phantom.b.y > phantom.locY && !phantom.world.isEmpty((new BlockPosition(phantom)).up(1))) {
|
|
+ this.verticalChange = Math.min(-1.0F, this.verticalChange);
|
|
+ updateOffset();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void updateOffset() {
|
|
+ this.c += this.direction * 15.0F * 0.017453292F;
|
|
+ phantom.setOrbitOffset(new Vec3D(phantom.totemPosition).add(
|
|
+ (double) (this.radius * MathHelper.cos(this.c)),
|
|
+ (double) (-4.0F + this.verticalChange),
|
|
+ (double) (this.radius * MathHelper.sin(this.c))));
|
|
+ }
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
class b extends PathfinderGoal {
|
|
|
|
private int b;
|
|
@@ -237,7 +394,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
private c() {}
|
|
|
|
public boolean a() {
|
|
- return PathfinderGoalTarget.a(EntityPhantom.this, EntityPhantom.this.getGoalTarget(), false, false);
|
|
+ return !isCirclingTotem() && PathfinderGoalTarget.a(EntityPhantom.this, EntityPhantom.this.getGoalTarget(), false, false); // Purpur
|
|
}
|
|
|
|
public void c() {
|
|
@@ -279,13 +436,13 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
|
|
public boolean a() {
|
|
- return EntityPhantom.this.getGoalTarget() != null && EntityPhantom.this.bC == EntityPhantom.AttackPhase.SWOOP;
|
|
+ return !isCirclingTotem() && EntityPhantom.this.getGoalTarget() != null && EntityPhantom.this.bC == EntityPhantom.AttackPhase.SWOOP; // Purpur
|
|
}
|
|
|
|
public boolean b() {
|
|
EntityLiving entityliving = EntityPhantom.this.getGoalTarget();
|
|
|
|
- return entityliving == null ? false : (!entityliving.isAlive() ? false : (entityliving instanceof EntityHuman && (((EntityHuman) entityliving).isSpectator() || ((EntityHuman) entityliving).u()) ? false : this.a()));
|
|
+ return !isCirclingTotem() && entityliving == null ? false : (!entityliving.isAlive() ? false : (entityliving instanceof EntityHuman && (((EntityHuman) entityliving).isSpectator() || ((EntityHuman) entityliving).u()) ? false : this.a())); // Purpur
|
|
}
|
|
|
|
public void c() {}
|
|
@@ -322,7 +479,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
|
|
public boolean a() {
|
|
- return EntityPhantom.this.getGoalTarget() == null || EntityPhantom.this.bC == EntityPhantom.AttackPhase.CIRCLE;
|
|
+ return !isCirclingTotem() && (EntityPhantom.this.getGoalTarget() == null || EntityPhantom.this.bC == EntityPhantom.AttackPhase.CIRCLE); // Purpur
|
|
}
|
|
|
|
public void c() {
|
|
@@ -387,13 +544,23 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
}
|
|
|
|
- class f extends ControllerLook {
|
|
+ class f extends ControllerLookWASD { // Purpur
|
|
|
|
public f(EntityInsentient entityinsentient) {
|
|
super(entityinsentient);
|
|
}
|
|
|
|
- public void a() {}
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ public void tick(EntityHuman rider) {
|
|
+ setYawPitch(rider.yaw, -rider.pitch * 0.75F);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void tick() {
|
|
+ // do nothing
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
|
|
class d extends EntityAIBodyControl {
|
|
@@ -408,7 +575,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;
|
|
|
|
@@ -416,7 +583,19 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
super(entityinsentient);
|
|
}
|
|
|
|
- public void a() {
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ 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 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/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java
|
|
index ab79317a..b783c073 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySquid.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySquid.java
|
|
@@ -24,6 +24,7 @@ public class EntitySquid extends EntityWaterAnimal {
|
|
this.setSize(0.8F, 0.8F);
|
|
//this.random.setSeed((long) (1 + this.getId())); // Paper
|
|
this.bI = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
|
|
+ this.canBeRiddenInWater = true; // Purpur
|
|
}
|
|
|
|
protected void n() {
|
|
@@ -173,6 +174,7 @@ public class EntitySquid extends EntityWaterAnimal {
|
|
// Paper end
|
|
}
|
|
|
|
+ public void setMovementVector(float x, float y, float z) { c(x, y, z); } // Purpur - OBFHELPER
|
|
public void c(float f, float f1, float f2) {
|
|
this.bK = f;
|
|
this.bL = f1;
|
|
@@ -183,6 +185,16 @@ public class EntitySquid extends EntityWaterAnimal {
|
|
return this.bK != 0.0F || this.bL != 0.0F || this.bM != 0.0F;
|
|
}
|
|
|
|
+ // 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
|
|
+
|
|
class a extends PathfinderGoal {
|
|
|
|
private int b;
|
|
@@ -252,6 +264,39 @@ public class EntitySquid extends EntityWaterAnimal {
|
|
}
|
|
|
|
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.cj();
|
|
|
|
if (i > 100) {
|
|
@@ -266,5 +311,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 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/ControllerMoveWASDFlying.java b/src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDFlying.java
|
|
new file mode 100644
|
|
index 00000000..197b4951
|
|
--- /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.motY = -0.05F;
|
|
+ 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 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 89a49f03..03593e70 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -644,5 +644,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
|
|
|