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:
@@ -315,10 +315,10 @@ index af33cab59932f4ec135caf94dc5828930833daf6..caa92e48d031cb54950e6613a82f407d
|
|||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
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
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||||
+++ b/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);
|
return new CraftBlock(world, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,19 +345,17 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
+ return defaultValue;
|
+ return defaultValue;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ java.util.concurrent.CompletableFuture<Object> future = new java.util.concurrent.CompletableFuture<>();
|
|
||||||
+
|
|
||||||
+ // Leaf start - SparklyPaper - parallel world ticking - Shutdown handling for async reads
|
+ // Leaf start - SparklyPaper - parallel world ticking - Shutdown handling for async reads
|
||||||
+ if (level.isShuttingDown()) {
|
+ try {
|
||||||
+ future.completeExceptionally(new IllegalStateException("World " + level.getWorld().getName() + " is shutting down. Cannot queue new buffered read: " + type));
|
+ if (level.isShuttingDown()) {
|
||||||
+ } else {
|
+ 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);
|
+ 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
|
+ 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
|
+ // 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) {
|
+ if (result == null) {
|
||||||
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "PWT: Buffered async read returned null for " + methodName + " - returning default.");
|
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "PWT: Buffered async read returned null for " + methodName + " - returning default.");
|
||||||
+ return defaultValue;
|
+ return defaultValue;
|
||||||
@@ -419,7 +417,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
}
|
}
|
||||||
// Paper end
|
// 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);
|
return this.getWorld().getChunkAt(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +430,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
public void setData(final byte data, boolean applyPhysics) {
|
public void setData(final byte data, boolean applyPhysics) {
|
||||||
if (applyPhysics) {
|
if (applyPhysics) {
|
||||||
this.setData(data, 3);
|
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) {
|
private void setData(final byte data, int flag) {
|
||||||
@@ -452,7 +450,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
return CraftMagicNumbers.toLegacyData(blockData);
|
return CraftMagicNumbers.toLegacyData(blockData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,6 +272,7 @@ public class CraftBlock implements Block {
|
@@ -179,6 +270,7 @@ public class CraftBlock implements Block {
|
||||||
@Override
|
@Override
|
||||||
public void setType(Material type, boolean applyPhysics) {
|
public void setType(Material type, boolean applyPhysics) {
|
||||||
Preconditions.checkArgument(type != null, "Material cannot be null");
|
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||||
@@ -460,7 +458,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
this.setBlockData(type.createBlockData(), applyPhysics);
|
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) {
|
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
|
// 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
|
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
|
||||||
// SPIGOT-4612: faster - just clear tile
|
// 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
|
@Override
|
||||||
public Material getType() {
|
public Material getType() {
|
||||||
@@ -540,7 +538,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Block getFace(final BlockFace face) {
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -616,7 +614,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -343,18 +468,65 @@ public class CraftBlock implements Block {
|
@@ -343,18 +466,65 @@ public class CraftBlock implements Block {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Biome getBiome() {
|
public Biome getBiome() {
|
||||||
@@ -684,7 +682,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio);
|
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
|
@Override
|
||||||
public boolean isBlockPowered() {
|
public boolean isBlockPowered() {
|
||||||
@@ -737,7 +735,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -397,46 +607,101 @@ public class CraftBlock implements Block {
|
@@ -397,46 +605,101 @@ public class CraftBlock implements Block {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBlockFacePowered(BlockFace face) {
|
public boolean isBlockFacePowered(BlockFace face) {
|
||||||
@@ -866,7 +864,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockPower() {
|
public int getBlockPower() {
|
||||||
@@ -479,105 +744,179 @@ public class CraftBlock implements Block {
|
@@ -479,105 +742,179 @@ public class CraftBlock implements Block {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PistonMoveReaction getPistonMoveReaction() {
|
public PistonMoveReaction getPistonMoveReaction() {
|
||||||
@@ -953,14 +951,14 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
+ int eventData = (eventId == net.minecraft.world.level.block.LevelEvent.PARTICLES_DESTROY_BLOCK)
|
+ int eventData = (eventId == net.minecraft.world.level.block.LevelEvent.PARTICLES_DESTROY_BLOCK)
|
||||||
+ ? net.minecraft.world.level.block.Block.getId(iblockdata) : 0;
|
+ ? net.minecraft.world.level.block.Block.getId(iblockdata) : 0;
|
||||||
+ this.world.levelEvent(eventId, this.position, eventData);
|
+ this.world.levelEvent(eventId, this.position, eventData);
|
||||||
}
|
+ }
|
||||||
+ // Drop experience using ServerLevel
|
+ // Drop experience using ServerLevel
|
||||||
+ if (dropExperience) {
|
+ if (dropExperience) {
|
||||||
+ int xp = block.getExpDrop(iblockdata, serverLevelForDrops, this.position, nmsItem, true);
|
+ int xp = block.getExpDrop(iblockdata, serverLevelForDrops, this.position, nmsItem, true);
|
||||||
+ if (xp > 0) { // Only pop if there's XP to drop
|
+ if (xp > 0) { // Only pop if there's XP to drop
|
||||||
+ block.popExperience(serverLevelForDrops, this.position, xp);
|
+ block.popExperience(serverLevelForDrops, this.position, xp);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
}
|
||||||
+ droppedItems = true;
|
+ droppedItems = true;
|
||||||
+ }
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
@@ -1087,7 +1085,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -592,31 +931,70 @@ public class CraftBlock implements Block {
|
@@ -592,31 +929,70 @@ public class CraftBlock implements Block {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
|
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
|
||||||
@@ -1168,7 +1166,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
@Override
|
@Override
|
||||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||||
this.getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, 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
|
@Override
|
||||||
public boolean isPassable() {
|
public boolean isPassable() {
|
||||||
@@ -1340,7 +1338,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -700,7 +1168,10 @@ public class CraftBlock implements Block {
|
@@ -700,7 +1166,10 @@ public class CraftBlock implements Block {
|
||||||
// Paper start
|
// Paper start
|
||||||
@Override
|
@Override
|
||||||
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
|
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
|
||||||
@@ -1352,7 +1350,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -713,26 +1184,76 @@ public class CraftBlock implements Block {
|
@@ -713,26 +1182,76 @@ public class CraftBlock implements Block {
|
||||||
return this.getNMS().getBlock().getDescriptionId();
|
return this.getNMS().getBlock().getDescriptionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user