Fix #280 - Ridables do not reset idle timer

This commit is contained in:
BillyGalbreath
2021-04-15 10:44:52 -05:00
parent 04f73c5831
commit 2e626184bb
8 changed files with 54 additions and 31 deletions

View File

@@ -419,7 +419,7 @@ index c9136f1b54ff0620a621b703b4e7487f4a63b01d..8b7f840bb1b24996b40c9bef85f4c1e9
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 451a28b1950bad61de7181a2fb89549063d8e2bf..81c0ccc4f8d0d1cf749cc2929c8d8f3c2c6c9887 100644
index 451a28b1950bad61de7181a2fb89549063d8e2bf..c0a6bbe570e95f4449b404b21855860c7aba057a 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -559,7 +559,7 @@ public abstract class EntityLiving extends Entity {
@@ -453,27 +453,41 @@ index 451a28b1950bad61de7181a2fb89549063d8e2bf..81c0ccc4f8d0d1cf749cc2929c8d8f3c
public void q(float f) {
this.bu = f;
}
@@ -2951,6 +2953,20 @@ public abstract class EntityLiving extends Entity {
}
}
// Paper end
@@ -2938,8 +2940,10 @@ public abstract class EntityLiving extends Entity {
this.collideNearby();
this.world.getMethodProfiler().exit();
// Paper start
- if (((WorldServer) world).hasEntityMoveEvent) {
- if (lastX != locX() || lastY != locY() || lastZ != locZ() || lastYaw != yaw || lastPitch != pitch) {
+ // Purpur start
+ if (hasRider() && ((WorldServer) world).hasRidableMoveEvent && this instanceof EntityInsentient) {
+ if (lastX != locX() || lastY != locY() || lastZ != locZ() || lastYaw != yaw || lastPitch != pitch) {
+ Location from = new Location(world.getWorld(), lastX, lastY, lastZ, lastYaw, lastPitch);
+ Location to = new Location (world.getWorld(), locX(), locY(), locZ(), yaw, pitch);
+ net.pl3x.purpur.event.entity.RidableMoveEvent event = new net.pl3x.purpur.event.entity.RidableMoveEvent((org.bukkit.entity.Mob) getBukkitLivingEntity(), (Player) getRider().getBukkitEntity(), from, to.clone());
+ if (!event.callEvent()) {
+ setLocation(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
+ } else if (!to.equals(event.getTo())) {
+ setLocation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ if (lastX != locX() || lastY != locY() || lastZ != locZ() || lastYaw != yaw || lastPitch != pitch) {
+ if (((WorldServer) world).hasEntityMoveEvent) {
+ // Purpur end
Location from = new Location(world.getWorld(), lastX, lastY, lastZ, lastYaw, lastPitch);
Location to = new Location (world.getWorld(), locX(), locY(), locZ(), yaw, pitch);
EntityMoveEvent event = new EntityMoveEvent(getBukkitLivingEntity(), from, to.clone());
@@ -2949,6 +2953,21 @@ public abstract class EntityLiving extends Entity {
setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
+ // Purpur start
+ if (hasRider()) {
+ getRider().resetIdleTimer();
+ if (((WorldServer) world).hasRidableMoveEvent && this instanceof EntityInsentient) {
+ Location from = new Location(world.getWorld(), lastX, lastY, lastZ, lastYaw, lastPitch);
+ Location to = new Location(world.getWorld(), locX(), locY(), locZ(), yaw, pitch);
+ net.pl3x.purpur.event.entity.RidableMoveEvent event = new net.pl3x.purpur.event.entity.RidableMoveEvent((org.bukkit.entity.Mob) getBukkitLivingEntity(), (Player) getRider().getBukkitEntity(), from, to.clone());
+ if (!event.callEvent()) {
+ setLocation(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
+ } else if (!to.equals(event.getTo())) {
+ setLocation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ }
+ }
+ }
+ }
+ // Purpur end
if (!this.world.isClientSide && this.dO() && this.aG()) {
this.damageEntity(DamageSource.DROWN, 1.0F);
+ // Purpur end
}
// Paper end
if (!this.world.isClientSide && this.dO() && this.aG()) {
diff --git a/src/main/java/net/minecraft/world/entity/EntityTameableAnimal.java b/src/main/java/net/minecraft/world/entity/EntityTameableAnimal.java
index 74636c4c0851da1cd5732daa0a2d1a4edda2050f..cdb56555889d17913d7b0c03d5ba23408a500f26 100644
--- a/src/main/java/net/minecraft/world/entity/EntityTameableAnimal.java
@@ -5401,10 +5415,19 @@ index e0324cdb2d4c85714eaad490a7a5c826b38e6b16..90cbef7fe8803295f82bddd6709fdf30
this.setTradingPlayer(entityhuman);
this.openTrade(entityhuman, this.getScoreboardDisplayName(), 1);
diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
index 2ee7daa155d812af8f84ba646106d801d2fb0fec..1062317c22171bccee78a2db1841e0fd2b3023d7 100644
index 2ee7daa155d812af8f84ba646106d801d2fb0fec..644f94002bfe2686f4c765251c3804c854b27869 100644
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
@@ -2258,4 +2258,15 @@ public abstract class EntityHuman extends EntityLiving {
@@ -183,6 +183,8 @@ public abstract class EntityHuman extends EntityLiving {
// CraftBukkit end
// Purpur start
+ public abstract void resetIdleTimer();
+
private javax.script.ScriptEngine scriptEngine = new javax.script.ScriptEngineManager().getEngineByName("rhino");
public void setAfk(boolean setAfk){
@@ -2258,4 +2260,15 @@ public abstract class EntityHuman extends EntityLiving {
return this.g;
}
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Add critical hit check to EntityDamagedByEntityEvent
diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
index 1062317c22171bccee78a2db1841e0fd2b3023d7..907bfe42bd866188639f7d25150fcde039c1e5f7 100644
index 644f94002bfe2686f4c765251c3804c854b27869..8b956fb01cff3e1990823430333e5d707bf9addf 100644
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
@@ -171,6 +171,7 @@ public abstract class EntityHuman extends EntityLiving {
@@ -16,7 +16,7 @@ index 1062317c22171bccee78a2db1841e0fd2b3023d7..907bfe42bd866188639f7d25150fcde0
// CraftBukkit start
public boolean fauxSleeping;
@@ -1164,6 +1165,7 @@ public abstract class EntityHuman extends EntityLiving {
@@ -1166,6 +1167,7 @@ public abstract class EntityHuman extends EntityLiving {
flag2 = flag2 && !world.paperConfig.disablePlayerCrits; // Paper
flag2 = flag2 && !this.isSprinting();
if (flag2) {
@@ -24,7 +24,7 @@ index 1062317c22171bccee78a2db1841e0fd2b3023d7..907bfe42bd866188639f7d25150fcde0
f *= 1.5F;
}
@@ -1200,6 +1202,7 @@ public abstract class EntityHuman extends EntityLiving {
@@ -1202,6 +1204,7 @@ public abstract class EntityHuman extends EntityLiving {
Vec3D vec3d = entity.getMot();
boolean flag5 = entity.damageEntity(DamageSource.playerAttack(this), f);

View File

@@ -7,7 +7,7 @@ Configurable chance to spawn a wolf that is rabid.
Rabid wolves attack all players, mobs, and animals.
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 81c0ccc4f8d0d1cf749cc2929c8d8f3c2c6c9887..72febe30dfcc731bc357d5fe1ede2a240f3d176d 100644
index c0a6bbe570e95f4449b404b21855860c7aba057a..04ae8af914e65ae9725d276a9dcc24893cbcabb9 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -2200,6 +2200,7 @@ public abstract class EntityLiving extends Entity {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Full netherite armor grants fire resistance
diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
index 907bfe42bd866188639f7d25150fcde039c1e5f7..b63019f40b28a2e543528a7919bbc08a4ccc8f07 100644
index 8b956fb01cff3e1990823430333e5d707bf9addf..89d6bfe81c9fb33e2ba51b9e215d79fac6245d16 100644
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
@@ -334,6 +334,16 @@ public abstract class EntityHuman extends EntityLiving {
@@ -336,6 +336,16 @@ public abstract class EntityHuman extends EntityLiving {
this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit
}

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] Add mobGriefing bypass to everything affected
This adds the "bypass-mob-griefing" world config option to everything that is affected by the gamerule.
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 72febe30dfcc731bc357d5fe1ede2a240f3d176d..ac5b13e943d70cfb982f9e2c8e19ab1e69b6ec43 100644
index 04ae8af914e65ae9725d276a9dcc24893cbcabb9..1757e44ecb9d23fd0ca6f7e7f9c07509b377675f 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -1571,7 +1571,7 @@ public abstract class EntityLiving extends Entity {

View File

@@ -19,10 +19,10 @@ index 63d93060b350069040876aaacb91c853d674ea7b..e9793954c872baacfe7be80ecf3888e8
}
return;
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index ac5b13e943d70cfb982f9e2c8e19ab1e69b6ec43..6ef78c9099a234abce3669a23e32777ec3beaba7 100644
index 1757e44ecb9d23fd0ca6f7e7f9c07509b377675f..26ae5f5d0b8acfd173e3401aa07bc6fcdc860978 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -2974,6 +2974,7 @@ public abstract class EntityLiving extends Entity {
@@ -2977,6 +2977,7 @@ public abstract class EntityLiving extends Entity {
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] One Punch Man!
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 6ef78c9099a234abce3669a23e32777ec3beaba7..49fefb5f20bda418ae9fcdc238630c5f27b1b859 100644
index 26ae5f5d0b8acfd173e3401aa07bc6fcdc860978..2c5280fe13fa962cfa514b41b1da15c019e30715 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -2019,6 +2019,23 @@ public abstract class EntityLiving extends Entity {

View File

@@ -18,7 +18,7 @@ index d321616b7f726f4ff307b46ced9efce6cc20b82f..c20787a20cf6f273092d2b7ef0d7d90a
public Iterable<ItemStack> bn() {
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 49fefb5f20bda418ae9fcdc238630c5f27b1b859..7dbfd2dca4d99fcafc3a2fcd83b39f5d52c24f1c 100644
index 2c5280fe13fa962cfa514b41b1da15c019e30715..82d3aaaf9bbb493d54f6bf2d34edafc5498aee88 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -394,7 +394,7 @@ public abstract class EntityLiving extends Entity {