Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
74f507f4e3
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e461dcfe #555: Item - add getters/setters for owner/thrower CraftBukkit Changes: 055870c4 #758: Item - add getters/setters for owner/thrower
84 Zeilen
3.8 KiB
Diff
84 Zeilen
3.8 KiB
Diff
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/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index ae3443aef2040fd2d3d214617c1b899309d127b7..65a3123b9c623d0a19868ba3dd6456a98c8915ad 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -120,7 +120,7 @@ public abstract class EntityLiving extends Entity {
|
|
private int jumpTicks;
|
|
private float bw;
|
|
public ItemStack activeItem; // Paper - public
|
|
- protected int bd;
|
|
+ protected int bd; protected final int getEatTimeTicks() { return this.bd; } protected final void setEatTimeTicks(int value) { this.bd = value; } // Paper - OBFHELPER
|
|
protected int be;
|
|
private BlockPosition bx;
|
|
private Optional<BlockPosition> by;
|
|
@@ -3039,6 +3039,11 @@ public abstract class EntityLiving extends Entity {
|
|
return ((Byte) this.datawatcher.get(EntityLiving.ag) & 2) > 0 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;
|
|
}
|
|
|
|
+ // Paper start - lag compensate eating
|
|
+ protected long eatStartTime;
|
|
+ protected int totalEatTimeTicks;
|
|
+ // Paper end
|
|
+
|
|
private void t() {
|
|
if (this.isHandRaised()) {
|
|
if (ItemStack.d(this.b(this.getRaisedHand()), this.activeItem)) {
|
|
@@ -3048,7 +3053,12 @@ public abstract class EntityLiving extends Entity {
|
|
this.b(this.activeItem, 5);
|
|
}
|
|
|
|
- if (--this.bd == 0 && !this.world.isClientSide && !this.activeItem.m()) {
|
|
+ // Paper start - lag compensate eating
|
|
+ // we add 1 to the expected time to avoid lag compensating when we should not
|
|
+ boolean shouldLagCompensate = this.activeItem.getItem().isFood() && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1 + this.totalEatTimeTicks) * 50 * (1000 * 1000));
|
|
+ if ((--this.bd == 0 || shouldLagCompensate) && !this.world.isClientSide && !this.activeItem.m()) {
|
|
+ this.setEatTimeTicks(0);
|
|
+ // Paper end
|
|
this.s();
|
|
}
|
|
} else {
|
|
@@ -3098,7 +3108,10 @@ public abstract class EntityLiving extends Entity {
|
|
|
|
if (!itemstack.isEmpty() && !this.isHandRaised() || forceUpdate) { // Paper use override flag
|
|
this.activeItem = itemstack;
|
|
- this.bd = itemstack.k();
|
|
+ // Paper start - lag compensate eating
|
|
+ this.bd = this.totalEatTimeTicks = itemstack.k();
|
|
+ this.eatStartTime = System.nanoTime();
|
|
+ // Paper end
|
|
if (!this.world.isClientSide) {
|
|
this.c(1, true);
|
|
this.c(2, enumhand == EnumHand.OFF_HAND);
|
|
@@ -3122,7 +3135,10 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
} else if (!this.isHandRaised() && !this.activeItem.isEmpty()) {
|
|
this.activeItem = ItemStack.b;
|
|
- this.bd = 0;
|
|
+ // Paper start - lag compensate eating
|
|
+ this.bd = this.totalEatTimeTicks = 0;
|
|
+ this.eatStartTime = -1L;
|
|
+ // Paper end
|
|
}
|
|
}
|
|
|
|
@@ -3250,7 +3266,10 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
this.activeItem = ItemStack.b;
|
|
- this.bd = 0;
|
|
+ // Paper start - lag compensate eating
|
|
+ this.bd = this.totalEatTimeTicks = 0;
|
|
+ this.eatStartTime = -1L;
|
|
+ // Paper end
|
|
}
|
|
|
|
public boolean isBlocking() {
|