Contents
Class ConnectedBlocksUtil
java.lang.Object
com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlocksUtil
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe outcome of evaluating aConnectedBlockRuleSet: the block type and rotation that should be applied at the evaluated position, plus any additional blocks that should be set at relative offsets (used by multi-block shapes like wide stairs). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDesiredConnectedBlockType(ChunkStore chunkStore, org.joml.Vector3ic coordinate, BlockType currentBlockType, int currentRotation, 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'sConnectedBlockRuleSet.static voidnotifyNeighborsAndCollectChanges(ChunkStore chunkStore, org.joml.Vector3ic origin, Map<org.joml.Vector3i, ConnectedBlocksUtil.ConnectedBlockResult> desiredChanges, org.joml.Vector3ic placementNormal) Walks the neighborhood aroundoriginand collects, intodesiredChanges, any neighbors whose connected-block rule set would produce a different block or rotation given the current world state.static voidsetConnectedBlockAndNotifyNeighbors(ChunkStore chunkStore, int blockTypeId, RotationTuple blockTypeRotation, org.joml.Vector3ic placementNormal, org.joml.Vector3ic blockPosition, Ref<ChunkStore> sectionRef, 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 toMAX_UPDATE_DEPTHblocks away.
-
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 toMAX_UPDATE_DEPTHblocks away.- Parameters:
chunkStore- TheChunkStorefor chunk component and data access.blockTypeId- The asset index of the block that was just placed, orBlockType.EMPTY_IDif 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 containingblockPosition.blockSection- TheBlockSectioncontainingblockPosition.
-
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 aroundoriginand collects, intodesiredChanges, 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- TheChunkStorefor 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'sConnectedBlockRuleSet.- Parameters:
chunkStore- TheChunkStorefor chunk component and data access.coordinate- The world coordinate of the block being evaluated.currentBlockType- The current block type atcoordinate.currentRotation- The current rotation index atcoordinate.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
OptionalifcurrentBlockTypehas no rule set or no pattern matched.
-