Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Data Asset Sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ This file has been generated using `./gradlew generateBedrockSoundLists` from th
[Mojang/bedrock-samples](https://github.com/Mojang/bedrock-samples/blob/84aa19df535fcf6d044f28bf76f236029bd8407a/metadata/doc_modules/addons.json)
[wiki.bedrock.dev](https://wiki.bedrock.dev/blocks/block-traits.html)

### data/bedrock/data_driven_blocks.nbt
[CloudburstMC/Data](https://github.com/CloudburstMC/Data/blob/e5c84599b43b2670e9c22ae3d032f925a7d9590c/data_driven_blocks.nbt)

### data/bedrock/effects.json

[minecraft.wiki](https://minecraft.wiki/w/Effect)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class BedrockMappingData extends MappingDataBase {
private IntSet javaFluidBlockStates;
private Int2IntMap javaPottedBlockStates;
private Map<String, IntSet> javaHeightMapBlockStates;
private Set<String> dataDrivenBedrockBlocks;

// Biomes
private CompoundTag bedrockBiomeDefinitions;
Expand Down Expand Up @@ -352,6 +353,13 @@ public void load() {
}
this.javaHeightMapBlockStates.put(entry.getKey(), blockStates);
}

final CompoundTag dataDrivenBedrockBlocksTag = this.readNbt("bedrock/data_driven_blocks.nbt");
this.dataDrivenBedrockBlocks = new HashSet<>(dataDrivenBedrockBlocksTag.size());
for (Map.Entry<String, Tag> entry : dataDrivenBedrockBlocksTag.getValue().entrySet()) {
this.dataDrivenBedrockBlocks.add(entry.getKey());
}

}

{ // Biomes
Expand Down Expand Up @@ -1101,6 +1109,10 @@ public Map<String, IntSet> getJavaHeightMapBlockStates() {
return this.javaHeightMapBlockStates;
}

public Set<String> getBedrockDataDrivenBlocks() {
return this.dataDrivenBedrockBlocks;
}

public CompoundTag getBedrockBiomeDefinitions() {
return this.bedrockBiomeDefinitions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public BlockStateRewriter(final BlockProperties[] blockProperties, final boolean
this.blockStateIdMappings.defaultReturnValue(-1);
this.legacyBlockStateIdMappings.defaultReturnValue(-1);

final List<BedrockBlockState> bedrockBlockStates = new ArrayList<>(BedrockProtocol.MAPPINGS.getBedrockBlockStates());
final List<BedrockBlockState> bedrockBlockStates = this.getBedrockBlockStates(blockProperties);
final Map<BlockState, Integer> javaBlockStates = BedrockProtocol.MAPPINGS.getJavaBlockStates();
final Map<BlockState, BlockState> bedrockToJavaBlockStates = BedrockProtocol.MAPPINGS.getBedrockToJavaBlockStates();
final Map<String, String> blockTags = BedrockProtocol.MAPPINGS.getBedrockCustomBlockTags();
Expand Down Expand Up @@ -192,6 +192,22 @@ public BlockStateRewriter(final BlockProperties[] blockProperties, final boolean
this.blockStateSanitizer = new BlockStateSanitizer(bedrockBlockStates);
}

private List<BedrockBlockState> getBedrockBlockStates(final BlockProperties[] definitions) {
final Set<String> registered = new HashSet<>();
for (final BlockProperties definition : definitions) {
if (definition.properties().contains("vanilla_block_data")) {
registered.add(definition.name().toLowerCase(Locale.ROOT));
}
}
final List<BedrockBlockState> states = new ArrayList<>(BedrockProtocol.MAPPINGS.getBedrockBlockStates().size());
for (final BedrockBlockState state : BedrockProtocol.MAPPINGS.getBedrockBlockStates()) {
if (!BedrockProtocol.MAPPINGS.getBedrockDataDrivenBlocks().contains(state.namespacedIdentifier()) || registered.contains(state.namespacedIdentifier())) {
states.add(state);
}
}
return states;
}

public int bedrockId(final CompoundTag bedrockBlockStateTag) {
final CompoundTag bedrockBlockStateTagClone = bedrockBlockStateTag.copy();
try {
Expand Down
Binary file not shown.