mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
Add native offhand support for *some* items
About 46 items are data-driven enough where we can tell Bedrock these items are permitted in the offhand.
This commit is contained in:
parent
c8fbffb638
commit
da5d8006ad
2 changed files with 28 additions and 1 deletions
|
@ -38,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.cloudburstmc.nbt.NbtMap;
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
import org.cloudburstmc.nbt.NbtType;
|
import org.cloudburstmc.nbt.NbtType;
|
||||||
|
import org.cloudburstmc.nbt.NbtUtils;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
|
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685;
|
import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
|
@ -102,6 +103,13 @@ public class ItemRegistryPopulator {
|
||||||
throw new AssertionError("Unable to load Java runtime item IDs", e);
|
throw new AssertionError("Unable to load Java runtime item IDs", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NbtMap vanillaComponents;
|
||||||
|
try (InputStream stream = bootstrap.getResourceOrThrow("mappings/item_components.nbt")) {
|
||||||
|
vanillaComponents = (NbtMap) NbtUtils.createGZIPReader(stream, true, true).readTag();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AssertionError("Unable to load Bedrock item components", e);
|
||||||
|
}
|
||||||
|
|
||||||
boolean customItemsAllowed = GeyserImpl.getInstance().getConfig().isAddNonBedrockItems();
|
boolean customItemsAllowed = GeyserImpl.getInstance().getConfig().isAddNonBedrockItems();
|
||||||
|
|
||||||
// List values here is important compared to HashSet - we need to preserve the order of what's given to us
|
// List values here is important compared to HashSet - we need to preserve the order of what's given to us
|
||||||
|
@ -531,6 +539,25 @@ public class ItemRegistryPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, Object> entry : vanillaComponents.entrySet()) {
|
||||||
|
String id = entry.getKey();
|
||||||
|
ItemDefinition definition = definitions.get(id);
|
||||||
|
if (definition == null) {
|
||||||
|
// Newer item most likely
|
||||||
|
GeyserImpl.getInstance().getLogger().debug(
|
||||||
|
"Skipping vanilla component " + id + " for protocol " + palette.protocolVersion()
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
NbtMapBuilder root = NbtMap.builder()
|
||||||
|
.putString("name", id)
|
||||||
|
.putInt("id", definition.getRuntimeId())
|
||||||
|
.putCompound("components", (NbtMap) entry.getValue());
|
||||||
|
|
||||||
|
componentItemData.add(new ComponentItemData(id, root.build()));
|
||||||
|
}
|
||||||
|
|
||||||
// Register the item forms of custom blocks
|
// Register the item forms of custom blocks
|
||||||
if (BlockRegistries.CUSTOM_BLOCKS.get().length != 0) {
|
if (BlockRegistries.CUSTOM_BLOCKS.get().length != 0) {
|
||||||
for (CustomBlockData customBlock : BlockRegistries.CUSTOM_BLOCKS.get()) {
|
for (CustomBlockData customBlock : BlockRegistries.CUSTOM_BLOCKS.get()) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ec45f59c8590945c9226921ef7e339f510983dc1
|
Subproject commit 88e50df1008916c266428ac11f76f07dc24638c5
|
Loading…
Reference in a new issue