diff --git a/build.gradle.kts b/build.gradle.kts index f951db8c..fe90887b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,7 @@ repositories { dependencies { remapper("net.fabricmc:tiny-remapper:0.8.6:fat") - decompiler("net.minecraftforge:forgeflower:1.5.605.7") + decompiler("net.minecraftforge:forgeflower:2.0.605.1") paperclip("io.papermc:paperclip:3.0.2") } diff --git a/gradle.properties b/gradle.properties index f009535d..1f5039e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ group=top.leavesmc.leaves -version=1.19.2-R0.1-SNAPSHOT +version=1.19.3-R0.1-SNAPSHOT -mcVersion=1.19.2 -packageVersion=1_19_R1 +mcVersion=1.19.3 +packageVersion=1_19_R2 org.gradle.jvmargs=-Xmx2G -paperRef=407a445aacbc6d3dd2993e495064800ffff7dddf +paperRef=0baf2ff1b9a6e0bd7a7a369597256902fde47fc7 diff --git a/patches/api/0001-Leaves-Server-Config.patch b/patches/api/0001-Leaves-Server-Config.patch index 592e18c1..d4ef421b 100644 --- a/patches/api/0001-Leaves-Server-Config.patch +++ b/patches/api/0001-Leaves-Server-Config.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Leaves Server Config diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index e43fef0152468944d8a33036344a43e95fe58476..1b311ecc6a2e4ccb7437eb74dcb7b3a881d035fd 100644 +index 2204336d8800311b65e894739ab1b27273e7c6f2..da7d83aee6dff653f131718233a21290e76242de 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -1968,6 +1968,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -1970,6 +1970,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi throw new UnsupportedOperationException("Not supported yet."); } // Paper end diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index 8032a94d..e6314b51 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index b0e4f11e8af4b909a56bb5576d05ef0537fb25f7..abca7e9e3b26b0f4086b6ace2f35b87d58393575 100644 +index d5d49bb2b47c889e12d17dc87b8c439a60b3fe67..97269144f53a3766e3ec646576ec06a55930a3a8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,8 +7,12 @@ plugins { @@ -16,14 +16,14 @@ index b0e4f11e8af4b909a56bb5576d05ef0537fb25f7..abca7e9e3b26b0f4086b6ace2f35b87d - implementation(project(":paper-mojangapi")) + implementation(project(":leaves-api")) // Leaves + // Leaves start -+ implementation("io.papermc.paper:paper-mojangapi:1.19.2-R0.1-SNAPSHOT") { ++ implementation("io.papermc.paper:paper-mojangapi:1.19.3-R0.1-SNAPSHOT") { + exclude("io.papermc.paper", "paper-api") + } + // Leaves end // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -56,13 +60,13 @@ tasks.jar { +@@ -55,13 +59,13 @@ tasks.jar { manifest { val git = Git(rootProject.layout.projectDirectory.path) val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() @@ -39,7 +39,7 @@ index b0e4f11e8af4b909a56bb5576d05ef0537fb25f7..abca7e9e3b26b0f4086b6ace2f35b87d "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -134,7 +138,7 @@ fun TaskContainer.registerRunTask( +@@ -133,7 +137,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -71,7 +71,7 @@ index 7b1843e16745ca8db2244e17490d291401f22679..0ac8bcb0a4b7d1da3d0e016617db7a81 metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { Map> map = new HashMap<>(); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 6dc6c3bccb4ba34268a87b0754c87eb1e0df4135..80d0af51faadaca638fbbd4bb98950b73473b925 100644 +index 710ca7d3a5659953f64bc6dccdd93b43300961cc..fd59a24743099e0599609bdb4d9b4578cd4c3940 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1654,7 +1654,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resourcekey, 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 - 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 @@ -65,10 +65,10 @@ index d89471935b2b5888cb5d1f6829ae479003451fda..a69b428d5465b2e434bfd21cd935997c this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0880f7b55d1ce9ff42206fbb2f201500ec5e6ea5..3b738b215ffe6663560dc7a435f6d03905daba0c 100644 +index 79c545b22c5ec202d66b3f6032f894c3de6b8520..4d22a40e7ff0b88aa204e0da81e71757ecc1dd7f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -966,6 +966,7 @@ public final class CraftServer implements Server { +@@ -979,6 +979,7 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); @@ -76,7 +76,7 @@ index 0880f7b55d1ce9ff42206fbb2f201500ec5e6ea5..3b738b215ffe6663560dc7a435f6d039 for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -981,6 +982,7 @@ public final class CraftServer implements Server { +@@ -994,6 +995,7 @@ public final class CraftServer implements Server { } } world.spigotConfig.init(); // Spigot @@ -84,7 +84,7 @@ index 0880f7b55d1ce9ff42206fbb2f201500ec5e6ea5..3b738b215ffe6663560dc7a435f6d039 } Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper -@@ -996,6 +998,7 @@ public final class CraftServer implements Server { +@@ -1009,6 +1011,7 @@ public final class CraftServer implements Server { this.reloadData(); org.spigotmc.SpigotConfig.registerCommands(); // Spigot io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper @@ -92,7 +92,7 @@ index 0880f7b55d1ce9ff42206fbb2f201500ec5e6ea5..3b738b215ffe6663560dc7a435f6d039 this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -@@ -2735,6 +2738,14 @@ public final class CraftServer implements Server { +@@ -2759,6 +2762,14 @@ public final class CraftServer implements Server { { return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); } @@ -108,7 +108,7 @@ index 0880f7b55d1ce9ff42206fbb2f201500ec5e6ea5..3b738b215ffe6663560dc7a435f6d039 @Override public void restart() { diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index c39290555a2900ad552eb9f1514f81344649fc1f..ed6a0e62e57fe31d2317127c85fbaafdd73736c9 100644 +index ed66126214ebfe770a6be35362fc15d1a04bfa8e..d8f6ada712c6345332e719ae46602cd84c060ecf 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -158,6 +158,14 @@ public class Main { diff --git a/patches/server/0005-Fix-gravity-block-duper.patch b/patches/server/0005-Fix-gravity-block-duper.patch index 06cc7146..63b655f9 100644 --- a/patches/server/0005-Fix-gravity-block-duper.patch +++ b/patches/server/0005-Fix-gravity-block-duper.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix gravity block duper diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index a1421689445b9df3f25889845c21cf37a439afe2..e0cc8171151f9db0d4b29980f097f81cacfe9718 100644 +index 7f94da8059147760cbdc2476d0e8beda4a105f40..9b3dda86d8094fa221f3cf88ef99b88b0edd105e 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -510,36 +510,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -46,7 +46,7 @@ index a1421689445b9df3f25889845c21cf37a439afe2..e0cc8171151f9db0d4b29980f097f81c public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -2898,7 +2870,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2917,7 +2889,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } this.processPortalCooldown(); @@ -56,10 +56,10 @@ index a1421689445b9df3f25889845c21cf37a439afe2..e0cc8171151f9db0d4b29980f097f81c } diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index b2d1a17867cdbaad0c6e5c2376c716f9461af124..76bf5ec58d93164b5eeed63b5dae8a5d39ef15e0 100644 +index 72f1866226269396ba0f0c1be269e237925d9322..f7585c4cbe9b22b6ddfe928763314e1f7af711c4 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -61,7 +61,7 @@ public class FallingBlockEntity extends Entity { +@@ -63,7 +63,7 @@ public class FallingBlockEntity extends Entity { @Nullable public CompoundTag blockData; protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); @@ -68,7 +68,7 @@ index b2d1a17867cdbaad0c6e5c2376c716f9461af124..76bf5ec58d93164b5eeed63b5dae8a5d public FallingBlockEntity(EntityType type, Level world) { super(type, world); -@@ -127,11 +127,7 @@ public class FallingBlockEntity extends Entity { +@@ -129,11 +129,7 @@ public class FallingBlockEntity extends Entity { @Override public void tick() { @@ -81,7 +81,7 @@ index b2d1a17867cdbaad0c6e5c2376c716f9461af124..76bf5ec58d93164b5eeed63b5dae8a5d if (this.blockState.isAir()) { this.discard(); } else { -@@ -144,11 +140,7 @@ public class FallingBlockEntity extends Entity { +@@ -146,11 +142,7 @@ public class FallingBlockEntity extends Entity { this.move(MoverType.SELF, this.getDeltaMovement()); diff --git a/patches/server/0006-Fix-trading-with-the-void.patch b/patches/server/0006-Fix-trading-with-the-void.patch index 91229e7e..52201a95 100644 --- a/patches/server/0006-Fix-trading-with-the-void.patch +++ b/patches/server/0006-Fix-trading-with-the-void.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix trading with the void diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 79aa3374fd47cd57d2e0810bb5afebbdb38a1892..bd3e6044de5a63c0372b4ed207feb5bb58de0d98 100644 +index f3a19d00f78e19aa98c57461efb90d79f656a992..bca4022ffff45803984ffbffdaf919376df75af9 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -2619,11 +2619,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2599,11 +2599,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Spigot end // Spigot Start if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message diff --git a/patches/server/0007-Player-can-edit-sign.patch b/patches/server/0007-Player-can-edit-sign.patch index 8d0786d9..20682666 100644 --- a/patches/server/0007-Player-can-edit-sign.patch +++ b/patches/server/0007-Player-can-edit-sign.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Player can edit sign diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java -index ed3d78494735ceda14ad0ea23adeadc374f3b35e..d0e9fd987687d6a0642a9e312668697f98106a0a 100644 +index aface9a9697095a29edaf73c9cdabc2c1414b9d7..c2053114c4e89418b9ae6e24a99d11a9542cd676 100644 --- a/src/main/java/net/minecraft/world/level/block/SignBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java @@ -3,6 +3,7 @@ package net.minecraft.world.level.block; @@ -16,7 +16,7 @@ index ed3d78494735ceda14ad0ea23adeadc374f3b35e..d0e9fd987687d6a0642a9e312668697f import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; -@@ -73,6 +74,7 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo +@@ -73,15 +74,24 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo boolean bl2 = itemStack.is(Items.GLOW_INK_SAC); boolean bl3 = itemStack.is(Items.INK_SAC); boolean bl4 = (bl2 || bl || bl3) && player.getAbilities().mayBuild; @@ -24,9 +24,14 @@ index ed3d78494735ceda14ad0ea23adeadc374f3b35e..d0e9fd987687d6a0642a9e312668697f if (world.isClientSide) { return bl4 ? InteractionResult.SUCCESS : InteractionResult.CONSUME; } else { -@@ -82,6 +84,14 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo +- BlockEntity bl5 = world.getBlockEntity(pos); +- if (!(bl5 instanceof SignBlockEntity)) { ++ BlockEntity blockEntity = world.getBlockEntity(pos); ++ if (!(blockEntity instanceof SignBlockEntity)) { + return InteractionResult.PASS; } else { - SignBlockEntity signBlockEntity = (SignBlockEntity)blockEntity; +- SignBlockEntity signBlockEntity = (SignBlockEntity)bl5; ++ SignBlockEntity signBlockEntity = (SignBlockEntity)blockEntity; boolean bl5 = signBlockEntity.hasGlowingText(); + // Leaves start - Player can edit sign + if (top.leavesmc.leaves.LeavesConfig.playerCanEditSign && bl7 && !signBlockEntity.isEditable) { diff --git a/patches/server/0010-Add-fakeplayer-support.patch b/patches/server/0010-Fakeplayer-support.patch similarity index 97% rename from patches/server/0010-Add-fakeplayer-support.patch rename to patches/server/0010-Fakeplayer-support.patch index 99e15c16..30322d23 100644 --- a/patches/server/0010-Add-fakeplayer-support.patch +++ b/patches/server/0010-Fakeplayer-support.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Thu, 3 Feb 2022 12:28:15 +0800 -Subject: [PATCH] Add fakeplayer support +Subject: [PATCH] Fakeplayer support diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index b9af91e89c98d69e0708324f246e2879f476be1a..7516fb266706ddf0935cb622ea11ab096428cd41 100644 +index cab8412d5183427b02c5f5d7b76aded8e9fbc491..9904aa8178bf64768a646dbc886cb774cb013af9 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -120,6 +120,7 @@ import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvi +@@ -125,6 +125,7 @@ import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvi import net.minecraft.util.profiling.metrics.storage.MetricsPersister; import net.minecraft.util.thread.ReentrantBlockableEventLoop; import net.minecraft.world.Difficulty; @@ -16,7 +16,7 @@ index b9af91e89c98d69e0708324f246e2879f476be1a..7516fb266706ddf0935cb622ea11ab09 import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ai.village.VillageSiege; import net.minecraft.world.entity.npc.CatSpawner; -@@ -181,6 +182,7 @@ import org.bukkit.event.server.ServerLoadEvent; +@@ -193,6 +194,7 @@ import org.bukkit.event.server.ServerLoadEvent; // CraftBukkit end import co.aikar.timings.MinecraftTimings; // Paper @@ -24,7 +24,7 @@ index b9af91e89c98d69e0708324f246e2879f476be1a..7516fb266706ddf0935cb622ea11ab09 public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements CommandSource, AutoCloseable { -@@ -938,6 +940,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop(16, EntityDataSerializers.INT), 0xFF); + + this.velocity = new Vector(0, 0, 0); @@ -778,9 +779,9 @@ index 0000000000000000000000000000000000000000..821d456d11b6f49ea8eba59e79d09980 + + private Packet[] getRenderPackets() { + return new Packet[]{ -+ new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, this), ++ new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this), + new ClientboundAddPlayerPacket(this), -+ new ClientboundSetEntityDataPacket(this.getId(), this.getEntityData(), true), ++ new ClientboundSetEntityDataPacket(this.getId(), this.getEntityData().packDirty()), + new ClientboundRotateHeadPacket(this, (byte) ((getYRot() * 256f) / 360f)) + }; + } @@ -807,7 +808,7 @@ index 0000000000000000000000000000000000000000..821d456d11b6f49ea8eba59e79d09980 + } + + private void removeTab() { -+ sendPacket(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, this)); ++ sendPacket(new ClientboundPlayerInfoRemovePacket(List.of(this.getUUID()))); + } + + private void setDead() { @@ -1108,7 +1109,7 @@ index 0000000000000000000000000000000000000000..821d456d11b6f49ea8eba59e79d09980 + + public void setOnFirePackets(boolean onFire) { + entityData.set(new EntityDataAccessor<>(0, EntityDataSerializers.BYTE), onFire ? (byte) 1 : (byte) 0); -+ sendPacket(new ClientboundSetEntityDataPacket(getId(), getEntityData(), false)); ++ sendPacket(new ClientboundSetEntityDataPacket(getId(), getEntityData().packDirty())); + } + + private void fallDamageCheck() { diff --git a/patches/server/0013-Add-isShrink-to-EntityResurrectEvent.patch b/patches/server/0013-Add-isShrink-to-EntityResurrectEvent.patch index 72bee293..cdf5014b 100644 --- a/patches/server/0013-Add-isShrink-to-EntityResurrectEvent.patch +++ b/patches/server/0013-Add-isShrink-to-EntityResurrectEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add isShrink to EntityResurrectEvent diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 11d7c42d65b91bf57b7bba7812aa17e60e018c67..3529f5fede54fbdf0a3783cce2e3322110685e99 100644 +index 9e075de3542bda8ae086c9ca68bcd00b16d565d0..be1b2d83666a3d7cb67c864590e9b2fbbf583a10 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1548,12 +1548,12 @@ public abstract class LivingEntity extends Entity { +@@ -1549,12 +1549,12 @@ public abstract class LivingEntity extends Entity { } org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null; @@ -23,7 +23,7 @@ index 11d7c42d65b91bf57b7bba7812aa17e60e018c67..3529f5fede54fbdf0a3783cce2e33221 itemstack1.shrink(1); } if (itemstack != null && this instanceof ServerPlayer) { -@@ -4414,3 +4414,4 @@ public abstract class LivingEntity extends Entity { +@@ -4436,3 +4436,4 @@ public abstract class LivingEntity extends Entity { } } diff --git a/patches/server/0018-No-chat-sign.patch b/patches/server/0018-No-chat-sign.patch index 258b3657..f5946777 100644 --- a/patches/server/0018-No-chat-sign.patch +++ b/patches/server/0018-No-chat-sign.patch @@ -5,52 +5,60 @@ Subject: [PATCH] No chat sign diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -index 28ddab1121e314e82bf764fd89f36714bd7445f8..786f89f9d75cf8ad6a6b097556a8d8b115e72abf 100644 +index fd5cbb45e9894b7895ea488e2b9876c0391f6f11..ceb9f13a171ec3e115ef9037f211ca7ccd7d4741 100644 --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -@@ -313,7 +313,7 @@ public final class ChatProcessor { +@@ -307,7 +307,7 @@ public final class ChatProcessor { private void sendToServer(final ChatType.Bound chatType, final @Nullable Function msgFunction) { final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console)); -- ChatProcessor.this.server.logChatMessage(toConsoleMessage.serverContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage, ChatProcessor.this.player.asChatSender()) ? null : "Not Secure"); -+ ChatProcessor.this.server.logChatMessage(toConsoleMessage.serverContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage, ChatProcessor.this.player.asChatSender()) || top.leavesmc.leaves.LeavesConfig.noChatSign ? null : "Not Secure"); // Leaves - No Not Secure +- ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure"); ++ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) || top.leavesmc.leaves.LeavesConfig.noChatSign ? null : "Not Secure"); // Leaves - No Not Secure } record ConstantFunction(net.minecraft.network.chat.Component component) implements Function { diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java -index 62ee3e8b03a4d67e5e9b78ed905c03f5302a7785..3ddc8605168117a84fc6cd18f09014b4c07b499d 100644 +index d1d2fc0c57523c1abf1e8bfec913c78927c3dafc..7e0d49edb49a290b9e3ff4465b5e3c49f1aec9da 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java -@@ -10,9 +10,15 @@ import net.minecraft.server.level.ServerPlayer; +@@ -2,6 +2,8 @@ package net.minecraft.network.protocol.game; - public record ServerboundChatPacket(String message, Instant timeStamp, long salt, MessageSignature signature, boolean signedPreview, LastSeenMessages.Update lastSeenMessages) implements Packet { - public ServerboundChatPacket(FriendlyByteBuf buf) { -- this(buf.readUtf(256), buf.readInstant(), buf.readLong(), new MessageSignature(buf), buf.readBoolean(), new LastSeenMessages.Update(buf)); -+ // Leaves start - EMPTY -+ this(buf.readUtf(256), buf.readInstant(), buf.readLong(), buf.readByteArray(), buf.readBoolean(), new LastSeenMessages.Update(buf)); - } - -+ private ServerboundChatPacket(String message, Instant timeStamp, long salt, byte[] bytes, boolean signedPreview, LastSeenMessages.Update lastSeenMessages) { -+ this(message, timeStamp, salt, MessageSignature.EMPTY, signedPreview, lastSeenMessages); -+ } -+ // Leaves end - EMPTY + import java.time.Instant; + import javax.annotation.Nullable; + ++import io.netty.buffer.ByteBuf; + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.chat.LastSeenMessages; + import net.minecraft.network.chat.MessageSignature; +@@ -9,8 +11,14 @@ import net.minecraft.network.protocol.Packet; + + public record ServerboundChatPacket(String message, Instant timeStamp, long salt, @Nullable MessageSignature signature, LastSeenMessages.Update lastSeenMessages) implements Packet { + public ServerboundChatPacket(FriendlyByteBuf buf) { +- this(buf.readUtf(256), buf.readInstant(), buf.readLong(), buf.readNullable(MessageSignature::read), new LastSeenMessages.Update(buf)); ++ // Leaves start - EMPTY ++ this(buf.readUtf(256), buf.readInstant(), buf.readLong(), buf.readBytes(new byte[256]), new LastSeenMessages.Update(buf)); ++ } ++ ++ private ServerboundChatPacket(String message, Instant timeStamp, long salt, ByteBuf byteBuf, LastSeenMessages.Update lastSeenMessages) { ++ this(message, timeStamp, salt, (MessageSignature) null, lastSeenMessages); + } ++ // Leaves end - EMPTY + @Override public void write(FriendlyByteBuf buf) { - buf.writeUtf(this.message, 256); diff --git a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -index 11183b4a39b9897e1b1067eb2a3556d2b1d90f52..a335bcf8fd9330e2e275d78671c6e2647cb0bac5 100644 +index 6e0a3086da142f1c42007a16bbec7edbab17da04..776be7f58746f96fe9bf7daf11053d3958690df2 100644 --- a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java +++ b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -@@ -28,6 +28,7 @@ public class ServerStatus { +@@ -27,6 +27,7 @@ public class ServerStatus { + @Nullable private String favicon; - private boolean previewsChat; private boolean enforcesSecureChat; + private boolean preventsChatReports; // Leaves - preventsChatReports @Nullable public Component getDescription() { -@@ -78,9 +79,19 @@ public class ServerStatus { +@@ -69,9 +70,19 @@ public class ServerStatus { } public boolean enforcesSecureChat() { @@ -71,7 +79,7 @@ index 11183b4a39b9897e1b1067eb2a3556d2b1d90f52..a335bcf8fd9330e2e275d78671c6e264 public static class Players { private final int maxPlayers; private final int numPlayers; -@@ -186,6 +197,10 @@ public class ServerStatus { +@@ -173,6 +184,10 @@ public class ServerStatus { serverStatus.setEnforcesSecureChat(GsonHelper.getAsBoolean(jsonObject, "enforcesSecureChat")); } @@ -82,7 +90,7 @@ index 11183b4a39b9897e1b1067eb2a3556d2b1d90f52..a335bcf8fd9330e2e275d78671c6e264 return serverStatus; } -@@ -210,6 +225,12 @@ public class ServerStatus { +@@ -196,6 +211,12 @@ public class ServerStatus { jsonObject.addProperty("favicon", serverStatus.getFavicon()); } @@ -96,22 +104,22 @@ index 11183b4a39b9897e1b1067eb2a3556d2b1d90f52..a335bcf8fd9330e2e275d78671c6e264 } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3775a75a54807e50eded612f26fec5ad0229fbca..5dd308320b2e2049a8827cfd9bea3cd0621f03c8 100644 +index 9904aa8178bf64768a646dbc886cb774cb013af9..7347cb4daf40996a559c2a4dec9b22b04d07ae53 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1109,6 +1109,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop packet) { + // Leaves start - no ClientboundPlayerChatHeaderPacket and rebuild ClientboundPlayerChatPacket + if (top.leavesmc.leaves.LeavesConfig.noChatSign) { -+ if (packet instanceof ClientboundPlayerChatHeaderPacket) { -+ return; -+ } else if (packet instanceof ClientboundPlayerChatPacket chat) { ++ if (packet instanceof ClientboundPlayerChatPacket chat) { + packet = new ClientboundSystemChatPacket(chat.chatType().resolve(this.player.level.registryAccess()) -+ .get().decorate(chat.message().serverContent()), false); ++ .get().decorate(chat.unsignedContent() != null ? chat.unsignedContent() ++ : Component.literal(chat.body().content())), false); + } + } + // Leaves end - no ClientboundPlayerChatHeaderPacket and rebuild ClientboundPlayerChatPacket @@ -153,9 +151,7 @@ index 63c9040ed2349eec500ba6e9090440347c514a3b..3aa71562966a31cf2b535f55fd3cf5cf public void send(Packet packet, @Nullable PacketSendListener callbacks) { + // Leaves start - no ClientboundPlayerChatHeaderPacket and rebuild ClientboundPlayerChatPacket + if (top.leavesmc.leaves.LeavesConfig.noChatSign) { -+ if (packet instanceof ClientboundPlayerChatHeaderPacket) { -+ return; -+ } else if (packet instanceof ClientboundPlayerChatPacket chat && callbacks != null) { ++ if (packet instanceof ClientboundPlayerChatPacket chat && callbacks != null) { + this.send(chat); + return; + } @@ -164,50 +160,19 @@ index 63c9040ed2349eec500ba6e9090440347c514a3b..3aa71562966a31cf2b535f55fd3cf5cf // CraftBukkit start if (packet == null || this.processedDisconnect) { // Spigot return; -@@ -2566,6 +2588,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - } - - private void broadcastChatMessage(PlayerChatMessage message) { -+ // Leaves start - no sign -+ if (top.leavesmc.leaves.LeavesConfig.noChatSign) { -+ message = PlayerChatMessage.unsigned(message.signer(), message.signedContent()); -+ } -+ // Leaves end - no sign - // CraftBukkit start - String s = message.signedContent().plain(); - if (s.isEmpty()) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 68233891ccb0f9389e22561421e743aa5c3ba02b..680ad9d8896aa0ce58ceefc4f9deb624b7384f5b 100644 +index 83c38c8c9fb53274f391065d947df566861a3e99..3c1ea8850c5d482d77c0bc137d72fc59dc337979 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1452,7 +1452,7 @@ public abstract class PlayerList { - // Paper end - boolean flag = this.verifyChatTrusted(message, sourceProfile); +@@ -1481,7 +1481,7 @@ public abstract class PlayerList { + } -- this.server.logChatMessage((unsignedFunction == null ? message : message.withUnsignedContent(unsignedFunction.apply(this.server.console))).serverContent(), params, flag ? null : "Not Secure"); // Paper -+ this.server.logChatMessage((unsignedFunction == null ? message : message.withUnsignedContent(unsignedFunction.apply(this.server.console))).serverContent(), params, flag || top.leavesmc.leaves.LeavesConfig.noChatSign ? null : "Not Secure"); // Paper // Leaves - No Not Secure - OutgoingPlayerChatMessage outgoingplayerchatmessage = OutgoingPlayerChatMessage.create(message); - boolean flag1 = message.isFullyFiltered(); - boolean flag2 = false; -diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index e2305caf0b3ce21810a31e05c943a6d859870bd5..ee8bc19a049a9f0235d959d41e4124865d5dabb1 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Player.java -+++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -205,7 +205,13 @@ public abstract class Player extends LivingEntity { - this.lastDeathLocation = Optional.empty(); - this.setUUID(UUIDUtil.getOrCreatePlayerUUID(gameProfile)); - this.gameProfile = gameProfile; -- this.profilePublicKey = publicKey; -+ // Leaves start - no public key -+ if (top.leavesmc.leaves.LeavesConfig.noChatSign) { -+ this.profilePublicKey = null; -+ } else { -+ this.profilePublicKey = publicKey; -+ } -+ // Leaves end - no public key - this.inventoryMenu = new InventoryMenu(this.inventory, !world.isClientSide, this); - this.containerMenu = this.inventoryMenu; - this.moveTo((double) pos.getX() + 0.5D, (double) (pos.getY() + 1), (double) pos.getZ() + 0.5D, yaw, 0.0F); + public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public +- return message.hasSignature() && !message.hasExpiredServer(Instant.now()); ++ return top.leavesmc.leaves.LeavesConfig.noChatSign || (message.hasSignature() && !message.hasExpiredServer(Instant.now())); // Leaves - No Not Secure + } + + // CraftBukkit start diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java index 06bf70f13432f557a65d3dad563f9014998839a6..857b8881ba2d526ee366aa04228b72bc8d7c8c47 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java diff --git a/patches/server/0019-Optimize-mob-spawning.patch b/patches/server/0019-Optimize-mob-spawning.patch index 52586d20..4213f10c 100644 --- a/patches/server/0019-Optimize-mob-spawning.patch +++ b/patches/server/0019-Optimize-mob-spawning.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimize mob spawning This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 595d2bf02a30d91535f8bc509aa8c37a840c274a..c4984f0d27e66e201b126a0f3649f6534b0cef53 100644 +index 7347cb4daf40996a559c2a4dec9b22b04d07ae53..81699351c4f9aa3a66270bcee060a504263cbed4 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -301,6 +301,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop atomicreference = new AtomicReference(); Thread thread = new io.papermc.paper.util.TickThread(() -> { // Paper - rewrite chunk system diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 03989bb74e56c743fbb115518971061ad72355d3..12dd19556a13990f3ed0b50384e8352b5d944822 100644 +index 41d9f243c0b56c81b70e64cfd3ca05b90d45343c..34df346cd337683a8f479f49a53319bae4f3fd07 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -341,6 +341,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -335,6 +335,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.info("JMX monitoring enabled"); } @@ -35,10 +35,10 @@ index 03989bb74e56c743fbb115518971061ad72355d3..12dd19556a13990f3ed0b50384e8352b } } diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 55d8ced734a408c990c6c4fbc81707bcb1f27daa..132bb7595af5106edd84ff2a6efa823aceee35bc 100644 +index 2212f9f48636357265d8e44aba415ea4f09f1fe7..b592f5fa1d235c2c3906dd893d079cd4211794ac 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -334,7 +334,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -342,7 +342,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new); this.regionManagers.add(this.dataRegionManager); // Paper end @@ -48,10 +48,10 @@ index 55d8ced734a408c990c6c4fbc81707bcb1f27daa..132bb7595af5106edd84ff2a6efa823a this.playerEntityTrackerTrackMaps = new com.destroystokyo.paper.util.misc.PlayerAreaMap[TRACKING_RANGE_TYPES.length]; this.entityTrackerTrackRanges = new int[TRACKING_RANGE_TYPES.length]; diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 4ff563d903633f181e1268daa77f250cfec204a0..b9c1d62b13465db6d435d1cda72ca759d8f0d22d 100644 +index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..b4e780f5b050b01ecb6b485b509235f735d71141 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -76,6 +76,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -77,6 +77,11 @@ public class ServerChunkCache extends ChunkSource { private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4]; @@ -63,7 +63,7 @@ index 4ff563d903633f181e1268daa77f250cfec204a0..b9c1d62b13465db6d435d1cda72ca759 private static int getChunkCacheKey(int x, int z) { return x & 3 | ((z & 3) << 2); } -@@ -711,18 +716,25 @@ public class ServerChunkCache extends ChunkSource { +@@ -712,18 +717,25 @@ public class ServerChunkCache extends ChunkSource { // Paper start - per player mob spawning NaturalSpawner.SpawnState spawnercreature_d; // moved down if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't count mobs when animals and monsters are disabled @@ -95,7 +95,7 @@ index 4ff563d903633f181e1268daa77f250cfec204a0..b9c1d62b13465db6d435d1cda72ca759 gameprofilerfiller.popPush("filteringLoadedChunks"); // Paper - moved down this.level.timings.chunkTicks.startTiming(); // Paper -@@ -760,8 +772,8 @@ public class ServerChunkCache extends ChunkSource { +@@ -761,8 +773,8 @@ public class ServerChunkCache extends ChunkSource { if ((true || this.level.isNaturalSpawningAllowed(chunkcoordintpair)) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, false)) { // Paper - optimise anyPlayerCloseEnoughForSpawning // Paper - the chunk is known ticking chunk1.incrementInhabitedTime(j); @@ -106,7 +106,7 @@ index 4ff563d903633f181e1268daa77f250cfec204a0..b9c1d62b13465db6d435d1cda72ca759 } if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - the chunk is known ticking -@@ -822,6 +834,30 @@ public class ServerChunkCache extends ChunkSource { +@@ -823,6 +835,30 @@ public class ServerChunkCache extends ChunkSource { } } // Paper end - controlled flush for entity tracker packets diff --git a/patches/server/0020-Dont-send-useless-entity-packets.patch b/patches/server/0020-Dont-send-useless-entity-packets.patch index cd01551f..559493a3 100644 --- a/patches/server/0020-Dont-send-useless-entity-packets.patch +++ b/patches/server/0020-Dont-send-useless-entity-packets.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Dont send useless entity packets This patch is Powered by Purpur(https://github.com/PurpurMC/Purpur) diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 2358bb1788cfb902bac9b3b7588954af2d2cd823..52a1fc859c4b494bcac9f6f6f971e477a3acbf85 100644 +index 190e9761087baec5827d722a8281f0ffb6798341..158da4c3b002a4948bfb214337aa28a55b358fc9 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -166,20 +166,29 @@ public class ServerEntity { +@@ -170,20 +170,29 @@ public class ServerEntity { boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L; if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround() && !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync @@ -46,7 +46,7 @@ index 2358bb1788cfb902bac9b3b7588954af2d2cd823..52a1fc859c4b494bcac9f6f6f971e477 } if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { -@@ -246,6 +255,21 @@ public class ServerEntity { +@@ -250,6 +259,21 @@ public class ServerEntity { } diff --git a/patches/server/0021-Multithreaded-Tracker.patch b/patches/server/0021-Multithreaded-Tracker.patch index b717699b..f69f1ad8 100644 --- a/patches/server/0021-Multithreaded-Tracker.patch +++ b/patches/server/0021-Multithreaded-Tracker.patch @@ -31,10 +31,10 @@ index f597d65d56964297eeeed6c7e77703764178fee0..a584f2d0829db0bb220b2934ae2934da public ChunkHolder.FullChunkStatus status; diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 322d7e06d014d7f69cd990c096e056074fa7066f..8d14c04e1cbc5de312bf47e4851e79f4176427da 100644 +index b592f5fa1d235c2c3906dd893d079cd4211794ac..634cde8069fc5ba467170a597e02da7c6b4e7b80 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1236,8 +1236,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1248,8 +1248,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider entity.tracker = null; // Paper - We're no longer tracked } @@ -73,11 +73,11 @@ index 322d7e06d014d7f69cd990c096e056074fa7066f..8d14c04e1cbc5de312bf47e4851e79f4 this.level.timings.tracker1.startTiming(); try { for (TrackedEntity tracker : this.entityMap.values()) { -@@ -1461,11 +1491,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1496,11 +1526,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public class TrackedEntity { -- final ServerEntity serverEntity; +- public final ServerEntity serverEntity; - final Entity entity; + public final ServerEntity serverEntity; // Leaves - package -> public + public final Entity entity; // Leaves - package -> public @@ -88,7 +88,7 @@ index 322d7e06d014d7f69cd990c096e056074fa7066f..8d14c04e1cbc5de312bf47e4851e79f4 public TrackedEntity(Entity entity, int i, int j, boolean flag) { this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit -@@ -1477,7 +1507,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1512,7 +1542,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper start - use distance map to optimise tracker com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet lastTrackerCandidates; @@ -97,7 +97,7 @@ index 322d7e06d014d7f69cd990c096e056074fa7066f..8d14c04e1cbc5de312bf47e4851e79f4 com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet oldTrackerCandidates = this.lastTrackerCandidates; this.lastTrackerCandidates = newTrackerCandidates; -@@ -1549,7 +1579,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1584,7 +1614,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void removePlayer(ServerPlayer player) { @@ -106,7 +106,7 @@ index 322d7e06d014d7f69cd990c096e056074fa7066f..8d14c04e1cbc5de312bf47e4851e79f4 if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); } -@@ -1557,7 +1587,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1592,7 +1622,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void updatePlayer(ServerPlayer player) { @@ -129,10 +129,10 @@ index ca42c2642a729b90d22b968af7258f3aee72e14b..464678e973513b5c9e0cf0910cac1b3b public boolean visible = true; diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 52a1fc859c4b494bcac9f6f6f971e477a3acbf85..52cfe588f49444f198db2e40c3073bc6583ca142 100644 +index 158da4c3b002a4948bfb214337aa28a55b358fc9..2f8e77692811604fdc19bff6ba0faeeadcd9bba6 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -272,14 +272,18 @@ public class ServerEntity { +@@ -276,14 +276,18 @@ public class ServerEntity { public void removePairing(ServerPlayer player) { this.entity.stopSeenByPlayer(player); @@ -153,19 +153,7 @@ index 52a1fc859c4b494bcac9f6f6f971e477a3acbf85..52cfe588f49444f198db2e40c3073bc6 this.entity.startSeenByPlayer(player); } -@@ -385,19 +389,28 @@ public class ServerEntity { - SynchedEntityData datawatcher = this.entity.getEntityData(); - - if (datawatcher.isDirty()) { -- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), datawatcher, false)); -+ // Leaves start - ensure main thread -+ ((ServerLevel) this.entity.level).chunkSource.chunkMap.runOnTrackerMainThread(() -> -+ this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), datawatcher, false)) -+ ); -+ // Leaves end - ensure main thread - } - - if (this.entity instanceof LivingEntity) { +@@ -398,12 +402,17 @@ public class ServerEntity { Set set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes(); if (!set.isEmpty()) { diff --git a/patches/server/0024-Optimize-suffocation.patch b/patches/server/0024-Optimize-suffocation.patch index 8d84c2a8..525f2667 100644 --- a/patches/server/0024-Optimize-suffocation.patch +++ b/patches/server/0024-Optimize-suffocation.patch @@ -6,19 +6,19 @@ Subject: [PATCH] Optimize suffocation This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 3529f5fede54fbdf0a3783cce2e3322110685e99..6451507ab1e99be308b741bf6269110415bdb46e 100644 +index be1b2d83666a3d7cb67c864590e9b2fbbf583a10..87e576b6e070e5d7bed803906e1f10817f18d965 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -400,7 +400,7 @@ public abstract class LivingEntity extends Entity { - if (this.isAlive()) { +@@ -402,7 +402,7 @@ public abstract class LivingEntity extends Entity { boolean flag = this instanceof net.minecraft.world.entity.player.Player; -- if (this.isInWall()) { -+ if ((!top.leavesmc.leaves.LeavesConfig.enableSuffocationOptimization || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { // Leaves - optimize suffocation - this.hurt(DamageSource.IN_WALL, 1.0F); - } else if (flag && !this.level.getWorldBorder().isWithinBounds(this.getBoundingBox())) { - double d0 = this.level.getWorldBorder().getDistanceToBorder(this) + this.level.getWorldBorder().getDamageSafeZone(); -@@ -1328,6 +1328,15 @@ public abstract class LivingEntity extends Entity { + if (!this.level.isClientSide) { +- if (this.isInWall()) { ++ if ((!top.leavesmc.leaves.LeavesConfig.enableSuffocationOptimization || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { // Leaves - optimize suffocation + this.hurt(DamageSource.IN_WALL, 1.0F); + } else if (flag && !this.level.getWorldBorder().isWithinBounds(this.getBoundingBox())) { + double d0 = this.level.getWorldBorder().getDistanceToBorder(this) + this.level.getWorldBorder().getDamageSafeZone(); +@@ -1327,6 +1327,15 @@ public abstract class LivingEntity extends Entity { return this.getHealth() <= 0.0F; } diff --git a/patches/server/0025-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch b/patches/server/0025-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch index cc8b4b66..2dddbce2 100644 --- a/patches/server/0025-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch +++ b/patches/server/0025-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Strip raytracing for EntityLiving#hasLineOfSight This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 6451507ab1e99be308b741bf6269110415bdb46e..6e569efe8c5695a875b97126bd4dcd05a86ccf1d 100644 +index 87e576b6e070e5d7bed803906e1f10817f18d965..1d52da0e31a1969b99339c510924ede8851449d4 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3631,7 +3631,13 @@ public abstract class LivingEntity extends Entity { +@@ -3656,7 +3656,13 @@ public abstract class LivingEntity extends Entity { Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ()); // Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists @@ -46,10 +46,10 @@ index d1eefa6ef3e9abfe7af4d8310aa64465fa2d5463..c91735828dc99af0b880a5a105025b42 default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { // Paper start - Prevent raytrace from loading chunks diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 4d880d9b56dc39a298e047cda3f2a31adef45cbc..daa3eb43727bbf8aefd2c69e711aa1709fba7eba 100644 +index 856055eeac058290b9b2146a11f5faccd1873df0..3fd487f9302f428171539e18f09f05c93037fab1 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -410,6 +410,91 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -409,6 +409,91 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return null; } diff --git a/patches/server/0026-Only-check-for-spooky-season-once-an-hour.patch b/patches/server/0026-Only-check-for-spooky-season-once-an-hour.patch index b514c2a8..e31319e2 100644 --- a/patches/server/0026-Only-check-for-spooky-season-once-an-hour.patch +++ b/patches/server/0026-Only-check-for-spooky-season-once-an-hour.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Only check for spooky season once an hour This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -index 50d4595b81f24949011c7565c5e3fc8c26c86019..8de1653e3fbf29e9de550a1976344bd8967485e3 100644 +index 320c558bbe80d4bbc641e895ec43cfa2b45e8d70..f57572620288d8f0e024d43a4e11e2125d45515c 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -@@ -253,13 +253,30 @@ public class Bat extends AmbientCreature { +@@ -256,13 +256,30 @@ public class Bat extends AmbientCreature { } } diff --git a/patches/server/0027-Move-ThreadUnsafeRandom-Initialization.patch b/patches/server/0027-Move-ThreadUnsafeRandom-Initialization.patch index a3ebd0c7..6eddf1f8 100644 --- a/patches/server/0027-Move-ThreadUnsafeRandom-Initialization.patch +++ b/patches/server/0027-Move-ThreadUnsafeRandom-Initialization.patch @@ -6,7 +6,7 @@ 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 bd3e6044de5a63c0372b4ed207feb5bb58de0d98..a8c7ecbd7191fcdb2e012cafcf7a0ac63db75055 100644 +index bca4022ffff45803984ffbffdaf919376df75af9..fcb0488725618382394096d61cc83d6afc099044 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -795,7 +795,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -19,10 +19,10 @@ index bd3e6044de5a63c0372b4ed207feb5bb58de0d98..a8c7ecbd7191fcdb2e012cafcf7a0ac6 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 daa3eb43727bbf8aefd2c69e711aa1709fba7eba..776aeb1ea8bb76d098452c72caf8d941c99f0f60 100644 +index 3fd487f9302f428171539e18f09f05c93037fab1..7d6fe65dc64afa00ecef0d1be2e13507086ab81a 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -272,6 +272,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -271,6 +271,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); @@ -31,7 +31,7 @@ index daa3eb43727bbf8aefd2c69e711aa1709fba7eba..776aeb1ea8bb76d098452c72caf8d941 protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, 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 - 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 -@@ -360,6 +362,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -359,6 +361,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { 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 } @@ -43,4 +43,4 @@ index daa3eb43727bbf8aefd2c69e711aa1709fba7eba..776aeb1ea8bb76d098452c72caf8d941 + // Paper start // ret true if no collision - public final boolean checkEntityCollision(BlockState data, Entity source, CollisionContext voxelshapedcollision, + public final boolean checkEntityCollision(BlockState data, Entity source, net.minecraft.world.phys.shapes.CollisionContext voxelshapedcollision, diff --git a/patches/server/0028-Optimize-random-calls-in-chunk-ticking.patch b/patches/server/0028-Optimize-random-calls-in-chunk-ticking.patch index d599f0e3..09f6c83a 100644 --- a/patches/server/0028-Optimize-random-calls-in-chunk-ticking.patch +++ b/patches/server/0028-Optimize-random-calls-in-chunk-ticking.patch @@ -6,10 +6,10 @@ 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/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index b9c1d62b13465db6d435d1cda72ca759d8f0d22d..70b7ef1309db9e61cab5cf9601fc9fc374265b11 100644 +index b4e780f5b050b01ecb6b485b509235f735d71141..1f1a9af7375bdadce325f8e755a64041320db055 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -707,6 +707,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -708,6 +708,11 @@ public class ServerChunkCache extends ChunkSource { ProfilerFiller gameprofilerfiller = this.level.getProfiler(); gameprofilerfiller.push("pollingChunks"); @@ -22,7 +22,7 @@ index b9c1d62b13465db6d435d1cda72ca759d8f0d22d..70b7ef1309db9e61cab5cf9601fc9fc3 boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index a8c7ecbd7191fcdb2e012cafcf7a0ac63db75055..d59cab4f6a243d9f2448cc7b396d7a4cf9378684 100644 +index fcb0488725618382394096d61cc83d6afc099044..1f3d26bdcd4c949d2cb57ac6313b3936fdcfb1e6 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -798,6 +798,13 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -48,17 +48,17 @@ index a8c7ecbd7191fcdb2e012cafcf7a0ac63db75055..d59cab4f6a243d9f2448cc7b396d7a4c blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper if (this.isRainingAt(blockposition)) { DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition); -@@ -832,7 +839,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - +@@ -838,7 +845,7 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.popPush("iceandsnow"); + int l; + - if (!this.paperConfig().environment.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow + if (!this.paperConfig().environment.disableIceAndSnow && (top.leavesmc.leaves.LeavesConfig.optimizeChunkTicking ? (this.currentIceAndSnowTick++ & 15) == 0 : this.random.nextInt(16) == 0)) { // Paper - Disable ice and snow // Paper - optimise random ticking // Leaves - optimize further random ticking // Paper start - optimise chunk ticking this.getRandomBlockPosition(j, 0, k, 15, blockposition); int normalY = chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, blockposition.getX() & 15, blockposition.getZ() & 15) + 1; 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 5e54cf312160e537d2fe6e6fedc618160359330e..c75ddded71d32bc8e9d219a8acc52482f776c526 100644 +index 28e4b302284f955a73e75d0f4276d55fb51826f5..1bf1af06fbd6501e98def7997c487c425d6a1623 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -88,6 +88,18 @@ public class LevelChunk extends ChunkAccess { diff --git a/patches/server/0029-Skip-POI-finding-if-stuck-in-vehicle.patch b/patches/server/0029-Skip-POI-finding-if-stuck-in-vehicle.patch index 2d143057..d2f2c2b3 100644 --- a/patches/server/0029-Skip-POI-finding-if-stuck-in-vehicle.patch +++ b/patches/server/0029-Skip-POI-finding-if-stuck-in-vehicle.patch @@ -6,17 +6,21 @@ Subject: [PATCH] Skip POI finding if stuck in vehicle This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index 43243537b765a2d270be6de3f053fea77ff67d18..7d8a137068ab2b33690c369f4da46e90b5f98e2e 100644 +index d4c91e0a0c64fcb7f1145de3f30134cb1f1f8ee6..44fc394dbab7e05a3bd7cab493300a964a6c46a5 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -72,6 +72,7 @@ public class AcquirePoi extends Behavior { - @Override - protected void start(ServerLevel world, PathfinderMob entity, long time) { - this.nextScheduledStart = time + 20L + (long)world.getRandom().nextInt(20); -+ if (top.leavesmc.leaves.LeavesConfig.skipPOIFindingInVehicle && entity.getNavigation().isStuck()) this.nextScheduledStart += 200L; // Leaves - wait an additional 10s to check again if they're stuck - PoiManager poiManager = world.getPoiManager(); - this.batchCache.long2ObjectEntrySet().removeIf((entry) -> { - return !entry.getValue().isStillValid(time); +@@ -47,6 +47,11 @@ public class AcquirePoi { + return false; + } else { + mutableLong.setValue(time + 20L + (long)world.getRandom().nextInt(20)); ++ // Leaves start - wait an additional 10s to check again if they're stuck ++ if (top.leavesmc.leaves.LeavesConfig.skipPOIFindingInVehicle && entity.getNavigation().isStuck()) { ++ mutableLong.add(200L); ++ } ++ // Leaves end - wait an additional 10s to check again if they're stuck + PoiManager poiManager = world.getPoiManager(); + long2ObjectMap.long2ObjectEntrySet().removeIf((entry) -> { + return !entry.getValue().isStillValid(time); diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java index 3647b4fe0d875af39bf55c5f8bf1bd9cf08709a8..179cb93d9dc77bcfef6a8d6bc73a3290483a67f5 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java diff --git a/patches/server/0031-Use-thread-unsafe-random-for-mob-spawning.patch b/patches/server/0031-Use-thread-unsafe-random-for-mob-spawning.patch index f441f0b1..0a5c7a29 100644 --- a/patches/server/0031-Use-thread-unsafe-random-for-mob-spawning.patch +++ b/patches/server/0031-Use-thread-unsafe-random-for-mob-spawning.patch @@ -6,10 +6,10 @@ 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 df83b6f0e217eec4c9e9707be0030c129fdeb545..e41e87258da5594c5ec164d76bb59bb327c1d94a 100644 +index 01b21f520ef1c834b9bafc3de85c1fa4fcf539d6..1a239af1c3fc254927979752d2ee18e780d17dab 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -417,12 +417,21 @@ public final class NaturalSpawner { +@@ -419,12 +419,21 @@ public final class NaturalSpawner { private static BlockPos getRandomPosWithin(Level world, LevelChunk chunk) { ChunkPos chunkcoordintpair = chunk.getPos(); diff --git a/patches/server/0032-Config-to-disable-method-profiler.patch b/patches/server/0032-Config-to-disable-method-profiler.patch index 41e31656..0877bf51 100644 --- a/patches/server/0032-Config-to-disable-method-profiler.patch +++ b/patches/server/0032-Config-to-disable-method-profiler.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Config to disable method profiler This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3d78ecf4a28b18af11b5ca46e10b4dae503063a3..1fab2e3a2206a897338c9b18f81f2de8c14e626b 100644 +index 81699351c4f9aa3a66270bcee060a504263cbed4..f834a809431ca3667be0c74d8fcbe9db46cbda22 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2240,6 +2240,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop attributes = Maps.newHashMap(); private final Set dirtyAttributes = Sets.newHashSet(); private final AttributeSupplier supplier; @@ -34,7 +34,7 @@ index c770ee21b7b699522941f6a1584d532001c04082..a0672f21797ff90e8bb6b16d3aaa671b } private void onAttributeModified(AttributeInstance instance) { -@@ -46,9 +48,15 @@ public class AttributeMap { +@@ -47,9 +49,15 @@ public class AttributeMap { @Nullable public AttributeInstance getInstance(Attribute attribute) { @@ -52,7 +52,7 @@ index c770ee21b7b699522941f6a1584d532001c04082..a0672f21797ff90e8bb6b16d3aaa671b + // Leaves end - cache lambda, as for some reason java allocates it anyways } - public boolean hasAttribute(Attribute attribute) { + @Nullable diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java index 0bba3458e6fc75a9d542691054cc255a521496c6..a557ea7adbb82dfff5c383b1d9acb8e0487fd4e9 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java diff --git a/patches/server/0036-Remove-lambda-from-ticking-guard.patch b/patches/server/0036-Remove-lambda-from-ticking-guard.patch index 4302f47a..c45ca9be 100644 --- a/patches/server/0036-Remove-lambda-from-ticking-guard.patch +++ b/patches/server/0036-Remove-lambda-from-ticking-guard.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Remove lambda from ticking guard 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 d59cab4f6a243d9f2448cc7b396d7a4cf9378684..3fa46ef92fc7be51e61361b1918162c563022094 100644 +index 1f3d26bdcd4c949d2cb57ac6313b3936fdcfb1e6..0f622e9efeb2a53fa0b73b74d1b410708b9c3269 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -728,7 +728,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -730,7 +730,24 @@ public class ServerLevel extends Level implements WorldGenLevel { } gameprofilerfiller.push("tick"); diff --git a/patches/server/0037-Remove-iterators-from-inventory-contains.patch b/patches/server/0037-Remove-iterators-from-inventory-contains.patch index a5be7887..c2d17781 100644 --- a/patches/server/0037-Remove-iterators-from-inventory-contains.patch +++ b/patches/server/0037-Remove-iterators-from-inventory-contains.patch @@ -6,7 +6,7 @@ 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 a1a625a8dacf4d2bbf75ddd90dce1b1be663c919..038c5fae763c5d387a23aaacc3264ab340588ab4 100644 +index 5bc033bf59d49eda1f8f2574165bbcbeab7faa0f..cf89cbffabf8b88265b5ffbc42b55fe617a32c82 100644 --- a/src/main/java/net/minecraft/world/entity/player/Inventory.java +++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java @@ -681,21 +681,35 @@ public class Inventory implements Container, Nameable { @@ -41,9 +41,9 @@ index a1a625a8dacf4d2bbf75ddd90dce1b1be663c919..038c5fae763c5d387a23aaacc3264ab3 + while (iterator1.hasNext()) { + ItemStack itemstack1 = (ItemStack) iterator1.next(); -- if (!itemstack1.isEmpty() && itemstack1.sameItem(stack)) { +- if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) { - return true; -+ if (!itemstack1.isEmpty() && itemstack1.sameItem(stack)) { ++ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) { + return true; + } } diff --git a/patches/server/0039-Remove-streams-and-iterators-from-range-check.patch b/patches/server/0039-Remove-streams-and-iterators-from-range-check.patch index 3df6bedb..ee5577a8 100644 --- a/patches/server/0039-Remove-streams-and-iterators-from-range-check.patch +++ b/patches/server/0039-Remove-streams-and-iterators-from-range-check.patch @@ -6,10 +6,10 @@ 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 7179137194040ee29f05227aa67bd5f1ec5b4045..39d0cc12f39c4ec77f32ee123e6b557948f0e303 100644 +index 634cde8069fc5ba467170a597e02da7c6b4e7b80..893475f58f649a40e3962092a3608636c1a996e1 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1619,19 +1619,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1654,19 +1654,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance); } diff --git a/patches/server/0040-Async-Pathfinding.patch b/patches/server/0040-Async-Pathfinding.patch index 1373cd04..855b6d0f 100644 --- a/patches/server/0040-Async-Pathfinding.patch +++ b/patches/server/0040-Async-Pathfinding.patch @@ -6,754 +6,15 @@ Subject: [PATCH] Async Pathfinding This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) But Pufferfish patch was ported downstream from the Petal fork -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index 7d8a137068ab2b33690c369f4da46e90b5f98e2e..5052ac5da62d3094b8f495a2a6825c2bd5a94905 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -93,27 +93,60 @@ public class AcquirePoi extends Behavior { - io.papermc.paper.util.PoiAccess.findNearestPoiPositions(poiManager, this.poiType, predicate, entity.blockPosition(), 48, 48*48, PoiManager.Occupancy.HAS_SPACE, false, 5, poiposes); - Set, BlockPos>> set = new java.util.HashSet<>(poiposes); - // Paper end - optimise POI access -- Path path = findPathToPois(entity, set); -- if (path != null && path.canReach()) { -- BlockPos blockPos = path.getTarget(); -- poiManager.getType(blockPos).ifPresent((holder) -> { -- poiManager.take(this.poiType, (holderx, blockPos2) -> { -- return blockPos2.equals(blockPos); -- }, blockPos, 1); -- entity.getBrain().setMemory(this.memoryToAcquire, GlobalPos.of(world.dimension(), blockPos)); -- this.onPoiAcquisitionEvent.ifPresent((byte_) -> { -- world.broadcastEntityEvent(entity, byte_); -+ // Leaves start - await on path async -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ Path possiblePath = findPathToPois(entity, set); -+ -+ // Leaves - wait on the path to be processed -+ top.leavesmc.leaves.path.AsyncPathProcessor.awaitProcessing(possiblePath, path -> { -+ // Leaves - readd canReach check -+ if (path == null || !path.canReach()) { -+ for(Pair, BlockPos> pair : set) { -+ this.batchCache.computeIfAbsent(pair.getSecond().asLong(), (m) -> { -+ return new AcquirePoi.JitteredLinearRetry(entity.level.random, time); -+ }); -+ } -+ return; -+ } -+ -+ BlockPos blockPos = path.getTarget(); -+ poiManager.getType(blockPos).ifPresent((holder) -> { -+ poiManager.take(this.poiType, (holderx, blockPos2) -> { -+ return blockPos2.equals(blockPos); -+ }, blockPos, 1); -+ entity.getBrain().setMemory(this.memoryToAcquire, GlobalPos.of(world.dimension(), blockPos)); -+ this.onPoiAcquisitionEvent.ifPresent((byte_) -> { -+ world.broadcastEntityEvent(entity, byte_); -+ }); -+ this.batchCache.clear(); -+ DebugPackets.sendPoiTicketCountPacket(world, blockPos); - }); -- this.batchCache.clear(); -- DebugPackets.sendPoiTicketCountPacket(world, blockPos); - }); - } else { -- for(Pair, BlockPos> pair : set) { -- this.batchCache.computeIfAbsent(pair.getSecond().asLong(), (m) -> { -- return new AcquirePoi.JitteredLinearRetry(entity.level.random, time); -+ Path path = findPathToPois(entity, set); -+ if (path != null && path.canReach()) { -+ BlockPos blockPos = path.getTarget(); -+ poiManager.getType(blockPos).ifPresent((holder) -> { -+ poiManager.take(this.poiType, (holderx, blockPos2) -> { -+ return blockPos2.equals(blockPos); -+ }, blockPos, 1); -+ entity.getBrain().setMemory(this.memoryToAcquire, GlobalPos.of(world.dimension(), blockPos)); -+ this.onPoiAcquisitionEvent.ifPresent((byte_) -> { -+ world.broadcastEntityEvent(entity, byte_); -+ }); -+ this.batchCache.clear(); -+ DebugPackets.sendPoiTicketCountPacket(world, blockPos); - }); -+ } else { -+ for(Pair, BlockPos> pair : set) { -+ this.batchCache.computeIfAbsent(pair.getSecond().asLong(), (m) -> { -+ return new AcquirePoi.JitteredLinearRetry(entity.level.random, time); -+ }); -+ } - } - } -+ -+ // Leaves end - await on path async - - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java -index 18364ce4c60172529b10bc9e3a813dcedc4b766f..c6fffe29c488126aa9f4ffdba13bc5dabd8148eb 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java -@@ -21,6 +21,7 @@ public class MoveToTargetSink extends Behavior { - private int remainingCooldown; - @Nullable - private Path path; -+ private boolean finishedProcessing; // Leaves - @Nullable - private BlockPos lastTargetPos; - private float speedModifier; -@@ -42,9 +43,10 @@ public class MoveToTargetSink extends Behavior { - Brain brain = entity.getBrain(); - WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); - boolean bl = this.reachedTarget(entity, walkTarget); -- if (!bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { -+ if (!bl && (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding && this.tryComputePath(entity, walkTarget, world.getGameTime()))) { // Leaves - this.lastTargetPos = walkTarget.getTarget().currentBlockPosition(); - return true; -+ } else if (!bl) { return true; // Leaves - } else { - brain.eraseMemory(MemoryModuleType.WALK_TARGET); - if (bl) { -@@ -58,6 +60,7 @@ public class MoveToTargetSink extends Behavior { - - @Override - protected boolean canStillUse(ServerLevel serverLevel, Mob mob, long l) { -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding && !finishedProcessing) return true; // Leaves - wait for path to process - if (this.path != null && this.lastTargetPos != null) { - Optional optional = mob.getBrain().getMemory(MemoryModuleType.WALK_TARGET); - PathNavigation pathNavigation = mob.getNavigation(); -@@ -81,28 +84,96 @@ public class MoveToTargetSink extends Behavior { - - @Override - protected void start(ServerLevel serverLevel, Mob mob, long l) { -+ if (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { // Leaves - mob.getBrain().setMemory(MemoryModuleType.PATH, this.path); - mob.getNavigation().moveTo(this.path, (double)this.speedModifier); -+ // Leaves start -+ } else { -+ Brain brain = mob.getBrain(); -+ WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); -+ -+ this.finishedProcessing = false; -+ this.lastTargetPos = walkTarget.getTarget().currentBlockPosition(); -+ this.path = this.computePath(mob, walkTarget); -+ } -+ // Leaves end - } - - @Override - protected void tick(ServerLevel world, Mob entity, long time) { -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding && this.path != null && !this.path.isProcessed()) return; // Leaves - wait for processing -+ -+ // Leaves start -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding && !finishedProcessing) { -+ this.finishedProcessing = true; -+ Brain brain = entity.getBrain(); -+ boolean canReach = this.path != null && this.path.canReach(); -+ if (canReach) { -+ brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); -+ } else if (brain.hasMemoryValue(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)) { -+ brain.setMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, time); -+ } -+ -+ if (!canReach) { -+ Optional walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET); -+ -+ if (walkTarget.isPresent()) { -+ BlockPos blockPos = walkTarget.get().getTarget().currentBlockPosition(); -+ Vec3 vec3 = DefaultRandomPos.getPosTowards((PathfinderMob)entity, 10, 7, Vec3.atBottomCenterOf(blockPos), (double)((float)Math.PI / 2F)); -+ if (vec3 != null) { -+ // try recalculating the path using a random position -+ this.path = entity.getNavigation().createPath(vec3.x, vec3.y, vec3.z, 0); -+ this.finishedProcessing = false; -+ return; -+ } -+ } -+ -+ brain.eraseMemory(MemoryModuleType.WALK_TARGET); -+ this.path = null; -+ -+ return; -+ } -+ -+ entity.getBrain().setMemory(MemoryModuleType.PATH, this.path); -+ entity.getNavigation().moveTo(this.path, (double)this.speedModifier); -+ } -+ // Leaves end -+ - Path path = entity.getNavigation().getPath(); - Brain brain = entity.getBrain(); -- if (this.path != path) { -+ if (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding && this.path != path) { // Leaves - this.path = path; - brain.setMemory(MemoryModuleType.PATH, path); - } - -- if (path != null && this.lastTargetPos != null) { -+ if (path != null && this.lastTargetPos != null && (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding || brain.hasMemoryValue(MemoryModuleType.WALK_TARGET))) { // Leaves - WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); -+ if (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { // Leaves - if (walkTarget.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0D && this.tryComputePath(entity, walkTarget, world.getGameTime())) { - this.lastTargetPos = walkTarget.getTarget().currentBlockPosition(); - this.start(world, entity, time); - } -+ // Leaves start -+ } else { -+ if (walkTarget.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0D) this.start(world, entity, time); -+ } -+ // Leaves end -+ -+ } -+ } - -+ // Leaves start -+ private Path computePath(Mob entity, WalkTarget walkTarget) { -+ BlockPos blockPos = walkTarget.getTarget().currentBlockPosition(); -+ this.speedModifier = walkTarget.getSpeedModifier(); -+ Brain brain = entity.getBrain(); -+ if (this.reachedTarget(entity, walkTarget)) { -+ brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); - } -+ -+ return entity.getNavigation().createPath(blockPos, 0); - } -+ // Leaves end - - private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) { - BlockPos blockPos = walkTarget.getTarget().currentBlockPosition(); -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java -index 9bd6d4f7b86daaaa9cfbad454dde06b797e3f667..7b0e66fcecfc18c77146fcc75e7977cdb8810226 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java -@@ -71,19 +71,41 @@ public class SetClosestHomeAsWalkTarget extends Behavior { - Set, BlockPos>> set = poiManager.findAllWithType((poiType) -> { - return poiType.is(PoiTypes.HOME); - }, predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY).collect(Collectors.toSet()); -- Path path = AcquirePoi.findPathToPois(pathfinderMob, set); -- if (path != null && path.canReach()) { -- BlockPos blockPos = path.getTarget(); -- Optional> optional = poiManager.getType(blockPos); -- if (optional.isPresent()) { -- entity.getBrain().setMemory(MemoryModuleType.WALK_TARGET, new WalkTarget(blockPos, this.speedModifier, 1)); -- DebugPackets.sendPoiTicketCountPacket(world, blockPos); -- } -- } else if (this.triedCount < 5) { -- this.batchCache.long2LongEntrySet().removeIf((entry) -> { -- return entry.getLongValue() < this.lastUpdate; -+ // Leaves start - await on path async -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ Path possiblePath = AcquirePoi.findPathToPois(pathfinderMob, set); -+ -+ // Leaves - wait on the path to be processed -+ top.leavesmc.leaves.path.AsyncPathProcessor.awaitProcessing(possiblePath, path -> { -+ if (path == null || !path.canReach() || this.triedCount < 5) { // Leaves - readd canReach check -+ this.batchCache.long2LongEntrySet().removeIf((entry) -> { -+ return entry.getLongValue() < this.lastUpdate; -+ }); -+ return; -+ } -+ -+ BlockPos blockPos = path.getTarget(); -+ Optional> optional = poiManager.getType(blockPos); -+ if (optional.isPresent()) { -+ entity.getBrain().setMemory(MemoryModuleType.WALK_TARGET, new WalkTarget(blockPos, this.speedModifier, 1)); -+ DebugPackets.sendPoiTicketCountPacket(world, blockPos); -+ } - }); -+ } else { -+ Path path = AcquirePoi.findPathToPois(pathfinderMob, set); -+ if (path != null && path.canReach()) { -+ BlockPos blockPos = path.getTarget(); -+ Optional> optional = poiManager.getType(blockPos); -+ if (optional.isPresent()) { -+ entity.getBrain().setMemory(MemoryModuleType.WALK_TARGET, new WalkTarget(blockPos, this.speedModifier, 1)); -+ DebugPackets.sendPoiTicketCountPacket(world, blockPos); -+ } -+ } else if (this.triedCount < 5) { -+ this.batchCache.long2LongEntrySet().removeIf((entry) -> { -+ return entry.getLongValue() < this.lastUpdate; -+ }); -+ } - } -- -+ // Leaves end - await on path async - } - } -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java -index 29a872393f2f995b13b4ed26b42c6464ab27ca73..a60195bbe6c59bca707ef202c5ee49b6dbf32704 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java -@@ -8,6 +8,14 @@ import net.minecraft.world.level.pathfinder.PathFinder; - import net.minecraft.world.phys.Vec3; - - public class AmphibiousPathNavigation extends PathNavigation { -+ // Leaves start -+ private static final top.leavesmc.leaves.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = () -> { -+ var nodeEvaluator = new AmphibiousNodeEvaluator(false); -+ nodeEvaluator.setCanPassDoors(true); -+ return nodeEvaluator; -+ }; -+ // Leaves end -+ - public AmphibiousPathNavigation(Mob mob, Level world) { - super(mob, world); - } -@@ -16,7 +24,13 @@ public class AmphibiousPathNavigation extends PathNavigation { - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new AmphibiousNodeEvaluator(false); - this.nodeEvaluator.setCanPassDoors(true); -- return new PathFinder(this.nodeEvaluator, range); -+ // Leaves start -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); -+ } else { -+ return new PathFinder(this.nodeEvaluator, range); -+ } -+ // Leaves end - } - - @Override -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java -index 27cd393e81f6ef9b5690c051624d8d2af50acd34..87f5fd2c616fbb4e0a3c2f9af49f8c0a866fbc86 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java -@@ -12,6 +12,15 @@ import net.minecraft.world.level.pathfinder.PathFinder; - import net.minecraft.world.phys.Vec3; - - public class FlyingPathNavigation extends PathNavigation { -+ -+ // Leaves start -+ private static final top.leavesmc.leaves.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = () -> { -+ var nodeEvaluator = new FlyNodeEvaluator(); -+ nodeEvaluator.setCanPassDoors(true); -+ return nodeEvaluator; -+ }; -+ // Leaves end -+ - public FlyingPathNavigation(Mob entity, Level world) { - super(entity, world); - } -@@ -20,7 +29,13 @@ public class FlyingPathNavigation extends PathNavigation { - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new FlyNodeEvaluator(); - this.nodeEvaluator.setCanPassDoors(true); -- return new PathFinder(this.nodeEvaluator, range); -+ // Leaves start -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); -+ } else { -+ return new PathFinder(this.nodeEvaluator, range); -+ } -+ // Leaves end - } - - @Override -@@ -45,9 +60,11 @@ public class FlyingPathNavigation extends PathNavigation { - this.recomputePath(); - } - -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding && this.path != null && !this.path.isProcessed()) return; // Leaves -+ - if (!this.isDone()) { - if (this.canUpdatePath()) { -- this.followThePath(); -+ this.followThePathSuper(); // Leaves - } else if (this.path != null && !this.path.isDone()) { - Vec3 vec3 = this.path.getNextEntityPos(this.mob); - if (this.mob.getBlockX() == Mth.floor(vec3.x) && this.mob.getBlockY() == Mth.floor(vec3.y) && this.mob.getBlockZ() == Mth.floor(vec3.z)) { -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -index f0248d839255763005ba333b0bfcf691407fb69b..9b1ef3c365d1523ec5dafa6f57b56d7d0f0a0e8a 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -@@ -15,6 +15,15 @@ import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; - import net.minecraft.world.phys.Vec3; - - public class GroundPathNavigation extends PathNavigation { -+ -+ // Leaves start -+ private static final top.leavesmc.leaves.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = () -> { -+ var nodeEvaluator = new WalkNodeEvaluator(); -+ nodeEvaluator.setCanPassDoors(true); -+ return nodeEvaluator; -+ }; -+ // Leaves end -+ - private boolean avoidSun; - - public GroundPathNavigation(Mob entity, Level world) { -@@ -25,7 +34,13 @@ public class GroundPathNavigation extends PathNavigation { - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new WalkNodeEvaluator(); - this.nodeEvaluator.setCanPassDoors(true); -- return new PathFinder(this.nodeEvaluator, range); -+ // Leaves start -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); -+ } else { -+ return new PathFinder(this.nodeEvaluator, range); -+ } -+ // Leaves end - } - - @Override -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index c1781c92ff59f0c9eb47cbbef01e3252c5e1a1bf..6faf6154dcbad4b9c30168612f603fdab6560454 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -150,6 +150,9 @@ public abstract class PathNavigation { - return null; - } else if (!this.canUpdatePath()) { - return null; -+ } else if (this.path instanceof top.leavesmc.leaves.path.AsyncPath asyncPath && !asyncPath.isProcessed() && asyncPath.hasSameProcessingPositions(positions)) { // Leaves start - catch early if it's still processing these positions let it keep processing -+ return this.path; -+ // Leaves end - } else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) { - return this.path; - } else { -@@ -176,11 +179,28 @@ public abstract class PathNavigation { - PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i)); - Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier); - this.level.getProfiler().pop(); -- if (path != null && path.getTarget() != null) { -+ -+ // Leaves start -+ if (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ if (path != null && path.getTarget() != null) { - this.targetPos = path.getTarget(); - this.reachRange = distance; - this.resetStuckTimeout(); -+ } -+ } else { -+ if (!positions.isEmpty()) this.targetPos = positions.iterator().next(); // Leaves - assign early a target position. most calls will only have 1 position -+ -+ top.leavesmc.leaves.path.AsyncPathProcessor.awaitProcessing(path, processedPath -> { -+ if (processedPath != this.path) return; // Leaves - check that processing didn't take so long that we calculated a new path -+ -+ if (processedPath != null && processedPath.getTarget() != null) { -+ this.targetPos = processedPath.getTarget(); -+ this.reachRange = distance; -+ this.resetStuckTimeout(); -+ } -+ }); - } -+ // Leaves end - - return path; - } -@@ -227,8 +247,8 @@ public abstract class PathNavigation { - if (this.isDone()) { - return false; - } else { -- this.trimPath(); -- if (this.path.getNodeCount() <= 0) { -+ if (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding || path.isProcessed()) this.trimPath(); // Leaves - only trim if processed -+ if ((!top.leavesmc.leaves.LeavesConfig.asyncPathfinding || path.isProcessed()) && this.path.getNodeCount() <= 0) { // Leaves - only check node count if processed - return false; - } else { - this.speedModifier = speed; -@@ -252,9 +272,11 @@ public abstract class PathNavigation { - this.recomputePath(); - } - -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding && this.path != null && !this.path.isProcessed()) return; // Leaves - skip pathfinding if we're still processing -+ - if (!this.isDone()) { - if (this.canUpdatePath()) { -- this.followThePath(); -+ this.followThePathSuper(); // Leaves - } else if (this.path != null && !this.path.isDone()) { - Vec3 vec3 = this.getTempMobPos(); - Vec3 vec32 = this.path.getNextEntityPos(this.mob); -@@ -276,6 +298,13 @@ public abstract class PathNavigation { - return this.level.getBlockState(blockPos.below()).isAir() ? pos.y : WalkNodeEvaluator.getFloorLevel(this.level, blockPos); - } - -+ // Leaves start - this fixes plugin compat by ensuring the isProcessed check is completed properly. -+ protected final void followThePathSuper() { -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding && !this.path.isProcessed()) return; // Leaves -+ followThePath(); -+ } -+ // Leaves end - this fixes plugin compat by ensuring the isProcessed check is completed properly. -+ - protected void followThePath() { - Vec3 vec3 = this.getTempMobPos(); - this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F; -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -index 8db20db72cd51046213625fac46c35854c59ec5d..28040c76ec4216a425e2c6c7216f96a006f10085 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -@@ -57,20 +57,42 @@ public class NearestBedSensor extends Sensor { - java.util.List, BlockPos>> poiposes = new java.util.ArrayList<>(); - // don't ask me why it's unbounded. ask mojang. - io.papermc.paper.util.PoiAccess.findAnyPoiPositions(poiManager, type -> type.is(PoiTypes.HOME), predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY, false, Integer.MAX_VALUE, poiposes); -- Path path = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes)); -- // Paper end - optimise POI access -- if (path != null && path.canReach()) { -- BlockPos blockPos = path.getTarget(); -- Optional> optional = poiManager.getType(blockPos); -- if (optional.isPresent()) { -- entity.getBrain().setMemory(MemoryModuleType.NEAREST_BED, blockPos); -- } -- } else if (this.triedCount < 5) { -- this.batchCache.long2LongEntrySet().removeIf((entry) -> { -- return entry.getLongValue() < this.lastUpdate; -+ -+ // Leaves start - await on path async -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ Path possiblePath = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes)); -+ // Paper end - optimise POI access -+ // Leaves - wait on the path to be processed -+ top.leavesmc.leaves.path.AsyncPathProcessor.awaitProcessing(possiblePath, path -> { -+ // Leaves - readd canReach check -+ if (path == null || !path.canReach()) { -+ this.batchCache.long2LongEntrySet().removeIf((entry) -> { -+ return entry.getLongValue() < this.lastUpdate; -+ }); -+ return; -+ } -+ -+ BlockPos blockPos = path.getTarget(); -+ Optional> optional = poiManager.getType(blockPos); -+ if (optional.isPresent()) { -+ entity.getBrain().setMemory(MemoryModuleType.NEAREST_BED, blockPos); -+ } - }); -+ } else { -+ Path path = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes)); -+ if (path != null && path.canReach()) { -+ BlockPos blockPos = path.getTarget(); -+ Optional> optional = poiManager.getType(blockPos); -+ if (optional.isPresent()) { -+ entity.getBrain().setMemory(MemoryModuleType.NEAREST_BED, blockPos); -+ } -+ } else if (this.triedCount < 5) { -+ this.batchCache.long2LongEntrySet().removeIf((entry) -> { -+ return entry.getLongValue() < this.lastUpdate; -+ }); -+ } - } -- -+ // Leaves end - await on path async - } - } - } -diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java -index a9cdf9034ad269f7a71358443acc053288cfbe6d..de28757a247b2c1e6d78aa2989db50d2137f4a57 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Bee.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java -@@ -1071,7 +1071,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { - } else { - Bee.this.pathfindRandomlyTowards(Bee.this.hivePos); - } -- } else { -+ } else if (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding || (navigation.getPath() != null && navigation.getPath().isProcessed())) { // Leaves - check processing - boolean flag = this.pathfindDirectlyTowards(Bee.this.hivePos); - - if (!flag) { -@@ -1133,7 +1133,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { - } else { - Path pathentity = Bee.this.navigation.getPath(); - -- return pathentity != null && pathentity.getTarget().equals(pos) && pathentity.canReach() && pathentity.isDone(); -+ return pathentity != null && (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding || pathentity.isProcessed()) && pathentity.getTarget().equals(pos) && pathentity.canReach() && pathentity.isDone(); // Leaves - ensure path is processed - } - } - } -diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -index bb6063ae7f4438916306ce876057f7488537b444..a6dac57da497586d5dada1a03ad96c7b815494e7 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -@@ -411,6 +411,14 @@ public class Frog extends Animal { - } - - static class FrogPathNavigation extends AmphibiousPathNavigation { -+ // Leaves start -+ private static final top.leavesmc.leaves.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = () -> { -+ var nodeEvaluator = new Frog.FrogNodeEvaluator(true); -+ nodeEvaluator.setCanPassDoors(true); -+ return nodeEvaluator; -+ }; -+ // Leaves end -+ - FrogPathNavigation(Frog frog, Level world) { - super(frog, world); - } -@@ -419,7 +427,13 @@ public class Frog extends Animal { - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new Frog.FrogNodeEvaluator(true); - this.nodeEvaluator.setCanPassDoors(true); -- return new PathFinder(this.nodeEvaluator, range); -+ // Leaves start -+ if (top.leavesmc.leaves.LeavesConfig.asyncPathfinding) { -+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); -+ } else { -+ return new PathFinder(this.nodeEvaluator, range); -+ } -+ // Leaves end - } - } - } -diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java -index 1b1305f5eaf5710b72c57ab4c3953e703a23f1e0..b62adaa514dc47fed866655b8f7046b0657cba73 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java -@@ -222,7 +222,7 @@ public class Drowned extends Zombie implements RangedAttackMob { - protected boolean closeToNextPos() { - Path pathentity = this.getNavigation().getPath(); - -- if (pathentity != null) { -+ if (pathentity != null && (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding || pathentity.isProcessed())) { // Leaves - ensure path is processed - BlockPos blockposition = pathentity.getTarget(); - - if (blockposition != null) { -diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java -index 2a335f277bd0e4b8ad0f60d8226eb8aaa80a871f..c765c6bdf6fe07495fe0a17d6a5494a72875af18 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/Path.java -@@ -30,6 +30,17 @@ public class Path { - this.reached = reachesTarget; - } - -+ // Leaves start -+ /** -+ * checks if the path is completely processed in the case of it being computed async -+ * -+ * @return true if the path is processed -+ */ -+ public boolean isProcessed() { -+ return true; -+ } -+ // Leaves end -+ - public void advance() { - ++this.nextNodeIndex; - } -@@ -104,6 +115,8 @@ public class Path { - } - - public boolean sameAs(@Nullable Path o) { -+ if (o == this) return true; // Leaves - short circuit -+ - if (o == null) { - return false; - } else if (o.nodes.size() != this.nodes.size()) { -diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -index d23481453717f715124156b5d83f6448f720d049..6cc6140f44827ccc055aafdd6bfb3a09d3cdacb4 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -25,36 +25,75 @@ public class PathFinder { - private static final boolean DEBUG = false; - private final BinaryHeap openSet = new BinaryHeap(); - -- public PathFinder(NodeEvaluator pathNodeMaker, int range) { -+ private final @Nullable top.leavesmc.leaves.path.NodeEvaluatorGenerator nodeEvaluatorGenerator; // Leaves - we use this later to generate an evaluator -+ -+ // Leaves start - add nodeEvaluatorGenerator as optional param -+ public PathFinder(NodeEvaluator pathNodeMaker, int range, @Nullable top.leavesmc.leaves.path.NodeEvaluatorGenerator nodeEvaluatorGenerator) { - this.nodeEvaluator = pathNodeMaker; - this.maxVisitedNodes = range; -+ this.nodeEvaluatorGenerator = nodeEvaluatorGenerator; -+ } -+ -+ public PathFinder(NodeEvaluator pathNodeMaker, int range) { -+ this(pathNodeMaker, range, null); - } -+ // Leaves end - add nodeEvaluatorGenerator as optional param - - @Nullable - public Path findPath(PathNavigationRegion world, Mob mob, Set positions, float followRange, int distance, float rangeMultiplier) { -- this.openSet.clear(); -- this.nodeEvaluator.prepare(world, mob); -- Node node = this.nodeEvaluator.getStart(); -+ if (!top.leavesmc.leaves.LeavesConfig.asyncPathfinding) this.openSet.clear(); // Leaves - it's always cleared in processPath -+ // Leaves start - use a generated evaluator if we have one otherwise run sync -+ var nodeEvaluator = this.nodeEvaluatorGenerator == null ? this.nodeEvaluator : top.leavesmc.leaves.path.NodeEvaluatorCache.takeNodeEvaluator(this.nodeEvaluatorGenerator); -+ nodeEvaluator.prepare(world, mob); -+ Node node = nodeEvaluator.getStart(); - if (node == null) { -+ top.leavesmc.leaves.path.NodeEvaluatorCache.removeNodeEvaluator(nodeEvaluator); - return null; - } else { - // Paper start - remove streams - and optimize collection - List> map = Lists.newArrayList(); - for (BlockPos pos : positions) { -- map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos)); -+ map.add(new java.util.AbstractMap.SimpleEntry<>(nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos)); - } - // Paper end -- Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier); -- this.nodeEvaluator.done(); -- return path; -+ -+ // Leaves start -+ if (this.nodeEvaluatorGenerator == null) { -+ // run sync :( -+ top.leavesmc.leaves.path.NodeEvaluatorCache.removeNodeEvaluator(nodeEvaluator); -+ return this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier); -+ } -+ -+ return new top.leavesmc.leaves.path.AsyncPath(Lists.newArrayList(), positions, () -> { -+ try { -+ return this.processPath(nodeEvaluator, node, map, followRange, distance, rangeMultiplier); -+ } finally { -+ nodeEvaluator.done(); -+ top.leavesmc.leaves.path.NodeEvaluatorCache.returnNodeEvaluator(nodeEvaluator); -+ } -+ }); -+ // Leaves end - use a generated evaluator if we have one otherwise run sync - } - } - -- @Nullable -+ // Leaves start - split pathfinding into the original sync method for compat and processing for delaying - // Paper start - optimize collection - private Path findPath(ProfilerFiller profiler, Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { -+ // readd the profiler code for sync - profiler.push("find_path"); - profiler.markForCharting(MetricCategory.PATH_FINDING); -+ -+ try { -+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier); -+ } finally { -+ this.nodeEvaluator.done(); -+ } -+ } -+ // Leaves end - split pathfinding into the original sync method for compat and processing for delaying -+ -+ private synchronized @org.jetbrains.annotations.NotNull Path processPath(NodeEvaluator nodeEvaluator, Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { // Leaves - sync to only use the caching functions in this class on a single thread -+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty()); // ensure that we have at least one position, which means we'll always return a path -+ - // Set set = positions.keySet(); - startNode.g = 0.0F; - startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection -@@ -91,7 +130,7 @@ public class PathFinder { - } - - if (!(node.distanceTo(startNode) >= followRange)) { -- int k = this.nodeEvaluator.getNeighbors(this.neighbors, node); -+ int k = nodeEvaluator.getNeighbors(this.neighbors, node); - - for(int l = 0; l < k; ++l) { - Node node2 = this.neighbors[l]; -@@ -123,9 +162,14 @@ public class PathFinder { - if (best == null || comparator.compare(path, best) < 0) - best = path; - } -+ -+ // Leaves start - ignore this warning, we know that the above loop always runs at least once since positions is not empty -+ //noinspection ConstantConditions - return best; - // Paper end -+ // Leaves end - ignore this warning, we know that the above loop always runs at least once since positions is not empty - } -+ // Leaves end - - protected float distance(Node a, Node b) { - return a.distanceTo(b); diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 6924ca89da0decc8f861842b770d0cfae7fc0ba1..84bbe8d232be70c87e460b5ef28fca1b7d17f32d 100644 +index 6924ca89da0decc8f861842b770d0cfae7fc0ba1..92f27779e8fdf827c2305c4531f478f2b179ecb9 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -340,6 +340,20 @@ public final class LeavesConfig { +@@ -340,6 +340,21 @@ public final class LeavesConfig { removeRangeCheckStreams = getBoolean("settings.performance.remove.range-check-streams-and-iterators", removeRangeCheckStreams); } ++ // only config now + public static boolean asyncPathfinding = false; + private static boolean asyncPathfindingLock = false; + private static void asyncPathfinding() { @@ -771,410 +32,3 @@ index 6924ca89da0decc8f861842b770d0cfae7fc0ba1..84bbe8d232be70c87e460b5ef28fca1b public static final class WorldConfig { public final String worldName; -diff --git a/src/main/java/top/leavesmc/leaves/path/AsyncPath.java b/src/main/java/top/leavesmc/leaves/path/AsyncPath.java -new file mode 100644 -index 0000000000000000000000000000000000000000..6f96acc71bc5470e5a32e5695d28c552df6af23c ---- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/path/AsyncPath.java -@@ -0,0 +1,284 @@ -+package top.leavesmc.leaves.path; -+ -+import net.minecraft.core.BlockPos; -+import net.minecraft.world.entity.Entity; -+import net.minecraft.world.level.pathfinder.Node; -+import net.minecraft.world.level.pathfinder.Path; -+import net.minecraft.world.phys.Vec3; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.ArrayList; -+import java.util.List; -+import java.util.Set; -+import java.util.function.Supplier; -+ -+// Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) -+ -+/** -+ * i'll be using this to represent a path that not be processed yet! -+ */ -+public class AsyncPath extends Path { -+ -+ /** -+ * marks whether this async path has been processed -+ */ -+ private volatile boolean processed = false; -+ -+ /** -+ * runnables waiting for path to be processed -+ */ -+ private final @NotNull List postProcessing = new ArrayList<>(); -+ -+ /** -+ * a list of positions that this path could path towards -+ */ -+ private final Set positions; -+ -+ /** -+ * the supplier of the real processed path -+ */ -+ private final Supplier pathSupplier; -+ -+ /* -+ * Processed values -+ */ -+ -+ /** -+ * this is a reference to the nodes list in the parent `Path` object -+ */ -+ private final List nodes; -+ /** -+ * the block we're trying to path to -+ *

-+ * while processing, we have no idea where this is so consumers of `Path` should check that the path is processed before checking the target block -+ */ -+ private @Nullable BlockPos target; -+ /** -+ * how far we are to the target -+ *

-+ * while processing, the target could be anywhere but theoretically we're always "close" to a theoretical target so default is 0 -+ */ -+ private float distToTarget = 0; -+ /** -+ * whether we can reach the target -+ *

-+ * while processing we can always theoretically reach the target so default is true -+ */ -+ private boolean canReach = true; -+ -+ public AsyncPath(@NotNull List emptyNodeList, @NotNull Set positions, @NotNull Supplier pathSupplier) { -+ //noinspection ConstantConditions -+ super(emptyNodeList, null, false); -+ -+ this.nodes = emptyNodeList; -+ this.positions = positions; -+ this.pathSupplier = pathSupplier; -+ -+ AsyncPathProcessor.queue(this); -+ } -+ -+ @Override -+ public boolean isProcessed() { -+ return this.processed; -+ } -+ -+ /** -+ * add a post-processing action -+ */ -+ public synchronized void postProcessing(@NotNull Runnable runnable) { -+ if (processed) runnable.run(); -+ else postProcessing.add(runnable); -+ } -+ -+ /** -+ * an easy way to check if this processing path is the same as an attempted new path -+ * -+ * @param positions - the positions to compare against -+ * @return true if we are processing the same positions -+ */ -+ public boolean hasSameProcessingPositions(final Set positions) { -+ if (this.positions.size() != positions.size()) { -+ return false; -+ } -+ -+ return this.positions.containsAll(positions); -+ } -+ -+ /** -+ * starts processing this path -+ */ -+ public synchronized void process() { -+ if (this.processed) { -+ return; -+ } -+ -+ final Path bestPath = this.pathSupplier.get(); -+ -+ this.nodes.addAll(bestPath.nodes); // we mutate this list to reuse the logic in Path -+ this.target = bestPath.getTarget(); -+ this.distToTarget = bestPath.getDistToTarget(); -+ this.canReach = bestPath.canReach(); -+ -+ this.processed = true; -+ -+ this.postProcessing.forEach(Runnable::run); -+ } -+ -+ /** -+ * if this path is accessed while it hasn't processed, just process it in-place -+ */ -+ private void checkProcessed() { -+ if (!this.processed) { -+ this.process(); -+ } -+ } -+ -+ /* -+ * overrides we need for final fields that we cannot modify after processing -+ */ -+ -+ @Override -+ public @NotNull BlockPos getTarget() { -+ this.checkProcessed(); -+ -+ return this.target; -+ } -+ -+ @Override -+ public float getDistToTarget() { -+ this.checkProcessed(); -+ -+ return this.distToTarget; -+ } -+ -+ @Override -+ public boolean canReach() { -+ this.checkProcessed(); -+ -+ return this.canReach; -+ } -+ -+ /* -+ * overrides to ensure we're processed first -+ */ -+ -+ @Override -+ public boolean isDone() { -+ return this.isProcessed() && super.isDone(); -+ } -+ -+ @Override -+ public void advance() { -+ this.checkProcessed(); -+ -+ super.advance(); -+ } -+ -+ @Override -+ public boolean notStarted() { -+ this.checkProcessed(); -+ -+ return super.notStarted(); -+ } -+ -+ @Nullable -+ @Override -+ public Node getEndNode() { -+ this.checkProcessed(); -+ -+ return super.getEndNode(); -+ } -+ -+ @Override -+ public Node getNode(int index) { -+ this.checkProcessed(); -+ -+ return super.getNode(index); -+ } -+ -+ @Override -+ public void truncateNodes(int length) { -+ this.checkProcessed(); -+ -+ super.truncateNodes(length); -+ } -+ -+ @Override -+ public void replaceNode(int index, Node node) { -+ this.checkProcessed(); -+ -+ super.replaceNode(index, node); -+ } -+ -+ @Override -+ public int getNodeCount() { -+ this.checkProcessed(); -+ -+ return super.getNodeCount(); -+ } -+ -+ @Override -+ public int getNextNodeIndex() { -+ this.checkProcessed(); -+ -+ return super.getNextNodeIndex(); -+ } -+ -+ @Override -+ public void setNextNodeIndex(int nodeIndex) { -+ this.checkProcessed(); -+ -+ super.setNextNodeIndex(nodeIndex); -+ } -+ -+ @Override -+ public Vec3 getEntityPosAtNode(Entity entity, int index) { -+ this.checkProcessed(); -+ -+ return super.getEntityPosAtNode(entity, index); -+ } -+ -+ @Override -+ public BlockPos getNodePos(int index) { -+ this.checkProcessed(); -+ -+ return super.getNodePos(index); -+ } -+ -+ @Override -+ public Vec3 getNextEntityPos(Entity entity) { -+ this.checkProcessed(); -+ -+ return super.getNextEntityPos(entity); -+ } -+ -+ @Override -+ public BlockPos getNextNodePos() { -+ this.checkProcessed(); -+ -+ return super.getNextNodePos(); -+ } -+ -+ @Override -+ public Node getNextNode() { -+ this.checkProcessed(); -+ -+ return super.getNextNode(); -+ } -+ -+ @Nullable -+ @Override -+ public Node getPreviousNode() { -+ this.checkProcessed(); -+ -+ return super.getPreviousNode(); -+ } -+ -+ @Override -+ public boolean hasNext() { -+ this.checkProcessed(); -+ -+ return super.hasNext(); -+ } -+} -diff --git a/src/main/java/top/leavesmc/leaves/path/AsyncPathProcessor.java b/src/main/java/top/leavesmc/leaves/path/AsyncPathProcessor.java -new file mode 100644 -index 0000000000000000000000000000000000000000..9aa66b327dbbb8624d473e1d9cb6eaab95ecb2dc ---- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/path/AsyncPathProcessor.java -@@ -0,0 +1,46 @@ -+package top.leavesmc.leaves.path; -+ -+import com.google.common.util.concurrent.ThreadFactoryBuilder; -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.world.level.pathfinder.Path; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.concurrent.CompletableFuture; -+import java.util.concurrent.Executor; -+import java.util.concurrent.Executors; -+import java.util.function.Consumer; -+ -+// Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) -+ -+/** -+ * used to handle the scheduling of async path processing -+ */ -+public class AsyncPathProcessor { -+ -+ private static final Executor mainThreadExecutor = MinecraftServer.getServer(); -+ private static final Executor pathProcessingExecutor = Executors.newCachedThreadPool(new ThreadFactoryBuilder() -+ .setNameFormat("puff-path-processor-%d") -+ .setPriority(Thread.NORM_PRIORITY - 2) -+ .build()); -+ -+ protected static CompletableFuture queue(@NotNull AsyncPath path) { -+ return CompletableFuture.runAsync(path::process, pathProcessingExecutor); -+ } -+ -+ /** -+ * takes a possibly unprocessed path, and waits until it is completed -+ * the consumer will be immediately invoked if the path is already processed -+ * the consumer will always be called on the main thread -+ * -+ * @param path a path to wait on -+ * @param afterProcessing a consumer to be called -+ */ -+ public static void awaitProcessing(@Nullable Path path, Consumer<@Nullable Path> afterProcessing) { -+ if (path != null && !path.isProcessed() && path instanceof AsyncPath asyncPath) { -+ asyncPath.postProcessing(() -> mainThreadExecutor.execute(() -> afterProcessing.accept(path))); -+ } else { -+ afterProcessing.accept(path); -+ } -+ } -+} -diff --git a/src/main/java/top/leavesmc/leaves/path/NodeEvaluatorCache.java b/src/main/java/top/leavesmc/leaves/path/NodeEvaluatorCache.java -new file mode 100644 -index 0000000000000000000000000000000000000000..a8d46e5a234d328e8d934f5c33ac380d82c1e09b ---- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/path/NodeEvaluatorCache.java -@@ -0,0 +1,44 @@ -+package top.leavesmc.leaves.path; -+ -+import net.minecraft.world.level.pathfinder.NodeEvaluator; -+import org.apache.commons.lang.Validate; -+import org.jetbrains.annotations.NotNull; -+ -+import java.util.Map; -+import java.util.Queue; -+import java.util.concurrent.ConcurrentHashMap; -+import java.util.concurrent.ConcurrentLinkedQueue; -+ -+// Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) -+public class NodeEvaluatorCache { -+ -+ private static final Map> threadLocalNodeEvaluators = new ConcurrentHashMap<>(); -+ private static final Map nodeEvaluatorToGenerator = new ConcurrentHashMap<>(); -+ -+ private static @NotNull Queue getDequeForGenerator(@NotNull NodeEvaluatorGenerator generator) { -+ return threadLocalNodeEvaluators.computeIfAbsent(generator, (key) -> new ConcurrentLinkedQueue<>()); -+ } -+ -+ public static @NotNull NodeEvaluator takeNodeEvaluator(@NotNull NodeEvaluatorGenerator generator) { -+ var nodeEvaluator = getDequeForGenerator(generator).poll(); -+ -+ if (nodeEvaluator == null) { -+ nodeEvaluator = generator.generate(); -+ } -+ -+ nodeEvaluatorToGenerator.put(nodeEvaluator, generator); -+ -+ return nodeEvaluator; -+ } -+ -+ public static void returnNodeEvaluator(@NotNull NodeEvaluator nodeEvaluator) { -+ final var generator = nodeEvaluatorToGenerator.remove(nodeEvaluator); -+ Validate.notNull(generator, "NodeEvaluator already returned"); -+ -+ getDequeForGenerator(generator).offer(nodeEvaluator); -+ } -+ -+ public static void removeNodeEvaluator(@NotNull NodeEvaluator nodeEvaluator) { -+ nodeEvaluatorToGenerator.remove(nodeEvaluator); -+ } -+} -diff --git a/src/main/java/top/leavesmc/leaves/path/NodeEvaluatorGenerator.java b/src/main/java/top/leavesmc/leaves/path/NodeEvaluatorGenerator.java -new file mode 100644 -index 0000000000000000000000000000000000000000..b1ea8440be70802220d7493a0d149a9061855383 ---- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/path/NodeEvaluatorGenerator.java -@@ -0,0 +1,9 @@ -+package top.leavesmc.leaves.path; -+ -+import net.minecraft.world.level.pathfinder.NodeEvaluator; -+import org.jetbrains.annotations.NotNull; -+ -+// Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) -+public interface NodeEvaluatorGenerator { -+ @NotNull NodeEvaluator generate(); -+} diff --git a/patches/server/0041-Cache-climbing-check-for-activation.patch b/patches/server/0041-Cache-climbing-check-for-activation.patch index 6c8679d6..ca7c0164 100644 --- a/patches/server/0041-Cache-climbing-check-for-activation.patch +++ b/patches/server/0041-Cache-climbing-check-for-activation.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Cache climbing check for activation This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 6e569efe8c5695a875b97126bd4dcd05a86ccf1d..d82af313939322c54099b90c99c4b8fb4e93fb4c 100644 +index 1d52da0e31a1969b99339c510924ede8851449d4..d131f76617f8fe09b1d81fad5a9c1ea58b9a0407 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1930,6 +1930,22 @@ public abstract class LivingEntity extends Entity { +@@ -1943,6 +1943,22 @@ public abstract class LivingEntity extends Entity { return this.lastClimbablePos; } @@ -46,10 +46,10 @@ index 1b42c98956342832c37f0aa266f85271daa4ba5b..b255456f7b9e154f128eace3e220e001 return 1; // Paper } diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 84bbe8d232be70c87e460b5ef28fca1b7d17f32d..70756c650b1e891569a4910590770688552e1228 100644 +index 92f27779e8fdf827c2305c4531f478f2b179ecb9..a144420ff6a351e567c3dade9e5a7d02510a9b70 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -354,6 +354,11 @@ public final class LeavesConfig { +@@ -355,6 +355,11 @@ public final class LeavesConfig { } } diff --git a/patches/server/0042-Use-aging-cache-for-biome-temperatures.patch b/patches/server/0042-Use-aging-cache-for-biome-temperatures.patch index 2348c93c..7814cf01 100644 --- a/patches/server/0042-Use-aging-cache-for-biome-temperatures.patch +++ b/patches/server/0042-Use-aging-cache-for-biome-temperatures.patch @@ -6,7 +6,7 @@ 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 ca259e278ad10347567c021376abca0287610432..968937e86bca8568a17988409506bcc0130b7790 100644 +index c4f1173aab1e53412a65793e06238e637910475a..44bb45b391a365d4ca4dcd7e284edbb04ed12a80 100644 --- a/src/main/java/net/minecraft/world/level/biome/Biome.java +++ b/src/main/java/net/minecraft/world/level/biome/Biome.java @@ -66,23 +66,37 @@ public final class Biome { @@ -102,10 +102,10 @@ index ca259e278ad10347567c021376abca0287610432..968937e86bca8568a17988409506bcc0 public boolean shouldFreeze(LevelReader world, BlockPos blockPos) { diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 70756c650b1e891569a4910590770688552e1228..c274f9068a2d317723f6b5da9348d73236a987fc 100644 +index a144420ff6a351e567c3dade9e5a7d02510a9b70..1fc965f3f082ec4ab4c4d45458d9512998ebb57b 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -359,6 +359,15 @@ public final class LeavesConfig { +@@ -360,6 +360,15 @@ public final class LeavesConfig { cacheClimbCheck = getBoolean("settings.performance.cache-climb-check", cacheClimbCheck); } diff --git a/patches/server/0043-Reduce-entity-fluid-lookups-if-no-fluids.patch b/patches/server/0043-Reduce-entity-fluid-lookups-if-no-fluids.patch index ea3cd090..d8c10ae7 100644 --- a/patches/server/0043-Reduce-entity-fluid-lookups-if-no-fluids.patch +++ b/patches/server/0043-Reduce-entity-fluid-lookups-if-no-fluids.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Reduce entity fluid lookups if no fluids This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0f40e5437f0d8e6e3f170eb72caae0ecd164a31c..02f9224a333cd400d1fe1f78684ab2a433c038fe 100644 +index b058ccd484fdf8294a3be203fdfec5ed67ef5a42..80dc0fa45c8c7ad157e7b456cbe65665dda0bd95 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4030,16 +4030,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4074,16 +4074,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { @@ -35,7 +35,7 @@ index 0f40e5437f0d8e6e3f170eb72caae0ecd164a31c..02f9224a333cd400d1fe1f78684ab2a4 double d1 = 0.0D; boolean flag = this.isPushedByFluid(); boolean flag1 = false; -@@ -4047,38 +4049,123 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4091,38 +4093,123 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { int k1 = 0; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); @@ -217,10 +217,10 @@ index b0c9fce9d4e06cac139e341d218d0b6aac1f1943..f53fee91b78ba4c1e17360a40d5a94fe }); diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index c274f9068a2d317723f6b5da9348d73236a987fc..ed73527cf29c4f08e3f4d98d968d5f5f489d357f 100644 +index 1fc965f3f082ec4ab4c4d45458d9512998ebb57b..cbf22dc0723b623f44aab059644c439984e21ec4 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -368,6 +368,11 @@ public final class LeavesConfig { +@@ -369,6 +369,11 @@ public final class LeavesConfig { } } diff --git a/patches/server/0044-Reduce-chunk-loading-lookups.patch b/patches/server/0044-Reduce-chunk-loading-lookups.patch index acbf64c6..b5fe074c 100644 --- a/patches/server/0044-Reduce-chunk-loading-lookups.patch +++ b/patches/server/0044-Reduce-chunk-loading-lookups.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Reduce chunk loading & lookups This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -index f22e615dba31619c97bf58930da060476a52facf..c330e65310821248409655953b88717f634b0db5 100644 +index f4002ac7cba7d5e41b4f11b98212c625f6a92a65..6feeb3d30e45c5aba4e8204fe7e76f8f0357ad08 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -317,11 +317,28 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -322,11 +322,28 @@ public class EnderMan extends Monster implements NeutralMob { private boolean teleport(double x, double y, double z) { BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z); @@ -42,10 +42,10 @@ index f22e615dba31619c97bf58930da060476a52facf..c330e65310821248409655953b88717f boolean flag1 = iblockdata.getFluidState().is(FluidTags.WATER); diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index ed73527cf29c4f08e3f4d98d968d5f5f489d357f..71a65447a60d8a0d265cfa4c47d0ab1f7437ac76 100644 +index cbf22dc0723b623f44aab059644c439984e21ec4..724917fda96daa17da900cfc226a076f68cd8ca6 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -373,6 +373,11 @@ public final class LeavesConfig { +@@ -374,6 +374,11 @@ public final class LeavesConfig { reduceEntityFluidLookup = getBoolean("settings.performance.reduce-entity-fluid-lookup", reduceEntityFluidLookup); } diff --git a/patches/server/0045-Simpler-ShapelessRecipes-comparison-for-Vanilla.patch b/patches/server/0045-Simpler-ShapelessRecipes-comparison-for-Vanilla.patch index f13a6ba9..1d9346e8 100644 --- a/patches/server/0045-Simpler-ShapelessRecipes-comparison-for-Vanilla.patch +++ b/patches/server/0045-Simpler-ShapelessRecipes-comparison-for-Vanilla.patch @@ -6,31 +6,32 @@ Subject: [PATCH] Simpler ShapelessRecipes comparison for Vanilla This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -index ffe5476d8ed15ee4384b679c341688787205ce59..d83377d264130893d13f9c323489858164bafe20 100644 +index e7c06d98532160499f2610f69de27e30a326b16f..1e454e36a4fc6de4bd245ee8a908ed4fea16e611 100644 --- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -25,12 +25,20 @@ public class ShapelessRecipe implements CraftingRecipe { - final String group; +@@ -26,13 +26,21 @@ public class ShapelessRecipe implements CraftingRecipe { + final CraftingBookCategory category; final ItemStack result; final NonNullList ingredients; + private final boolean isBukkit; // Leaves - public ShapelessRecipe(ResourceLocation id, String group, ItemStack output, NonNullList input) { + public ShapelessRecipe(ResourceLocation id, String group, CraftingBookCategory category, ItemStack output, NonNullList input) { + // Leaves start -+ this(id, group, output, input, false); ++ this(id, group, category, output, input, false); + } + -+ public ShapelessRecipe(ResourceLocation id, String group, ItemStack output, NonNullList input, boolean isBukkit) { ++ public ShapelessRecipe(ResourceLocation id, String group, CraftingBookCategory category, ItemStack output, NonNullList input, boolean isBukkit) { + // Leaves end this.id = id; this.group = group; + this.category = category; this.result = output; this.ingredients = input; + this.isBukkit = isBukkit; // Leaves } // CraftBukkit start -@@ -73,6 +81,28 @@ public class ShapelessRecipe implements CraftingRecipe { +@@ -81,6 +89,28 @@ public class ShapelessRecipe implements CraftingRecipe { } public boolean matches(CraftingContainer inventory, Level world) { @@ -60,22 +61,22 @@ index ffe5476d8ed15ee4384b679c341688787205ce59..d83377d264130893d13f9c3234898581 int i = 0; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -index 0b3b46348ac9195bff1492ffc11fcbff7d3f5c6f..5d4a0081a69f9917aae15a9f2d3d239186e45611 100644 +index f7ea77dd82d978ad307f99c743efacfb34478b3d..96be7a7b030b2f82ac91f0c5c8e66f282fd4d6bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -@@ -43,6 +43,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe +@@ -44,6 +44,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe data.set(i, toNMS(ingred.get(i), true)); } -- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data)); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data, true)); // Leaves - is bukkit recipe +- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data)); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true)); // Leaves - is bukkit recipe } } diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 71a65447a60d8a0d265cfa4c47d0ab1f7437ac76..40d1d67172a90123a23020e71e06ced9d859d752 100644 +index 724917fda96daa17da900cfc226a076f68cd8ca6..d4a65880aed6f7bc2973e8e6011f3959f37caf15 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -378,6 +378,11 @@ public final class LeavesConfig { +@@ -379,6 +379,11 @@ public final class LeavesConfig { reduceChuckLoadAndLookup = getBoolean("settings.performance.reduce-chuck-load-and-lookup", reduceChuckLoadAndLookup); } diff --git a/patches/server/0046-PCA-sync-protocol.patch b/patches/server/0046-PCA-sync-protocol.patch index 4cc62a91..354693d6 100644 --- a/patches/server/0046-PCA-sync-protocol.patch +++ b/patches/server/0046-PCA-sync-protocol.patch @@ -5,10 +5,10 @@ Subject: [PATCH] PCA sync protocol diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c910fe0ed602d2444c0695159961867f9472d66f..6c6032bbf09a47319e9bc2dcccbb9a4b54598f12 100644 +index f7870d551bf6045b649c9c8768b5ad5c8d3488ae..ca4ff892bf647f9ee7c05e6afb1d88c5c8b46eaf 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -245,6 +245,7 @@ import org.bukkit.inventory.CraftingInventory; +@@ -241,6 +241,7 @@ import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.SmithingInventory; @@ -16,7 +16,7 @@ index c910fe0ed602d2444c0695159961867f9472d66f..6c6032bbf09a47319e9bc2dcccbb9a4b // CraftBukkit end public class ServerGamePacketListenerImpl implements ServerPlayerConnection, TickablePacketListener, ServerGamePacketListener { -@@ -3698,6 +3699,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3547,6 +3548,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.disconnect("Invalid payload UNREGISTER!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); // Paper - kick event cause } } else { @@ -34,10 +34,10 @@ index c910fe0ed602d2444c0695159961867f9472d66f..6c6032bbf09a47319e9bc2dcccbb9a4b byte[] data = new byte[packet.data.readableBytes()]; packet.data.readBytes(data); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index d0dfbb0341a0d614a38975dec82eee4a5c950526..4e3e0f7bfe54616fb6733ef2f8f05959eee0f47e 100644 +index 3c1ea8850c5d482d77c0bc137d72fc59dc337979..0f5c3159ed9d15024b35d32d282994f67568b2eb 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -387,6 +387,7 @@ public abstract class PlayerList { +@@ -396,6 +396,7 @@ public abstract class PlayerList { bot1.render(playerconnection, true,player.getBukkitEntity().getWorld() == bot1.getBukkitEntity().getWorld())); // Leaves - render bot } // Leaves end - bot support @@ -46,10 +46,10 @@ index d0dfbb0341a0d614a38975dec82eee4a5c950526..4e3e0f7bfe54616fb6733ef2f8f05959 final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -index a8da601b8342aa6e4902b452eb588c76c98a7adf..1fac7a290d22ca4becea60282dc5f4eea97d0015 100644 +index 821b88d0c32f946af9af1c2e211b38446fab4ecb..5655f6800a03cb5f31523b9a2e94e47666d3bf0e 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -324,6 +324,11 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, +@@ -340,6 +340,11 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, @Override public void containerChanged(Container sender) { @@ -62,7 +62,7 @@ index a8da601b8342aa6e4902b452eb588c76c98a7adf..1fac7a290d22ca4becea60282dc5f4ee this.updateContainerEquipment(); diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -index 5eab7d50734551d96128dfebee126a1da4c51375..bf5b421cddfd2fe6cce3b9cf14415e4ec8cecd42 100644 +index ca96b893e22de3ae7c11d5cded51edf70bdcb6f2..a0380713ff1e3faa285c76ea45f75c9c480caafe 100644 --- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java @@ -65,6 +65,15 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @@ -101,10 +101,10 @@ index b8fb7b5a347298ada16bc8b818edf1863e3f6040..ca71b5b61d85df4a3e74c69823184b52 @Override public boolean stillValid(Player player) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index c6aeda6497cb59673b469588142f5f15a338389d..ed09bac5e6ddb1f134353af70615dcce707363bb 100644 +index cac2768fe520b591990c7bc943ae7e95f49efb31..59938c323ad2597af03a310e930d1a61f1a456c7 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -574,6 +574,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit +@@ -568,6 +568,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit } @@ -122,7 +122,7 @@ index c6aeda6497cb59673b469588142f5f15a338389d..ed09bac5e6ddb1f134353af70615dcce public boolean stillValid(net.minecraft.world.entity.player.Player player) { return this.level.getBlockEntity(this.worldPosition) != this ? false : player.distanceToSqr((double) this.worldPosition.getX() + 0.5D, (double) this.worldPosition.getY() + 0.5D, (double) this.worldPosition.getZ() + 0.5D) <= 64.0D; diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -index f52487e1cfcfab1bf22ab2cb52f998283a86e340..82f883f678eae83b028f78861de9ff2fd3471440 100644 +index 416aa989ebb18a8741cc9d605a1180ab830f6643..213bc3c11ff4ed9bc761e8153aa669d1e2301960 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java @@ -131,6 +131,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { @@ -321,7 +321,7 @@ index ccad692aba2ed77259f6814d88f01b91ed9d229b..01bf32fd730000bdf3a71abe0ad9546c } } diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index 137bdf1168b9e1d00164471e4e79f56c000c2696..47522524ca4e7105f5fa624fc7c438f0c4f9a8c5 100644 +index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..25a9c38c60d183bb65b14f4d7550ab98b431c218 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java @@ -259,6 +259,16 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl @@ -342,10 +342,10 @@ index 137bdf1168b9e1d00164471e4e79f56c000c2696..47522524ca4e7105f5fa624fc7c438f0 public int[] getSlotsForFace(Direction side) { return ShulkerBoxBlockEntity.SLOTS; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index eb7733699a417d1ee73bc0c9d08eba61a34d8b7b..23be24cfc89abb7474464be3bb56e47f1d2e971b 100644 +index 4d22a40e7ff0b88aa204e0da81e71757ecc1dd7f..d52f9d6685a17f46186ed706d59cbe3819234a0d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -372,6 +372,7 @@ public final class CraftServer implements Server { +@@ -385,6 +385,7 @@ public final class CraftServer implements Server { MapPalette.setMapColorCache(new CraftMapColorCache(this.logger)); } datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper @@ -353,7 +353,7 @@ index eb7733699a417d1ee73bc0c9d08eba61a34d8b7b..23be24cfc89abb7474464be3bb56e47f } public boolean getCommandBlockOverride(String command) { -@@ -967,6 +968,13 @@ public final class CraftServer implements Server { +@@ -980,6 +981,13 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); top.leavesmc.leaves.LeavesConfig.init((File) console.options.valueOf("leaves-settings")); // Leaves - Server Config @@ -368,10 +368,10 @@ index eb7733699a417d1ee73bc0c9d08eba61a34d8b7b..23be24cfc89abb7474464be3bb56e47f // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 40d1d67172a90123a23020e71e06ced9d859d752..51a576f75c065a896f4f2a223c3e87241c925720 100644 +index d4a65880aed6f7bc2973e8e6011f3959f37caf15..cb09cbb64bfe8de91a78b2dd1dc135f5d5688477 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -383,6 +383,21 @@ public final class LeavesConfig { +@@ -384,6 +384,21 @@ public final class LeavesConfig { simplerVanillaShapelessRecipes = getBoolean("settings.performance.simpler-vanilla-shapeless-recipes", simplerVanillaShapelessRecipes); } diff --git a/patches/server/0047-BBOR-Protocol.patch b/patches/server/0047-BBOR-Protocol.patch index 441d4ed4..248fb4d3 100644 --- a/patches/server/0047-BBOR-Protocol.patch +++ b/patches/server/0047-BBOR-Protocol.patch @@ -5,7 +5,7 @@ Subject: [PATCH] BBOR Protocol diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c95d1fb9854ed303200d9800d5c230a8b8c0a177..fd71694e3c21926851d91b2f1a5a9be577add443 100644 +index f834a809431ca3667be0c74d8fcbe9db46cbda22..f6bc15c331f22aba5cbb41261dbc10a4dc1e2a8d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1581,6 +1581,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop structures = new HashMap<>(); -+ final Registry structureFeatureRegistry = chunk.getLevel().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY); ++ final Registry structureFeatureRegistry = chunk.getLevel().registryAccess().registryOrThrow(Registries.STRUCTURE); + for (var es : chunk.getAllStarts().entrySet()) { + final var optional = structureFeatureRegistry.getResourceKey(es.getKey()); + optional.ifPresent(key -> structures.put(key.location().toString(), es.getValue())); diff --git a/patches/server/0048-InstantBlockUpdater-Reintroduced.patch b/patches/server/0048-InstantBlockUpdater-Reintroduced.patch index 1fe47165..e1a978d3 100644 --- a/patches/server/0048-InstantBlockUpdater-Reintroduced.patch +++ b/patches/server/0048-InstantBlockUpdater-Reintroduced.patch @@ -5,10 +5,10 @@ Subject: [PATCH] InstantBlockUpdater Reintroduced diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 1070d33c3df23f0ed6073eee2e67680e831e53fc..53a5507692c89dd3584e9d356b802cd03364bf91 100644 +index dda31b5eea92ce3de9de0e4054ee9c7f6df631e4..dd3868045923eed8c6eaf87a57d9bf7dcd466433 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -70,6 +70,7 @@ import net.minecraft.world.level.lighting.LevelLightEngine; +@@ -72,6 +72,7 @@ import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.redstone.CollectingNeighborUpdater; @@ -16,7 +16,7 @@ index 1070d33c3df23f0ed6073eee2e67680e831e53fc..53a5507692c89dd3584e9d356b802cd0 import net.minecraft.world.level.redstone.NeighborUpdater; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import net.minecraft.world.level.storage.LevelData; -@@ -318,7 +319,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -317,7 +318,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.thread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, i); this.isDebug = flag1; @@ -32,10 +32,10 @@ index 1070d33c3df23f0ed6073eee2e67680e831e53fc..53a5507692c89dd3584e9d356b802cd0 this.getWorldBorder().world = (ServerLevel) this; // From PlayerList.setPlayerFileData diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 3e5855c5eef8038c5af69ef447fe0c2b90c33acb..5d1a6ed87f4139dce18343e4a0d70a8922cab308 100644 +index 25a86927e6616a9b2105c06d789bc74c7efa6e60..3dc43c3e292724d199b973273006350a594e754e 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -403,6 +403,15 @@ public final class LeavesConfig { +@@ -404,6 +404,15 @@ public final class LeavesConfig { bborProtocol = getBoolean("settings.protocol.bbor-protocol", bborProtocol); } diff --git a/patches/server/0049-Random-flatten-triangular-distribution.patch b/patches/server/0049-Random-flatten-triangular-distribution.patch index d39476bd..ff28b1e6 100644 --- a/patches/server/0049-Random-flatten-triangular-distribution.patch +++ b/patches/server/0049-Random-flatten-triangular-distribution.patch @@ -25,10 +25,10 @@ index ff1ad1024419182f7f3de578442c1c033d4c9ebb..d93f3eeea17d58ccc01c6010b2d49f81 default void consumeCount(int count) { diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 5d1a6ed87f4139dce18343e4a0d70a8922cab308..3740b315b07a3d6450b11a24d6a4793fc14193d3 100644 +index 3dc43c3e292724d199b973273006350a594e754e..04fa3429d0725446565c01d9ae1b28193b599c4f 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -412,6 +412,11 @@ public final class LeavesConfig { +@@ -413,6 +413,11 @@ public final class LeavesConfig { } } diff --git a/patches/server/0050-Jade-Protocol.patch b/patches/server/0050-Jade-Protocol.patch index 6c7c0377..210d6071 100644 --- a/patches/server/0050-Jade-Protocol.patch +++ b/patches/server/0050-Jade-Protocol.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Jade Protocol diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 4bb6153345dd87b86fc226779e3e1b2cb0de0a09..f6f9ae994c06fea9e0382d69726e4bbc944784af 100644 +index cd8a6f64064786ff46a8330d95b3aa7e6acc86dc..d89e347a83a7dbc4d775075a35d67764ffcb66b0 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3707,6 +3707,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3556,6 +3556,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic if (top.leavesmc.leaves.LeavesConfig.bborProtocol && packet.identifier.equals(top.leavesmc.leaves.protocol.BBORProtocol.SUBSCRIBE)) { top.leavesmc.leaves.protocol.BBORProtocol.onPlayerSubscribed(player); } @@ -19,10 +19,10 @@ index 4bb6153345dd87b86fc226779e3e1b2cb0de0a09..f6f9ae994c06fea9e0382d69726e4bbc ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex); this.disconnect("Invalid custom payload!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 0ddde154bf753e1fa483df8dd58c71b7a17e4779..761b0f00a52b2d3a9b7f2f2e3a27eda3a0e4325e 100644 +index ec3b537819dc741b53be679f353b647895d2bd2d..4d0668ba0e1051094e735dc28224fa9f78c38730 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -389,6 +389,7 @@ public abstract class PlayerList { +@@ -398,6 +398,7 @@ public abstract class PlayerList { // Leaves end - bot support top.leavesmc.leaves.protocol.PcaSyncProtocol.onJoin(player); // Leaves - pca top.leavesmc.leaves.protocol.BBORProtocol.onPlayerLoggedIn(player); // Leaves - bbor @@ -31,10 +31,10 @@ index 0ddde154bf753e1fa483df8dd58c71b7a17e4779..761b0f00a52b2d3a9b7f2f2e3a27eda3 final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java -index 3dd4e6d622a6daafa00ae971edd88a147e34beef..d18950885dd6636e8cd4774f0c37e47c423bd47e 100644 +index e8574bd4b412c1db82aaec9dced47b63de9dbf28..066b0dbbb6d4d6f4526bd1f622162ffe582ad369 100644 --- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -245,7 +245,7 @@ public class Tadpole extends AbstractFish { +@@ -247,7 +247,7 @@ public class Tadpole extends AbstractFish { } @@ -44,10 +44,10 @@ index 3dd4e6d622a6daafa00ae971edd88a147e34beef..d18950885dd6636e8cd4774f0c37e47c } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 03740189a2dbe7985e16ebf3facaeec4cf7ff57f..b104432053cca743e02cbf74abbbc0ae9a6df3d2 100644 +index 5cef8260a3e5f10a808ec77d6e5b24e729fddee4..0cf052a3b2de082ef8cb25147d4a73a673bc04da 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -373,6 +373,7 @@ public final class CraftServer implements Server { +@@ -386,6 +386,7 @@ public final class CraftServer implements Server { } datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper top.leavesmc.leaves.protocol.PcaSyncProtocol.init(); // Leaves - pca @@ -55,7 +55,7 @@ index 03740189a2dbe7985e16ebf3facaeec4cf7ff57f..b104432053cca743e02cbf74abbbc0ae } public boolean getCommandBlockOverride(String command) { -@@ -982,6 +983,11 @@ public final class CraftServer implements Server { +@@ -995,6 +996,11 @@ public final class CraftServer implements Server { top.leavesmc.leaves.protocol.BBORProtocol.loggedOutAllPlayer(); } // Leaves end - bbor @@ -68,10 +68,10 @@ index 03740189a2dbe7985e16ebf3facaeec4cf7ff57f..b104432053cca743e02cbf74abbbc0ae // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 3740b315b07a3d6450b11a24d6a4793fc14193d3..88544d0972e0f1d4339b8a5da8085c0643b799d5 100644 +index 04fa3429d0725446565c01d9ae1b28193b599c4f..82bb440e8f724dd1310b3c068f6d4c4e5296a9aa 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -417,6 +417,11 @@ public final class LeavesConfig { +@@ -418,6 +418,11 @@ public final class LeavesConfig { flattenTriangularDistribution = getBoolean("settings.modify.flatten-triangular-distribution", flattenTriangularDistribution); } @@ -85,10 +85,10 @@ index 3740b315b07a3d6450b11a24d6a4793fc14193d3..88544d0972e0f1d4339b8a5da8085c06 public final String worldName; diff --git a/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..a5d076e67efe46c7ad2c0ae896c1903100c5fadf +index 0000000000000000000000000000000000000000..569ccfc9ac059abdc5690e686889ed03047c2517 --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java -@@ -0,0 +1,571 @@ +@@ -0,0 +1,572 @@ +package top.leavesmc.leaves.protocol; + +import com.google.common.cache.Cache; @@ -102,6 +102,7 @@ index 0000000000000000000000000000000000000000..a5d076e67efe46c7ad2c0ae896c19031 +import io.netty.buffer.Unpooled; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; ++import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.FriendlyByteBuf; @@ -467,7 +468,7 @@ index 0000000000000000000000000000000000000000..a5d076e67efe46c7ad2c0ae896c19031 + tag.putInt("x", pos.getX()); + tag.putInt("y", pos.getY()); + tag.putInt("z", pos.getZ()); -+ tag.putString("id", Registry.BLOCK_ENTITY_TYPE.getKey(tile.getType()).toString()); ++ tag.putString("id", BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(tile.getType()).toString()); + + FriendlyByteBuf buf1 = new FriendlyByteBuf(Unpooled.buffer()); + buf1.writeNbt(tag); diff --git a/patches/server/0051-Carpet-alternative-block-placement-Protocol.patch b/patches/server/0051-Carpet-alternative-block-placement-Protocol.patch index c3814c52..5c3fb327 100644 --- a/patches/server/0051-Carpet-alternative-block-placement-Protocol.patch +++ b/patches/server/0051-Carpet-alternative-block-placement-Protocol.patch @@ -5,23 +5,23 @@ Subject: [PATCH] Carpet alternative block placement Protocol diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index f6f9ae994c06fea9e0382d69726e4bbc944784af..b2d5218bd97be400cd18185e9a5305df76635d6e 100644 +index d89e347a83a7dbc4d775075a35d67764ffcb66b0..41d551d322f3d41945a8dcfb22eb536d50307b37 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1960,7 +1960,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - Vec3 vec3d2 = vec3d.subtract(vec3d1); - double d0 = 1.0000001D; +@@ -1952,7 +1952,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + Vec3 vec3d2 = vec3d.subtract(vec3d1); + double d0 = 1.0000001D; -- if (Math.abs(vec3d2.x()) < 1.0000001D && Math.abs(vec3d2.y()) < 1.0000001D && Math.abs(vec3d2.z()) < 1.0000001D) { -+ if (top.leavesmc.leaves.LeavesConfig.carpetAlternativeBlockPlacement || (Math.abs(vec3d2.x()) < 1.0000001D && Math.abs(vec3d2.y()) < 1.0000001D && Math.abs(vec3d2.z()) < 1.0000001D)) { // Leaves - carpetAlternativeBlockPlacement - Direction enumdirection = movingobjectpositionblock.getDirection(); +- if (Math.abs(vec3d2.x()) < 1.0000001D && Math.abs(vec3d2.y()) < 1.0000001D && Math.abs(vec3d2.z()) < 1.0000001D) { ++ if (top.leavesmc.leaves.LeavesConfig.carpetAlternativeBlockPlacement || (Math.abs(vec3d2.x()) < 1.0000001D && Math.abs(vec3d2.y()) < 1.0000001D && Math.abs(vec3d2.z()) < 1.0000001D)) { // Leaves - carpetAlternativeBlockPlacement + Direction enumdirection = movingobjectpositionblock.getDirection(); - this.player.resetLastActionTime(); + this.player.resetLastActionTime(); diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java -index 62d6c5b7590ff4faef5d8c7a8be03155b7338480..753d81a8daabfc424af323f9ebf52415b2fb618f 100644 +index b0204af850ee182773ad458208cccd946ad148d5..3ab714721b51b039291b8e8a4b4da5118e18f5b7 100644 --- a/src/main/java/net/minecraft/world/item/BlockItem.java +++ b/src/main/java/net/minecraft/world/item/BlockItem.java -@@ -156,7 +156,7 @@ public class BlockItem extends Item { +@@ -158,7 +158,7 @@ public class BlockItem extends Item { @Nullable protected BlockState getPlacementState(BlockPlaceContext context) { @@ -31,10 +31,10 @@ index 62d6c5b7590ff4faef5d8c7a8be03155b7338480..753d81a8daabfc424af323f9ebf52415 return iblockdata != null && this.canPlace(context, iblockdata) ? iblockdata : null; } diff --git a/src/main/java/net/minecraft/world/item/StandingAndWallBlockItem.java b/src/main/java/net/minecraft/world/item/StandingAndWallBlockItem.java -index d48fca67718290dd22133e72715646b3e1de4099..e0ab3f5bb3bc1da1941d10821b38bf4c0d66d6b7 100644 +index 39b8b3675ac58409e05fac07e07c8016c5280d81..928b1ece5b094dee8a5e37bfd3afd626cb1bd03a 100644 --- a/src/main/java/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/src/main/java/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -27,7 +27,7 @@ public class StandingAndWallBlockItem extends BlockItem { +@@ -34,7 +34,7 @@ public class StandingAndWallBlockItem extends BlockItem { @Nullable @Override protected BlockState getPlacementState(BlockPlaceContext context) { @@ -43,20 +43,20 @@ index d48fca67718290dd22133e72715646b3e1de4099..e0ab3f5bb3bc1da1941d10821b38bf4c BlockState iblockdata1 = null; Level world = context.getLevel(); BlockPos blockposition = context.getClickedPos(); -@@ -38,7 +38,7 @@ public class StandingAndWallBlockItem extends BlockItem { +@@ -45,7 +45,7 @@ public class StandingAndWallBlockItem extends BlockItem { Direction enumdirection = aenumdirection[j]; - if (enumdirection != Direction.UP) { -- BlockState iblockdata2 = enumdirection == Direction.DOWN ? this.getBlock().getStateForPlacement(context) : iblockdata; -+ BlockState iblockdata2 = enumdirection == Direction.DOWN ? this.getBlock().getRealStateForPlacement(context) : iblockdata; // Leaves - carpetAlternativeBlockPlacement + if (enumdirection != this.attachmentDirection.getOpposite()) { +- BlockState iblockdata2 = enumdirection == this.attachmentDirection ? this.getBlock().getStateForPlacement(context) : iblockdata; ++ BlockState iblockdata2 = enumdirection == this.attachmentDirection ? this.getBlock().getRealStateForPlacement(context) : iblockdata; // Leaves - carpetAlternativeBlockPlacement - if (iblockdata2 != null && iblockdata2.canSurvive(world, blockposition)) { + if (iblockdata2 != null && this.canPlace(world, iblockdata2, blockposition)) { iblockdata1 = iblockdata2; 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 2e65b44f10aeb44fd524a58e7eb815a566c1ad61..138e7c233f087da4c7f0c7adb58648b9da45ec1b 100644 +index 7b71073027f4cf79736546500ededdfbb83d968e..085097d454869e46adafd1cff5908e39211bb91e 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -429,6 +429,19 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -427,6 +427,19 @@ public class Block extends BlockBehaviour implements ItemLike { public void stepOn(Level world, BlockPos pos, BlockState state, Entity entity) {} @@ -77,10 +77,10 @@ index 2e65b44f10aeb44fd524a58e7eb815a566c1ad61..138e7c233f087da4c7f0c7adb58648b9 public BlockState getStateForPlacement(BlockPlaceContext ctx) { return this.defaultBlockState(); diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 88544d0972e0f1d4339b8a5da8085c0643b799d5..ae6fa6d4dbd350841ed1924477d02a2c974f5aed 100644 +index 82bb440e8f724dd1310b3c068f6d4c4e5296a9aa..43b0083d51e8d78092595a93755ed2e1b84c4694 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -422,6 +422,15 @@ public final class LeavesConfig { +@@ -423,6 +423,15 @@ public final class LeavesConfig { jadeProtocol = getBoolean("settings.protocol.jade-protocol", jadeProtocol); }