diff --git a/leaves-server/minecraft-patches/features/0064-Optimize-sun-burn-tick.patch b/leaves-server/minecraft-patches/features/0063-Optimize-sun-burn-tick.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0064-Optimize-sun-burn-tick.patch rename to leaves-server/minecraft-patches/features/0063-Optimize-sun-burn-tick.patch diff --git a/leaves-server/minecraft-patches/features/0063-Reduce-array-allocations.patch b/leaves-server/minecraft-patches/features/0063-Reduce-array-allocations.patch deleted file mode 100644 index cfc0cbcf..00000000 --- a/leaves-server/minecraft-patches/features/0063-Reduce-array-allocations.patch +++ /dev/null @@ -1,226 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 20 Jul 2023 15:03:28 +0800 -Subject: [PATCH] Reduce array allocations - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -index ba20e87d2105ce53cdaf4049de2388d05fcd1b56..35b5eb517fd8b25e5f755c18f666339a4a09badc 100644 ---- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -@@ -29,6 +29,7 @@ import java.util.Arrays; - import java.util.Iterator; - import java.util.List; - import java.util.function.Predicate; -+import org.leavesmc.leaves.util.ArrayConstants; - - public final class ChunkEntitySlices { - -@@ -378,7 +379,7 @@ public final class ChunkEntitySlices { - - private static final class BasicEntityList { - -- private static final Entity[] EMPTY = new Entity[0]; -+ // protected static final Entity[] EMPTY = new Entity[0]; // Leaves - reduce array allocations - private static final int DEFAULT_CAPACITY = 4; - - private E[] storage; -@@ -389,7 +390,7 @@ public final class ChunkEntitySlices { - } - - public BasicEntityList(final int cap) { -- this.storage = (E[])(cap <= 0 ? EMPTY : new Entity[cap]); -+ this.storage = (E[])(cap <= 0 ? ArrayConstants.emptyEntityArray : new Entity[cap]); // Leaves - reduce array allocations - } - - public boolean isEmpty() { -@@ -401,7 +402,7 @@ public final class ChunkEntitySlices { - } - - private void resize() { -- if (this.storage == EMPTY) { -+ if (this.storage == ArrayConstants.emptyEntityArray) { // Leaves - reduce array allocations - this.storage = (E[])new Entity[DEFAULT_CAPACITY]; - } else { - this.storage = Arrays.copyOf(this.storage, this.storage.length * 2); -diff --git a/net/minecraft/nbt/ByteArrayTag.java b/net/minecraft/nbt/ByteArrayTag.java -index 6fbb131b472a3093b137d8ced9889777a133bd5b..9372cdd6cef64c8b5019e3f73d7d8512caed0c60 100644 ---- a/net/minecraft/nbt/ByteArrayTag.java -+++ b/net/minecraft/nbt/ByteArrayTag.java -@@ -144,7 +144,7 @@ public final class ByteArrayTag implements CollectionTag { - - @Override - public void clear() { -- this.data = new byte[0]; -+ this.data = org.leavesmc.leaves.util.ArrayConstants.emptyByteArray; // Leaves - reduce array allocations - } - - @Override -diff --git a/net/minecraft/nbt/IntArrayTag.java b/net/minecraft/nbt/IntArrayTag.java -index a8ea2aeb5a02903a37376fb78b49c10745147411..9b9cc3821f30380d095a8c4b11a246fb2b648df7 100644 ---- a/net/minecraft/nbt/IntArrayTag.java -+++ b/net/minecraft/nbt/IntArrayTag.java -@@ -151,7 +151,7 @@ public final class IntArrayTag implements CollectionTag { - - @Override - public void clear() { -- this.data = new int[0]; -+ this.data = org.leavesmc.leaves.util.ArrayConstants.emptyIntArray; // Leaves - reduce array allocations - } - - @Override -diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index 7af8b2cf9ccfeadac1cc60541da31ba6f4dc0edb..284cdbd6034ec8962409abba6da37eab311018cc 100644 ---- a/net/minecraft/network/Connection.java -+++ b/net/minecraft/network/Connection.java -@@ -65,6 +65,7 @@ import org.apache.commons.lang3.Validate; - import org.slf4j.Logger; - import org.slf4j.Marker; - import org.slf4j.MarkerFactory; -+import org.leavesmc.leaves.util.ArrayConstants; - - public class Connection extends SimpleChannelInboundHandler> { - private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F; -diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index a2199f7aac4f44a70087dd90fe9330fcb8970772..11cd457958e2643549f0d8786dfbf8711cdc9a87 100644 ---- a/net/minecraft/server/level/ServerLevel.java -+++ b/net/minecraft/server/level/ServerLevel.java -@@ -165,6 +165,7 @@ import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; - import net.minecraft.world.ticks.LevelTicks; - import org.slf4j.Logger; -+import org.leavesmc.leaves.util.ArrayConstants; - - public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLevel, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevelReader, ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel { // Paper - rewrite chunk system // Paper - chunk tick iteration - public static final BlockPos END_SPAWN_POINT = new BlockPos(100, 50, 0); -diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 655ca2ead22addbb458b89e12cb2be1d269e4f5e..926b09363bf5c8555a27e4be0374a5a0d3ee0c0d 100644 ---- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -236,6 +236,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; - import org.bukkit.event.player.PlayerToggleSneakEvent; - import org.bukkit.event.player.PlayerToggleSprintEvent; - // CraftBukkit end -+import org.leavesmc.leaves.util.ArrayConstants; - - public class ServerGamePacketListenerImpl - extends ServerCommonPacketListenerImpl -@@ -796,7 +797,7 @@ public class ServerGamePacketListenerImpl - // Paper start - final int index; - if (packet.getCommand().length() > 64 && ((index = packet.getCommand().indexOf(' ')) == -1 || index >= 64)) { -- this.disconnectAsync(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - add proper async disconnect -+ this.disconnectAsync(Component.translatable("disconnect.spam", ArrayConstants.emptyObjectArray), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - add proper async disconnect // Leaves - reduce array allocations - return; - } - // Paper end -diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 7950f4f88d8a83ed5610b7af4e134557d32da3f0..07342673c333436fc3f4779ffcfa0a451bd524dd 100644 ---- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -49,6 +49,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer; - import org.bukkit.craftbukkit.util.Waitable; - import org.bukkit.event.player.AsyncPlayerPreLoginEvent; - import org.bukkit.event.player.PlayerPreLoginEvent; -+import org.leavesmc.leaves.util.ArrayConstants; - - public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener, CraftPlayer.TransferCookieConnection { - // CraftBukkit end -diff --git a/net/minecraft/server/players/StoredUserList.java b/net/minecraft/server/players/StoredUserList.java -index d445e8f126f077d8419c52fa5436ea963a1a42a4..0c0f70b5c624e05811aef398a2e6c29c14a9e323 100644 ---- a/net/minecraft/server/players/StoredUserList.java -+++ b/net/minecraft/server/players/StoredUserList.java -@@ -21,6 +21,7 @@ import javax.annotation.Nullable; - import net.minecraft.Util; - import net.minecraft.util.GsonHelper; - import org.slf4j.Logger; -+import org.leavesmc.leaves.util.ArrayConstants; - - public abstract class StoredUserList> { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -70,7 +71,7 @@ public abstract class StoredUserList> { - } - - public String[] getUserList() { -- return this.map.keySet().toArray(new String[0]); -+ return (String[]) this.map.keySet().toArray(ArrayConstants.emptyStringArray); // Leaves - reduce array allocations - } - - public boolean isEmpty() { -diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java -index 50993ce7519a77c6a9d36cb925125adccda7037f..e5124b566e791c1c011b301f910a892689cf3c65 100644 ---- a/net/minecraft/util/ZeroBitStorage.java -+++ b/net/minecraft/util/ZeroBitStorage.java -@@ -5,7 +5,7 @@ import java.util.function.IntConsumer; - import org.apache.commons.lang3.Validate; - - public class ZeroBitStorage implements BitStorage { -- public static final long[] RAW = new long[0]; -+ public static final long[] RAW = org.leavesmc.leaves.util.ArrayConstants.emptyLongArray; // Leaves - reduce array allocations - private final int size; - - public ZeroBitStorage(int size) { -diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 7c13e7b7a547150642c4a4bddf5e8dee1d580984..21d50e9a60be430d8fff259d31793c5a897d2272 100644 ---- a/net/minecraft/world/level/Level.java -+++ b/net/minecraft/world/level/Level.java -@@ -93,6 +93,7 @@ import org.bukkit.craftbukkit.block.CraftBlockState; - import org.bukkit.craftbukkit.block.data.CraftBlockData; - import org.bukkit.entity.SpawnCategory; - // CraftBukkit end -+import org.leavesmc.leaves.util.ArrayConstants; - - public abstract class Level implements LevelAccessor, UUIDLookup, AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel, ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system // Paper - optimise collisions - public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); -diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java -index a647d76d365a60b95a3eb7927ac426bf70d417f3..056a88405be08bf6acd5c94b6f9d042b15a1ba0a 100644 ---- a/net/minecraft/world/level/block/ComposterBlock.java -+++ b/net/minecraft/world/level/block/ComposterBlock.java -@@ -419,7 +419,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return new int[0]; -+ return org.leavesmc.leaves.util.ArrayConstants.emptyIntArray; // Leaves - reduce array allocations - } - - @Override -@@ -454,7 +454,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return side == Direction.UP ? new int[]{0} : new int[0]; -+ return side == Direction.UP ? org.leavesmc.leaves.util.ArrayConstants.zeroSingletonIntArray : org.leavesmc.leaves.util.ArrayConstants.emptyIntArray; // Leaves - reduce array allocations - } - - @Override -@@ -505,7 +505,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return side == Direction.DOWN ? new int[]{0} : new int[0]; -+ return side == Direction.DOWN ? org.leavesmc.leaves.util.ArrayConstants.zeroSingletonIntArray : org.leavesmc.leaves.util.ArrayConstants.emptyIntArray; // Leaves - reduce array allocations - } - - @Override -diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 78b3bdb668320e9cf2fb09b59929fac43cf56aca..f1f3c52a147165881de76b1f94ef57cfc9142a2a 100644 ---- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -38,13 +38,14 @@ import net.minecraft.world.level.block.AbstractFurnaceBlock; - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.phys.Vec3; -+import org.leavesmc.leaves.util.ArrayConstants; - - public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible { - protected static final int SLOT_INPUT = 0; - protected static final int SLOT_FUEL = 1; - protected static final int SLOT_RESULT = 2; - public static final int DATA_LIT_TIME = 0; -- private static final int[] SLOTS_FOR_UP = new int[]{0}; -+ private static final int[] SLOTS_FOR_UP = ArrayConstants.zeroSingletonIntArray; // Leaves - reduce array allocations - private static final int[] SLOTS_FOR_DOWN = new int[]{2, 1}; - private static final int[] SLOTS_FOR_SIDES = new int[]{1}; - public static final int DATA_LIT_DURATION = 1; diff --git a/leaves-server/minecraft-patches/features/0065-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch b/leaves-server/minecraft-patches/features/0064-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0065-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch rename to leaves-server/minecraft-patches/features/0064-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch diff --git a/leaves-server/minecraft-patches/features/0066-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch b/leaves-server/minecraft-patches/features/0065-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0066-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch rename to leaves-server/minecraft-patches/features/0065-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch diff --git a/leaves-server/minecraft-patches/features/0067-Optimized-CubePointRange.patch b/leaves-server/minecraft-patches/features/0066-Optimized-CubePointRange.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0067-Optimized-CubePointRange.patch rename to leaves-server/minecraft-patches/features/0066-Optimized-CubePointRange.patch diff --git a/leaves-server/minecraft-patches/features/0068-Check-frozen-ticks-before-landing-block.patch b/leaves-server/minecraft-patches/features/0067-Check-frozen-ticks-before-landing-block.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0068-Check-frozen-ticks-before-landing-block.patch rename to leaves-server/minecraft-patches/features/0067-Check-frozen-ticks-before-landing-block.patch index c48b40d2..7ebf4d9d 100644 --- a/leaves-server/minecraft-patches/features/0068-Check-frozen-ticks-before-landing-block.patch +++ b/leaves-server/minecraft-patches/features/0067-Check-frozen-ticks-before-landing-block.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Check frozen ticks before landing block This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 6893ca36cd4ae9a62fecedb1167cc6cf797a7f8f..23eb3e6a1e4f59132296d3bad9cbf858270dfe62 100644 +index a95fec1506af042bd3d4424e93aa3f4de9627487..ce624ed17bc5c9b5e13d280f8dda736581b21821 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -523,10 +523,10 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaves-server/minecraft-patches/features/0069-Skip-entity-move-if-movement-is-zero.patch b/leaves-server/minecraft-patches/features/0068-Skip-entity-move-if-movement-is-zero.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0069-Skip-entity-move-if-movement-is-zero.patch rename to leaves-server/minecraft-patches/features/0068-Skip-entity-move-if-movement-is-zero.patch diff --git a/leaves-server/minecraft-patches/features/0070-Skip-cloning-advancement-criteria.patch b/leaves-server/minecraft-patches/features/0069-Skip-cloning-advancement-criteria.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0070-Skip-cloning-advancement-criteria.patch rename to leaves-server/minecraft-patches/features/0069-Skip-cloning-advancement-criteria.patch diff --git a/leaves-server/minecraft-patches/features/0071-Fix-villagers-dont-release-memory.patch b/leaves-server/minecraft-patches/features/0070-Fix-villagers-dont-release-memory.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0071-Fix-villagers-dont-release-memory.patch rename to leaves-server/minecraft-patches/features/0070-Fix-villagers-dont-release-memory.patch diff --git a/leaves-server/minecraft-patches/features/0072-Avoid-anvil-too-expensive.patch b/leaves-server/minecraft-patches/features/0071-Avoid-anvil-too-expensive.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0072-Avoid-anvil-too-expensive.patch rename to leaves-server/minecraft-patches/features/0071-Avoid-anvil-too-expensive.patch diff --git a/leaves-server/minecraft-patches/features/0073-Bow-infinity-fix.patch b/leaves-server/minecraft-patches/features/0072-Bow-infinity-fix.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0073-Bow-infinity-fix.patch rename to leaves-server/minecraft-patches/features/0072-Bow-infinity-fix.patch index 4b2b7dfc..f03e48a0 100644 --- a/leaves-server/minecraft-patches/features/0073-Bow-infinity-fix.patch +++ b/leaves-server/minecraft-patches/features/0072-Bow-infinity-fix.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Bow infinity fix diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index e3de8bba5d37c2dc8c91d09e2225463ffbc2f7e5..3d6b240617d7e9cd16e0691d3de36ae53d13e04d 100644 +index a00e1ccb915e9e33b0c56b228cb0447d8af1e195..7d606ed45d88bc269943c013b4793583bacb1c83 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java @@ -2165,7 +2165,7 @@ public abstract class Player extends LivingEntity { diff --git a/leaves-server/minecraft-patches/features/0074-Zero-tick-plants.patch b/leaves-server/minecraft-patches/features/0073-Zero-tick-plants.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0074-Zero-tick-plants.patch rename to leaves-server/minecraft-patches/features/0073-Zero-tick-plants.patch diff --git a/leaves-server/minecraft-patches/features/0075-Force-peaceful-mode-switch.patch b/leaves-server/minecraft-patches/features/0074-Force-peaceful-mode-switch.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0075-Force-peaceful-mode-switch.patch rename to leaves-server/minecraft-patches/features/0074-Force-peaceful-mode-switch.patch diff --git a/leaves-server/minecraft-patches/features/0076-Replay-Mod-API.patch b/leaves-server/minecraft-patches/features/0075-Replay-Mod-API.patch similarity index 99% rename from leaves-server/minecraft-patches/features/0076-Replay-Mod-API.patch rename to leaves-server/minecraft-patches/features/0075-Replay-Mod-API.patch index e9e347f6..f03ea5b5 100644 --- a/leaves-server/minecraft-patches/features/0076-Replay-Mod-API.patch +++ b/leaves-server/minecraft-patches/features/0075-Replay-Mod-API.patch @@ -120,10 +120,10 @@ index 814bb2981ab32b216b7953e9b14fe09e96cc7c89..45f884bf598b38ec45baf423b84f5293 .filter(player -> !playerList.isOp(player.getGameProfile())) .map(player -> player.getGameProfile().getName()), diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 11cd457958e2643549f0d8786dfbf8711cdc9a87..76f056351208432e78717ce41adf3a85ff6a6c57 100644 +index a2199f7aac4f44a70087dd90fe9330fcb8970772..9b1a65036392a965dc0ce93247dfc0cf53630034 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2647,7 +2647,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2646,7 +2646,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); // Leaves start - skip @@ -132,7 +132,7 @@ index 11cd457958e2643549f0d8786dfbf8711cdc9a87..76f056351208432e78717ce41adf3a85 ServerLevel.this.realPlayers.add(serverPlayer); } // Leaves end - skip -@@ -2718,7 +2718,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2717,7 +2717,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); // Leaves start - skip diff --git a/leaves-server/minecraft-patches/features/0077-Leaves-I18n.patch b/leaves-server/minecraft-patches/features/0076-Leaves-I18n.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0077-Leaves-I18n.patch rename to leaves-server/minecraft-patches/features/0076-Leaves-I18n.patch diff --git a/leaves-server/minecraft-patches/features/0078-Fix-minecraft-hopper-not-work-without-player.patch b/leaves-server/minecraft-patches/features/0077-Fix-minecraft-hopper-not-work-without-player.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0078-Fix-minecraft-hopper-not-work-without-player.patch rename to leaves-server/minecraft-patches/features/0077-Fix-minecraft-hopper-not-work-without-player.patch diff --git a/leaves-server/minecraft-patches/features/0079-RNG-Fishing.patch b/leaves-server/minecraft-patches/features/0078-RNG-Fishing.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0079-RNG-Fishing.patch rename to leaves-server/minecraft-patches/features/0078-RNG-Fishing.patch diff --git a/leaves-server/minecraft-patches/features/0080-Wool-Hopper-Counter.patch b/leaves-server/minecraft-patches/features/0079-Wool-Hopper-Counter.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0080-Wool-Hopper-Counter.patch rename to leaves-server/minecraft-patches/features/0079-Wool-Hopper-Counter.patch diff --git a/leaves-server/minecraft-patches/features/0081-Spider-jockeys-drop-gapples.patch b/leaves-server/minecraft-patches/features/0080-Spider-jockeys-drop-gapples.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0081-Spider-jockeys-drop-gapples.patch rename to leaves-server/minecraft-patches/features/0080-Spider-jockeys-drop-gapples.patch diff --git a/leaves-server/minecraft-patches/features/0082-Force-Void-Trade.patch b/leaves-server/minecraft-patches/features/0081-Force-Void-Trade.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0082-Force-Void-Trade.patch rename to leaves-server/minecraft-patches/features/0081-Force-Void-Trade.patch diff --git a/leaves-server/minecraft-patches/features/0083-Villager-infinite-discounts.patch b/leaves-server/minecraft-patches/features/0082-Villager-infinite-discounts.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0083-Villager-infinite-discounts.patch rename to leaves-server/minecraft-patches/features/0082-Villager-infinite-discounts.patch diff --git a/leaves-server/minecraft-patches/features/0084-CCE-update-suppression.patch b/leaves-server/minecraft-patches/features/0083-CCE-update-suppression.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0084-CCE-update-suppression.patch rename to leaves-server/minecraft-patches/features/0083-CCE-update-suppression.patch diff --git a/leaves-server/minecraft-patches/features/0085-Disable-offline-warn-if-use-proxy.patch b/leaves-server/minecraft-patches/features/0084-Disable-offline-warn-if-use-proxy.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0085-Disable-offline-warn-if-use-proxy.patch rename to leaves-server/minecraft-patches/features/0084-Disable-offline-warn-if-use-proxy.patch diff --git a/leaves-server/minecraft-patches/features/0086-Armor-stand-cant-kill-by-mob-projectile.patch b/leaves-server/minecraft-patches/features/0085-Armor-stand-cant-kill-by-mob-projectile.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0086-Armor-stand-cant-kill-by-mob-projectile.patch rename to leaves-server/minecraft-patches/features/0085-Armor-stand-cant-kill-by-mob-projectile.patch index 314b4ab3..8a2efc45 100644 --- a/leaves-server/minecraft-patches/features/0086-Armor-stand-cant-kill-by-mob-projectile.patch +++ b/leaves-server/minecraft-patches/features/0085-Armor-stand-cant-kill-by-mob-projectile.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Armor stand cant kill by mob projectile diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 9ef422c34a70367f4dcee50b51a17143d14f131c..f0ba5459a6b87265cdddec3ff1f987726d0a6658 100644 +index f09bf1f8b23aae530b14129b7a56c96285ef2cf1..a09bd2121d457cace3e38f321985cff8817b2a2f 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -414,6 +414,15 @@ public class ArmorStand extends LivingEntity { diff --git a/leaves-server/minecraft-patches/features/0087-Make-Item-tick-vanilla.patch b/leaves-server/minecraft-patches/features/0086-Make-Item-tick-vanilla.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0087-Make-Item-tick-vanilla.patch rename to leaves-server/minecraft-patches/features/0086-Make-Item-tick-vanilla.patch diff --git a/leaves-server/minecraft-patches/features/0088-Copper-Bulb-1-gt-delay.patch b/leaves-server/minecraft-patches/features/0087-Copper-Bulb-1-gt-delay.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0088-Copper-Bulb-1-gt-delay.patch rename to leaves-server/minecraft-patches/features/0087-Copper-Bulb-1-gt-delay.patch diff --git a/leaves-server/minecraft-patches/features/0089-Crafter-1-gt-delay.patch b/leaves-server/minecraft-patches/features/0088-Crafter-1-gt-delay.patch similarity index 94% rename from leaves-server/minecraft-patches/features/0089-Crafter-1-gt-delay.patch rename to leaves-server/minecraft-patches/features/0088-Crafter-1-gt-delay.patch index d4decf1e..92a5bf4a 100644 --- a/leaves-server/minecraft-patches/features/0089-Crafter-1-gt-delay.patch +++ b/leaves-server/minecraft-patches/features/0088-Crafter-1-gt-delay.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Crafter 1 gt delay diff --git a/net/minecraft/world/level/block/CrafterBlock.java b/net/minecraft/world/level/block/CrafterBlock.java -index 38b03c7b02bdfc579e5e126c12de3d878e26d188..4faacd60632b9cf8c3384b4fa2720795cb69a9c2 100644 +index 33e24f2c3b63b2d3b55dfae2f2e55869abeed055..3ce56a24e131c3ea4c6d568e3f7bd2de8076ac60 100644 --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java @@ -75,7 +75,7 @@ public class CrafterBlock extends BaseEntityBlock { diff --git a/leaves-server/minecraft-patches/features/0090-More-Region-Format-Support.patch b/leaves-server/minecraft-patches/features/0089-More-Region-Format-Support.patch similarity index 99% rename from leaves-server/minecraft-patches/features/0090-More-Region-Format-Support.patch rename to leaves-server/minecraft-patches/features/0089-More-Region-Format-Support.patch index bee65514..37db07b3 100644 --- a/leaves-server/minecraft-patches/features/0090-More-Region-Format-Support.patch +++ b/leaves-server/minecraft-patches/features/0089-More-Region-Format-Support.patch @@ -54,7 +54,7 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..a6573e327ace16b7ea320eb1440ffcbc + public void moonrise$write(final org.leavesmc.leaves.region.IRegionFile regionFile) throws IOException; // Leaves - more region format } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 7a09e5252164ac7efa8429aa3e46d8d3b1a0f6da..434561ae48c8d6b71c2158338e6e6b08c787d04b 100644 +index 2005719308a281128a5edc24a563df929418c6e3..f1681577f27a618338cae1634094e728c98fc3ff 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -943,10 +943,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, AutoCl +@@ -1200,7 +1200,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl } if ((flags & 1) != 0) { diff --git a/leaves-server/minecraft-patches/features/0094-Renewable-deepslate.patch b/leaves-server/minecraft-patches/features/0093-Renewable-deepslate.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0094-Renewable-deepslate.patch rename to leaves-server/minecraft-patches/features/0093-Renewable-deepslate.patch diff --git a/leaves-server/minecraft-patches/features/0095-Renewable-sponges.patch b/leaves-server/minecraft-patches/features/0094-Renewable-sponges.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0095-Renewable-sponges.patch rename to leaves-server/minecraft-patches/features/0094-Renewable-sponges.patch diff --git a/leaves-server/minecraft-patches/features/0096-Renewable-coral.patch b/leaves-server/minecraft-patches/features/0095-Renewable-coral.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0096-Renewable-coral.patch rename to leaves-server/minecraft-patches/features/0095-Renewable-coral.patch diff --git a/leaves-server/minecraft-patches/features/0097-Fast-resume.patch b/leaves-server/minecraft-patches/features/0096-Fast-resume.patch similarity index 97% rename from leaves-server/minecraft-patches/features/0097-Fast-resume.patch rename to leaves-server/minecraft-patches/features/0096-Fast-resume.patch index 7faa2a45..5ffc5340 100644 --- a/leaves-server/minecraft-patches/features/0097-Fast-resume.patch +++ b/leaves-server/minecraft-patches/features/0096-Fast-resume.patch @@ -59,7 +59,7 @@ index f473999938840562b1007a789600342e5796a123..7e20b6469ef06c0338b5298d36b3a1ba final long[] counterTypes = ((ChunkSystemTicketType)(Object)type).moonrise$getCounterTypes(); if (counterTypes.length == 0) { diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 434561ae48c8d6b71c2158338e6e6b08c787d04b..684e8b09f8334c35553e8c09e92fc218fdb3440b 100644 +index f1681577f27a618338cae1634094e728c98fc3ff..6bc08a61a51b19e8f5670b0c54a3faeeab16bbc4 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -742,6 +742,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -Date: Thu, 20 Jul 2023 15:03:28 +0800 -Subject: [PATCH] Reduce array allocations - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -index 58ca24715eafd1ac3cc9657b1cc235049d69bb59..99d78a2e321f0703e0e5048c30ff7b0b7219aa8b 100644 ---- a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -+++ b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -@@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender; - import org.checkerframework.checker.nullness.qual.NonNull; - import org.checkerframework.checker.nullness.qual.Nullable; - import org.checkerframework.framework.qual.DefaultQualifier; -+import org.leavesmc.leaves.util.ArrayConstants; - - @DefaultQualifier(NonNull.class) - public final class VersionCommand implements PaperSubcommand { -@@ -14,7 +15,7 @@ public final class VersionCommand implements PaperSubcommand { - public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { - final @Nullable Command redirect = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); - if (redirect != null) { -- redirect.execute(sender, "paper", new String[0]); -+ redirect.execute(sender, "paper", ArrayConstants.emptyStringArray); // Leaves - reduce array allocations - } - return true; - } -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java -index 4abe58077fae4e68cceda9624fed013bca1d6f22..02e8ddbe4cbde3924e19f8e972be42d04ad7c39c 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java -@@ -165,7 +165,7 @@ public class CraftEntityEquipment implements EntityEquipment { - - @Override - public void clear() { -- for (net.minecraft.world.entity.EquipmentSlot slot : net.minecraft.world.entity.EquipmentSlot.values()) { -+ for (net.minecraft.world.entity.EquipmentSlot slot : net.minecraft.world.entity.EquipmentSlot.VALUES) { // Leaves - reduce array allocations - this.setEquipment(slot, null, false); - } - } -diff --git a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -index 306ca8db11d16a03ce73b9a5a8be7efc11ee4b57..a599a5c40bb7e67cfe4ca9085268f60afe5b0893 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -@@ -6,6 +6,7 @@ import java.util.ArrayList; - import java.util.Collection; - import java.util.Iterator; - import java.util.NoSuchElementException; -+import org.leavesmc.leaves.util.ArrayConstants; - - public final class WeakCollection implements Collection { - static final Object NO_VALUE = new Object(); -@@ -164,7 +165,7 @@ public final class WeakCollection implements Collection { - - @Override - public Object[] toArray() { -- return this.toArray(new Object[0]); -+ return this.toArray(ArrayConstants.emptyObjectArray); // Leaves - reduce array allocations - } - - @Override diff --git a/leaves-server/paper-patches/features/0012-Replay-Mod-API.patch b/leaves-server/paper-patches/features/0011-Replay-Mod-API.patch similarity index 100% rename from leaves-server/paper-patches/features/0012-Replay-Mod-API.patch rename to leaves-server/paper-patches/features/0011-Replay-Mod-API.patch diff --git a/leaves-server/paper-patches/features/0013-Force-minecraft-command.patch b/leaves-server/paper-patches/features/0012-Force-minecraft-command.patch similarity index 100% rename from leaves-server/paper-patches/features/0013-Force-minecraft-command.patch rename to leaves-server/paper-patches/features/0012-Force-minecraft-command.patch diff --git a/leaves-server/paper-patches/features/0014-Bytebuf-API.patch b/leaves-server/paper-patches/features/0013-Bytebuf-API.patch similarity index 100% rename from leaves-server/paper-patches/features/0014-Bytebuf-API.patch rename to leaves-server/paper-patches/features/0013-Bytebuf-API.patch diff --git a/leaves-server/paper-patches/features/0015-Leaves-plugin.patch b/leaves-server/paper-patches/features/0014-Leaves-plugin.patch similarity index 100% rename from leaves-server/paper-patches/features/0015-Leaves-plugin.patch rename to leaves-server/paper-patches/features/0014-Leaves-plugin.patch diff --git a/leaves-server/paper-patches/features/0016-Fix-SculkCatalyst-exp-skip.patch b/leaves-server/paper-patches/features/0015-Fix-SculkCatalyst-exp-skip.patch similarity index 96% rename from leaves-server/paper-patches/features/0016-Fix-SculkCatalyst-exp-skip.patch rename to leaves-server/paper-patches/features/0015-Fix-SculkCatalyst-exp-skip.patch index 1fff3933..493379ad 100644 --- a/leaves-server/paper-patches/features/0016-Fix-SculkCatalyst-exp-skip.patch +++ b/leaves-server/paper-patches/features/0015-Fix-SculkCatalyst-exp-skip.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix SculkCatalyst exp skip diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 014be969debccfd812b5e1d97dbc43b87309fce7..a72855d6c6c1a44ee44a2e9fb3d9c9b002b2dd3f 100644 +index 03778c286144d8f04147f37aa59fb73fcc584833..daea37a117101a9f3b463e87bfc8f0f9db394aca 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -851,7 +851,7 @@ public class CraftEventFactory { diff --git a/leaves-server/paper-patches/features/0017-Leaves-Config-API.patch b/leaves-server/paper-patches/features/0016-Leaves-Config-API.patch similarity index 100% rename from leaves-server/paper-patches/features/0017-Leaves-Config-API.patch rename to leaves-server/paper-patches/features/0016-Leaves-Config-API.patch diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/NoBlockUpdateCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/NoBlockUpdateCommand.java index fffcac8c..7593a046 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/NoBlockUpdateCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/NoBlockUpdateCommand.java @@ -14,6 +14,7 @@ import org.leavesmc.leaves.LeavesConfig; import java.util.List; +// TODO merge to /leaves blockupdate public class NoBlockUpdateCommand extends Command { private static boolean noBlockUpdate = false; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java deleted file mode 100644 index 232e3cb0..00000000 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.leavesmc.leaves.util; - -import net.minecraft.server.level.ServerLevel; - -// Powered by Gale(https://github.com/GaleMC/Gale) - -public class ArrayConstants { - - private ArrayConstants() { - } - - public static final Object[] emptyObjectArray = new Object[0]; - public static final int[] emptyIntArray = new int[0]; - public static final int[] zeroSingletonIntArray = new int[]{0}; - public static final byte[] emptyByteArray = new byte[0]; - public static final String[] emptyStringArray = new String[0]; - public static final long[] emptyLongArray = new long[0]; - public static final org.bukkit.entity.Entity[] emptyBukkitEntityArray = new org.bukkit.entity.Entity[0]; - public static final net.minecraft.world.entity.Entity[] emptyEntityArray = new net.minecraft.world.entity.Entity[0]; - public static final ServerLevel[] emptyServerLevelArray = new ServerLevel[0]; - -} diff --git a/patches/removed/server/0022-Early-return-optimization-for-target-finding.patch b/patches/removed/server/0022-Early-return-optimization-for-target-finding.patch deleted file mode 100644 index 2281acf7..00000000 --- a/patches/removed/server/0022-Early-return-optimization-for-target-finding.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sun, 14 Aug 2022 17:16:19 +0800 -Subject: [PATCH] Early return optimization for target finding - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -index aecb0ad814586bfc5e56755ee14379a69388b38c..c618d7c87a0b2e2ee55cbe64cae80178fd8bd651 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -@@ -76,9 +76,17 @@ public class TargetingConditions { - } - - if (this.range > 0.0) { -+ // Leaves start - check range before getting visibility -+ double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ()); -+ if (org.leavesmc.leaves.LeavesConfig.entityTargetFindingOptimization) { -+ double followRangeRaw = this.useFollowRange ? this.getFollowRange(baseEntity) : this.range; -+ if (f > followRangeRaw * followRangeRaw) { // the actual follow range will always be this value or smaller, so if the distance is larger then it never will return true after getting invis -+ return false; -+ } -+ } -+ // Leaves end - check range before getting visibility - double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0; - double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0); // Paper - Fix MC-145656 -- double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ()); - if (f > e * e) { - return false; - } diff --git a/patches/removed/server/0024-Move-ThreadUnsafeRandom-Initialization.patch b/patches/removed/server/0024-Move-ThreadUnsafeRandom-Initialization.patch deleted file mode 100644 index 7b5df3f3..00000000 --- a/patches/removed/server/0024-Move-ThreadUnsafeRandom-Initialization.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sun, 14 Aug 2022 10:54:33 +0800 -Subject: [PATCH] Move ThreadUnsafeRandom Initialization - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 81ebb247a8d5c5cd77a3d4ce729146c9fbfa3668..43977320ffefa9bff45e63194005375d9a2fe8b0 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -804,7 +804,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - } - // Paper start - optimise random block ticking - private final BlockPos.MutableBlockPos chunkTickMutablePosition = new BlockPos.MutableBlockPos(); -- private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); -+ // private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); // Leaves - moved to super - // Paper end - - public void tickChunk(LevelChunk chunk, int randomTickSpeed) { -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 41acb79ec31f6f53589d698d1d4547485f0adc71..42206013ca0790f1366319669fe433640a74798c 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -203,11 +203,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - // Paper end - -- public abstract ResourceKey getTypeKey(); -+ protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); // Leaves - move thread unsafe random initialization - -+ public abstract ResourceKey getTypeKey(); - // Paper start - rewrite chunk system - private ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup; - -+ - @Override - public final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup moonrise$getEntityLookup() { - return this.entityLookup; -@@ -255,14 +257,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - public ChunkAccess moonrise$getSpecificChunkIfLoaded(final int chunkX, final int chunkZ, final ChunkStatus leastStatus) { - return this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, false); - } -- - @Override - public void moonrise$midTickTasks() { - // no-op on ClientLevel - } - // Paper end - rewrite chunk system - -- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config - this.generator = gen; -@@ -347,6 +348,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray - } - -+ // Leaves start - thread unsafe random get -+ public net.minecraft.util.RandomSource getThreadUnsafeRandom() { -+ return randomTickRandom; -+ } -+ // Leaves end - thread unsafe random get -+ - // Paper start - Cancel hit for vanished players - // ret true if no collision - public final boolean checkEntityCollision(BlockState data, Entity source, net.minecraft.world.phys.shapes.CollisionContext voxelshapedcollision, diff --git a/patches/removed/server/0026-Remove-iterators-from-inventory-contains.patch b/patches/removed/server/0026-Remove-iterators-from-inventory-contains.patch deleted file mode 100644 index 002b1f2a..00000000 --- a/patches/removed/server/0026-Remove-iterators-from-inventory-contains.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Wed, 17 Aug 2022 11:04:12 +0800 -Subject: [PATCH] Remove iterators from inventory contains - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java -index 0e214d502998e9eb959952b257844529992df0df..9506c4cf1c757219f9f01c06cf61ad3e40ee0979 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Inventory.java -+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java -@@ -649,17 +649,31 @@ public class Inventory implements Container, Nameable { - } - - public boolean contains(ItemStack stack) { -- Iterator iterator = this.compartments.iterator(); -+ // Leaves start - don't allocate iterators -+ if (org.leavesmc.leaves.LeavesConfig.performance.remove.inventoryContainsIterators) { -+ for (int i = 0; i < this.compartments.size(); i++) { -+ List list = this.compartments.get(i); -+ for (int j = 0; j < list.size(); j++) { -+ ItemStack itemstack = list.get(j); -+ -+ if (!itemstack.isEmpty() && ItemStack.isSameItemSameComponents(itemstack, stack)) { -+ return true; -+ } -+ } -+ } -+ } else { -+ Iterator iterator = this.compartments.iterator(); - -- while (iterator.hasNext()) { -- List list = (List) iterator.next(); -- Iterator iterator1 = list.iterator(); -+ while (iterator.hasNext()) { -+ List list = (List) iterator.next(); -+ Iterator iterator1 = list.iterator(); - -- while (iterator1.hasNext()) { -- ItemStack itemstack1 = (ItemStack) iterator1.next(); -+ while (iterator1.hasNext()) { -+ ItemStack itemstack1 = (ItemStack) iterator1.next(); - -- if (!itemstack1.isEmpty() && ItemStack.isSameItemSameComponents(itemstack1, stack)) { -- return true; -+ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameComponents(itemstack1, stack)) { -+ return true; -+ } - } - } - } -@@ -668,17 +682,30 @@ public class Inventory implements Container, Nameable { - } - - public boolean contains(TagKey tag) { -- Iterator iterator = this.compartments.iterator(); -+ if (org.leavesmc.leaves.LeavesConfig.performance.remove.inventoryContainsIterators) { -+ for (int i = 0; i < this.compartments.size(); i++) { -+ List list = this.compartments.get(i); -+ for (int j = 0; j < list.size(); j++) { -+ ItemStack itemstack = list.get(j); - -- while (iterator.hasNext()) { -- List list = (List) iterator.next(); -- Iterator iterator1 = list.iterator(); -+ if (!itemstack.isEmpty() && itemstack.is(tag)) { -+ return true; -+ } -+ } -+ } -+ } else { -+ Iterator iterator = this.compartments.iterator(); -+ -+ while (iterator.hasNext()) { -+ List list = (List) iterator.next(); -+ Iterator iterator1 = list.iterator(); - -- while (iterator1.hasNext()) { -- ItemStack itemstack = (ItemStack) iterator1.next(); -+ while (iterator1.hasNext()) { -+ ItemStack itemstack = (ItemStack) iterator1.next(); - -- if (!itemstack.isEmpty() && itemstack.is(tag)) { -- return true; -+ if (!itemstack.isEmpty() && itemstack.is(tag)) { -+ return true; -+ } - } - } - } -@@ -687,21 +714,34 @@ public class Inventory implements Container, Nameable { - } - - public boolean contains(Predicate predicate) { -- Iterator iterator = this.compartments.iterator(); -+ if (org.leavesmc.leaves.LeavesConfig.performance.remove.inventoryContainsIterators) { -+ for (int i = 0; i < this.compartments.size(); i++) { -+ List list = this.compartments.get(i); -+ for (int j = 0; j < list.size(); j++) { -+ ItemStack itemstack = list.get(j); - -- while (iterator.hasNext()) { -- List list = (List) iterator.next(); -- Iterator iterator1 = list.iterator(); -+ if (predicate.test(itemstack)) { -+ return true; -+ } -+ } -+ } -+ } else { -+ Iterator iterator = this.compartments.iterator(); - -- while (iterator1.hasNext()) { -- ItemStack itemstack = (ItemStack) iterator1.next(); -+ while (iterator.hasNext()) { -+ List list = (List) iterator.next(); -+ Iterator iterator1 = list.iterator(); - -- if (predicate.test(itemstack)) { -- return true; -+ while (iterator1.hasNext()) { -+ ItemStack itemstack = (ItemStack) iterator1.next(); -+ -+ if (predicate.test(itemstack)) { -+ return true; -+ } - } - } - } -- -+ // Leaves end - don't allocate iterators - return false; - } - diff --git a/patches/removed/server/0026-Use-thread-unsafe-random-for-mob-spawning.patch b/patches/removed/server/0026-Use-thread-unsafe-random-for-mob-spawning.patch deleted file mode 100644 index e8d2f211..00000000 --- a/patches/removed/server/0026-Use-thread-unsafe-random-for-mob-spawning.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Mon, 15 Aug 2022 08:23:51 +0800 -Subject: [PATCH] Use thread unsafe random for mob spawning - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 189a6bd4967aba72e12170e091dbb5b779e752a0..9c72271382fa0b6be5f38b45577fb1ae81ce80a3 100644 ---- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java -+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -408,12 +408,21 @@ public final class NaturalSpawner { - - private static BlockPos getRandomPosWithin(Level world, LevelChunk chunk) { - ChunkPos chunkcoordintpair = chunk.getPos(); -- int i = chunkcoordintpair.getMinBlockX() + world.random.nextInt(16); -- int j = chunkcoordintpair.getMinBlockZ() + world.random.nextInt(16); -- int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1; -- int l = Mth.randomBetweenInclusive(world.random, world.getMinBuildHeight(), k); -- -- return new BlockPos(i, l, j); -+ // Leaves start - use thread unsafe random -+ if (org.leavesmc.leaves.LeavesConfig.useMoreThreadUnsafeRandom) { -+ int i = chunkcoordintpair.getMinBlockX() + world.getThreadUnsafeRandom().nextInt(16); -+ int j = chunkcoordintpair.getMinBlockZ() + world.getThreadUnsafeRandom().nextInt(16); -+ int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1; -+ int l = Mth.randomBetweenInclusive(world.getThreadUnsafeRandom(), world.getMinBuildHeight(), k); -+ return new BlockPos(i, l, j); -+ } else { -+ int i = chunkcoordintpair.getMinBlockX() + world.random.nextInt(16); -+ int j = chunkcoordintpair.getMinBlockZ() + world.random.nextInt(16); -+ int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1; -+ int l = Mth.randomBetweenInclusive(world.random, world.getMinBuildHeight(), k); -+ return new BlockPos(i, l, j); -+ } -+ // Leaves end - use thread unsafe random - } - - public static boolean isValidEmptySpawnBlock(BlockGetter blockView, BlockPos pos, BlockState state, FluidState fluidState, EntityType entityType) { diff --git a/patches/removed/server/0028-Remove-streams-and-iterators-from-range-check.patch b/patches/removed/server/0028-Remove-streams-and-iterators-from-range-check.patch deleted file mode 100644 index 35db91a9..00000000 --- a/patches/removed/server/0028-Remove-streams-and-iterators-from-range-check.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Wed, 17 Aug 2022 11:19:33 +0800 -Subject: [PATCH] Remove streams and iterators from range check - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 0451f7499121a53ce1bd13130581548f60b61996..e0650881a3f90532fc446607cf5ae34da4a2a1dc 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1284,19 +1284,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance); - } - -+ // Leaves start -+ private static int getHighestRange(Entity parent, int highest) { -+ List passengers = parent.getPassengers(); -+ -+ for (int i = 0, size = passengers.size(); i < size; i++) { -+ Entity entity = passengers.get(i); -+ int range = entity.getType().clientTrackingRange() * 16; -+ range = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, range); // Paper -+ -+ if (range > highest) { // Paper - we need the lowest range thanks to the fact that our tracker doesn't account for passenger logic // Tuinity - not anymore! -+ highest = range; -+ } -+ -+ highest = getHighestRange(entity, highest); -+ } -+ -+ return highest; -+ } -+ // Leaves end -+ - private int getEffectiveRange() { - int i = this.range; -- Iterator iterator = this.entity.getIndirectPassengers().iterator(); -+ // Leaves start - remove iterators and streams -+ if (org.leavesmc.leaves.LeavesConfig.removeRangeCheckStreams) { -+ i = getHighestRange(this.entity, i); -+ } else { -+ Iterator iterator = this.entity.getIndirectPassengers().iterator(); - -- while (iterator.hasNext()) { -- Entity entity = (Entity) iterator.next(); -- int j = entity.getType().clientTrackingRange() * 16; -- j = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, j); // Paper -+ while (iterator.hasNext()) { -+ Entity entity = (Entity) iterator.next(); -+ int j = entity.getType().clientTrackingRange() * 16; -+ j = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, j); // Paper - -- if (j > i) { -- i = j; -+ if (j > i) { -+ i = j; -+ } - } - } -+ // Leaves end - remove iterators and streams - - return this.scaledRange(i); - } diff --git a/patches/removed/server/0030-Use-aging-cache-for-biome-temperatures.patch b/patches/removed/server/0030-Use-aging-cache-for-biome-temperatures.patch deleted file mode 100644 index e0de2be5..00000000 --- a/patches/removed/server/0030-Use-aging-cache-for-biome-temperatures.patch +++ /dev/null @@ -1,236 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 18 Aug 2022 16:53:45 +0800 -Subject: [PATCH] Use aging cache for biome temperatures - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java -index 90c165c890a2d998e3b0af9b4310e3995ede6f64..6db6f96af0058d5eaf725e743d3019e3a3b8604c 100644 ---- a/src/main/java/net/minecraft/world/level/biome/Biome.java -+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java -@@ -63,7 +63,17 @@ public final class Biome { - private final BiomeGenerationSettings generationSettings; - private final MobSpawnSettings mobSettings; - private final BiomeSpecialEffects specialEffects; -- private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { -+ // Leaves start - use our cache -+ private final ThreadLocal temperatureCache; -+ private final ThreadLocal temperatureAgingCache; -+ -+ Biome(Biome.ClimateSettings weather, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings spawnSettings) { -+ this.climateSettings = weather; -+ this.generationSettings = generationSettings; -+ this.mobSettings = spawnSettings; -+ this.specialEffects = effects; -+ -+ temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { - Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) { - protected void rehash(int i) { - } -@@ -71,13 +81,13 @@ public final class Biome { - long2FloatLinkedOpenHashMap.defaultReturnValue(Float.NaN); - return long2FloatLinkedOpenHashMap; - })); -- -- Biome(Biome.ClimateSettings weather, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings spawnSettings) { -- this.climateSettings = weather; -- this.generationSettings = generationSettings; -- this.mobSettings = spawnSettings; -- this.specialEffects = effects; -+ temperatureAgingCache = ThreadLocal.withInitial(() -> { -+ return Util.make(() -> { -+ return new org.leavesmc.leaves.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE); -+ }); -+ }); - } -+ // Leaves end - use our cache - - public int getSkyColor() { - return this.specialEffects.getSkyColor(); -@@ -111,7 +121,33 @@ public final class Biome { - - @Deprecated - public float getTemperature(BlockPos blockPos) { -- return this.getHeightAdjustedTemperature(blockPos); // Paper - optimise random ticking -+ long l = blockPos.asLong(); -+ // Leaves start - use our cache -+ if (org.leavesmc.leaves.LeavesConfig.biomeTemperaturesUseAgingCache) { -+ org.leavesmc.leaves.structs.Long2FloatAgingCache cache = this.temperatureAgingCache.get(); -+ float f = cache.getValue(l); -+ if (!Float.isNaN(f)) { -+ return f; -+ } else { -+ float g = this.getHeightAdjustedTemperature(blockPos); -+ cache.putValue(l, g); -+ return g; -+ } -+ } else { -+ Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = this.temperatureCache.get(); -+ float f = long2FloatLinkedOpenHashMap.get(l); -+ if (!Float.isNaN(f)) { -+ return f; -+ } else { -+ float g = this.getHeightAdjustedTemperature(blockPos); -+ if (long2FloatLinkedOpenHashMap.size() == 1024) { -+ long2FloatLinkedOpenHashMap.removeFirstFloat(); -+ } -+ long2FloatLinkedOpenHashMap.put(l, g); -+ return g; -+ } -+ } -+ // Leaves end - use our cache - } - - public boolean shouldFreeze(LevelReader world, BlockPos blockPos) { -@@ -139,6 +175,7 @@ public final class Biome { - - return false; - } -+ // Leaves end - use our cache - } - - public boolean coldEnoughToSnow(BlockPos pos) { -@@ -166,6 +203,7 @@ public final class Biome { - - return false; - } -+ // Leaves end - use our cache - } - - public BiomeGenerationSettings getGenerationSettings() { -@@ -317,6 +355,7 @@ public final class Biome { - + this.generationSettings - + ",\n}"; - } -+ // Leaves end - use our cache - } - - public static record ClimateSettings(boolean hasPrecipitation, float temperature, Biome.TemperatureModifier temperatureModifier, float downfall) { -diff --git a/src/main/java/org/leavesmc/leaves/structs/Long2FloatAgingCache.java b/src/main/java/org/leavesmc/leaves/structs/Long2FloatAgingCache.java -new file mode 100644 -index 0000000000000000000000000000000000000000..cd8b1bbfe553c28b75ea92d344364650756e9fdd ---- /dev/null -+++ b/src/main/java/org/leavesmc/leaves/structs/Long2FloatAgingCache.java -@@ -0,0 +1,121 @@ -+package org.leavesmc.leaves.structs; -+ -+import it.unimi.dsi.fastutil.HashCommon; -+ -+// Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) -+ -+/** -+ * A replacement for the cache used in Biome. -+ */ -+public class Long2FloatAgingCache { -+ -+ private static class AgingEntry { -+ private long data; -+ private float value; -+ private int uses = 0; -+ private int age = 0; -+ -+ private AgingEntry(long data, float value) { -+ this.data = data; -+ this.value = value; -+ } -+ -+ public void replace(long data, float flag) { -+ this.data = data; -+ this.value = flag; -+ } -+ -+ public int getValue() { -+ return this.uses - (this.age >> 1); // age isn't as important as uses -+ } -+ -+ public void incrementUses() { -+ this.uses = this.uses + 1 & Integer.MAX_VALUE; -+ } -+ -+ public void incrementAge() { -+ this.age = this.age + 1 & Integer.MAX_VALUE; -+ } -+ } -+ -+ private final AgingEntry[] entries; -+ private final int mask; -+ private final int maxDistance; // the most amount of entries to check for a value -+ -+ public Long2FloatAgingCache(int size) { -+ int arraySize = HashCommon.nextPowerOfTwo(size); -+ this.entries = new AgingEntry[arraySize]; -+ this.mask = arraySize - 1; -+ this.maxDistance = Math.min(arraySize, 4); -+ } -+ -+ public float getValue(long data) { -+ AgingEntry curr; -+ int pos; -+ -+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) { -+ return Float.NaN; -+ } else if (data == curr.data) { -+ curr.incrementUses(); -+ return curr.value; -+ } -+ -+ int checked = 1; // start at 1 because we already checked the first spot above -+ -+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) { -+ if (data == curr.data) { -+ curr.incrementUses(); -+ return curr.value; -+ } else if (++checked >= this.maxDistance) { -+ break; -+ } -+ } -+ -+ return Float.NaN; -+ } -+ -+ public void putValue(long data, float value) { -+ AgingEntry curr; -+ int pos; -+ -+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) { -+ this.entries[pos] = new AgingEntry(data, value); // add -+ return; -+ } else if (data == curr.data) { -+ curr.incrementUses(); -+ return; -+ } -+ -+ int checked = 1; // start at 1 because we already checked the first spot above -+ -+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) { -+ if (data == curr.data) { -+ curr.incrementUses(); -+ return; -+ } else if (++checked >= this.maxDistance) { -+ this.forceAdd(data, value); -+ return; -+ } -+ } -+ -+ this.entries[pos] = new AgingEntry(data, value); // add -+ } -+ -+ private void forceAdd(long data, float value) { -+ int expectedPos = HashCommon.mix(HashCommon.long2int(data)) & this.mask; -+ AgingEntry entryToRemove = this.entries[expectedPos]; -+ -+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) { -+ int pos = i & this.mask; -+ AgingEntry entry = this.entries[pos]; -+ if (entry.getValue() < entryToRemove.getValue()) { -+ entryToRemove = entry; -+ } -+ -+ entry.incrementAge(); // use this as a mechanism to age the other entries -+ } -+ -+ // remove the least used/oldest entry -+ entryToRemove.replace(data, value); -+ } -+} diff --git a/patches/removed/server/0041-Improve-fluid-direction-caching.patch b/patches/removed/server/0041-Improve-fluid-direction-caching.patch deleted file mode 100644 index d92b446c..00000000 --- a/patches/removed/server/0041-Improve-fluid-direction-caching.patch +++ /dev/null @@ -1,262 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Fri, 16 Dec 2022 07:45:51 +0800 -Subject: [PATCH] Improve fluid direction caching - -This patch is Powered by Pufferfish -(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index 1c0712295695727ee9c4d430d4157b8e17cbd71f..1687ab4965433459219bb5d8aaf5ec8e5baeb605 100644 ---- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -53,6 +53,11 @@ public abstract class FlowingFluid extends Fluid { - object2bytelinkedopenhashmap.defaultReturnValue((byte) 127); - return object2bytelinkedopenhashmap; - }); -+ // Leaves start - use our own cache -+ private static final ThreadLocal> localFluidDirectionCache = ThreadLocal.withInitial(() -> { -+ return new org.leavesmc.leaves.structs.FluidDirectionCache<>(2048); -+ }); -+ // Leaves end - use our own cache - private final Map shapes = Maps.newIdentityHashMap(); - - public FlowingFluid() {} -@@ -240,40 +245,70 @@ public abstract class FlowingFluid extends Fluid { - } - - private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) { -- Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap; -+ // Leaves end - cache -+ if (!org.leavesmc.leaves.LeavesConfig.improveFluidDirectionCaching) { -+ Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap; -+ -+ if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { -+ object2bytelinkedopenhashmap = (Object2ByteLinkedOpenHashMap) FlowingFluid.OCCLUSION_CACHE.get(); -+ } else { -+ object2bytelinkedopenhashmap = null; -+ } - -- if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { -- object2bytelinkedopenhashmap = (Object2ByteLinkedOpenHashMap) FlowingFluid.OCCLUSION_CACHE.get(); -- } else { -- object2bytelinkedopenhashmap = null; -- } -+ Block.BlockStatePairKey block_a; -+ -+ if (object2bytelinkedopenhashmap != null) { -+ block_a = new Block.BlockStatePairKey(state, fromState, face); -+ byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a); -+ -+ if (b0 != 127) { -+ return b0 != 0; -+ } -+ } else { -+ block_a = null; -+ } - -- Block.BlockStatePairKey block_a; -+ VoxelShape voxelshape = state.getCollisionShape(world, pos); -+ VoxelShape voxelshape1 = fromState.getCollisionShape(world, fromPos); -+ boolean flag = !Shapes.mergedFaceOccludes(voxelshape, voxelshape1, face); - -- if (object2bytelinkedopenhashmap != null) { -- block_a = new Block.BlockStatePairKey(state, fromState, face); -- byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a); -+ if (object2bytelinkedopenhashmap != null) { -+ if (object2bytelinkedopenhashmap.size() == 200) { -+ object2bytelinkedopenhashmap.removeLastByte(); -+ } - -- if (b0 != 127) { -- return b0 != 0; -+ object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0)); - } -+ -+ return flag; - } else { -- block_a = null; -- } -+ org.leavesmc.leaves.structs.FluidDirectionCache cache = null; -+ if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { -+ cache = localFluidDirectionCache.get(); -+ } - -- VoxelShape voxelshape = state.getCollisionShape(world, pos); -- VoxelShape voxelshape1 = fromState.getCollisionShape(world, fromPos); -- boolean flag = !Shapes.mergedFaceOccludes(voxelshape, voxelshape1, face); -+ Block.BlockStatePairKey block_a; -+ if (cache != null) { -+ block_a = new Block.BlockStatePairKey(state, fromState, face); -+ Boolean flag = cache.getValue(block_a); -+ if (flag != null) { -+ return flag; -+ } -+ } else { -+ block_a = null; -+ } - -- if (object2bytelinkedopenhashmap != null) { -- if (object2bytelinkedopenhashmap.size() == 200) { -- object2bytelinkedopenhashmap.removeLastByte(); -+ VoxelShape voxelshape = state.getCollisionShape(world, pos); -+ VoxelShape voxelshape1 = fromState.getCollisionShape(world, fromPos); -+ boolean flag = !Shapes.mergedFaceOccludes(voxelshape, voxelshape1, face); -+ -+ if (cache != null) { -+ cache.putValue(block_a, flag); - } - -- object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0)); -+ return flag; - } -- -- return flag; -+ // Leaves start - cache - } - - public abstract Fluid getFlowing(); -diff --git a/src/main/java/org/leavesmc/leaves/structs/FluidDirectionCache.java b/src/main/java/org/leavesmc/leaves/structs/FluidDirectionCache.java -new file mode 100644 -index 0000000000000000000000000000000000000000..e07a7c68d6d552767a77ffc507e6023b77daeac5 ---- /dev/null -+++ b/src/main/java/org/leavesmc/leaves/structs/FluidDirectionCache.java -@@ -0,0 +1,138 @@ -+package org.leavesmc.leaves.structs; -+ -+import it.unimi.dsi.fastutil.HashCommon; -+ -+// Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) -+ -+/** -+ * This is a replacement for the cache used in FluidTypeFlowing. -+ * The requirements for the previous cache were: -+ * - Store 200 entries -+ * - Look for the flag in the cache -+ * - If it exists, move to front of cache -+ * - If it doesn't exist, remove last entry in cache and insert in front -+ *

-+ * This class accomplishes something similar, however has a few different -+ * requirements put into place to make this more optimize: -+ *

-+ * - maxDistance is the most amount of entries to be checked, instead -+ * of having to check the entire list. -+ * - In combination with that, entries are all tracked by age and how -+ * frequently they're used. This enables us to remove old entries, -+ * without constantly shifting any around. -+ *

-+ * Usage of the previous map would have to reset the head every single usage, -+ * shifting the entire map. Here, nothing happens except an increment when -+ * the cache is hit, and when it needs to replace an old element only a single -+ * element is modified. -+ */ -+public class FluidDirectionCache { -+ -+ private static class FluidDirectionEntry { -+ private final T data; -+ private final boolean flag; -+ private int uses = 0; -+ private int age = 0; -+ -+ private FluidDirectionEntry(T data, boolean flag) { -+ this.data = data; -+ this.flag = flag; -+ } -+ -+ public int getValue() { -+ return this.uses - (this.age >> 1); // age isn't as important as uses -+ } -+ -+ public void incrementUses() { -+ this.uses = this.uses + 1 & Integer.MAX_VALUE; -+ } -+ -+ public void incrementAge() { -+ this.age = this.age + 1 & Integer.MAX_VALUE; -+ } -+ } -+ -+ private final FluidDirectionEntry[] entries; -+ private final int mask; -+ private final int maxDistance; // the most amount of entries to check for a value -+ -+ public FluidDirectionCache(int size) { -+ int arraySize = HashCommon.nextPowerOfTwo(size); -+ this.entries = new FluidDirectionEntry[arraySize]; -+ this.mask = arraySize - 1; -+ this.maxDistance = Math.min(arraySize, 4); -+ } -+ -+ public Boolean getValue(T data) { -+ FluidDirectionEntry curr; -+ int pos; -+ -+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) { -+ return null; -+ } else if (data.equals(curr.data)) { -+ curr.incrementUses(); -+ return curr.flag; -+ } -+ -+ int checked = 1; // start at 1 because we already checked the first spot above -+ -+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) { -+ if (data.equals(curr.data)) { -+ curr.incrementUses(); -+ return curr.flag; -+ } else if (++checked >= this.maxDistance) { -+ break; -+ } -+ } -+ -+ return null; -+ } -+ -+ public void putValue(T data, boolean flag) { -+ FluidDirectionEntry curr; -+ int pos; -+ -+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) { -+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add -+ return; -+ } else if (data.equals(curr.data)) { -+ curr.incrementUses(); -+ return; -+ } -+ -+ int checked = 1; // start at 1 because we already checked the first spot above -+ -+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) { -+ if (data.equals(curr.data)) { -+ curr.incrementUses(); -+ return; -+ } else if (++checked >= this.maxDistance) { -+ this.forceAdd(data, flag); -+ return; -+ } -+ } -+ -+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add -+ } -+ -+ private void forceAdd(T data, boolean flag) { -+ int expectedPos = HashCommon.mix(data.hashCode()) & this.mask; -+ -+ int toRemovePos = expectedPos; -+ FluidDirectionEntry entryToRemove = this.entries[toRemovePos]; -+ -+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) { -+ int pos = i & this.mask; -+ FluidDirectionEntry entry = this.entries[pos]; -+ if (entry.getValue() < entryToRemove.getValue()) { -+ toRemovePos = pos; -+ entryToRemove = entry; -+ } -+ -+ entry.incrementAge(); // use this as a mechanism to age the other entries -+ } -+ -+ // remove the least used/oldest entry -+ this.entries[toRemovePos] = new FluidDirectionEntry(data, flag); -+ } -+} diff --git a/patches/removed/server/0058-Spawn-ignore-lc.patch b/patches/removed/server/0058-Spawn-ignore-lc.patch deleted file mode 100644 index e43a352a..00000000 --- a/patches/removed/server/0058-Spawn-ignore-lc.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 29 Jun 2023 22:40:24 +0800 -Subject: [PATCH] Spawn ignore lc - - -diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 4772d0b1c70213bb73aa22eca820ade21335b3a8..9f188a921781f9620b6dcdc6c7549a8a4709efa1 100644 ---- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java -+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -230,6 +230,19 @@ public final class NaturalSpawner { - } - public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer trackEntity) { - // Paper end - Optional per player mob spawns -+ // Leaves start - ignore lc -+ if (org.leavesmc.leaves.LeavesConfig.ignoreLC) { -+ int spawnN = 0; -+ for (int i = chunk.getMinBuildHeight(); i < chunk.getMaxBuildHeight(); i += 16) { -+ net.minecraft.world.level.chunk.LevelChunkSection section = chunk.getSections()[chunk.getSectionIndex(i)]; -+ if (section != null && !section.hasOnlyAir()) { -+ BlockPos pos = getRandomPosInChunk(world, chunk).offset(0, i, 0); -+ spawnN += spawnCategoryForPosition(group, world, chunk, pos, checker, runner, maxSpawns, trackEntity); -+ } -+ } -+ return spawnN; -+ } -+ // Leaves stop - ignore lc - BlockPos blockposition = NaturalSpawner.getRandomPosWithin(world, chunk); - - if (blockposition.getY() >= world.getMinY() + 1) { -@@ -237,6 +250,16 @@ public final class NaturalSpawner { - } - } - -+ // Leaves start - ignore lc -+ private static BlockPos getRandomPosInChunk(Level world, LevelChunk chunk) { -+ ChunkPos chunkPos = chunk.getPos(); -+ int x = chunkPos.getMinBlockX() + world.random.nextInt(16); -+ int z = chunkPos.getMinBlockZ() + world.random.nextInt(16); -+ int y = world.random.nextInt(16) + 1; -+ return new BlockPos(x, y, z); -+ } -+ // Leaves stop - ignore lc -+ - @VisibleForDebug - public static void spawnCategoryForPosition(MobCategory group, ServerLevel world, BlockPos pos) { - NaturalSpawner.spawnCategoryForPosition(group, world, world.getChunk(pos), pos, (entitytypes, blockposition1, ichunkaccess) -> { diff --git a/patches/removed/server/0067-Cache-world-generator-sea-level.patch b/patches/removed/server/0067-Cache-world-generator-sea-level.patch deleted file mode 100644 index 65de710d..00000000 --- a/patches/removed/server/0067-Cache-world-generator-sea-level.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Tue, 18 Jul 2023 14:22:06 +0800 -Subject: [PATCH] Cache world generator sea level - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -index 3f39d6c786d9dfdd9ad591e08ff05fcbb41a1df6..be411653a89e4c3585db95509e3a93d140a05fba 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -61,12 +61,17 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { - private static final BlockState AIR = Blocks.AIR.defaultBlockState(); - public final Holder settings; - private final Supplier globalFluidPicker; -+ private int cachedSeaLevel; // Leaves - cache world generator sea level - - public NoiseBasedChunkGenerator(BiomeSource biomeSource, Holder settings) { - super(biomeSource); - this.settings = settings; - this.globalFluidPicker = Suppliers.memoize(() -> { -- return NoiseBasedChunkGenerator.createFluidPicker((NoiseGeneratorSettings) settings.value()); -+ // Leaves start - cache world generator sea level -+ var fluidPicker = NoiseBasedChunkGenerator.createFluidPicker((NoiseGeneratorSettings) settings.value()); -+ this.cachedSeaLevel = settings.value().seaLevel(); -+ return fluidPicker; -+ // Leaves end - cache world generator sea level - }); - } - -@@ -409,7 +414,13 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { - - @Override - public int getSeaLevel() { -- return ((NoiseGeneratorSettings) this.settings.value()).seaLevel(); -+ // Leaves start - cache world generator sea level -+ if (!org.leavesmc.leaves.LeavesConfig.performance.cacheWorldGeneratorSeaLevel) { -+ return ((NoiseGeneratorSettings) this.settings.value()).seaLevel(); -+ } else { -+ return cachedSeaLevel; -+ } -+ // Leaves end - cache world generator sea level - } - - @Override diff --git a/patches/removed/server/0077-Cache-BlockStatePairKey-hash.patch b/patches/removed/server/0077-Cache-BlockStatePairKey-hash.patch deleted file mode 100644 index 462ba53b..00000000 --- a/patches/removed/server/0077-Cache-BlockStatePairKey-hash.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Tue, 18 Jul 2023 14:59:26 +0800 -Subject: [PATCH] Cache BlockStatePairKey hash - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index 0c31c53b1512f0c47a525eff04c1b783cb782fd3..e09b35bfed9880ea6c8168ff6099f1a1a5fb6527 100644 ---- a/src/main/java/net/minecraft/world/level/block/Block.java -+++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -626,11 +626,18 @@ public class Block extends BlockBehaviour implements ItemLike { - private final BlockState first; - private final BlockState second; - private final Direction direction; -+ private final int hash; // Leaves - cache BlockStatePairKey hash - - public BlockStatePairKey(BlockState self, BlockState other, Direction facing) { - this.first = self; - this.second = other; - this.direction = facing; -+ // Leaves start - cache BlockStatePairKey hash -+ int hash = this.first.hashCode(); -+ hash = 31 * hash + this.second.hashCode(); -+ hash = 31 * hash + this.direction.hashCode(); -+ this.hash = hash; -+ // Leaves end - cache BlockStatePairKey hash - } - - public boolean equals(Object object) { -@@ -646,11 +653,17 @@ public class Block extends BlockBehaviour implements ItemLike { - } - - public int hashCode() { -- int i = this.first.hashCode(); -+ // Leaves start - cache BlockStatePairKey hash -+ if (!org.leavesmc.leaves.LeavesConfig.cacheBlockStatePairKeyHash) { -+ int i = this.first.hashCode(); - -- i = 31 * i + this.second.hashCode(); -- i = 31 * i + this.direction.hashCode(); -- return i; -+ i = 31 * i + this.second.hashCode(); -+ i = 31 * i + this.direction.hashCode(); -+ return i; -+ } else { -+ return this.hash; -+ } -+ // Leaves end - cache BlockStatePairKey hash - } - } - } diff --git a/patches/removed/server/0099-Disable-moved-wrongly-threshold.patch b/patches/removed/server/0099-Disable-moved-wrongly-threshold.patch deleted file mode 100644 index 097d97d0..00000000 --- a/patches/removed/server/0099-Disable-moved-wrongly-threshold.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 28 Sep 2023 20:30:46 +0800 -Subject: [PATCH] Disable moved wrongly threshold - - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index a0b0bee8c2c0452d41872722875dbb131ccceacf..fd05c29b888f7979e208e51cfc8a4110f3324eb9 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -574,7 +574,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - } - // Paper end - Prevent moving into unloaded chunks - -- if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { -+ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // Leaves - disable can - // CraftBukkit end - ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); - this.send(new ClientboundMoveVehiclePacket(entity)); -@@ -610,7 +610,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - d10 = d6 * d6 + d7 * d7 + d8 * d8; - boolean flag2 = false; - -- if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot -+ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot // Leaves - disable can - flag2 = true; // Paper - diff on change, this should be moved wrongly - ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", new Object[]{entity.getName().getString(), this.player.getName().getString(), Math.sqrt(d10)}); - } -@@ -1426,7 +1426,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY, - toX, toY, toZ, toYaw, toPitch, true); - if (!event.isAllowed()) { -- if (event.getLogWarning()) -+ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && event.getLogWarning()) // Leaves - disable can - ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); - this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); - return; -@@ -1496,7 +1496,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - d10 = d6 * d6 + d7 * d7 + d8 * d8; - boolean movedWrongly = false; // Paper - Add fail move event; rename - -- if (!this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot -+ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && !this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot // Leaves - disable can - // Paper start - Add fail move event - io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY, - toX, toY, toZ, toYaw, toPitch, true); diff --git a/patches/removed/server/0107-Fix-fortress-mob-spawn.patch b/patches/removed/server/0107-Fix-fortress-mob-spawn.patch deleted file mode 100644 index e09009fe..00000000 --- a/patches/removed/server/0107-Fix-fortress-mob-spawn.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MC_XiaoHei -Date: Mon, 29 Jul 2024 08:20:31 +0800 -Subject: [PATCH] Fix fortress mob spawn - - -diff --git a/net/minecraft/world/level/biome/MobSpawnSettings.java b/net/minecraft/world/level/biome/MobSpawnSettings.java -index db3b8a237d63255aa9ffd70c88a093002a6bd770..7d28dcb8c3dbbf2875c8d04cd60d56445d9dc325 100644 ---- a/net/minecraft/world/level/biome/MobSpawnSettings.java -+++ b/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -155,6 +155,14 @@ public class MobSpawnSettings { - this.maxCount = maxCount; - } - -+ // Leaves start - fix fortress mob spawn -+ @Override -+ public boolean equals(Object obj) { -+ if(!org.leavesmc.leaves.LeavesConfig.modify.oldMC.fixFortressMobSpawn || !(obj instanceof SpawnerData other)) return this == obj; -+ return this.type == other.type && this.minCount == other.minCount && this.maxCount == other.maxCount; -+ } -+ // Leaves end - fix fortress mob spawn -+ - @Override - public String toString() { - return EntityType.getKey(this.type) + "*(" + this.minCount + "-" + this.maxCount + ")"; diff --git a/patches/removed/server/0115-Fix-Warden-GameEventListener-register-on-load.patch b/patches/removed/server/0115-Fix-Warden-GameEventListener-register-on-load.patch deleted file mode 100644 index c7d6387f..00000000 --- a/patches/removed/server/0115-Fix-Warden-GameEventListener-register-on-load.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sat, 8 Feb 2025 17:43:55 +0800 -Subject: [PATCH] Fix Warden GameEventListener register on load - -I completely don't understand why it can be fixed, but it fixed - -diff --git a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -index 2b98932e69271571e6e9350c55c82edc858d76f6..5a0297759836de779c5230d3d19497cd7ac4b37d 100644 ---- a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -+++ b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -@@ -41,7 +41,7 @@ public class DynamicGameEventListener { - - private static void ifChunkExists(LevelReader level, @Nullable SectionPos sectionPos, Consumer dispatcherConsumer) { - if (sectionPos != null) { -- ChunkAccess chunk = level.getChunkIfLoadedImmediately(sectionPos.getX(), sectionPos.getZ()); // Paper - Perf: can cause sync loads while completing a chunk, resulting in deadlock -+ ChunkAccess chunk = level.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.FULL, false); // Leaves - disable perf, to fix listener load - if (chunk != null) { - dispatcherConsumer.accept(chunk.getListenerRegistry(sectionPos.y())); - } diff --git a/patches/removed/server/0131-Optimize-random-calls-in-chunk-ticking.patch b/patches/removed/server/0131-Optimize-random-calls-in-chunk-ticking.patch deleted file mode 100644 index c5a94b75..00000000 --- a/patches/removed/server/0131-Optimize-random-calls-in-chunk-ticking.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 27 Jun 2024 20:15:05 +0800 -Subject: [PATCH] Optimize random calls in chunk ticking - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 421fa38abbef8037a3e90ff2e7c8acb76e77a4df..3db7d4ec535654fe8a3e425c6e55859fde37c8de 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -834,7 +834,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - gameprofilerfiller.push("thunder"); - final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change - -- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder -+ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && (org.leavesmc.leaves.LeavesConfig.optimizeChunkTicking ? chunk.shouldDoLightning(this.random) : this.random.nextInt(this.spigotConfig.thunderChance) == 0)) { // Spigot // Paper - Option to disable thunder // Leaves - replace random with shouldDoLightning - blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper - - if (this.isRainingAt(blockposition)) { -diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 94015519f379fab094b4b24c4b3a1900c1194e17..45a6b59ba3d869e0d6a28de0139908dd35ce6fd9 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -86,6 +86,17 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - private final LevelChunkTicks blockTicks; - private final LevelChunkTicks fluidTicks; - -+ // Leaves start - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively -+ private int lightningTick; -+ public final boolean shouldDoLightning(net.minecraft.util.RandomSource random) { -+ if (this.lightningTick-- <= 0) { -+ this.lightningTick = random.nextInt(this.level.spigotConfig.thunderChance) << 1; -+ return true; -+ } -+ return false; -+ } -+ // Leaves end -+ - public LevelChunk(Level world, ChunkPos pos) { - this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null); - } -@@ -109,6 +120,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - this.postLoad = entityLoader; - this.blockTicks = blockTickScheduler; - this.fluidTicks = fluidTickScheduler; -+ -+ if (org.leavesmc.leaves.LeavesConfig.optimizeChunkTicking) this.lightningTick = this.level.getThreadUnsafeRandom().nextInt(100000) << 1; // Leaves - initialize lightning tick - } - - // CraftBukkit start