Skip to content

Commit

Permalink
Fix #13 - Don't send flyingSpeed attributes if mob is not ridable
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyGalbreath committed Mar 28, 2020
1 parent 6edf462 commit 6f28664
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 58 deletions.
120 changes: 72 additions & 48 deletions patches/server/0008-Ridables.patch
@@ -1,4 +1,4 @@
From c8dcf89a9b9727f1fbc8ca37fb1bb7ecf7407ff6 Mon Sep 17 00:00:00 2001
From b3b398af1dfdf76518724e83a5ef59a323274f59 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 6 Feb 2020 19:53:59 -0600
Subject: [PATCH] Ridables
Expand All @@ -10,9 +10,9 @@ Subject: [PATCH] Ridables
.../net/minecraft/server/DamageSource.java | 3 +
.../java/net/minecraft/server/Entity.java | 69 +-
.../net/minecraft/server/EntityAgeable.java | 2 +-
.../java/net/minecraft/server/EntityBat.java | 54 ++
.../java/net/minecraft/server/EntityBat.java | 58 ++
.../java/net/minecraft/server/EntityBee.java | 118 +++-
.../net/minecraft/server/EntityBlaze.java | 47 ++
.../net/minecraft/server/EntityBlaze.java | 51 ++
.../java/net/minecraft/server/EntityCat.java | 34 +-
.../minecraft/server/EntityCaveSpider.java | 17 +
.../net/minecraft/server/EntityChicken.java | 19 +
Expand All @@ -28,7 +28,7 @@ Subject: [PATCH] Ridables
.../net/minecraft/server/EntityEvoker.java | 22 +
.../java/net/minecraft/server/EntityFish.java | 21 +-
.../java/net/minecraft/server/EntityFox.java | 57 +-
.../net/minecraft/server/EntityGhast.java | 42 +-
.../net/minecraft/server/EntityGhast.java | 46 +-
.../minecraft/server/EntityGiantZombie.java | 25 +
.../net/minecraft/server/EntityGuardian.java | 47 +-
.../minecraft/server/EntityGuardianElder.java | 17 +
Expand All @@ -50,7 +50,7 @@ Subject: [PATCH] Ridables
.../net/minecraft/server/EntityOcelot.java | 19 +
.../net/minecraft/server/EntityPanda.java | 47 +-
.../net/minecraft/server/EntityParrot.java | 77 ++-
.../net/minecraft/server/EntityPhantom.java | 73 ++-
.../net/minecraft/server/EntityPhantom.java | 77 ++-
.../java/net/minecraft/server/EntityPig.java | 48 +-
.../net/minecraft/server/EntityPigZombie.java | 17 +
.../net/minecraft/server/EntityPillager.java | 19 +
Expand All @@ -75,12 +75,12 @@ Subject: [PATCH] Ridables
.../minecraft/server/EntityTropicalFish.java | 17 +
.../net/minecraft/server/EntityTurtle.java | 115 +++-
.../net/minecraft/server/EntityTypes.java | 6 +
.../java/net/minecraft/server/EntityVex.java | 61 +-
.../java/net/minecraft/server/EntityVex.java | 65 +-
.../net/minecraft/server/EntityVillager.java | 22 +
.../server/EntityVillagerTrader.java | 18 +
.../minecraft/server/EntityVindicator.java | 19 +
.../net/minecraft/server/EntityWitch.java | 21 +-
.../net/minecraft/server/EntityWither.java | 65 +-
.../net/minecraft/server/EntityWither.java | 69 +-
.../java/net/minecraft/server/EntityWolf.java | 121 ++--
.../net/minecraft/server/EntityZombie.java | 19 +
.../minecraft/server/EntityZombieHusk.java | 17 +
Expand All @@ -102,7 +102,7 @@ Subject: [PATCH] Ridables
.../net/pl3x/purpur/entity/DolphinSpit.java | 119 ++++
.../pathfinder/PathfinderGoalHasRider.java | 21 +
.../craftbukkit/entity/CraftEntity.java | 27 +
98 files changed, 3403 insertions(+), 204 deletions(-)
98 files changed, 3427 insertions(+), 204 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
Expand Down Expand Up @@ -371,7 +371,7 @@ index 3d27f0964a..822316a65f 100644
}

diff --git a/src/main/java/net/minecraft/server/EntityBat.java b/src/main/java/net/minecraft/server/EntityBat.java
index 34239160be..dfc2ce9729 100644
index 34239160be..592408bac9 100644
--- a/src/main/java/net/minecraft/server/EntityBat.java
+++ b/src/main/java/net/minecraft/server/EntityBat.java
@@ -14,9 +14,44 @@ public class EntityBat extends EntityAmbient {
Expand Down Expand Up @@ -419,16 +419,20 @@ index 34239160be..dfc2ce9729 100644
@Override
protected void initDatawatcher() {
super.initDatawatcher();
@@ -64,6 +99,8 @@ public class EntityBat extends EntityAmbient {
@@ -64,6 +99,12 @@ public class EntityBat extends EntityAmbient {
protected void initAttributes() {
super.initAttributes();
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(6.0D);
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED); // Purpur
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D); // Purpur
+ // Purpur start
+ if (world != null && world.purpurConfig.batRidable) {
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED);
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D);
+ }
+ // Purpur end
}

public boolean isAsleep() {
@@ -95,6 +132,13 @@ public class EntityBat extends EntityAmbient {
@@ -95,6 +136,13 @@ public class EntityBat extends EntityAmbient {

@Override
protected void mobTick() {
Expand All @@ -442,7 +446,7 @@ index 34239160be..dfc2ce9729 100644
super.mobTick();
BlockPosition blockposition = new BlockPosition(this);
BlockPosition blockposition1 = blockposition.up();
@@ -229,4 +273,14 @@ public class EntityBat extends EntityAmbient {
@@ -229,4 +277,14 @@ public class EntityBat extends EntityAmbient {
protected float b(EntityPose entitypose, EntitySize entitysize) {
return entitysize.height / 2.0F;
}
Expand Down Expand Up @@ -639,7 +643,7 @@ index c7d79efdf6..7e4aad7716 100644
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/server/EntityBlaze.java b/src/main/java/net/minecraft/server/EntityBlaze.java
index da6a3fa2c8..1e220131ca 100644
index da6a3fa2c8..d02130e0d1 100644
--- a/src/main/java/net/minecraft/server/EntityBlaze.java
+++ b/src/main/java/net/minecraft/server/EntityBlaze.java
@@ -10,6 +10,7 @@ public class EntityBlaze extends EntityMonster {
Expand Down Expand Up @@ -700,16 +704,20 @@ index da6a3fa2c8..1e220131ca 100644
this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(new Class[0])); // Purpur - decompile error
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
}
@@ -34,6 +71,8 @@ public class EntityBlaze extends EntityMonster {
@@ -34,6 +71,12 @@ public class EntityBlaze extends EntityMonster {
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(6.0D);
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D);
this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(48.0D);
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED); // Purpur
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D); // Purpur
+ // Purpur start
+ if (world != null && world.purpurConfig.blazeRidable) {
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED);
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D);
+ }
+ // Purpur end
}

@Override
@@ -87,6 +126,14 @@ public class EntityBlaze extends EntityMonster {
@@ -87,6 +130,14 @@ public class EntityBlaze extends EntityMonster {
this.damageEntity(DamageSource.DROWN, 1.0F);
}

Expand Down Expand Up @@ -1843,7 +1851,7 @@ index 82a32d5dbf..4f53090d3d 100644

}
diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java
index e1c2540d14..85e6c195f3 100644
index e1c2540d14..46841df718 100644
--- a/src/main/java/net/minecraft/server/EntityGhast.java
+++ b/src/main/java/net/minecraft/server/EntityGhast.java
@@ -14,11 +14,47 @@ public class EntityGhast extends EntityFlying implements IMonster {
Expand Down Expand Up @@ -1894,16 +1902,20 @@ index e1c2540d14..85e6c195f3 100644
this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, (entityliving) -> {
return Math.abs(entityliving.locY() - this.locY()) <= 4.0D;
}));
@@ -60,6 +96,8 @@ public class EntityGhast extends EntityFlying implements IMonster {
@@ -60,6 +96,12 @@ public class EntityGhast extends EntityFlying implements IMonster {
super.initAttributes();
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(10.0D);
this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(100.0D);
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED); // Purpur
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D); // Purpur
+ // Purpur start
+ if (world != null && world.purpurConfig.ghastRidable) {
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED);
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D);
+ }
+ // Purpur end
}

@Override
@@ -255,7 +293,7 @@ public class EntityGhast extends EntityFlying implements IMonster {
@@ -255,7 +297,7 @@ public class EntityGhast extends EntityFlying implements IMonster {
}
}

Expand All @@ -1912,7 +1924,7 @@ index e1c2540d14..85e6c195f3 100644

private final EntityGhast i;
private int j;
@@ -266,7 +304,7 @@ public class EntityGhast extends EntityFlying implements IMonster {
@@ -266,7 +308,7 @@ public class EntityGhast extends EntityFlying implements IMonster {
}

@Override
Expand Down Expand Up @@ -3026,7 +3038,7 @@ index 94e57a2d85..7ba2f3a351 100644
this.goalSelector.a(2, this.goalSit);
this.goalSelector.a(2, new PathfinderGoalFollowOwner(this, 1.0D, 5.0F, 1.0F, true));
diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
index 90eeddb1af..c3a5e24617 100644
index 90eeddb1af..5ccbc341d2 100644
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
@@ -22,6 +22,40 @@ public class EntityPhantom extends EntityFlying implements IMonster {
Expand Down Expand Up @@ -3082,17 +3094,21 @@ index 90eeddb1af..c3a5e24617 100644
this.targetSelector.a(1, new EntityPhantom.b());
}

@@ -39,6 +75,9 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -39,6 +75,13 @@ public class EntityPhantom extends EntityFlying implements IMonster {
protected void initAttributes() {
super.initAttributes();
this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE);
+ this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.01D); // Purpur
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED); // Purpur
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D); // Purpur
+ // Purpur start
+ if (world != null && world.purpurConfig.phantomRidable) {
+ this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.01D);
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED);
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D);
+ }
+ // Purpur end
}

@Override
@@ -103,7 +142,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -103,7 +146,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {

@Override
public void movementTick() {
Expand All @@ -3101,31 +3117,31 @@ index 90eeddb1af..c3a5e24617 100644
this.setOnFire(8);
}

@@ -215,6 +254,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -215,6 +258,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {

@Override
public boolean a() {
+ if (getRider() != null) return false; // Purpur - pathfinder does not have a flag
if (this.c > 0) {
--this.c;
return false;
@@ -244,6 +284,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -244,6 +288,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {

@Override
public boolean b() {
+ if (getRider() != null) return false; // Purpur - pathfinder does not have a flag
EntityLiving entityliving = EntityPhantom.this.getGoalTarget();

return entityliving != null ? EntityPhantom.this.a(entityliving, PathfinderTargetCondition.a) : false;
@@ -258,6 +299,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -258,6 +303,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {

@Override
public boolean a() {
+ if (getRider() != null) return false; // Purpur - pathfinder does not have a flag
EntityLiving entityliving = EntityPhantom.this.getGoalTarget();

return entityliving != null ? EntityPhantom.this.a(EntityPhantom.this.getGoalTarget(), PathfinderTargetCondition.a) : false;
@@ -447,14 +489,23 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -447,14 +493,23 @@ public class EntityPhantom extends EntityFlying implements IMonster {
}
}

Expand All @@ -3151,7 +3167,7 @@ index 90eeddb1af..c3a5e24617 100644
}

class d extends EntityAIBodyControl {
@@ -470,7 +521,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -470,7 +525,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
}
}

Expand All @@ -3160,7 +3176,7 @@ index 90eeddb1af..c3a5e24617 100644

private float j = 0.1F;

@@ -479,7 +530,19 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -479,7 +534,19 @@ public class EntityPhantom extends EntityFlying implements IMonster {
}

@Override
Expand Down Expand Up @@ -4371,7 +4387,7 @@ index 4100e367a4..a0d932c403 100644
if (this.bg == null) {
this.bg = SystemUtils.a("entity", IRegistry.ENTITY_TYPE.getKey(this));
diff --git a/src/main/java/net/minecraft/server/EntityVex.java b/src/main/java/net/minecraft/server/EntityVex.java
index cf274666c7..d890f7bdfa 100644
index cf274666c7..d919f44ab8 100644
--- a/src/main/java/net/minecraft/server/EntityVex.java
+++ b/src/main/java/net/minecraft/server/EntityVex.java
@@ -19,6 +19,50 @@ public class EntityVex extends EntityMonster {
Expand Down Expand Up @@ -4447,16 +4463,20 @@ index cf274666c7..d890f7bdfa 100644
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error
this.targetSelector.a(2, new EntityVex.b(this));
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
@@ -56,6 +102,8 @@ public class EntityVex extends EntityMonster {
@@ -56,6 +102,12 @@ public class EntityVex extends EntityMonster {
super.initAttributes();
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(14.0D);
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(4.0D);
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED); // Purpur
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D); // Purpur
+ // Purpur start
+ if (world != null && world.purpurConfig.vexRidable) {
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED);
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D);
+ }
+ // Purpur end
}

@Override
@@ -287,14 +335,21 @@ public class EntityVex extends EntityMonster {
@@ -287,14 +339,21 @@ public class EntityVex extends EntityMonster {
}
}

Expand Down Expand Up @@ -4631,7 +4651,7 @@ index 1432d3f6bf..447387bd78 100644
this.targetSelector.a(2, this.bz);
this.targetSelector.a(3, this.bA);
diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java
index bace6cf36a..cb83130bf9 100644
index bace6cf36a..151cb57028 100644
--- a/src/main/java/net/minecraft/server/EntityWither.java
+++ b/src/main/java/net/minecraft/server/EntityWither.java
@@ -18,7 +18,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
Expand Down Expand Up @@ -4727,16 +4747,20 @@ index bace6cf36a..cb83130bf9 100644
int i;

if (this.eq() > 0) {
@@ -512,6 +563,8 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
@@ -512,6 +563,12 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.6000000238418579D);
this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(40.0D);
this.getAttributeInstance(GenericAttributes.ARMOR).setValue(4.0D);
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED); // Purpur
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D); // Purpur
+ // Purpur start
+ if (world != null && world.purpurConfig.witherRidable) {
+ this.getAttributeMap().b(GenericAttributes.FLYING_SPEED);
+ this.getAttributeInstance(GenericAttributes.FLYING_SPEED).setValue(0.6000000238418579D);
+ }
+ // Purpur end
}

public int eq() {
@@ -523,11 +576,11 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
@@ -523,11 +580,11 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
}

public int getHeadTarget(int i) {
Expand All @@ -4750,7 +4774,7 @@ index bace6cf36a..cb83130bf9 100644
}

public boolean J_() {
@@ -541,7 +594,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
@@ -541,7 +598,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {

@Override
protected boolean n(Entity entity) {
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0024-Phantoms-only-attack-insomniacs.patch
@@ -1,4 +1,4 @@
From 93c7052db9377ed3c1f0be96966b48eae3978f3e Mon Sep 17 00:00:00 2001
From fdc38d9e66b905b052caff62d0810ad74989f4fa Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Fri, 29 Nov 2019 20:33:41 -0600
Subject: [PATCH] Phantoms only attack insomniacs
Expand All @@ -10,10 +10,10 @@ Subject: [PATCH] Phantoms only attack insomniacs
3 files changed, 4 insertions(+)

diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
index c3a5e24617..6d2984c8d5 100644
index 5ccbc341d2..cb5eed8785 100644
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
@@ -272,6 +272,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -276,6 +276,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
EntityHuman entityhuman = (EntityHuman) iterator.next();

if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) {
Expand Down

0 comments on commit 6f28664

Please sign in to comment.