Skip to content

Commit 6002c9c

Browse files
Only add a tag to the bedrock item if it is needed (#4925)
1 parent 22c59c4 commit 6002c9c

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import org.geysermc.geyser.inventory.recipe.GeyserShapelessRecipe;
5050
import org.geysermc.geyser.inventory.recipe.GeyserStonecutterData;
5151
import org.geysermc.geyser.inventory.recipe.TrimRecipe;
52+
import org.geysermc.geyser.item.type.BedrockRequiresTagItem;
53+
import org.geysermc.geyser.item.type.Item;
5254
import org.geysermc.geyser.registry.Registries;
5355
import org.geysermc.geyser.registry.type.ItemMapping;
5456
import org.geysermc.geyser.session.GeyserSession;
@@ -443,13 +445,18 @@ private RecipeContext(GeyserSession session, CraftingDataPacket packet, Int2Obje
443445
}
444446

445447
List<String> translateShulkerBoxRecipe(GeyserShapelessRecipe recipe) {
446-
ItemData output = ItemTranslator.translateToBedrock(session, recipe.result());
448+
ItemStack result = recipe.result();
449+
ItemData output = ItemTranslator.translateToBedrock(session, result);
447450
if (!output.isValid()) {
448451
// Likely modded item that Bedrock will complain about if it persists
449452
return null;
450453
}
451-
// Strip NBT - tools won't appear in the recipe book otherwise
452-
// output = output.toBuilder().tag(null).build(); // TODO confirm???
454+
455+
Item javaItem = Registries.JAVA_ITEMS.get(result.getId());
456+
if (!(javaItem instanceof BedrockRequiresTagItem)) {
457+
// Strip NBT - tools won't appear in the recipe book otherwise
458+
output = output.toBuilder().tag(null).build();
459+
}
453460
ItemDescriptorWithCount[][] inputCombinations = combinations(session, recipe.ingredients());
454461
if (inputCombinations == null) {
455462
return null;
@@ -467,13 +474,18 @@ List<String> translateShulkerBoxRecipe(GeyserShapelessRecipe recipe) {
467474
}
468475

469476
List<String> translateShapelessRecipe(GeyserShapelessRecipe recipe) {
470-
ItemData output = ItemTranslator.translateToBedrock(session, recipe.result());
477+
ItemStack result = recipe.result();
478+
ItemData output = ItemTranslator.translateToBedrock(session, result);
471479
if (!output.isValid()) {
472480
// Likely modded item that Bedrock will complain about if it persists
473481
return null;
474482
}
475-
// Strip NBT - tools won't appear in the recipe book otherwise
476-
//output = output.toBuilder().tag(null).build(); // TODO confirm this is still true???
483+
484+
Item javaItem = Registries.JAVA_ITEMS.get(result.getId());
485+
if (!(javaItem instanceof BedrockRequiresTagItem)) {
486+
// Strip NBT - tools won't appear in the recipe book otherwise
487+
output = output.toBuilder().tag(null).build();
488+
}
477489
ItemDescriptorWithCount[][] inputCombinations = combinations(session, recipe.ingredients());
478490
if (inputCombinations == null) {
479491
return null;
@@ -491,13 +503,18 @@ List<String> translateShapelessRecipe(GeyserShapelessRecipe recipe) {
491503
}
492504

493505
List<String> translateShapedRecipe(GeyserShapedRecipe recipe) {
494-
ItemData output = ItemTranslator.translateToBedrock(session, recipe.result());
506+
ItemStack result = recipe.result();
507+
ItemData output = ItemTranslator.translateToBedrock(session, result);
495508
if (!output.isValid()) {
496509
// Likely modded item that Bedrock will complain about if it persists
497510
return null;
498511
}
499-
// See above
500-
//output = output.toBuilder().tag(null).build();
512+
513+
Item javaItem = Registries.JAVA_ITEMS.get(result.getId());
514+
if (!(javaItem instanceof BedrockRequiresTagItem)) {
515+
// Strip NBT - tools won't appear in the recipe book otherwise
516+
output = output.toBuilder().tag(null).build();
517+
}
501518
ItemDescriptorWithCount[][] inputCombinations = combinations(session, recipe.ingredients());
502519
if (inputCombinations == null) {
503520
return null;

0 commit comments

Comments
 (0)