From a48bd8375e873cf768c6d194d4fb63932267550e Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Sat, 20 Apr 2024 15:51:02 -0300 Subject: [PATCH] Fix build --- ...-Rebrand-to-SparklyPaper-and-Build-C.patch | 6 +- .../0016-Optimize-tickBlockEntities.patch | 6 +- .../server/0018-Parallel-world-ticking.patch | 89 +++++++++---------- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch b/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch index 6a7b1b6..c62780e 100644 --- a/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch +++ b/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch @@ -5,7 +5,7 @@ Subject: [PATCH] new fork who dis - Rebrand to SparklyPaper and Build Changes diff --git a/build.gradle.kts b/build.gradle.kts -index 241808d8619e17c0681f79acbbc98af5bf52dd89..d7bf3d87a67f44da74c4ff2788c0726b6394cf57 100644 +index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..fad6e6cbbd1e7ea3bb83374cb7e7a1bfac46ead1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,8 @@ import io.papermc.paperweight.util.* @@ -56,7 +56,7 @@ index 241808d8619e17c0681f79acbbc98af5bf52dd89..d7bf3d87a67f44da74c4ff2788c0726b "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -155,7 +169,7 @@ fun TaskContainer.registerRunTask( +@@ -150,7 +164,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -66,7 +66,7 @@ index 241808d8619e17c0681f79acbbc98af5bf52dd89..d7bf3d87a67f44da74c4ff2788c0726b standardInput = System.`in` workingDir = rootProject.layout.projectDirectory diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 93b661e9cb7743aeff7da3972942cb73049a5e4c..2ed30382cb42c1957e6666a2320a4b013acd3b02 100644 +index 2dc07e5ef249636e85ad9c78e3729e9e066a8fe8..9a36662c8db97ad66e4d0528fa7651356e412757 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1865,7 +1865,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entities = new io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet<>(true); // Paper - rewrite this, always keep this updated - why would we EVER tick an entity that's not ticking? @@ -1435,7 +1435,6 @@ index 4cdfc433df67afcd455422e9baf56f167dd712ae..f52b3740bd48f8527a36d48a0454e7d6 private void ensureActiveIsNotIterated() { // Paper - replace with better logic, do not delay removals -@@ -16,13 +23,13 @@ public class EntityTickList { } public void add(Entity entity) { @@ -1461,10 +1460,10 @@ index 4cdfc433df67afcd455422e9baf56f167dd712ae..f52b3740bd48f8527a36d48a0454e7d6 // To ensure nothing weird happens with dimension travelling, do not iterate over new entries... // (by dfl iterator() is configured to not iterate over new entries) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525ab728aa31 100644 +index 01797d9791f19dfda4b168218eadeaae97f11eab..b5e4413aae97e5c103c88c5d61347199974e1168 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -440,7 +440,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -441,7 +441,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } private boolean unloadChunk0(int x, int z, boolean save) { @@ -1473,7 +1472,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a if (!this.isChunkLoaded(x, z)) { return true; } -@@ -455,7 +455,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -456,7 +456,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean regenerateChunk(int x, int z) { @@ -1482,7 +1481,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper // Paper start - implement regenerateChunk method final ServerLevel serverLevel = this.world; -@@ -518,6 +518,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -519,6 +519,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean refreshChunk(int x, int z) { @@ -1490,7 +1489,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (playerChunk == null) return false; -@@ -553,7 +554,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -554,7 +555,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { @@ -1499,7 +1498,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a warnUnsafeChunk("loading a faraway chunk", x, z); // Paper // Paper start - Optimize this method ChunkPos chunkPos = new ChunkPos(x, z); -@@ -813,6 +814,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -833,6 +834,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { @@ -1507,7 +1506,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a this.world.captureTreeGeneration = true; this.world.captureBlockStates = true; boolean grownTree = this.generateTree(loc, type); -@@ -923,11 +925,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -943,11 +945,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { @@ -1521,7 +1520,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? net.minecraft.world.level.Level.ExplosionInteraction.MOB : net.minecraft.world.level.Level.ExplosionInteraction.NONE).wasCanceled; } // Paper end -@@ -1004,6 +1008,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1024,6 +1028,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -1529,7 +1528,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper // Transient load for this tick return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); -@@ -1034,6 +1039,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1054,6 +1059,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setBiome(int x, int y, int z, Holder bb) { BlockPos pos = new BlockPos(x, 0, z); @@ -1537,7 +1536,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos); -@@ -2339,6 +2345,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2359,6 +2365,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) { @@ -1545,7 +1544,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position)); } // Paper end -@@ -2459,7 +2466,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2479,7 +2486,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start public java.util.concurrent.CompletableFuture getChunkAtAsync(int x, int z, boolean gen, boolean urgent) { warnUnsafeChunk("getting a faraway chunk async", x, z); // Paper @@ -1555,7 +1554,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..295eca9de3e1e5d7eb01f9ff015b525a if (immediate != null) { return java.util.concurrent.CompletableFuture.completedFuture(new CraftChunk(immediate)); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb024a1d017 100644 +index ac11f18690434922179b61ffcc3036dea025b0cb..f6470c32af48f73c2668d2014e736d827f947379 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -75,6 +75,11 @@ public class CraftBlock implements Block { @@ -1570,7 +1569,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 return this.world.getBlockState(this.position); } -@@ -151,6 +156,11 @@ public class CraftBlock implements Block { +@@ -157,6 +162,11 @@ public class CraftBlock implements Block { } private void setData(final byte data, int flag) { @@ -1582,7 +1581,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flag); } -@@ -192,6 +202,12 @@ public class CraftBlock implements Block { +@@ -198,6 +208,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) { @@ -1591,11 +1590,11 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 + io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); + } + // SparklyPaper end - parallel world ticking -+ ++ // 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 -@@ -337,18 +353,33 @@ public class CraftBlock implements Block { +@@ -343,18 +359,33 @@ public class CraftBlock implements Block { @Override public Biome getBiome() { @@ -1629,7 +1628,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio); } -@@ -396,6 +427,11 @@ public class CraftBlock implements Block { +@@ -402,6 +433,11 @@ public class CraftBlock implements Block { @Override public boolean isBlockFaceIndirectlyPowered(BlockFace face) { @@ -1641,7 +1640,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 int power = this.world.getMinecraftWorld().getSignal(this.position, CraftBlock.blockFaceToNotch(face)); Block relative = this.getRelative(face); -@@ -408,6 +444,11 @@ public class CraftBlock implements Block { +@@ -414,6 +450,11 @@ public class CraftBlock implements Block { @Override public int getBlockPower(BlockFace face) { @@ -1653,7 +1652,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 int power = 0; net.minecraft.world.level.Level world = this.world.getMinecraftWorld(); int x = this.getX(); -@@ -478,6 +519,11 @@ public class CraftBlock implements Block { +@@ -484,6 +525,11 @@ public class CraftBlock implements Block { @Override public boolean breakNaturally() { @@ -1665,7 +1664,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 return this.breakNaturally(null); } -@@ -537,6 +583,11 @@ public class CraftBlock implements Block { +@@ -543,6 +589,11 @@ public class CraftBlock implements Block { @Override public boolean applyBoneMeal(BlockFace face) { @@ -1677,7 +1676,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 Direction direction = CraftBlock.blockFaceToNotch(face); BlockFertilizeEvent event = null; ServerLevel world = this.getCraftWorld().getHandle(); -@@ -548,8 +599,8 @@ public class CraftBlock implements Block { +@@ -554,8 +605,8 @@ public class CraftBlock implements Block { world.captureTreeGeneration = false; if (world.capturedBlockStates.size() > 0) { @@ -1688,7 +1687,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 List blocks = new ArrayList<>(world.capturedBlockStates.values()); world.capturedBlockStates.clear(); StructureGrowEvent structureEvent = null; -@@ -638,6 +689,11 @@ public class CraftBlock implements Block { +@@ -644,6 +695,11 @@ public class CraftBlock implements Block { @Override public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) { @@ -1700,7 +1699,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 Preconditions.checkArgument(start != null, "Location start cannot be null"); Preconditions.checkArgument(this.getWorld().equals(start.getWorld()), "Location start cannot be a different world"); start.checkFinite(); -@@ -679,6 +735,11 @@ public class CraftBlock implements Block { +@@ -685,6 +741,11 @@ public class CraftBlock implements Block { @Override public boolean canPlace(BlockData data) { @@ -1712,7 +1711,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 Preconditions.checkArgument(data != null, "BlockData cannot be null"); net.minecraft.world.level.block.state.BlockState iblockdata = ((CraftBlockData) data).getState(); net.minecraft.world.level.Level world = this.world.getMinecraftWorld(); -@@ -713,6 +774,11 @@ public class CraftBlock implements Block { +@@ -719,6 +780,11 @@ public class CraftBlock implements Block { @Override public void tick() { @@ -1721,9 +1720,9 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..0631fcf5749bfd7ca4ba8bad8a959fb0 + io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); + } + // SparklyPaper end - parallel world ticking - net.minecraft.world.level.block.state.BlockState blockData = this.getNMS(); - net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld(); - + final ServerLevel level = this.world.getMinecraftWorld(); + this.getNMS().tick(level, this.position, level.random); + } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index 7cd0fae59c497861063827eda4243cc6c11e7cff..8d2f84442b8872224a0b3701dbd9876f54890efb 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -1749,7 +1748,7 @@ index 7cd0fae59c497861063827eda4243cc6c11e7cff..8d2f84442b8872224a0b3701dbd9876f } else { this.snapshot = this.createSnapshot(tileEntity); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java -index d11d854ae90b99aa2ce227994d07fe1fe9b4a60a..3040588155878dcbeb4fb5d71cf99b83f88e0a82 100644 +index 2cfaa59a0bb6b5253b5a8dcc38ae65e0f085fd3f..d7bcf51c68b6fa03a136e4a6472b1b1cc2dae045 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -210,6 +210,12 @@ public class CraftBlockState implements BlockState { @@ -1761,18 +1760,18 @@ index d11d854ae90b99aa2ce227994d07fe1fe9b4a60a..3040588155878dcbeb4fb5d71cf99b83 + io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); + } + // SparklyPaper end - parallel world ticking -+ ++ if (block.getType() != this.getType()) { if (!force) { return false; -@@ -350,6 +356,7 @@ public class CraftBlockState implements BlockState { +@@ -340,6 +346,7 @@ public class CraftBlockState implements BlockState { @Override public java.util.Collection getDrops(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Entity entity) { + io.papermc.paper.util.TickThread.ensureTickThread(world.getHandle(), position, "Cannot modify world asynchronously"); // SparklyPaper - parallel world ticking + this.requirePlaced(); net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item); - // Modelled off EntityHuman#hasBlock diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index 8afc396c162d928902a9d9beb9f039b06630f755..4cde4be86dc03ebbfb5c12a910acbf9978fd42d4 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java @@ -1798,10 +1797,10 @@ index 8afc396c162d928902a9d9beb9f039b06630f755..4cde4be86dc03ebbfb5c12a910acbf99 // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index cb3e9672f375a1a660757a05362729ddb5ca7504..6a6ae69a5b33a16612ee7062cd6c774ebb3f6e41 100644 +index c0823c612de9dc2a64cc797f061eef25c5f31359..a32d6756e62f6b6d7d3412f9773bd9639dad5c3e 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -942,7 +942,7 @@ public class CraftEventFactory { +@@ -943,7 +943,7 @@ public class CraftEventFactory { return CraftEventFactory.handleBlockSpreadEvent(world, source, target, block, 2); } @@ -1810,7 +1809,7 @@ index cb3e9672f375a1a660757a05362729ddb5ca7504..6a6ae69a5b33a16612ee7062cd6c774e public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) { // Suppress during worldgen -@@ -954,7 +954,7 @@ public class CraftEventFactory { +@@ -955,7 +955,7 @@ public class CraftEventFactory { CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag); state.setData(block); @@ -1819,7 +1818,7 @@ index cb3e9672f375a1a660757a05362729ddb5ca7504..6a6ae69a5b33a16612ee7062cd6c774e Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { -@@ -2140,7 +2140,7 @@ public class CraftEventFactory { +@@ -2146,7 +2146,7 @@ public class CraftEventFactory { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1)); org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to));