Class ConnectedBlocksUtil

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

public class ConnectedBlocksUtil extends Object
Utility methods for evaluating and applying connected-block updates when a block is placed or removed.

Connected blocks (stairs, fences, roofs, custom pattern-driven blocks, etc.) change shape based on their neighbors. After a block change, the placed block plus a bounded neighborhood around it must be re-evaluated so each block's shape stays consistent with its surroundings.

  • Constructor Details

    • ConnectedBlocksUtil

      public ConnectedBlocksUtil()
  • Method Details

    • setConnectedBlockAndNotifyNeighbors

      public static void setConnectedBlockAndNotifyNeighbors(@Nonnull ChunkStore chunkStore, int blockTypeId, @Nonnull RotationTuple blockTypeRotation, @Nonnull org.joml.Vector3ic placementNormal, @Nonnull org.joml.Vector3ic blockPosition, @Nonnull Ref<ChunkStore> sectionRef, @Nonnull BlockSection blockSection)
      Called after a block has been placed or removed to refresh its connected-block shape (if it is one) and propagate shape updates to neighbors up to MAX_UPDATE_DEPTH blocks away.
      Parameters:
      chunkStore - The ChunkStore for chunk component and data access.
      blockTypeId - The asset index of the block that was just placed, or BlockType.EMPTY_ID if the block was removed.
      blockTypeRotation - The rotation of the placed block.
      placementNormal - The face normal of the block placed against, or the zero vector for removals and non-placement updates.
      blockPosition - The world coordinate of the changed block.
      sectionRef - The reference of the chunk section containing blockPosition.
      blockSection - The BlockSection containing blockPosition.
    • notifyNeighborsAndCollectChanges

      public static void notifyNeighborsAndCollectChanges(@Nonnull ChunkStore chunkStore, @Nonnull org.joml.Vector3ic origin, @Nonnull Map<org.joml.Vector3i, ConnectedBlocksUtil.ConnectedBlockResult> desiredChanges, @Nonnull org.joml.Vector3ic placementNormal)
      Walks the neighborhood around origin and collects, into desiredChanges, any neighbors whose connected-block rule set would produce a different block or rotation given the current world state.

      Filler blocks are followed back to their origin block before evaluation so the result is keyed by the neighbor's real position, not its filler position.

      Parameters:
      chunkStore - The ChunkStore for chunk component and data access.
      origin - The world coordinate whose neighborhood is being evaluated.
      desiredChanges - Output map populated with neighbor coordinates that should change, mapped to the new block result. Entries already present are skipped to avoid revisiting.
      placementNormal - The face normal of the original placement, forwarded to rule-set evaluations.
    • getDesiredConnectedBlockType

      @Nonnull public static Optional<ConnectedBlocksUtil.ConnectedBlockResult> getDesiredConnectedBlockType(@Nonnull ChunkStore chunkStore, @Nonnull org.joml.Vector3ic coordinate, @Nonnull BlockType currentBlockType, int currentRotation, @Nonnull org.joml.Vector3ic placementNormal, boolean isPlacement)
      Resolves the desired connected-block result for the block at the given coordinate, by delegating to the block type's ConnectedBlockRuleSet.
      Parameters:
      chunkStore - The ChunkStore for chunk component and data access.
      coordinate - The world coordinate of the block being evaluated.
      currentBlockType - The current block type at coordinate.
      currentRotation - The current rotation index at coordinate.
      placementNormal - The face normal of the original placement, or the zero vector for updates.
      isPlacement - Indicates whether the block is being placed (as opposed to updated).
      Returns:
      the desired result, or an empty Optional if currentBlockType has no rule set or no pattern matched.