diff --git a/leaves-server/minecraft-patches/features/0117-Recipe-send-all.patch b/leaves-server/minecraft-patches/features/0117-Recipe-send-all.patch new file mode 100644 index 00000000..28dcaa3d --- /dev/null +++ b/leaves-server/minecraft-patches/features/0117-Recipe-send-all.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Thu, 27 Mar 2025 13:04:35 +0800 +Subject: [PATCH] Recipe send all + + +diff --git a/net/minecraft/stats/ServerRecipeBook.java b/net/minecraft/stats/ServerRecipeBook.java +index e3985b70cee7f7d56f179aeef8c2a6a6b312d83a..a476f6b6554b4c7ba1625ab4b9da3bcf3d40955b 100644 +--- a/net/minecraft/stats/ServerRecipeBook.java ++++ b/net/minecraft/stats/ServerRecipeBook.java +@@ -150,12 +150,23 @@ public class ServerRecipeBook extends RecipeBook { + + public void sendInitialRecipeBook(ServerPlayer player) { + player.connection.send(new ClientboundRecipeBookSettingsPacket(this.getBookSettings())); +- List list = new ArrayList<>(this.known.size()); ++ // Leaves start - recipe-send-all ++ List list; + +- for (ResourceKey> resourceKey : this.known) { +- this.displayResolver +- .displaysForRecipe(resourceKey, entry -> list.add(new ClientboundRecipeBookAddPacket.Entry(entry, false, this.highlight.contains(resourceKey)))); ++ if (org.leavesmc.leaves.LeavesConfig.protocol.recipeSendAll) { ++ list = new ArrayList<>(player.server.getRecipeManager().getRecipes().size()); ++ player.server.getRecipeManager().getRecipes().stream().map(RecipeHolder::id).forEach( key -> { ++ this.displayResolver ++ .displaysForRecipe(key, entry -> list.add(new ClientboundRecipeBookAddPacket.Entry(entry, false, this.highlight.contains(key)))); ++ }); ++ } else { ++ list = new ArrayList<>(this.known.size()); ++ for (ResourceKey> resourceKey : this.known) { ++ this.displayResolver ++ .displaysForRecipe(resourceKey, entry -> list.add(new ClientboundRecipeBookAddPacket.Entry(entry, false, this.highlight.contains(resourceKey)))); ++ } + } ++ // Leaves end - recipe-send-all + + player.connection.send(new ClientboundRecipeBookAddPacket(list, true)); + } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java index 7f8eb1ca..ba1d71d1 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java @@ -835,6 +835,9 @@ public final class LeavesConfig { @GlobalConfig("rei-server-protocol") public boolean reiServerProtocol = false; + + @GlobalConfig("recipe-send-all") + public boolean recipeSendAll = false; } public static MiscConfig mics = new MiscConfig(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java index 4a3f9d3e..fc330157 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java @@ -35,6 +35,7 @@ import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarFile; +// TODO refactor public class LeavesProtocolManager { private static final Class[] PAYLOAD_PARAMETER_TYPES = {ResourceLocation.class, FriendlyByteBuf.class}; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java index 75f384bf..fdf5d035 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java @@ -19,7 +19,7 @@ import org.leavesmc.leaves.protocol.rei.payload.CreateItemHotbarPayload; import org.leavesmc.leaves.protocol.rei.payload.CreateItemMessagePayload; import org.leavesmc.leaves.protocol.rei.payload.CreateItemPayload; -@LeavesProtocol(namespace = "roughlyenoughitems") +// @LeavesProtocol(namespace = "roughlyenoughitems") TODO will fix public class REIServerProtocol { public static final String PROTOCOL_ID = "roughlyenoughitems";