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

Backport changes from ver/1.21.8

See 667f15c124

Co-Authored-By: MrlingXD <90316914+wling-art@users.noreply.github.com>
This commit is contained in:
Dreeam
2025-10-12 23:40:58 -04:00
parent 4a97094219
commit 8757c3617b
2 changed files with 34 additions and 20 deletions

View File

@@ -604,7 +604,7 @@ index d4048661575ebfaf128ba25da365843774364e0e..33dd16a26edd2974f04d9a868d3e58e8
// Gale start - Pufferfish - SIMD support // Gale start - Pufferfish - SIMD support
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index a66e5f6652d9633c856490de36d8d8fdf8a5298a..d6524d5c442555eaeb4d90f6a101262ee669f0d9 100644 index a66e5f6652d9633c856490de36d8d8fdf8a5298a..81f891a26dd7fd1be87d1488aaf58863d66481c5 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -182,7 +182,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -182,7 +182,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -696,7 +696,7 @@ index a66e5f6652d9633c856490de36d8d8fdf8a5298a..d6524d5c442555eaeb4d90f6a101262e
+ } + }
+ +
+ // Executes the actual read operation based on the request type + // Executes the actual read operation based on the request type
+ private Object executeReadRequest(org.dreeam.leaf.async.world.WorldReadRequest request) { + public Object executeReadRequest(org.dreeam.leaf.async.world.WorldReadRequest request) {
+ Object[] params = request.params(); + Object[] params = request.params();
+ BlockPos pos; // Declare pos outside the switch + BlockPos pos; // Declare pos outside the switch
+ +

View File

@@ -5,6 +5,8 @@ Subject: [PATCH] SparklyPaper: Parallel world ticking
Original project: https://github.com/SparklyPower/SparklyPaper Original project: https://github.com/SparklyPower/SparklyPaper
Co-authored-by: MrlingXD <90316914+wling-art@users.noreply.github.com>
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..2fb65ce228da94eb7d9364ee0f94582300178f1d 100644 index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..2fb65ce228da94eb7d9364ee0f94582300178f1d 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java --- a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
@@ -315,10 +317,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..d3935cfe0ef5d6e8df6f3bb9894a1b7a165c3561 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,110 @@ public class CraftBlock implements Block {
return new CraftBlock(world, position); return new CraftBlock(world, position);
} }
@@ -345,6 +347,18 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
+ return defaultValue; + return defaultValue;
+ } + }
+ +
+ // Leaf start - SparklyPaper - parallel world ticking - Deadlock prevention
+ if (Thread.currentThread() instanceof ca.spottedleaf.moonrise.common.util.TickThread.ServerLevelTickThread) {
+ try {
+ org.dreeam.leaf.async.world.WorldReadRequest request = new org.dreeam.leaf.async.world.WorldReadRequest(type, params, null);
+ Object result = level.executeReadRequest(request);
+ return (T) result;
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+ // Leaf end - SparklyPaper - parallel world ticking - Deadlock prevention
+
+ java.util.concurrent.CompletableFuture<Object> future = new java.util.concurrent.CompletableFuture<>(); + 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
@@ -419,7 +433,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
} }
// Paper end // Paper end
@@ -144,10 +229,12 @@ public class CraftBlock implements Block { @@ -144,10 +241,12 @@ public class CraftBlock implements Block {
return this.getWorld().getChunkAt(this); return this.getWorld().getChunkAt(this);
} }
@@ -432,7 +446,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 +256,18 @@ public class CraftBlock implements Block {
} }
private void setData(final byte data, int flag) { private void setData(final byte data, int flag) {
@@ -452,7 +466,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
return CraftMagicNumbers.toLegacyData(blockData); return CraftMagicNumbers.toLegacyData(blockData);
} }
@@ -179,6 +272,7 @@ public class CraftBlock implements Block { @@ -179,6 +284,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 +474,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 +304,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 +487,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 +338,62 @@ public class CraftBlock implements Block {
@Override @Override
public Material getType() { public Material getType() {
@@ -540,7 +554,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 +434,36 @@ public class CraftBlock implements Block {
@Override @Override
public String toString() { public String toString() {
@@ -616,7 +630,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
} }
@Override @Override
@@ -343,18 +468,65 @@ public class CraftBlock implements Block { @@ -343,18 +480,65 @@ public class CraftBlock implements Block {
@Override @Override
public Biome getBiome() { public Biome getBiome() {
@@ -684,7 +698,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 +554,50 @@ public class CraftBlock implements Block {
@Override @Override
public boolean isBlockPowered() { public boolean isBlockPowered() {
@@ -737,7 +751,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
} }
@Override @Override
@@ -397,46 +607,101 @@ public class CraftBlock implements Block { @@ -397,46 +619,101 @@ public class CraftBlock implements Block {
@Override @Override
public boolean isBlockFacePowered(BlockFace face) { public boolean isBlockFacePowered(BlockFace face) {
@@ -866,7 +880,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
@Override @Override
public int getBlockPower() { public int getBlockPower() {
@@ -479,105 +744,179 @@ public class CraftBlock implements Block { @@ -479,105 +756,179 @@ public class CraftBlock implements Block {
@Override @Override
public PistonMoveReaction getPistonMoveReaction() { public PistonMoveReaction getPistonMoveReaction() {
@@ -953,14 +967,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 +1101,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
} }
@Override @Override
@@ -592,31 +931,70 @@ public class CraftBlock implements Block { @@ -592,31 +943,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 +1182,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 +1029,147 @@ public class CraftBlock implements Block {
@Override @Override
public boolean isPassable() { public boolean isPassable() {
@@ -1340,7 +1354,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
} }
@Override @Override
@@ -700,7 +1168,10 @@ public class CraftBlock implements Block { @@ -700,7 +1180,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 +1366,7 @@ index 811823a1a7e24a19a7e37eb4c08efdfa19e839ed..839cfe99c028c596e15ba63c8a6e4a51
} }
@Override @Override
@@ -713,26 +1184,76 @@ public class CraftBlock implements Block { @@ -713,26 +1196,76 @@ public class CraftBlock implements Block {
return this.getNMS().getBlock().getDescriptionId(); return this.getNMS().getBlock().getDescriptionId();
} }