Only add a tag to the bedrock item if it is needed (#4925)

This commit is contained in:
chris 2024-07-31 21:22:22 +02:00 committed by GitHub
parent 22c59c465f
commit 6002c9c7a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,6 +49,8 @@ import org.geysermc.geyser.inventory.recipe.GeyserShapedRecipe;
import org.geysermc.geyser.inventory.recipe.GeyserShapelessRecipe;
import org.geysermc.geyser.inventory.recipe.GeyserStonecutterData;
import org.geysermc.geyser.inventory.recipe.TrimRecipe;
import org.geysermc.geyser.item.type.BedrockRequiresTagItem;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession;
@ -443,13 +445,18 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
}
List<String> translateShulkerBoxRecipe(GeyserShapelessRecipe recipe) {
ItemData output = ItemTranslator.translateToBedrock(session, recipe.result());
ItemStack result = recipe.result();
ItemData output = ItemTranslator.translateToBedrock(session, result);
if (!output.isValid()) {
// Likely modded item that Bedrock will complain about if it persists
return null;
}
Item javaItem = Registries.JAVA_ITEMS.get(result.getId());
if (!(javaItem instanceof BedrockRequiresTagItem)) {
// Strip NBT - tools won't appear in the recipe book otherwise
// output = output.toBuilder().tag(null).build(); // TODO confirm???
output = output.toBuilder().tag(null).build();
}
ItemDescriptorWithCount[][] inputCombinations = combinations(session, recipe.ingredients());
if (inputCombinations == null) {
return null;
@ -467,13 +474,18 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
}
List<String> translateShapelessRecipe(GeyserShapelessRecipe recipe) {
ItemData output = ItemTranslator.translateToBedrock(session, recipe.result());
ItemStack result = recipe.result();
ItemData output = ItemTranslator.translateToBedrock(session, result);
if (!output.isValid()) {
// Likely modded item that Bedrock will complain about if it persists
return null;
}
Item javaItem = Registries.JAVA_ITEMS.get(result.getId());
if (!(javaItem instanceof BedrockRequiresTagItem)) {
// Strip NBT - tools won't appear in the recipe book otherwise
//output = output.toBuilder().tag(null).build(); // TODO confirm this is still true???
output = output.toBuilder().tag(null).build();
}
ItemDescriptorWithCount[][] inputCombinations = combinations(session, recipe.ingredients());
if (inputCombinations == null) {
return null;
@ -491,13 +503,18 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
}
List<String> translateShapedRecipe(GeyserShapedRecipe recipe) {
ItemData output = ItemTranslator.translateToBedrock(session, recipe.result());
ItemStack result = recipe.result();
ItemData output = ItemTranslator.translateToBedrock(session, result);
if (!output.isValid()) {
// Likely modded item that Bedrock will complain about if it persists
return null;
}
// See above
//output = output.toBuilder().tag(null).build();
Item javaItem = Registries.JAVA_ITEMS.get(result.getId());
if (!(javaItem instanceof BedrockRequiresTagItem)) {
// Strip NBT - tools won't appear in the recipe book otherwise
output = output.toBuilder().tag(null).build();
}
ItemDescriptorWithCount[][] inputCombinations = combinations(session, recipe.ingredients());
if (inputCombinations == null) {
return null;