13
0
geforkt von Mirrors/Paper

Fix integer overflow for lag compensating eating check (#10797)

Dieser Commit ist enthalten in:
Lulu13022002 2024-05-26 22:35:58 +02:00
Ursprung dd6b67a80a
Commit dfcf0b3ac3

Datei anzeigen

@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- 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().components().has(DataComponents.FOOD) && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1 + this.totalEatTimeTicks) * 50 * (1000 * 1000));
+ boolean shouldLagCompensate = this.useItem.has(DataComponents.FOOD) && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1L + this.totalEatTimeTicks) * 50L * (1000L * 1000L));
+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !stack.useOnRelease()) {
+ this.useItemRemaining = 0;
+ // Paper end - lag compensate eating