Merge remote-tracking branch 'upstream/master' into feature/1.20.70

This commit is contained in:
Joshua Castle 2024-03-11 00:04:10 -07:00
commit 9ac44f1655
No known key found for this signature in database
GPG Key ID: 7ECA1A2FC38ABA9F
1 changed files with 13 additions and 5 deletions

View File

@ -27,7 +27,6 @@ package org.geysermc.geyser.translator.protocol.java;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRecipePacket;
import org.cloudburstmc.protocol.bedrock.packet.UnlockedRecipesPacket;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@ -47,12 +46,22 @@ public class JavaClientboundRecipesTranslator extends PacketTranslator<Clientbou
recipesPacket.getUnlockedRecipes().addAll(getBedrockRecipes(session, packet.getAlreadyKnownRecipes()));
}
case ADD -> {
List<String> recipes = getBedrockRecipes(session, packet.getRecipes());
if (recipes.isEmpty()) {
// Sending an empty list here packet will crash the client as of 1.20.60
return;
}
recipesPacket.setAction(UnlockedRecipesPacket.ActionType.NEWLY_UNLOCKED);
recipesPacket.getUnlockedRecipes().addAll(getBedrockRecipes(session, packet.getRecipes()));
recipesPacket.getUnlockedRecipes().addAll(recipes);
}
case REMOVE -> {
List<String> recipes = getBedrockRecipes(session, packet.getRecipes());
if (recipes.isEmpty()) {
// Sending an empty list here will crash the client as of 1.20.60
return;
}
recipesPacket.setAction(UnlockedRecipesPacket.ActionType.REMOVE_UNLOCKED);
recipesPacket.getUnlockedRecipes().addAll(getBedrockRecipes(session, packet.getRecipes()));
recipesPacket.getUnlockedRecipes().addAll(recipes);
}
}
session.sendUpstreamPacket(recipesPacket);
@ -70,5 +79,4 @@ public class JavaClientboundRecipesTranslator extends PacketTranslator<Clientbou
}
return recipes;
}
}
}