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;
}
}