9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00

Recipe send all, and remove rei (#443 #391)

This commit is contained in:
violetc
2025-03-27 13:06:27 +08:00
parent bea888478e
commit 324ac1170b
4 changed files with 43 additions and 1 deletions

View File

@@ -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<ClientboundRecipeBookAddPacket.Entry> list = new ArrayList<>(this.known.size());
+ // Leaves start - recipe-send-all
+ List<ClientboundRecipeBookAddPacket.Entry> list;
- for (ResourceKey<Recipe<?>> 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<Recipe<?>> 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));
}

View File

@@ -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();

View File

@@ -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};

View File

@@ -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";