mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939) PaperMC/Paper@1922be90 Update custom tags (#12183) PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009) PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949) PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992) PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974) PaperMC/Paper@42b653b1 Expose more argument types (#12665) PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010) PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996) PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
53 lines
2.7 KiB
Diff
53 lines
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Fri, 23 Dec 2022 20:42:50 +0100
|
|
Subject: [PATCH] Reduce block destruction packet allocations
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Cache block break animation packet"
|
|
By: VytskaLT <VytskaLT@protonmail.com>
|
|
As part of: SportPaper (https://github.com/Electroid/SportPaper)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 617eb1b9d30d499124576c5d7cb5152571cc6b84..ad114ca013e0d09d40755acbe916586868a519ed 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1579,6 +1579,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
@Override
|
|
public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) {
|
|
+ // Gale start - SportPaper - reduce block destruction packet allocations
|
|
+ var players = this.server.getPlayerList().getPlayers();
|
|
+
|
|
+ if (players.isEmpty()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(breakerId, pos, progress);
|
|
+ // Gale end - SportPaper - reduce block destruction packet allocations
|
|
// CraftBukkit start
|
|
Player breakerPlayer = null;
|
|
Entity entity = this.getEntity(breakerId);
|
|
@@ -1595,7 +1604,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
.callEvent();
|
|
}
|
|
// Paper end - Add BlockBreakProgressUpdateEvent
|
|
- for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) {
|
|
+ for (ServerPlayer serverPlayer : players) { // Gale - SportPaper - reduce block destruction packet allocations
|
|
if (serverPlayer != null && serverPlayer.level() == this && serverPlayer.getId() != breakerId) {
|
|
double d = pos.getX() - serverPlayer.getX();
|
|
double d1 = pos.getY() - serverPlayer.getY();
|
|
@@ -1606,7 +1615,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
// CraftBukkit end
|
|
if (d * d + d1 * d1 + d2 * d2 < 1024.0) {
|
|
- serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress));
|
|
+ serverPlayer.connection.send(packet); // Gale - SportPaper - reduce block destruction packet allocations
|
|
}
|
|
}
|
|
}
|