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

Remove blockstate version (#4011)

* Remove blockstate version

* Regr, add comment why version tag is removed
Dieser Commit ist enthalten in:
Valaphee The Meerkat 2023-09-06 20:19:51 +02:00 committet von GitHub
Ursprung 0d5cb51d5f
Commit 54bb1f3d13
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 10 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -83,8 +83,7 @@ public class ItemFrameEntity extends Entity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
NbtMapBuilder blockBuilder = NbtMap.builder() NbtMapBuilder blockBuilder = NbtMap.builder()
.putString("name", this.definition.entityType() == EntityType.GLOW_ITEM_FRAME ? "minecraft:glow_frame" : "minecraft:frame") .putString("name", this.definition.entityType() == EntityType.GLOW_ITEM_FRAME ? "minecraft:glow_frame" : "minecraft:frame");
.putInt("version", session.getBlockMappings().getBlockStateVersion());
NbtMapBuilder statesBuilder = NbtMap.builder() NbtMapBuilder statesBuilder = NbtMap.builder()
.putInt("facing_direction", direction.ordinal()) .putInt("facing_direction", direction.ordinal())
.putByte("item_frame_map_bit", (byte) 0) .putByte("item_frame_map_bit", (byte) 0)

Datei anzeigen

@ -147,6 +147,7 @@ public final class BlockRegistryPopulator {
vanillaBlockStates = new ArrayList<>(blockPalette.getList("blocks", NbtType.COMPOUND)); vanillaBlockStates = new ArrayList<>(blockPalette.getList("blocks", NbtType.COMPOUND));
for (int i = 0; i < vanillaBlockStates.size(); i++) { for (int i = 0; i < vanillaBlockStates.size(); i++) {
NbtMapBuilder builder = vanillaBlockStates.get(i).toBuilder(); NbtMapBuilder builder = vanillaBlockStates.get(i).toBuilder();
builder.remove("version"); // Remove all nbt tags which are not needed for differentiating states
builder.remove("name_hash"); // Quick workaround - was added in 1.19.20 builder.remove("name_hash"); // Quick workaround - was added in 1.19.20
builder.remove("network_id"); // Added in 1.19.80 - ???? builder.remove("network_id"); // Added in 1.19.80 - ????
builder.putCompound("states", statesInterner.intern((NbtMap) builder.remove("states"))); builder.putCompound("states", statesInterner.intern((NbtMap) builder.remove("states")));
@ -157,7 +158,6 @@ public final class BlockRegistryPopulator {
} catch (Exception e) { } catch (Exception e) {
throw new AssertionError("Unable to get blocks from runtime block states", e); throw new AssertionError("Unable to get blocks from runtime block states", e);
} }
int stateVersion = vanillaBlockStates.get(0).getInt("version");
List<BlockPropertyData> customBlockProperties = new ArrayList<>(); List<BlockPropertyData> customBlockProperties = new ArrayList<>();
List<NbtMap> customBlockStates = new ArrayList<>(); List<NbtMap> customBlockStates = new ArrayList<>();
@ -166,7 +166,7 @@ public final class BlockRegistryPopulator {
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()) {
customBlockProperties.add(CustomBlockRegistryPopulator.generateBlockPropertyData(customBlock, protocolVersion)); customBlockProperties.add(CustomBlockRegistryPopulator.generateBlockPropertyData(customBlock, protocolVersion));
CustomBlockRegistryPopulator.generateCustomBlockStates(customBlock, customBlockStates, customExtBlockStates, stateVersion); CustomBlockRegistryPopulator.generateCustomBlockStates(customBlock, customBlockStates, customExtBlockStates);
} }
blockStates.addAll(customBlockStates); blockStates.addAll(customBlockStates);
GeyserImpl.getInstance().getLogger().debug("Added " + customBlockStates.size() + " custom block states to v" + protocolVersion + " palette."); GeyserImpl.getInstance().getLogger().debug("Added " + customBlockStates.size() + " custom block states to v" + protocolVersion + " palette.");
@ -237,7 +237,7 @@ 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();
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.get(buildBedrockState(entry.getValue(), stateVersion, stateMapper)); GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.get(buildBedrockState(entry.getValue(), stateMapper));
GeyserBedrockBlock bedrockDefinition; GeyserBedrockBlock bedrockDefinition;
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId); CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);
@ -245,7 +245,7 @@ public final class BlockRegistryPopulator {
bedrockDefinition = vanillaBedrockDefinition; bedrockDefinition = vanillaBedrockDefinition;
if (bedrockDefinition == null) { if (bedrockDefinition == null) {
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" +
palette.getKey().key() + buildBedrockState(entry.getValue(), stateVersion, stateMapper)); palette.getKey().key() + buildBedrockState(entry.getValue(), stateMapper));
} }
} else { } else {
bedrockDefinition = customBlockStateDefinitions.get(blockStateOverride); bedrockDefinition = customBlockStateDefinitions.get(blockStateOverride);
@ -341,8 +341,7 @@ public final class BlockRegistryPopulator {
} }
}); });
BlockRegistries.BLOCKS.register(palette.getKey().valueInt(), builder.blockStateVersion(stateVersion) BlockRegistries.BLOCKS.register(palette.getKey().valueInt(), builder.bedrockRuntimeMap(bedrockRuntimeMap)
.bedrockRuntimeMap(bedrockRuntimeMap)
.javaToBedrockBlocks(javaToBedrockBlocks) .javaToBedrockBlocks(javaToBedrockBlocks)
.javaToVanillaBedrockBlocks(javaToVanillaBedrockBlocks) .javaToVanillaBedrockBlocks(javaToVanillaBedrockBlocks)
.stateDefinitionMap(blockStateOrderedMap) .stateDefinitionMap(blockStateOrderedMap)
@ -579,11 +578,10 @@ public final class BlockRegistryPopulator {
return blockStateSet; return blockStateSet;
} }
private static NbtMap buildBedrockState(JsonNode node, int blockStateVersion, BiFunction<String, NbtMapBuilder, String> statesMapper) { private static NbtMap buildBedrockState(JsonNode node, BiFunction<String, NbtMapBuilder, String> statesMapper) {
NbtMapBuilder tagBuilder = NbtMap.builder(); NbtMapBuilder tagBuilder = NbtMap.builder();
String bedrockIdentifier = node.get("bedrock_identifier").textValue(); String bedrockIdentifier = node.get("bedrock_identifier").textValue();
tagBuilder.putString("name", bedrockIdentifier) tagBuilder.putString("name", bedrockIdentifier);
.putInt("version", blockStateVersion);
NbtMapBuilder statesBuilder = NbtMap.builder(); NbtMapBuilder statesBuilder = NbtMap.builder();

Datei anzeigen

@ -200,9 +200,8 @@ public class CustomBlockRegistryPopulator {
* @param customBlock the custom block data to generate states for * @param customBlock the custom block data to generate states for
* @param blockStates the list of NBT maps to append the custom block states to * @param blockStates the list of NBT maps to append the custom block states to
* @param customExtBlockStates the list of custom block states to append the custom block states to * @param customExtBlockStates the list of custom block states to append the custom block states to
* @param stateVersion the state version to use for the custom block states
*/ */
static void generateCustomBlockStates(CustomBlockData customBlock, List<NbtMap> blockStates, List<CustomBlockState> customExtBlockStates, int stateVersion) { static void generateCustomBlockStates(CustomBlockData customBlock, List<NbtMap> blockStates, List<CustomBlockState> customExtBlockStates) {
int totalPermutations = 1; int totalPermutations = 1;
for (CustomBlockProperty<?> property : customBlock.properties().values()) { for (CustomBlockProperty<?> property : customBlock.properties().values()) {
totalPermutations *= property.values().size(); totalPermutations *= property.values().size();
@ -219,7 +218,6 @@ public class CustomBlockRegistryPopulator {
blockStates.add(NbtMap.builder() blockStates.add(NbtMap.builder()
.putString("name", customBlock.identifier()) .putString("name", customBlock.identifier())
.putInt("version", stateVersion)
.putCompound("states", states) .putCompound("states", states)
.build()); .build());
customExtBlockStates.add(new GeyserCustomBlockState(customBlock, states)); customExtBlockStates.add(new GeyserCustomBlockState(customBlock, states));

Datei anzeigen

@ -46,8 +46,6 @@ public class BlockMappings implements DefinitionRegistry<GeyserBedrockBlock> {
BlockDefinition bedrockWater; BlockDefinition bedrockWater;
BlockDefinition bedrockMovingBlock; BlockDefinition bedrockMovingBlock;
int blockStateVersion;
GeyserBedrockBlock[] javaToBedrockBlocks; GeyserBedrockBlock[] javaToBedrockBlocks;
GeyserBedrockBlock[] javaToVanillaBedrockBlocks; GeyserBedrockBlock[] javaToVanillaBedrockBlocks;