Contents
Class ConnectedBlockRuleSet
java.lang.Object
com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlockRuleSet
- Direct Known Subclasses:
CustomTemplateConnectedBlockRuleSet, PatternedConnectedBlockRuleSet, RoofConnectedBlockRuleSet, StairConnectedBlockRuleSet
Defines how a "smart block" (a block whose shape depends on its neighbors) chooses which concrete variant
to display based on the surrounding world.
Attached to a BlockType: when that block is placed or its neighbors change,
getConnectedBlockType(ChunkStore, Vector3ic, BlockType, int, Vector3ic, boolean) is invoked to produce the replacement block (e.g. stair corner vs. straight,
fence post vs. cross-piece). Subclasses pick the matching logic (stair-like, roof-like, or a pattern-based
template) and resolve to a ConnectedBlocksUtil.ConnectedBlockResult.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CodecMapCodec<ConnectedBlockRuleSet> The codec used to parseConnectedBlockRuleSetinstances. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetConnectedBlockType(ChunkStore chunkStore, org.joml.Vector3ic testedCoordinate, BlockType blockType, int rotation, org.joml.Vector3ic placementNormal, boolean isPlacement) Called to fetch the connected block type for a block at the given coordinate, with the given block type and rotation, when being placed or updated.abstract booleantoPacket(BlockTypeAssetMap<String, BlockType> assetMap) Called to create a new packet instance for this connected block rule set, using the given asset map to fetch connected block types by their asset ID.voidupdateCachedBlockTypes(BlockType blockType, BlockTypeAssetMap<String, BlockType> assetMap) Called once after asset resolution so the rule set can cache lookups against the resolved variants.
-
Field Details
-
CODEC
The codec used to parseConnectedBlockRuleSetinstances.
-
-
Constructor Details
-
ConnectedBlockRuleSet
public ConnectedBlockRuleSet()
-
-
Method Details
-
onlyUpdateOnPlacement
public abstract boolean onlyUpdateOnPlacement()- Returns:
trueif the block should only update its connected block type on placement,falseotherwise.
-
getConnectedBlockType
public abstract Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(@Nonnull ChunkStore chunkStore, @Nonnull org.joml.Vector3ic testedCoordinate, @Nonnull BlockType blockType, int rotation, @Nonnull org.joml.Vector3ic placementNormal, boolean isPlacement) Called to fetch the connected block type for a block at the given coordinate, with the given block type and rotation, when being placed or updated.- Parameters:
chunkStore- TheChunkStorefor chunk component and data access.testedCoordinate- The coordinate of the block being tested for connected block type updates.blockType- TheBlockTypeof the block being tested for connected block type updates.rotation- The rotation of the block being tested for connected block type updates.placementNormal- The face normal of the block being placed against, if the block is being placed. Otherwise, this will be a zero vector.isPlacement- Indicates whether the block is being placed (as opposed to updated).- Returns:
- an
Optionalcontaining theConnectedBlocksUtil.ConnectedBlockResultif a connected block type was found, or an emptyOptionalif no connected block type applies.
-
updateCachedBlockTypes
public void updateCachedBlockTypes(@Nonnull BlockType blockType, @Nonnull BlockTypeAssetMap<String, BlockType> assetMap) Called once after asset resolution so the rule set can cache lookups against the resolved variants. Implementations that maintain block-id to shape lookup maps should rebuild them here. The default implementation is a no-op; not all rule sets need cached state.- Parameters:
blockType- The baseBlockTypethat owns this rule set; variants resolve relative to it.assetMap- TheBlockTypeAssetMapfor resolving variant block types to their asset index.
-
toPacket
@Nullable public ConnectedBlockRuleSet toPacket(@Nonnull BlockTypeAssetMap<String, BlockType> assetMap) Called to create a new packet instance for this connected block rule set, using the given asset map to fetch connected block types by their asset ID.- Parameters:
assetMap- TheBlockTypeAssetMapfor fetching connected block types by their asset ID.- Returns:
- a new
ConnectedBlockRuleSetinstance representing this connected block rule set, ornullif this connected block rule set should not be sent to clients.
-
getUpdateMode
-