9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-29 20:09:17 +00:00

Revert "fix pwt thread dead"

This reverts commit ffe613e0e9.
This commit is contained in:
hayanesuru
2025-06-07 14:44:37 +09:00
parent ffe613e0e9
commit 5e570748a7

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..1e6042dfc768e208b2fe5738bce2f933c44268c7 100644
index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a515b0a5764 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -74,13 +74,96 @@ public class CraftBlock implements Block {
@@ -74,13 +74,98 @@ public class CraftBlock implements Block {
return new CraftBlock(world, position);
}
@@ -345,17 +345,19 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
+ return defaultValue;
+ }
+
+ // Leaf start - SparklyPaper - parallel world ticking - Shutdown handling for async reads
+ 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;
+ }
+ 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 {
+ 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;
@@ -417,7 +419,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
}
// Paper end
@@ -144,10 +227,12 @@ public class CraftBlock implements Block {
@@ -144,10 +229,12 @@ public class CraftBlock implements Block {
return this.getWorld().getChunkAt(this);
}
@@ -430,7 +432,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
public void setData(final byte data, boolean applyPhysics) {
if (applyPhysics) {
this.setData(data, 3);
@@ -157,12 +242,18 @@ public class CraftBlock implements Block {
@@ -157,12 +244,18 @@ public class CraftBlock implements Block {
}
private void setData(final byte data, int flag) {
@@ -450,7 +452,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
return CraftMagicNumbers.toLegacyData(blockData);
}
@@ -179,6 +270,7 @@ public class CraftBlock implements Block {
@@ -179,6 +272,7 @@ public class CraftBlock implements Block {
@Override
public void setType(Material type, boolean applyPhysics) {
Preconditions.checkArgument(type != null, "Material cannot be null");
@@ -458,7 +460,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
this.setBlockData(type.createBlockData(), applyPhysics);
}
@@ -198,6 +290,12 @@ public class CraftBlock implements Block {
@@ -198,6 +292,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) {
@@ -471,7 +473,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
// 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 +324,62 @@ public class CraftBlock implements Block {
@@ -226,22 +326,62 @@ public class CraftBlock implements Block {
@Override
public Material getType() {
@@ -538,7 +540,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
}
public Block getFace(final BlockFace face) {
@@ -282,51 +420,36 @@ public class CraftBlock implements Block {
@@ -282,51 +422,36 @@ public class CraftBlock implements Block {
@Override
public String toString() {
@@ -614,7 +616,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
}
@Override
@@ -343,18 +466,65 @@ public class CraftBlock implements Block {
@@ -343,18 +468,65 @@ public class CraftBlock implements Block {
@Override
public Biome getBiome() {
@@ -682,7 +684,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio);
}
@@ -370,12 +540,50 @@ public class CraftBlock implements Block {
@@ -370,12 +542,50 @@ public class CraftBlock implements Block {
@Override
public boolean isBlockPowered() {
@@ -735,7 +737,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
}
@Override
@@ -397,46 +605,101 @@ public class CraftBlock implements Block {
@@ -397,46 +607,101 @@ public class CraftBlock implements Block {
@Override
public boolean isBlockFacePowered(BlockFace face) {
@@ -864,7 +866,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
@Override
public int getBlockPower() {
@@ -479,105 +742,179 @@ public class CraftBlock implements Block {
@@ -479,105 +744,179 @@ public class CraftBlock implements Block {
@Override
public PistonMoveReaction getPistonMoveReaction() {
@@ -951,14 +953,14 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
+ 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 {
@@ -1085,7 +1087,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
}
@Override
@@ -592,31 +929,70 @@ public class CraftBlock implements Block {
@@ -592,31 +931,70 @@ public class CraftBlock implements Block {
@Override
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
@@ -1166,7 +1168,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
this.getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
@@ -639,57 +1015,147 @@ public class CraftBlock implements Block {
@@ -639,57 +1017,147 @@ public class CraftBlock implements Block {
@Override
public boolean isPassable() {
@@ -1338,7 +1340,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
}
@Override
@@ -700,7 +1166,10 @@ public class CraftBlock implements Block {
@@ -700,7 +1168,10 @@ public class CraftBlock implements Block {
// Paper start
@Override
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
@@ -1350,7 +1352,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..1e6042dfc768e208b2fe5738bce2f933
}
@Override
@@ -713,26 +1182,76 @@ public class CraftBlock implements Block {
@@ -713,26 +1184,76 @@ public class CraftBlock implements Block {
return this.getNMS().getBlock().getDescriptionId();
}