mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 15:00:30 +01:00
Fix sleeping pos desync
This commit is contained in:
parent
87ce7c7209
commit
7f856a1d1f
5 changed files with 33 additions and 14 deletions
|
@ -52,6 +52,25 @@ index 8ba573bb4099ee5b27b61f333e72d794c48d5f29..69bdf3f2ee731e59e8d454816a9ca72c
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
index b4568e0dcb33aa516c1bcd7338e7f9220ac71ff6..a55985205cbd5d318a15552816ce44560d323559 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -870,12 +870,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
|
||||||
|
if (nbt.contains("SleepingX", 99) && nbt.contains("SleepingY", 99) && nbt.contains("SleepingZ", 99)) {
|
||||||
|
BlockPos blockposition = new BlockPos(nbt.getInt("SleepingX"), nbt.getInt("SleepingY"), nbt.getInt("SleepingZ"));
|
||||||
|
-
|
||||||
|
+ if (this.position().distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 16 * 16) { // Paper - The sleeping pos will always also set the actual pos, so a desync suggests something is wrong
|
||||||
|
this.setSleepingPos(blockposition);
|
||||||
|
this.entityData.set(LivingEntity.DATA_POSE, Pose.SLEEPING);
|
||||||
|
if (!this.firstTick) {
|
||||||
|
this.setPosToBed(blockposition);
|
||||||
|
}
|
||||||
|
+ } // Paper - The sleeping pos will always also set the actual pos, so a desync suggests something is wrong
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbt.contains("Brain", 10)) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
index 026654c4d3a910f0dbfed5475f23137086618242..1881deb9d8ffc884ba23843936615181f4220623 100644
|
index 026654c4d3a910f0dbfed5475f23137086618242..1881deb9d8ffc884ba23843936615181f4220623 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
|
|
@ -26,10 +26,10 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index b4568e0dcb33aa516c1bcd7338e7f9220ac71ff6..00bf8fb845f9230e8e01edbf202ffd208ff4cf8f 100644
|
index a55985205cbd5d318a15552816ce44560d323559..2b77cc316a8ca5bf75b4aa7f5e881d920bef094c 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -3724,7 +3724,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3725,7 +3725,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
|
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
|
||||||
|
|
||||||
// Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists
|
// Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists
|
||||||
|
|
|
@ -17,10 +17,10 @@ index edf937591abf62416bd692e40b7b7a6badbe877d..b40864e41e1506884fdefefbf3cf4833
|
||||||
};
|
};
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index 00bf8fb845f9230e8e01edbf202ffd208ff4cf8f..66e302f7a9d2b4dfe0a5b1c988c67f91f6ce0c98 100644
|
index 2b77cc316a8ca5bf75b4aa7f5e881d920bef094c..7d9890670b47a51839784914b0b96a994c1c6ace 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -1436,7 +1436,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -1437,7 +1437,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
if (!source.is(DamageTypeTags.IS_PROJECTILE)) {
|
if (!source.is(DamageTypeTags.IS_PROJECTILE)) {
|
||||||
Entity entity = source.getDirectEntity();
|
Entity entity = source.getDirectEntity();
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ index 00bf8fb845f9230e8e01edbf202ffd208ff4cf8f..66e302f7a9d2b4dfe0a5b1c988c67f91
|
||||||
LivingEntity entityliving = (LivingEntity) entity;
|
LivingEntity entityliving = (LivingEntity) entity;
|
||||||
|
|
||||||
this.blockUsingShield(entityliving);
|
this.blockUsingShield(entityliving);
|
||||||
@@ -1530,11 +1530,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -1531,11 +1531,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity1 != null && !source.is(DamageTypeTags.NO_KNOCKBACK)) {
|
if (entity1 != null && !source.is(DamageTypeTags.NO_KNOCKBACK)) {
|
||||||
|
@ -44,7 +44,7 @@ index 00bf8fb845f9230e8e01edbf202ffd208ff4cf8f..66e302f7a9d2b4dfe0a5b1c988c67f91
|
||||||
d0 = (Math.random() - Math.random()) * 0.01D;
|
d0 = (Math.random() - Math.random()) * 0.01D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2265,7 +2266,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -2266,7 +2267,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||||
Entity entity = damagesource.getDirectEntity();
|
Entity entity = damagesource.getDirectEntity();
|
||||||
|
|
||||||
|
|
|
@ -150,10 +150,10 @@ index 4816897a82c569717bf7ea139a55ab3fd931a63e..91feb12732564c90656da487664dbc12
|
||||||
this.sendLevelInfo(player, worldserver1);
|
this.sendLevelInfo(player, worldserver1);
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index 66e302f7a9d2b4dfe0a5b1c988c67f91f6ce0c98..3c517a82ac15a96f6be449a2422d5c9e894091a5 100644
|
index 7d9890670b47a51839784914b0b96a994c1c6ace..1ce4cf3b601cc3b002c1453cc105c1278264cc31 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -3822,6 +3822,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3823,6 +3823,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
|
return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,10 @@ index ef3048a4748113538a0ee0af5b526b2cd51d5c29..a7b217ddbcbf92513bd38101fdfca207
|
||||||
|
|
||||||
if (this.hasDelayedDestroy) {
|
if (this.hasDelayedDestroy) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index 3c517a82ac15a96f6be449a2422d5c9e894091a5..b9a7b9049b21eb81175168ec75f2446328a2c039 100644
|
index 1ce4cf3b601cc3b002c1453cc105c1278264cc31..6523795e715e5d472739e9bc6433143115c3de8f 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -3827,6 +3827,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3828,6 +3828,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
this.getEntityData().resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer);
|
this.getEntityData().resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer);
|
||||||
}
|
}
|
||||||
// Paper end - Properly cancel usable items
|
// Paper end - Properly cancel usable items
|
||||||
|
@ -77,7 +77,7 @@ index 3c517a82ac15a96f6be449a2422d5c9e894091a5..b9a7b9049b21eb81175168ec75f24463
|
||||||
private void updatingUsingItem() {
|
private void updatingUsingItem() {
|
||||||
if (this.isUsingItem()) {
|
if (this.isUsingItem()) {
|
||||||
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
||||||
@@ -3845,7 +3849,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3846,7 +3850,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
this.triggerItemUseEffects(stack, 5);
|
this.triggerItemUseEffects(stack, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ index 3c517a82ac15a96f6be449a2422d5c9e894091a5..b9a7b9049b21eb81175168ec75f24463
|
||||||
this.completeUsingItem();
|
this.completeUsingItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3893,7 +3902,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3894,7 +3903,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
|
||||||
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
||||||
this.useItem = itemstack;
|
this.useItem = itemstack;
|
||||||
|
@ -103,7 +103,7 @@ index 3c517a82ac15a96f6be449a2422d5c9e894091a5..b9a7b9049b21eb81175168ec75f24463
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
this.setLivingEntityFlag(1, true);
|
this.setLivingEntityFlag(1, true);
|
||||||
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
||||||
@@ -3918,7 +3930,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -3919,7 +3931,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
}
|
}
|
||||||
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
|
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||||
this.useItem = ItemStack.EMPTY;
|
this.useItem = ItemStack.EMPTY;
|
||||||
|
@ -115,7 +115,7 @@ index 3c517a82ac15a96f6be449a2422d5c9e894091a5..b9a7b9049b21eb81175168ec75f24463
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4053,7 +4068,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -4054,7 +4069,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.useItem = ItemStack.EMPTY;
|
this.useItem = ItemStack.EMPTY;
|
||||||
|
|
Loading…
Reference in a new issue