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
105 lines
5.8 KiB
Diff
105 lines
5.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: peaches94 <peachescu94@gmail.com>
|
|
Date: Sat, 2 Jul 2022 00:35:56 -0500
|
|
Subject: [PATCH] Multithreaded Tracker
|
|
|
|
Original license: GPL v3
|
|
Original project: https://github.com/Bloom-host/Petal
|
|
|
|
Original license: GPL v3
|
|
Original project: https://github.com/TECHNOVE/Airplane-Experimental
|
|
|
|
Co-authored-by: Paul Sauve <paul@technove.co>
|
|
Co-authored-by: Kevin Raneri <kevin.raneri@gmail.com>
|
|
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
|
|
This patch refactored from original multithreaded tracker (Petal version),
|
|
and is derived from the Airplane fork by Paul Sauve, the tree is like:
|
|
Airplane -> Pufferfish? -> Petal -> Leaf
|
|
|
|
We made much of tracking logic asynchronously, and fixed visible issue
|
|
for the case of some NPC plugins which using real entity type, e.g. Citizens.
|
|
|
|
But it is still recommending to use those packet based, virtual entity
|
|
based NPC plugins, e.g. ZNPC Plus, Adyeshach, Fancy NPC, etc.
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
|
index db031298c2090eb36032de4b52335c62186e4cfb..84905d7802f8a5c3f68e15f1b17ef08216ad1f4e 100644
|
|
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
|
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
|
@@ -42,6 +42,12 @@ class PaperEventManager {
|
|
if (event.isAsynchronous() && this.server.isPrimaryThread()) {
|
|
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
|
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
|
+ // Leaf start - Multithreaded tracker
|
|
+ if (org.dreeam.leaf.config.modules.async.MultithreadedTracker.enabled) {
|
|
+ net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(event::callEvent);
|
|
+ return;
|
|
+ }
|
|
+ // Leaf end - Multithreaded tracker
|
|
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index 2a63e8e725fa97da5d4b9fba6bfe19377c7cfbe1..0c286eabd8e4d5e599d93a151874af6bf3642265 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -758,7 +758,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
ChunkMap.TrackedEntity entityTracker = world.getChunkSource().chunkMap.entityMap.get(this.getEntityId());
|
|
|
|
if (entityTracker != null) {
|
|
- for (ServerPlayerConnection connection : entityTracker.seenBy) {
|
|
+ for (ServerPlayerConnection connection : entityTracker.seenBy()) { // Leaf - Multithreaded tracker
|
|
players.add(connection.getPlayer().getBukkitEntity());
|
|
}
|
|
}
|
|
@@ -1074,7 +1074,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
return;
|
|
}
|
|
|
|
- for (final ServerPlayerConnection connection : entityTracker.seenBy) {
|
|
+ for (final ServerPlayerConnection connection : entityTracker.seenBy()) { // Leaf - Multithreaded tracker
|
|
this.getHandle().resendPossiblyDesyncedEntityData(connection.getPlayer());
|
|
}
|
|
}
|
|
@@ -1221,7 +1221,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
}
|
|
|
|
Set<org.bukkit.entity.Player> set = new java.util.HashSet<>(tracker.seenBy.size());
|
|
- for (net.minecraft.server.network.ServerPlayerConnection connection : tracker.seenBy) {
|
|
+ for (net.minecraft.server.network.ServerPlayerConnection connection : tracker.seenBy()) { // Leaf - Multithreaded tracker
|
|
set.add(connection.getPlayer().getBukkitEntity().getPlayer());
|
|
}
|
|
return set;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 3a3fbbfa0b82092cd9ac8eab2d179fb9f590aec8..566eab1add471266c8617747c8c25ee04e13c02f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1751,6 +1751,26 @@ public class CraftEventFactory {
|
|
}
|
|
|
|
public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity, boolean checkSetResult) {
|
|
+ // Leaf start - Multithreaded tracker
|
|
+ if (org.dreeam.leaf.config.modules.async.MultithreadedTracker.enabled && Thread.currentThread() instanceof org.dreeam.leaf.async.tracker.MultithreadedTracker.MultithreadedTrackerThread) {
|
|
+ java.util.concurrent.CompletableFuture<Boolean> future = new java.util.concurrent.CompletableFuture<>();
|
|
+ net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> {
|
|
+ boolean resultFlag = false;
|
|
+ CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos);
|
|
+ snapshot.setData(state);
|
|
+
|
|
+ BlockFormEvent event = (entity == null) ? new BlockFormEvent(snapshot.getBlock(), snapshot) : new EntityBlockFormEvent(entity.getBukkitEntity(), snapshot.getBlock(), snapshot);
|
|
+ if (event.callEvent()) {
|
|
+ boolean result = snapshot.place(flags);
|
|
+ resultFlag = !checkSetResult || result;
|
|
+ }
|
|
+
|
|
+ future.complete(resultFlag);
|
|
+ });
|
|
+
|
|
+ return future.join();
|
|
+ }
|
|
+ // Leaf end - Multithreaded tracker
|
|
CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos);
|
|
snapshot.setData(state);
|
|
|