mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Inventory overrides for multistate bedrock blocks
This commit is contained in:
parent
df710cb279
commit
3d1d51d198
3 changed files with 14 additions and 2 deletions
|
@ -164,6 +164,7 @@ public final class BlockRegistryPopulator {
|
|||
BiFunction<String, NbtMapBuilder, String> stateMapper = blockMappers.getOrDefault(palette.getKey(), emptyMapper);
|
||||
|
||||
int[] javaToBedrockBlocks = new int[BLOCKS_JSON.size()];
|
||||
int[] javaToVanillaBedrockBlocks = new int[BLOCKS_JSON.size()];
|
||||
|
||||
Map<String, NbtMap> flowerPotBlocks = new Object2ObjectOpenHashMap<>();
|
||||
Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
|
||||
|
@ -175,11 +176,12 @@ public final class BlockRegistryPopulator {
|
|||
javaRuntimeId++;
|
||||
Map.Entry<String, JsonNode> entry = blocksIterator.next();
|
||||
String javaId = entry.getKey();
|
||||
int vanillaBedrockRuntimeId = blockStateOrderedMap.getOrDefault(buildBedrockState(entry.getValue(), stateVersion, stateMapper), -1);
|
||||
|
||||
int bedrockRuntimeId;
|
||||
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);
|
||||
if (blockStateOverride == null) {
|
||||
bedrockRuntimeId = blockStateOrderedMap.getOrDefault(buildBedrockState(entry.getValue(), stateVersion, stateMapper), -1);
|
||||
bedrockRuntimeId = vanillaBedrockRuntimeId;
|
||||
if (bedrockRuntimeId == -1) {
|
||||
throw new RuntimeException("Unable to find " + javaId + " Bedrock runtime ID! Built NBT tag: \n" +
|
||||
buildBedrockState(entry.getValue(), stateVersion, stateMapper));
|
||||
|
@ -218,6 +220,7 @@ public final class BlockRegistryPopulator {
|
|||
flowerPotBlocks.put(cleanJavaIdentifier.intern(), blockStates.get(bedrockRuntimeId));
|
||||
}
|
||||
|
||||
javaToVanillaBedrockBlocks[javaRuntimeId] = vanillaBedrockRuntimeId;
|
||||
javaToBedrockBlocks[javaRuntimeId] = bedrockRuntimeId;
|
||||
}
|
||||
|
||||
|
@ -252,6 +255,7 @@ public final class BlockRegistryPopulator {
|
|||
|
||||
BlockRegistries.BLOCKS.register(palette.getKey().valueInt(), builder.blockStateVersion(stateVersion)
|
||||
.javaToBedrockBlocks(javaToBedrockBlocks)
|
||||
.javaToVanillaBedrockBlocks(javaToVanillaBedrockBlocks)
|
||||
.itemFrames(itemFrames)
|
||||
.flowerPotBlocks(flowerPotBlocks)
|
||||
.jigsawStateIds(jigsawStateIds)
|
||||
|
|
|
@ -375,7 +375,7 @@ public class ItemRegistryPopulator {
|
|||
// and the last, if relevant. We then iterate over all those values and get their Bedrock equivalents
|
||||
Integer lastBlockRuntimeId = entry.getValue().getLastBlockRuntimeId() == null ? firstBlockRuntimeId : entry.getValue().getLastBlockRuntimeId();
|
||||
for (int i = firstBlockRuntimeId; i <= lastBlockRuntimeId; i++) {
|
||||
int bedrockBlockRuntimeId = blockMappings.getBedrockBlockId(i);
|
||||
int bedrockBlockRuntimeId = blockMappings.getVanillaBedrockBlockId(i);
|
||||
NbtMap blockTag = blockMappings.getBedrockBlockStates().get(bedrockBlockRuntimeId);
|
||||
String bedrockName = blockTag.getString("name");
|
||||
if (!bedrockName.equals(correctBedrockIdentifier)) {
|
||||
|
|
|
@ -47,6 +47,7 @@ public class BlockMappings {
|
|||
int blockStateVersion;
|
||||
|
||||
int[] javaToBedrockBlocks;
|
||||
int[] javaToVanillaBedrockBlocks;
|
||||
|
||||
NbtList<NbtMap> bedrockBlockStates;
|
||||
int[] remappedVanillaIds;
|
||||
|
@ -68,6 +69,13 @@ public class BlockMappings {
|
|||
return this.javaToBedrockBlocks[state];
|
||||
}
|
||||
|
||||
public int getVanillaBedrockBlockId(int state) {
|
||||
if (state >= this.javaToVanillaBedrockBlocks.length) {
|
||||
return bedrockAirId;
|
||||
}
|
||||
return this.javaToVanillaBedrockBlocks[state];
|
||||
}
|
||||
|
||||
public int getItemFrame(NbtMap tag) {
|
||||
return this.itemFrames.getOrDefault(tag, -1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue