3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 00:00:41 +01:00

Map experimental items to 'minecraft:unknown' Bedrock block

Dieser Commit ist enthalten in:
Camotoy 2024-11-01 14:42:21 -04:00
Ursprung dc1674fcbf
Commit dd8a7a7edd
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
6 geänderte Dateien mit 31 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -320,13 +320,17 @@ public class CommandRegistry implements EventRegistrar {
cloud.commandExecutor().executeCommand(source, command);
}
public void export(GeyserSession session, List<CommandData> bedrockCommands) {
public void export(GeyserSession session, List<CommandData> bedrockCommands, Set<String> knownAliases) {
cloud.commandTree().rootNodes().forEach(commandTree -> {
var command = commandTree.command();
// Command null happens if you register an extension command with custom Cloud parameters...
if (command == null || session.hasPermission(command.commandPermission().permissionString())) {
var rootComponent = commandTree.component();
String name = rootComponent.name();
if (!knownAliases.add(name)) {
// If the server already defined the command, let's not crash.
return;
}
LinkedHashMap<String, Set<CommandEnumConstraint>> values = new LinkedHashMap<>();
for (String s : rootComponent.aliases()) {

Datei anzeigen

@ -283,7 +283,7 @@ public final class BlockRegistryPopulator {
.build();
}
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.getOrDefault(bedrockTag, airDefinition); // FIXME EEE
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.get(bedrockTag);
GeyserBedrockBlock bedrockDefinition;
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);

Datei anzeigen

@ -84,6 +84,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -95,7 +96,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class ItemRegistryPopulator {
record PaletteVersion(String version, int protocolVersion, Map<Item, String> javaOnlyItems, Remapper remapper) {
record PaletteVersion(String version, int protocolVersion, Map<Item, Item> javaOnlyItems, Remapper remapper) {
public PaletteVersion(String version, int protocolVersion) {
this(version, protocolVersion, Collections.emptyMap(), (item, mapping) -> mapping);
@ -109,11 +110,17 @@ public class ItemRegistryPopulator {
}
public static void populate() {
List<Item> bundles = List.of(Items.BUNDLE, Items.BLACK_BUNDLE, Items.BLUE_BUNDLE, Items.BROWN_BUNDLE, Items.CYAN_BUNDLE, Items.GRAY_BUNDLE,
Items.GREEN_BUNDLE, Items.LIGHT_BLUE_BUNDLE, Items.LIGHT_GRAY_BUNDLE, Items.LIME_BUNDLE, Items.MAGENTA_BUNDLE, Items.ORANGE_BUNDLE, Items.RED_BUNDLE,
Items.PINK_BUNDLE, Items.PURPLE_BUNDLE, Items.WHITE_BUNDLE, Items.YELLOW_BUNDLE);
Map<Item, Item> pre1_21_2Items = new HashMap<>();
bundles.forEach(bundle -> pre1_21_2Items.put(bundle, Items.SHULKER_SHELL));
List<PaletteVersion> paletteVersions = new ArrayList<>(3);
paletteVersions.add(new PaletteVersion("1_20_80", Bedrock_v671.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion685_671::remapItem));
paletteVersions.add(new PaletteVersion("1_21_0", Bedrock_v685.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion712_685::remapItem));
paletteVersions.add(new PaletteVersion("1_21_20", Bedrock_v712.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion729_712::remapItem));
paletteVersions.add(new PaletteVersion("1_21_30", Bedrock_v729.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion748_729::remapItem));
paletteVersions.add(new PaletteVersion("1_20_80", Bedrock_v671.CODEC.getProtocolVersion(), pre1_21_2Items, Conversion685_671::remapItem));
paletteVersions.add(new PaletteVersion("1_21_0", Bedrock_v685.CODEC.getProtocolVersion(), pre1_21_2Items, Conversion712_685::remapItem));
paletteVersions.add(new PaletteVersion("1_21_20", Bedrock_v712.CODEC.getProtocolVersion(), pre1_21_2Items, Conversion729_712::remapItem));
paletteVersions.add(new PaletteVersion("1_21_30", Bedrock_v729.CODEC.getProtocolVersion(), pre1_21_2Items, Conversion748_729::remapItem));
paletteVersions.add(new PaletteVersion("1_21_40", Bedrock_v748.CODEC.getProtocolVersion()));
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
@ -227,7 +234,7 @@ public class ItemRegistryPopulator {
Set<Item> javaOnlyItems = new ObjectOpenHashSet<>();
Collections.addAll(javaOnlyItems, Items.SPECTRAL_ARROW, Items.DEBUG_STICK,
Items.KNOWLEDGE_BOOK, Items.TIPPED_ARROW, Items.BUNDLE);
Items.KNOWLEDGE_BOOK, Items.TIPPED_ARROW);
if (!customItemsAllowed) {
javaOnlyItems.add(Items.FURNACE_MINECART);
}
@ -243,9 +250,9 @@ public class ItemRegistryPopulator {
throw new RuntimeException("Extra item in mappings? " + entry.getKey());
}
GeyserMappingItem mappingItem;
String replacementItem = palette.javaOnlyItems().get(javaItem);
Item replacementItem = palette.javaOnlyItems().get(javaItem);
if (replacementItem != null) {
mappingItem = items.get(replacementItem); // java only item, a java id fallback has been provided
mappingItem = items.get(replacementItem.javaIdentifier()); // java only item, a java id fallback has been provided
} else {
// check if any mapping changes need to be made on this version
mappingItem = palette.remapper().remap(javaItem, entry.getValue());
@ -260,8 +267,7 @@ public class ItemRegistryPopulator {
String bedrockIdentifier = mappingItem.getBedrockIdentifier();
ItemDefinition definition = definitions.get(bedrockIdentifier);
if (definition == null) {
definition = definitions.get("minecraft:air");
//throw new RuntimeException("Missing Bedrock ItemDefinition in version " + palette.version() + " for mapping: " + mappingItem);
throw new RuntimeException("Missing Bedrock ItemDefinition in version " + palette.version() + " for mapping: " + mappingItem);
}
BlockDefinition bedrockBlock = null;

Datei anzeigen

@ -215,7 +215,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
}
if (session.getGeyser().platformType() == PlatformType.STANDALONE) {
session.getGeyser().commandRegistry().export(session, commandData);
session.getGeyser().commandRegistry().export(session, commandData, knownAliases);
}
// Add our commands to the AvailableCommandsPacket for the bedrock client

Datei anzeigen

@ -110,6 +110,9 @@ public class JavaRecipeBookAddTranslator extends PacketTranslator<ClientboundRec
for (int i = 0; i < left.size(); i++) {
List<ItemDescriptorWithCount> inputs = left.get(i);
String recipeId = contents.id() + "_" + i;
if (recipeId.equals("1318_0")) {
System.out.println(display);
}
int recipeNetworkId = netId++;
craftingDataPacket.getCraftingData().add(ShapedRecipeData.shaped(recipeId,
shapedRecipe.width(), shapedRecipe.height(), inputs,
@ -268,8 +271,12 @@ public class JavaRecipeBookAddTranslator extends PacketTranslator<ClientboundRec
Pair<Item, ItemData> pair = translateToOutput(session, display.result());
if (pair == null || !pair.right().isValid()) {
// Likely modded item Bedrock will complain about
// Implementation note: ItemData#isValid() may return true for air because count might be > 0 and the air definition may not be ItemDefinition.AIR
return null;
}
if (pair.left() == Items.PALE_OAK_TRAPDOOR) {
System.out.println(pair.right());
}
ItemData output = pair.right();
if (!(pair.left() instanceof BedrockRequiresTagItem)) {

@ -1 +1 @@
Subproject commit 4200a8c57a79a87b5b9e7ea1aaf9d5522c4f5626
Subproject commit e1eafe2c5304012d23acba80659459f7868fe2b1