Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 07:40:10 +01:00
Inventory overrides for multistate bedrock blocks
Dieser Commit ist enthalten in:
Ursprung
df710cb279
Commit
3d1d51d198
@ -164,6 +164,7 @@ public final class BlockRegistryPopulator {
|
|||||||
BiFunction<String, NbtMapBuilder, String> stateMapper = blockMappers.getOrDefault(palette.getKey(), emptyMapper);
|
BiFunction<String, NbtMapBuilder, String> stateMapper = blockMappers.getOrDefault(palette.getKey(), emptyMapper);
|
||||||
|
|
||||||
int[] javaToBedrockBlocks = new int[BLOCKS_JSON.size()];
|
int[] javaToBedrockBlocks = new int[BLOCKS_JSON.size()];
|
||||||
|
int[] javaToVanillaBedrockBlocks = new int[BLOCKS_JSON.size()];
|
||||||
|
|
||||||
Map<String, NbtMap> flowerPotBlocks = new Object2ObjectOpenHashMap<>();
|
Map<String, NbtMap> flowerPotBlocks = new Object2ObjectOpenHashMap<>();
|
||||||
Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
|
Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
|
||||||
@ -175,11 +176,12 @@ public final class BlockRegistryPopulator {
|
|||||||
javaRuntimeId++;
|
javaRuntimeId++;
|
||||||
Map.Entry<String, JsonNode> entry = blocksIterator.next();
|
Map.Entry<String, JsonNode> entry = blocksIterator.next();
|
||||||
String javaId = entry.getKey();
|
String javaId = entry.getKey();
|
||||||
|
int vanillaBedrockRuntimeId = blockStateOrderedMap.getOrDefault(buildBedrockState(entry.getValue(), stateVersion, stateMapper), -1);
|
||||||
|
|
||||||
int bedrockRuntimeId;
|
int bedrockRuntimeId;
|
||||||
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);
|
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);
|
||||||
if (blockStateOverride == null) {
|
if (blockStateOverride == null) {
|
||||||
bedrockRuntimeId = blockStateOrderedMap.getOrDefault(buildBedrockState(entry.getValue(), stateVersion, stateMapper), -1);
|
bedrockRuntimeId = vanillaBedrockRuntimeId;
|
||||||
if (bedrockRuntimeId == -1) {
|
if (bedrockRuntimeId == -1) {
|
||||||
throw new RuntimeException("Unable to find " + javaId + " Bedrock runtime ID! Built NBT tag: \n" +
|
throw new RuntimeException("Unable to find " + javaId + " Bedrock runtime ID! Built NBT tag: \n" +
|
||||||
buildBedrockState(entry.getValue(), stateVersion, stateMapper));
|
buildBedrockState(entry.getValue(), stateVersion, stateMapper));
|
||||||
@ -218,6 +220,7 @@ public final class BlockRegistryPopulator {
|
|||||||
flowerPotBlocks.put(cleanJavaIdentifier.intern(), blockStates.get(bedrockRuntimeId));
|
flowerPotBlocks.put(cleanJavaIdentifier.intern(), blockStates.get(bedrockRuntimeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
javaToVanillaBedrockBlocks[javaRuntimeId] = vanillaBedrockRuntimeId;
|
||||||
javaToBedrockBlocks[javaRuntimeId] = bedrockRuntimeId;
|
javaToBedrockBlocks[javaRuntimeId] = bedrockRuntimeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +255,7 @@ public final class BlockRegistryPopulator {
|
|||||||
|
|
||||||
BlockRegistries.BLOCKS.register(palette.getKey().valueInt(), builder.blockStateVersion(stateVersion)
|
BlockRegistries.BLOCKS.register(palette.getKey().valueInt(), builder.blockStateVersion(stateVersion)
|
||||||
.javaToBedrockBlocks(javaToBedrockBlocks)
|
.javaToBedrockBlocks(javaToBedrockBlocks)
|
||||||
|
.javaToVanillaBedrockBlocks(javaToVanillaBedrockBlocks)
|
||||||
.itemFrames(itemFrames)
|
.itemFrames(itemFrames)
|
||||||
.flowerPotBlocks(flowerPotBlocks)
|
.flowerPotBlocks(flowerPotBlocks)
|
||||||
.jigsawStateIds(jigsawStateIds)
|
.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
|
// 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();
|
Integer lastBlockRuntimeId = entry.getValue().getLastBlockRuntimeId() == null ? firstBlockRuntimeId : entry.getValue().getLastBlockRuntimeId();
|
||||||
for (int i = firstBlockRuntimeId; i <= lastBlockRuntimeId; i++) {
|
for (int i = firstBlockRuntimeId; i <= lastBlockRuntimeId; i++) {
|
||||||
int bedrockBlockRuntimeId = blockMappings.getBedrockBlockId(i);
|
int bedrockBlockRuntimeId = blockMappings.getVanillaBedrockBlockId(i);
|
||||||
NbtMap blockTag = blockMappings.getBedrockBlockStates().get(bedrockBlockRuntimeId);
|
NbtMap blockTag = blockMappings.getBedrockBlockStates().get(bedrockBlockRuntimeId);
|
||||||
String bedrockName = blockTag.getString("name");
|
String bedrockName = blockTag.getString("name");
|
||||||
if (!bedrockName.equals(correctBedrockIdentifier)) {
|
if (!bedrockName.equals(correctBedrockIdentifier)) {
|
||||||
|
@ -47,6 +47,7 @@ public class BlockMappings {
|
|||||||
int blockStateVersion;
|
int blockStateVersion;
|
||||||
|
|
||||||
int[] javaToBedrockBlocks;
|
int[] javaToBedrockBlocks;
|
||||||
|
int[] javaToVanillaBedrockBlocks;
|
||||||
|
|
||||||
NbtList<NbtMap> bedrockBlockStates;
|
NbtList<NbtMap> bedrockBlockStates;
|
||||||
int[] remappedVanillaIds;
|
int[] remappedVanillaIds;
|
||||||
@ -68,6 +69,13 @@ public class BlockMappings {
|
|||||||
return this.javaToBedrockBlocks[state];
|
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) {
|
public int getItemFrame(NbtMap tag) {
|
||||||
return this.itemFrames.getOrDefault(tag, -1);
|
return this.itemFrames.getOrDefault(tag, -1);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren