mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix client crash issue if empty recipe is sent (#4485)
* Fix client crash issue if empty recipe is sent Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * More efficent order Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Recipes are recipies Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --------- Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
This commit is contained in:
parent
0ad7c4325d
commit
a0fd720e7c
1 changed files with 13 additions and 5 deletions
|
@ -27,7 +27,6 @@ package org.geysermc.geyser.translator.protocol.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRecipePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRecipePacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.UnlockedRecipesPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.UnlockedRecipesPacket;
|
||||||
import org.geysermc.geyser.network.GameProtocol;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
|
@ -47,12 +46,22 @@ public class JavaClientboundRecipesTranslator extends PacketTranslator<Clientbou
|
||||||
recipesPacket.getUnlockedRecipes().addAll(getBedrockRecipes(session, packet.getAlreadyKnownRecipes()));
|
recipesPacket.getUnlockedRecipes().addAll(getBedrockRecipes(session, packet.getAlreadyKnownRecipes()));
|
||||||
}
|
}
|
||||||
case ADD -> {
|
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.setAction(UnlockedRecipesPacket.ActionType.NEWLY_UNLOCKED);
|
||||||
recipesPacket.getUnlockedRecipes().addAll(getBedrockRecipes(session, packet.getRecipes()));
|
recipesPacket.getUnlockedRecipes().addAll(recipes);
|
||||||
}
|
}
|
||||||
case REMOVE -> {
|
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.setAction(UnlockedRecipesPacket.ActionType.REMOVE_UNLOCKED);
|
||||||
recipesPacket.getUnlockedRecipes().addAll(getBedrockRecipes(session, packet.getRecipes()));
|
recipesPacket.getUnlockedRecipes().addAll(recipes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.sendUpstreamPacket(recipesPacket);
|
session.sendUpstreamPacket(recipesPacket);
|
||||||
|
@ -71,4 +80,3 @@ public class JavaClientboundRecipesTranslator extends PacketTranslator<Clientbou
|
||||||
return recipes;
|
return recipes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue