Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a way for "geyser_custom" blocks to be recognized by the reader. #5300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.geysermc.geyser.api.block.custom.CustomBlockData;
import org.geysermc.geyser.api.block.custom.CustomBlockPermutation;
import org.geysermc.geyser.api.block.custom.CustomBlockState;
import org.geysermc.geyser.api.block.custom.NonVanillaCustomBlockData;
import org.geysermc.geyser.api.block.custom.component.*;
import org.geysermc.geyser.api.block.custom.component.PlacementConditions.BlockFilterType;
import org.geysermc.geyser.api.block.custom.component.PlacementConditions.Face;
Expand Down Expand Up @@ -262,6 +263,20 @@ public CustomBlockMapping readBlockMappingEntry(String identifier, JsonNode node
.creativeCategory(creativeCategory)
.creativeGroup(creativeGroup);

// Check if block has the custom namespace, if so then use NonVanillaCustomBlockData
if (identifier.startsWith("geyser_custom:")) {
CustomBlockComponentsMapping componentsMapping = createCustomBlockComponentsMapping(node, identifier, name);
NonVanillaCustomBlockData blockData = NonVanillaCustomBlockData.builder()
.name(name)
.namespace("geyser_custom")
.includedInCreativeInventory(includedInCreativeInventory)
.creativeCategory(creativeCategory)
.creativeGroup(creativeGroup)
.components(componentsMapping.components())
.build();
return new CustomBlockMapping(blockData, Map.of(identifier, new CustomBlockStateMapping(blockData.defaultBlockState(), componentsMapping.extendedCollisionBox())), identifier, !onlyOverrideStates);
}

if (BlockRegistries.JAVA_IDENTIFIER_TO_ID.get().containsKey(identifier)) {
// There is only one Java block state to override
CustomBlockComponentsMapping componentsMapping = createCustomBlockComponentsMapping(node, identifier, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public static String getCleanIdentifier(String fullJavaIdentifier) {
}

public static BlockCollision getCollision(int blockId) {
if (blockId == -1) return null;
return BlockRegistries.COLLISIONS.get(blockId);
}

Expand Down
Loading