Class BlockOperations

java.lang.Object
com.hypixel.hytale.server.core.universe.world.chunk.BlockOperations

public class BlockOperations extends Object
  • Constructor Details

    • BlockOperations

      public BlockOperations()
  • Method Details

    • setBlock

      public static boolean setBlock(ChunkStore chunkStore, Ref<ChunkStore> sectionRef, ChunkSection section, BlockSection blockSection, BlockComponentSection blockComponentSection, HeightmapColumn heightmapColumn, int x, int y, int z, int id, @Nonnull BlockType blockType, int rotation, int filler, int settings)
    • setBlock

      public static boolean setBlock(@Nonnull ChunkStore chunkStore, @Nonnull Ref<ChunkStore> sectionRef, int x, int y, int z, int id, @Nonnull BlockType blockType, int rotation, int filler, int settings)
      One-off overload that resolves the section and column components from a section reference, then forwards to setBlock(ChunkStore, Ref, ChunkSection, BlockSection, BlockComponentSection, HeightmapColumn, int, int, int, int, BlockType, int, int, int). Callers writing any blocks within a section should resolve the components once and use the full overload instead.
    • setBlockPreLoad

      public static boolean setBlockPreLoad(@Nonnull ChunkSection section, @Nonnull BlockSection blockSection, int x, int y, int z, int id, int rotation, int filler)
      Applies a block change to a section holder during chunk pre-load processing, before the section is added to the store. Writes the palette and the ticking flag only: lighting is computed after load, block entities, physics, fillers and replication need a live store reference, and the heightmap is derived from the final section contents after the pre-load events run.
    • testPlaceBlock

      public static boolean testPlaceBlock(ComponentAccessor<ChunkStore> accessor, BlockSection section, int worldX, int worldY, int worldZ, @Nonnull BlockType blockTypeToTest, int rotationIndex)
    • testPlaceBlock

      public static boolean testPlaceBlock(ComponentAccessor<ChunkStore> accessor, BlockSection section, int worldX, int worldY, int worldZ, @Nonnull BlockType blockTypeToTest, int rotationIndex, BlockOperations.TestBlockFunction func)
      Tests whether a block of the given type and rotation could be placed at the given position, checking every cell covered by its rotated hitbox. Does not modify the world. Returns false if the block type has no hitbox asset, a cell falls in a section that isn't loaded, or a cell is occupied and func does not permit placing over it.
    • updateBlockArea

      public static void updateBlockArea(ChunkStore chunkStore, ChunkSection chunkSection, BlockSection section, BlockType blockType, int rotation, int x, int y, int z)
      Marks the surrounding area covered by the block's rotated bounding box as ticking, so those positions receive tick updates. For positions within the same chunk section, the ticking flag is set directly; for positions in other sections, the section is fetched asynchronously (without triggering chunk loading or generation).
      Parameters:
      chunkStore - the chunk store used to resolve cross-section references
      chunkSection - the chunk section containing the placed block
      section - the block section containing the placed block
      blockType - the type of block being placed, used to look up its hitbox
      rotation - the block's rotation variant index
      x - world x coordinate of the placed block
      y - world y coordinate of the placed block
      z - world z coordinate of the placed block
    • updateBlockArea

      public static void updateBlockArea(ChunkStore chunkStore, ChunkSection chunkSection, BlockSection section, int x, int y, int z)
      Marks the 3x3x3 area around a single block as ticking. Use this for changes that are not a block placement, such as a fluid edit, where there is no hitbox to cover.
      Parameters:
      chunkStore - the chunk store used to resolve cross-section references
      chunkSection - the chunk section containing the changed block
      section - the block section containing the changed block
      x - world x coordinate of the changed block
      y - world y coordinate of the changed block
      z - world z coordinate of the changed block
    • spawnBlockParticles

      public static void spawnBlockParticles(ChunkStore chunkStore, int oldBlockId, int newBlockId, int x, int y, int z, boolean isPhysics)
      Sends block particle effects to nearby players based on the type of block change.
      Parameters:
      chunkStore - the chunk store used to access the world notification handler
      oldBlockId - the block ID that was previously at this position
      newBlockId - the block ID now at this position
      x - world x coordinate of the block change
      y - world y coordinate of the block change
      z - world z coordinate of the block change
      isPhysics - whether the removal was caused by physics (e.g. gravity), which uses a different particle event than manual breaking
    • setBlockInteractionState

      public static void setBlockInteractionState(@Nonnull ChunkStore chunkStore, @Nonnull Ref<ChunkStore> chunkSectionReference, int x, int y, int z, @Nonnull BlockType blockType, @Nonnull String state, boolean force)
    • resolveBaseBlockPosition

      @Nonnull public static BlockPosition resolveBaseBlockPosition(@Nonnull ChunkStore chunkStore, @Nonnull BlockPosition position)
      Resolves the base block position for the given target position by following its filler offset back to the origin block. Returns the input position unchanged if the block's chunk section is not loaded or it is not a filler block.
      Parameters:
      chunkStore - The chunk store to read the filler from.
      position - The candidate target block position.
      Returns:
      The base block position, or position if no offset could be resolved.