Class CustomTemplateConnectedBlockRuleSet

java.lang.Object
com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlockRuleSet
com.hypixel.hytale.server.core.universe.world.connectedblocks.CustomTemplateConnectedBlockRuleSet

public class CustomTemplateConnectedBlockRuleSet extends ConnectedBlockRuleSet
A ConnectedBlockRuleSet that delegates pattern matching to a CustomConnectedBlockTemplateAsset.

The template names a set of shapes; this rule set maps each shape name to a BlockPattern that describes which concrete BlockTypes represent that shape. At placement or update time, the template's patterns are evaluated against the world, and the matching shape's BlockPattern selects the resulting block.

  • Field Details

  • Constructor Details

    • CustomTemplateConnectedBlockRuleSet

      public CustomTemplateConnectedBlockRuleSet()
  • Method Details

    • getShapeNameToBlockPatternMap

      @Nonnull public Map<String, BlockPattern> getShapeNameToBlockPatternMap()
      Returns:
      the map of shape names to the BlockPattern that produces the resulting block when that shape matches.
    • updateCachedBlockTypes

      public void updateCachedBlockTypes(@Nonnull BlockType blockType, @Nonnull BlockTypeAssetMap<String, BlockType> assetMap)
      Description copied from class: ConnectedBlockRuleSet
      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.
      Overrides:
      updateCachedBlockTypes in class ConnectedBlockRuleSet
      Parameters:
      blockType - The base BlockType that owns this rule set; variants resolve relative to it.
      assetMap - The BlockTypeAssetMap for resolving variant block types to their asset index.
    • getShapesForBlockType

      @Nonnull public Set<String> getShapesForBlockType(int blockTypeKey)
      Parameters:
      blockTypeKey - The asset index of the block type to look up.
      Returns:
      the shape names that resolve to the given block type, or an empty set if none do. Never null.
    • getShapeTemplateAsset

      @Nullable public CustomConnectedBlockTemplateAsset getShapeTemplateAsset()
      Returns:
      the CustomConnectedBlockTemplateAsset this rule set delegates to, or null if no asset with the configured id is registered.
    • onlyUpdateOnPlacement

      public boolean onlyUpdateOnPlacement()
      Specified by:
      onlyUpdateOnPlacement in class ConnectedBlockRuleSet
      Returns:
      true if the block should only update its connected block type on placement, false otherwise.
    • getConnectedBlockType

      @Nonnull public Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(@Nonnull ChunkStore chunkStore, @Nonnull org.joml.Vector3ic testedCoordinate, @Nonnull BlockType blockType, int rotation, @Nonnull org.joml.Vector3ic placementNormal, boolean isPlacement)
      Description copied from class: ConnectedBlockRuleSet
      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.
      Specified by:
      getConnectedBlockType in class ConnectedBlockRuleSet
      Parameters:
      chunkStore - The ChunkStore for chunk component and data access.
      testedCoordinate - The coordinate of the block being tested for connected block type updates.
      blockType - The BlockType of 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 Optional containing the ConnectedBlocksUtil.ConnectedBlockResult if a connected block type was found, or an empty Optional if no connected block type applies.