mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 00:47:38 +01:00
Add lag compensation for breaking blocks
This commit is contained in:
parent
38dc3b25d8
commit
84556f3cda
@ -1,74 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Tue, 14 Jan 2020 15:28:28 -0800
|
||||
Subject: [PATCH] Lag compensate eating
|
||||
|
||||
When the server is lagging, players will wait longer when eating.
|
||||
Change to also use a time check instead if it passes.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index ac59a1e5ae4fe84af44220d721b60f2e157e0f1f..ca179b062fa6142da584ad1a091e63d89403a0f0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3653,6 +3653,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;
|
||||
}
|
||||
|
||||
+ // Paper start - lag compensate eating
|
||||
+ protected long eatStartTime;
|
||||
+ protected int totalEatTimeTicks;
|
||||
+ // Paper end
|
||||
+
|
||||
private void updatingUsingItem() {
|
||||
if (this.isUsingItem()) {
|
||||
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
||||
@@ -3671,7 +3676,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.triggerItemUseEffects(stack, 5);
|
||||
}
|
||||
|
||||
- if (--this.useItemRemaining == 0 && !this.level().isClientSide && !stack.useOnRelease()) {
|
||||
+ // Paper start - lag compensate eating
|
||||
+ // we add 1 to the expected time to avoid lag compensating when we should not
|
||||
+ boolean shouldLagCompensate = this.useItem.getItem().isEdible() && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1 + this.totalEatTimeTicks) * 50 * (1000 * 1000));
|
||||
+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !stack.useOnRelease()) {
|
||||
+ this.useItemRemaining = 0;
|
||||
+ // Paper end
|
||||
this.completeUsingItem();
|
||||
}
|
||||
|
||||
@@ -3719,7 +3729,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag
|
||||
this.useItem = itemstack;
|
||||
- this.useItemRemaining = itemstack.getUseDuration();
|
||||
+ // Paper start - lag compensate eating
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = itemstack.getUseDuration();
|
||||
+ this.eatStartTime = System.nanoTime();
|
||||
+ // Paper end
|
||||
if (!this.level().isClientSide) {
|
||||
this.setLivingEntityFlag(1, true);
|
||||
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
||||
@@ -3744,7 +3757,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||
this.useItem = ItemStack.EMPTY;
|
||||
- this.useItemRemaining = 0;
|
||||
+ // Paper start - lag compensate eating
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = 0;
|
||||
+ this.eatStartTime = -1L;
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3877,7 +3893,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
this.useItem = ItemStack.EMPTY;
|
||||
- this.useItemRemaining = 0;
|
||||
+ // Paper start - lag compensate eating
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = 0;
|
||||
+ this.eatStartTime = -1L;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public boolean isBlocking() {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Entity Jump API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index ca179b062fa6142da584ad1a091e63d89403a0f0..4008d402b01d7ea25a56d16ebbf00e182b0d60c3 100644
|
||||
index ac59a1e5ae4fe84af44220d721b60f2e157e0f1f..81a64f4fc3e06ff9b32f91fc502809e0436d6e26 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3284,8 +3284,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@ -12,7 +12,7 @@ The entity's current team collision rule causes them to NEVER collide.
|
||||
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 4008d402b01d7ea25a56d16ebbf00e182b0d60c3..d8c337ae968f04af8870591da6c89dc25b5db311 100644
|
||||
index 81a64f4fc3e06ff9b32f91fc502809e0436d6e26..5fe5fef2e10944edc0c43da6e9d137e418c189c9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3399,10 +3399,24 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index d8c337ae968f04af8870591da6c89dc25b5db311..29c5372f48211e86fa8cfbdea9e10025a4f310d1 100644
|
||||
index 5fe5fef2e10944edc0c43da6e9d137e418c189c9..1f8c62aa221241c6532eb60e2c9b7344ef834b23 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2196,7 +2196,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@ -80,7 +80,7 @@ index eed16b541a9c39ed4697e783612e6f7b7ff23b70..1d2dd9b8ae43f22d875cb530130118df
|
||||
|
||||
public float getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState, float max) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 29c5372f48211e86fa8cfbdea9e10025a4f310d1..a8f51cb5be994783eca8ff13eb172fd651deb05e 100644
|
||||
index 1f8c62aa221241c6532eb60e2c9b7344ef834b23..655bd3b1ba3c2c02d70d41ae343c4aa97c3ce9a0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1711,9 +1711,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Don't check chunk for portal on world gen entity add
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index a8f51cb5be994783eca8ff13eb172fd651deb05e..4d9149d3a1d5711b88ce86fb34dbdc926cbe8c31 100644
|
||||
index 655bd3b1ba3c2c02d70d41ae343c4aa97c3ce9a0..b80192d4d35cfb6ad155ac34b5296d689a154387 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3511,7 +3511,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user