9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

fix pwt thread dead

This commit is contained in:
hayanesuru
2025-06-07 14:33:28 +09:00
parent afef9c5d73
commit ffe613e0e9

View File

@@ -315,10 +315,10 @@ index af33cab59932f4ec135caf94dc5828930833daf6..caa92e48d031cb54950e6613a82f407d
}
// Paper end
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a515b0a5764 100644
index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933c44268c7 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -74,13 +74,98 @@ public class CraftBlock implements Block {
@@ -74,13 +74,96 @@ public class CraftBlock implements Block {
return new CraftBlock(world, position);
}
@@ -345,19 +345,17 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
+ return defaultValue;
+ }
+
+ java.util.concurrent.CompletableFuture<Object> future = new java.util.concurrent.CompletableFuture<>();
+
+ // Leaf start - SparklyPaper - parallel world ticking - Shutdown handling for async reads
+ if (level.isShuttingDown()) {
+ future.completeExceptionally(new IllegalStateException("World " + level.getWorld().getName() + " is shutting down. Cannot queue new buffered read: " + type));
+ } else {
+ try {
+ if (level.isShuttingDown()) {
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "World " + level.getWorld().getName() + " is shutting down. Cannot queue new buffered read: " + type + " " + methodName, new Throwable());
+ return defaultValue;
+ }
+
+ org.dreeam.leaf.async.world.WorldReadRequest request = new org.dreeam.leaf.async.world.WorldReadRequest(type, params, future);
+ level.asyncReadRequestQueue.offer(request); // Assumes queue exists on ServerLevel
+ }
+ Object result = request.future().join(); // Block until tick thread completes it
+ // Leaf end - SparklyPaper - parallel world ticking - Shutdown handling for async reads
+
+ try {
+ Object result = future.join(); // Block until tick thread completes it
+ if (result == null) {
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "PWT: Buffered async read returned null for " + methodName + " - returning default.");
+ return defaultValue;
@@ -419,7 +417,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
}
// Paper end
@@ -144,10 +229,12 @@ public class CraftBlock implements Block {
@@ -144,10 +227,12 @@ public class CraftBlock implements Block {
return this.getWorld().getChunkAt(this);
}
@@ -432,7 +430,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
public void setData(final byte data, boolean applyPhysics) {
if (applyPhysics) {
this.setData(data, 3);
@@ -157,12 +244,18 @@ public class CraftBlock implements Block {
@@ -157,12 +242,18 @@ public class CraftBlock implements Block {
}
private void setData(final byte data, int flag) {
@@ -452,7 +450,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
return CraftMagicNumbers.toLegacyData(blockData);
}
@@ -179,6 +272,7 @@ public class CraftBlock implements Block {
@@ -179,6 +270,7 @@ public class CraftBlock implements Block {
@Override
public void setType(Material type, boolean applyPhysics) {
Preconditions.checkArgument(type != null, "Material cannot be null");
@@ -460,7 +458,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
this.setBlockData(type.createBlockData(), applyPhysics);
}
@@ -198,6 +292,12 @@ public class CraftBlock implements Block {
@@ -198,6 +290,12 @@ public class CraftBlock implements Block {
}
public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics) {
@@ -473,7 +471,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
// SPIGOT-4612: faster - just clear tile
@@ -226,22 +326,62 @@ public class CraftBlock implements Block {
@@ -226,22 +324,62 @@ public class CraftBlock implements Block {
@Override
public Material getType() {
@@ -540,7 +538,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
}
public Block getFace(final BlockFace face) {
@@ -282,51 +422,36 @@ public class CraftBlock implements Block {
@@ -282,51 +420,36 @@ public class CraftBlock implements Block {
@Override
public String toString() {
@@ -616,7 +614,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
}
@Override
@@ -343,18 +468,65 @@ public class CraftBlock implements Block {
@@ -343,18 +466,65 @@ public class CraftBlock implements Block {
@Override
public Biome getBiome() {
@@ -684,7 +682,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio);
}
@@ -370,12 +542,50 @@ public class CraftBlock implements Block {
@@ -370,12 +540,50 @@ public class CraftBlock implements Block {
@Override
public boolean isBlockPowered() {
@@ -737,7 +735,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
}
@Override
@@ -397,46 +607,101 @@ public class CraftBlock implements Block {
@@ -397,46 +605,101 @@ public class CraftBlock implements Block {
@Override
public boolean isBlockFacePowered(BlockFace face) {
@@ -866,7 +864,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
@Override
public int getBlockPower() {
@@ -479,105 +744,179 @@ public class CraftBlock implements Block {
@@ -479,105 +742,179 @@ public class CraftBlock implements Block {
@Override
public PistonMoveReaction getPistonMoveReaction() {
@@ -953,14 +951,14 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
+ int eventData = (eventId == net.minecraft.world.level.block.LevelEvent.PARTICLES_DESTROY_BLOCK)
+ ? net.minecraft.world.level.block.Block.getId(iblockdata) : 0;
+ this.world.levelEvent(eventId, this.position, eventData);
}
+ }
+ // Drop experience using ServerLevel
+ if (dropExperience) {
+ int xp = block.getExpDrop(iblockdata, serverLevelForDrops, this.position, nmsItem, true);
+ if (xp > 0) { // Only pop if there's XP to drop
+ block.popExperience(serverLevelForDrops, this.position, xp);
+ }
+ }
}
+ droppedItems = true;
+ }
+ } else {
@@ -1087,7 +1085,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
}
@Override
@@ -592,31 +931,70 @@ public class CraftBlock implements Block {
@@ -592,31 +929,70 @@ public class CraftBlock implements Block {
@Override
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
@@ -1168,7 +1166,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
this.getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
@@ -639,57 +1017,147 @@ public class CraftBlock implements Block {
@@ -639,57 +1015,147 @@ public class CraftBlock implements Block {
@Override
public boolean isPassable() {
@@ -1340,7 +1338,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
}
@Override
@@ -700,7 +1168,10 @@ public class CraftBlock implements Block {
@@ -700,7 +1166,10 @@ public class CraftBlock implements Block {
// Paper start
@Override
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
@@ -1352,7 +1350,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
}
@Override
@@ -713,26 +1184,76 @@ public class CraftBlock implements Block {
@@ -713,26 +1182,76 @@ public class CraftBlock implements Block {
return this.getNMS().getBlock().getDescriptionId();
}