mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@88a3a870 Configurable xp orb merge group count (#12503) PaperMC/Paper@53d1d04e Disable Item Obfuscation for entity related stacks (#12297) PaperMC/Paper@c98cd658 Add configuration interface to expose certain config values (#12273) PaperMC/Paper@42a2a6c2 Supports the ability for commands to be registered internally (#12520) PaperMC/Paper@753cff7c Improvements for Dump paper commands (#12512) PaperMC/Paper@e2da5d2f Registry API for supported Mob Variants (#12417) PaperMC/Paper@ab0253fe Expand PlayerDeathEvent API (#12221) PaperMC/Paper@cbcf75a5 Update visual fire handling with TriState support (#12303) PaperMC/Paper@6c3964d2 Properly save level data async (#12530) PaperMC/Paper@d2ad2e66 Add missing EntityLookup#getAllMapped from Moonrise PaperMC/Paper@358e72ec Remove simplify remote item matching stuff for now PaperMC/Paper@04ffca0b Also remove CraftPlayer methods PaperMC/Paper@a2525819 Update mache PaperMC/Paper@d683970d Add FishHookStateChangeEvent (#12165) PaperMC/Paper@369ad170 Cached tag parser for itemstack reading (#12547) PaperMC/Paper@841d6342 Fix ItemStack#addUnsafeEnchantment ignored for missing enchantment component (#12549) PaperMC/Paper@c000b352 fix(bukkit-brig-forwarding-map): Invert isEmpty method (#12555) PaperMC/Paper@28d7df75 Backport HeroesOfTheVillage datafixer fix PaperMC/Paper@f1dbed07 Implement BlocksAttack DamageReduction and ItemDamage (#12538) PaperMC/Paper@cc38032b Deprecate TeleportCause CHORUS_FRUIT for CONSUMABLE_EFFECT (#12546) PaperMC/Paper@35878677 [ci/skip] Fix format and mentions for ItemDamageFunction (#12560) PaperMC/Paper@7171d299 [ci/skip] Mention CAN_PLACE/CAN_BREAK component in ItemMeta (#12559) PaperMC/Paper@6f73e62e Add getPickItemStack (#12552) PaperMC/Paper@ce0fa4c4 Replace old version command with brigadier equivalent (#12502) PaperMC/Paper@fa360aa8 Add some missing annotations and an incorrect one (#12204) PaperMC/Paper@113b18ee Update paperweight and Gradle wrapper (#12573) PaperMC/Paper@f303a076 fix: Don't hardcode checks for translation registries (#12571) PaperMC/Paper@87349c31 Fix CombatTracker stale on death (#12562) PaperMC/Paper@b70bca6b Revert "fix: Don't hardcode checks for translation registries (#12571)" Purpur Changes: PurpurMC/Purpur@93011bc1 Add configuration setting to re-add End void rings (#1656) PurpurMC/Purpur@c2f48591 [ci/skip] only set default world config values once PurpurMC/Purpur@6f5bbae5 [ci/skip] move some code around PurpurMC/Purpur@5c1a9835 fix issue with `shift-right-click-repairs-mending-points` PurpurMC/Purpur@3156e446 check damage value of tool correctly PurpurMC/Purpur@a9fe4f25 Updated Upstream (Paper) PurpurMC/Purpur@9d0aa8eb Updated Upstream (Paper) PurpurMC/Purpur@603c7557 Updated Upstream (Paper) PurpurMC/Purpur@eca78060 Updated Upstream (Paper) PurpurMC/Purpur@e4e9cfdf Updated Upstream (Paper) PurpurMC/Purpur@3de2fc7d Updated Upstream (Paper) PurpurMC/Purpur@09f547de add `mob-griefing-override` config options (#1661) PurpurMC/Purpur@1dd9bd0c Updated Upstream (Paper) PurpurMC/Purpur@7a8aa86a finish updating gradle PurpurMC/Purpur@fd78b90f bandaid fix: increase the daemon heap for now
213 lines
11 KiB
Diff
213 lines
11 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Thu, 24 Apr 2025 16:36:16 -0400
|
|
Subject: [PATCH] Paw optimization
|
|
|
|
Some random optimizations
|
|
|
|
- Remove Paper's dead code
|
|
- Only set shuffle random seed if is really used
|
|
- Secret patches (WIP)
|
|
|
|
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
|
|
index c83ee2137a57e62003b1d20c3ceea9f569350a53..de1f271d36c7daa10c398e146386b51e2622df9a 100644
|
|
--- a/net/minecraft/network/Connection.java
|
|
+++ b/net/minecraft/network/Connection.java
|
|
@@ -660,13 +660,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener)
|
|
|| loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.VERIFYING
|
|
|| Connection.joinAttemptsThisTick++ < MAX_PER_TICK) {
|
|
- // Paper start - detailed watchdog information
|
|
- net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener);
|
|
- try {
|
|
tickablePacketListener.tick();
|
|
- } finally {
|
|
- net.minecraft.network.protocol.PacketUtils.packetProcessing.pop();
|
|
- } // Paper end - detailed watchdog information
|
|
} // Paper end - Buffer joins to world
|
|
}
|
|
|
|
diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java
|
|
index 4535858701b2bb232b9d2feb2af6551526232ddc..e65c62dbe4c1560ae153e4c4344e9194c783a2f4 100644
|
|
--- a/net/minecraft/network/protocol/PacketUtils.java
|
|
+++ b/net/minecraft/network/protocol/PacketUtils.java
|
|
@@ -21,8 +21,6 @@ public class PacketUtils {
|
|
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, BlockableEventLoop<?> executor) throws RunningOnDifferentThreadException {
|
|
if (!executor.isSameThread()) {
|
|
executor.executeIfPossible(() -> {
|
|
- packetProcessing.push(processor); // Paper - detailed watchdog information
|
|
- try { // Paper - detailed watchdog information
|
|
if (processor instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players
|
|
if (processor.shouldHandleMessage(packet)) {
|
|
try {
|
|
@@ -37,12 +35,6 @@ public class PacketUtils {
|
|
} else {
|
|
LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
|
|
}
|
|
- // Paper start - detailed watchdog information
|
|
- } finally {
|
|
- totalMainThreadPacketsProcessed.getAndIncrement();
|
|
- packetProcessing.pop();
|
|
- }
|
|
- // Paper end - detailed watchdog information
|
|
});
|
|
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
|
|
}
|
|
@@ -69,22 +61,4 @@ public class PacketUtils {
|
|
|
|
packetListener.fillCrashReport(crashReport);
|
|
}
|
|
-
|
|
- // Paper start - detailed watchdog information
|
|
- public static final java.util.concurrent.ConcurrentLinkedDeque<PacketListener> packetProcessing = new java.util.concurrent.ConcurrentLinkedDeque<>();
|
|
- static final java.util.concurrent.atomic.AtomicLong totalMainThreadPacketsProcessed = new java.util.concurrent.atomic.AtomicLong();
|
|
-
|
|
- public static long getTotalProcessedPackets() {
|
|
- return totalMainThreadPacketsProcessed.get();
|
|
- }
|
|
-
|
|
- public static java.util.List<PacketListener> getCurrentPacketProcessors() {
|
|
- java.util.List<PacketListener> listeners = new java.util.ArrayList<>(4);
|
|
- for (PacketListener listener : packetProcessing) {
|
|
- listeners.add(listener);
|
|
- }
|
|
-
|
|
- return listeners;
|
|
- }
|
|
- // Paper end - detailed watchdog information
|
|
}
|
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
index 0f9d18dd29e210ad656da211a3cb1cb25cd4efb1..d1c36cd17c83e7e0167046093c4a2b8427c8bae0 100644
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -622,8 +622,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
try {
|
|
this.chunkMap.collectSpawningChunks(list);
|
|
// Paper start - chunk tick iteration optimisation
|
|
- this.shuffleRandom.setSeed(this.level.random.nextLong());
|
|
- if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled
|
|
+ if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
|
|
+ this.shuffleRandom.setSeed(this.level.random.nextLong()); // Leaf - paw optimization - Only set seed if is really used
|
|
+ Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled
|
|
+ }
|
|
// Paper end - chunk tick iteration optimisation
|
|
|
|
for (LevelChunk levelChunk : list) {
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index a753481afe02a2367c378c7f39206fde23eda00d..753b4255d9e9b9628bc5825a6b4f0f2540f06e7a 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1367,13 +1367,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
// Paper end - log detailed entity tick information
|
|
|
|
public void tickNonPassenger(Entity entity) {
|
|
- // Paper start - log detailed entity tick information
|
|
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
|
|
- try {
|
|
- if (currentlyTickingEntity.get() == null) {
|
|
- currentlyTickingEntity.lazySet(entity);
|
|
- }
|
|
- // Paper end - log detailed entity tick information
|
|
entity.setOldPosAndRot();
|
|
entity.tickCount++;
|
|
entity.totalEntityAge++; // Paper - age-like counter for all entities
|
|
@@ -1386,13 +1380,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
for (Entity entity1 : entity.getPassengers()) {
|
|
this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2
|
|
}
|
|
- // Paper start - log detailed entity tick information
|
|
- } finally {
|
|
- if (currentlyTickingEntity.get() == entity) {
|
|
- currentlyTickingEntity.lazySet(null);
|
|
- }
|
|
- }
|
|
- // Paper end - log detailed entity tick information
|
|
}
|
|
|
|
private void tickPassenger(Entity ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index f3a6c98fb803f2141be0ef8315ed9294515f1b73..6d8c7d90b0a64e99a2e811ccdb84a03be95e27b3 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -1140,16 +1140,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.onGround;
|
|
}
|
|
|
|
- // Paper start - detailed watchdog information
|
|
- public final Object posLock = new Object(); // Paper - log detailed entity tick information
|
|
-
|
|
- @Nullable
|
|
- private Vec3 moveVector;
|
|
- private double moveStartX;
|
|
- private double moveStartY;
|
|
- private double moveStartZ;
|
|
- // Paper end - detailed watchdog information
|
|
-
|
|
public void move(MoverType type, Vec3 movement) {
|
|
// Gale start - VMP - skip entity move if movement is zero
|
|
if (!this.boundingBoxChanged && movement.equals(Vec3.ZERO)) {
|
|
@@ -1157,16 +1147,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
// Gale end - VMP - skip entity move if movement is zero
|
|
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
|
- // Paper start - detailed watchdog information
|
|
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
|
- synchronized (this.posLock) {
|
|
- this.moveStartX = this.getX();
|
|
- this.moveStartY = this.getY();
|
|
- this.moveStartZ = this.getZ();
|
|
- this.moveVector = movement;
|
|
- }
|
|
- try {
|
|
- // Paper end - detailed watchdog information
|
|
if (this.noPhysics) {
|
|
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
|
|
} else {
|
|
@@ -1300,13 +1281,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
// Gale end - skip negligible planar movement multiplication
|
|
}
|
|
}
|
|
- // Paper start - detailed watchdog information
|
|
- } finally {
|
|
- synchronized (this.posLock) { // Paper
|
|
- this.moveVector = null;
|
|
- } // Paper
|
|
- }
|
|
- // Paper end - detailed watchdog information
|
|
}
|
|
|
|
private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) {
|
|
@@ -4817,9 +4791,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
public void setDeltaMovement(Vec3 deltaMovement) {
|
|
- synchronized (this.posLock) { // Paper - detailed watchdog information
|
|
this.deltaMovement = deltaMovement;
|
|
- } // Paper - detailed watchdog information
|
|
}
|
|
|
|
public void addDeltaMovement(Vec3 addend) {
|
|
@@ -4927,9 +4899,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
// Paper end - Fix MC-4
|
|
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
|
- synchronized (this.posLock) { // Paper - detailed watchdog information
|
|
this.position = new Vec3(x, y, z);
|
|
- } // Paper - detailed watchdog information
|
|
int floor = Mth.floor(x);
|
|
int floor1 = Mth.floor(y);
|
|
int floor2 = Mth.floor(z);
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java
|
|
index ef9c2c0a665a1acf490affd9cd4496ae9d677410..27e7c1bb585f30165bd501bb8f8aab0dd147ca5b 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java
|
|
@@ -48,7 +48,7 @@ public class DesertPyramidStructure extends SinglePieceStructure {
|
|
}
|
|
}
|
|
|
|
- ObjectArrayList<BlockPos> list = new ObjectArrayList<>(set.stream().toList());
|
|
+ ObjectArrayList<BlockPos> list = new ObjectArrayList<>(set); // Leaf - paw optimization - TODO: use array
|
|
RandomSource randomSource = RandomSource.create(level.getSeed()).forkPositional().at(pieces.calculateBoundingBox().getCenter());
|
|
Util.shuffle(list, randomSource);
|
|
int min = Math.min(set.size(), randomSource.nextInt(5, 8));
|