Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 02:50:09 +01:00
Port lag compensation patch
Dieser Commit ist enthalten in:
Ursprung
821081d646
Commit
1d0fcb5aaf
@ -8,10 +8,10 @@ Areas affected by lag comepnsation:
|
||||
- Eating food items
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 6d7224787d328540319c76f904e00cbe96d53565..5df535aae94bbba940da5d21eb72afc945915f4c 100644
|
||||
index 330bee331335454a61cf8350a6654217c8124445..54e581db732c3a104142a2bbc228ecbe16aec0fc 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -315,6 +315,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -322,6 +322,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
public volatile Thread shutdownThread; // Paper
|
||||
public volatile boolean abnormalExit = false; // Paper
|
||||
@ -19,7 +19,7 @@ index 6d7224787d328540319c76f904e00cbe96d53565..5df535aae94bbba940da5d21eb72afc9
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
@@ -1754,6 +1755,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1775,6 +1776,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
|
||||
worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
|
||||
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers
|
||||
@ -28,13 +28,13 @@ index 6d7224787d328540319c76f904e00cbe96d53565..5df535aae94bbba940da5d21eb72afc9
|
||||
this.profiler.push(() -> {
|
||||
String s = String.valueOf(worldserver);
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 05bf2094d10f924401eb122cd3fe4540aafce497..d4376ed215d97066a21e462fae2a0e25ad8a16a1 100644
|
||||
index 7ba34da235ea536b929e1c8bc2cc39e48b33f5aa..dafc35584d86ed1c18e4f328cb92523952664f73 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -570,6 +570,17 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
return player != null && player.level() == this ? player : null;
|
||||
@@ -518,6 +518,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
return this.nearbyPlayers;
|
||||
}
|
||||
// Paper end - optimise getPlayerByUUID
|
||||
// Paper end - rewrite chunk system
|
||||
+ // Paper start - lag compensation
|
||||
+ private long lagCompensationTick = net.minecraft.server.MinecraftServer.SERVER_INIT;
|
||||
+
|
||||
@ -50,10 +50,10 @@ index 05bf2094d10f924401eb122cd3fe4540aafce497..d4376ed215d97066a21e462fae2a0e25
|
||||
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
||||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index c7efde4e2b87b14e768429748b01c1bce659682b..1047027610624c9ba4bb5afd5d7f0714a062b198 100644
|
||||
index 24b1715397ba8e6f5e9841a030d0e3d964356f89..cc01ead133cc6859ca5d7a1d0ac3c12955e590da 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -127,7 +127,7 @@ public class ServerPlayerGameMode {
|
||||
@@ -129,7 +129,7 @@ public class ServerPlayerGameMode {
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@ -63,10 +63,10 @@ index c7efde4e2b87b14e768429748b01c1bce659682b..1047027610624c9ba4bb5afd5d7f0714
|
||||
|
||||
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
|
||||
index 81a8296e25275639718e0839888ac6a900b54bf3..4928dc3c879ddad0fe8c377b1b26e543a1c40cca 100644
|
||||
index 909accac7538e1c0c0c51deb2ee0605697c059d0..4c4050fe8f3b788481350caeb2077fa91be12060 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3823,6 +3823,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -3900,6 +3900,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer);
|
||||
}
|
||||
// Paper end - Properly cancel usable items
|
||||
@ -77,7 +77,7 @@ index 81a8296e25275639718e0839888ac6a900b54bf3..4928dc3c879ddad0fe8c377b1b26e543
|
||||
private void updatingUsingItem() {
|
||||
if (this.isUsingItem()) {
|
||||
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
||||
@@ -3841,7 +3845,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -3918,7 +3922,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.triggerItemUseEffects(stack, 5);
|
||||
}
|
||||
|
||||
@ -91,19 +91,19 @@ index 81a8296e25275639718e0839888ac6a900b54bf3..4928dc3c879ddad0fe8c377b1b26e543
|
||||
this.completeUsingItem();
|
||||
}
|
||||
|
||||
@@ -3887,7 +3896,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -3964,7 +3973,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
||||
this.useItem = itemstack;
|
||||
- this.useItemRemaining = itemstack.getUseDuration();
|
||||
- this.useItemRemaining = itemstack.getUseDuration(this);
|
||||
+ // Paper start - lag compensate eating
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = itemstack.getUseDuration();
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = itemstack.getUseDuration(this);
|
||||
+ this.eatStartTime = System.nanoTime();
|
||||
+ // Paper end - lag compensate eating
|
||||
if (!this.level().isClientSide) {
|
||||
this.setLivingEntityFlag(1, true);
|
||||
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
||||
@@ -3912,7 +3924,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -3989,7 +4001,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||
this.useItem = ItemStack.EMPTY;
|
||||
@ -115,7 +115,7 @@ index 81a8296e25275639718e0839888ac6a900b54bf3..4928dc3c879ddad0fe8c377b1b26e543
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4047,7 +4062,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -4129,7 +4144,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
this.useItem = ItemStack.EMPTY;
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren