Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Hardcode armor trim recipes
Dieser Commit ist enthalten in:
Ursprung
c2285e018b
Commit
d8ec4a5389
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.inventory.recipe;
|
||||
|
||||
import org.cloudburstmc.protocol.bedrock.data.TrimMaterial;
|
||||
import org.cloudburstmc.protocol.bedrock.data.TrimPattern;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemDescriptorWithCount;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemTagDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Hardcoded recipe information about armor trims until further improvements can be made. This information was scraped
|
||||
* from BDS 1.19.81 with a world with the next_major_update and sniffer features enabled, using ProxyPass.
|
||||
*/
|
||||
public class TrimRecipe {
|
||||
|
||||
// For TrimDataPacket, which BDS sends just before the CraftingDataPacket
|
||||
public static final List<TrimPattern> PATTERNS;
|
||||
public static final List<TrimMaterial> MATERIALS;
|
||||
|
||||
// For CraftingDataPacket
|
||||
public static final String ID = "minecraft:smithing_armor_trim";
|
||||
public static final ItemDescriptorWithCount BASE = tagDescriptor("minecraft:trimmable_armors");
|
||||
public static final ItemDescriptorWithCount ADDITION = tagDescriptor("minecraft:trim_materials");
|
||||
public static final ItemDescriptorWithCount TEMPLATE = tagDescriptor("minecraft:trim_templates");
|
||||
|
||||
static {
|
||||
List<TrimPattern> patterns = new ArrayList<>(16);
|
||||
patterns.add(new TrimPattern("minecraft:ward_armor_trim_smithing_template", "ward"));
|
||||
patterns.add(new TrimPattern("minecraft:sentry_armor_trim_smithing_template", "sentry"));
|
||||
patterns.add(new TrimPattern("minecraft:snout_armor_trim_smithing_template", "snout"));
|
||||
patterns.add(new TrimPattern("minecraft:dune_armor_trim_smithing_template", "dune"));
|
||||
patterns.add(new TrimPattern("minecraft:spire_armor_trim_smithing_template", "spire"));
|
||||
patterns.add(new TrimPattern("minecraft:tide_armor_trim_smithing_template", "tide"));
|
||||
patterns.add(new TrimPattern("minecraft:wild_armor_trim_smithing_template", "wild"));
|
||||
patterns.add(new TrimPattern("minecraft:rib_armor_trim_smithing_template", "rib"));
|
||||
patterns.add(new TrimPattern("minecraft:coast_armor_trim_smithing_template", "coast"));
|
||||
patterns.add(new TrimPattern("minecraft:shaper_armor_trim_smithing_template", "shaper"));
|
||||
patterns.add(new TrimPattern("minecraft:eye_armor_trim_smithing_template", "eye"));
|
||||
patterns.add(new TrimPattern("minecraft:vex_armor_trim_smithing_template", "vex"));
|
||||
patterns.add(new TrimPattern("minecraft:silence_armor_trim_smithing_template", "silence"));
|
||||
patterns.add(new TrimPattern("minecraft:wayfinder_armor_trim_smithing_template", "wayfinder"));
|
||||
patterns.add(new TrimPattern("minecraft:raiser_armor_trim_smithing_template", "raiser"));
|
||||
patterns.add(new TrimPattern("minecraft:host_armor_trim_smithing_template", "host"));
|
||||
PATTERNS = Collections.unmodifiableList(patterns);
|
||||
|
||||
List<TrimMaterial> materials = new ArrayList<>(10);
|
||||
materials.add(new TrimMaterial("quartz", "§h", "minecraft:quartz"));
|
||||
materials.add(new TrimMaterial("iron", "§i", "minecraft:iron_ingot"));
|
||||
materials.add(new TrimMaterial("netherite", "§j", "minecraft:netherite_ingot"));
|
||||
materials.add(new TrimMaterial("redstone", "§m", "minecraft:redstone"));
|
||||
materials.add(new TrimMaterial("copper", "§n", "minecraft:copper_ingot"));
|
||||
materials.add(new TrimMaterial("gold", "§p", "minecraft:gold_ingot"));
|
||||
materials.add(new TrimMaterial("emerald", "§q", "minecraft:emerald"));
|
||||
materials.add(new TrimMaterial("diamond", "§s", "minecraft:diamond"));
|
||||
materials.add(new TrimMaterial("lapis", "§t", "minecraft:lapis_lazuli"));
|
||||
materials.add(new TrimMaterial("amethyst", "§u", "minecraft:amethyst_shard"));
|
||||
MATERIALS = Collections.unmodifiableList(materials);
|
||||
}
|
||||
|
||||
private TrimRecipe() {
|
||||
//no-op
|
||||
}
|
||||
|
||||
private static ItemDescriptorWithCount tagDescriptor(String tag) {
|
||||
return new ItemDescriptorWithCount(new ItemTagDescriptor(tag), 1);
|
||||
}
|
||||
}
|
@ -32,7 +32,6 @@ import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.SmithingTransformRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.SmithingTrimRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateRecipesPacket;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
@ -42,13 +41,16 @@ import org.cloudburstmc.protocol.bedrock.data.defintions.ItemDefinition;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.MultiRecipeData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.RecipeData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.SmithingTrimRecipeData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.DefaultDescriptor;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemDescriptorWithCount;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.CraftingDataPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.TrimDataPacket;
|
||||
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
||||
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.registry.Registries;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
@ -165,27 +167,9 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
// todo 1.20: BDS sends the trim recipes very concisely using item tag descriptors. this code doesn't result in trim recipes working.
|
||||
case SMITHING_TRIM -> {
|
||||
SmithingTrimRecipeData data = (SmithingTrimRecipeData) recipe.getData();
|
||||
|
||||
for (ItemStack template : data.getTemplate().getOptions()) {
|
||||
ItemDescriptorWithCount bedrockTemplate = ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, template));
|
||||
|
||||
for (ItemStack base : data.getBase().getOptions()) {
|
||||
ItemDescriptorWithCount bedrockBase = ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, base));
|
||||
|
||||
for (ItemStack addition : data.getAddition().getOptions()) {
|
||||
ItemDescriptorWithCount bedrockAddition = ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, addition));
|
||||
|
||||
craftingDataPacket.getCraftingData().add(org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.SmithingTrimRecipeData.of(recipe.getIdentifier(),
|
||||
bedrockBase, bedrockAddition, bedrockTemplate, "smithing_table", netId++));
|
||||
// ignored currently - see below
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
default -> {
|
||||
List<RecipeData> craftingData = recipeTypes.get(recipe.getType());
|
||||
if (craftingData != null) {
|
||||
@ -230,6 +214,19 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: if the server/viaversion doesn't send trim recipes then we shouldn't either.
|
||||
|
||||
// BDS sends armor trim templates and materials before the CraftingDataPacket
|
||||
TrimDataPacket trimDataPacket = new TrimDataPacket();
|
||||
trimDataPacket.getPatterns().addAll(TrimRecipe.PATTERNS);
|
||||
trimDataPacket.getMaterials().addAll(TrimRecipe.MATERIALS);
|
||||
session.sendUpstreamPacket(trimDataPacket);
|
||||
|
||||
// Identical smithing_trim recipe sent by BDS that uses tag-descriptors, as the client seems to ignore the
|
||||
// approach of using many default-descriptors (which we do for smithing_transform)
|
||||
craftingDataPacket.getCraftingData().add(SmithingTrimRecipeData.of(TrimRecipe.ID,
|
||||
TrimRecipe.BASE, TrimRecipe.ADDITION, TrimRecipe.TEMPLATE, "smithing_table", netId++));
|
||||
|
||||
session.sendUpstreamPacket(craftingDataPacket);
|
||||
session.setCraftingRecipes(recipeMap);
|
||||
session.setStonecutterRecipes(stonecutterRecipeMap);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren