Class FillerBlockUtil

java.lang.Object
com.hypixel.hytale.server.core.util.FillerBlockUtil

public class FillerBlockUtil extends Object
Since:
19/4/18
Version:
1.0
  • Field Details

  • Constructor Details

    • FillerBlockUtil

      public FillerBlockUtil()
  • Method Details

    • forEachFillerBlock

      public static void forEachFillerBlock(@Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes, @Nonnull TriIntConsumer consumer)
    • forEachFillerBlock

      public static void forEachFillerBlock(float threshold, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes, @Nonnull TriIntConsumer consumer)
    • forEachFillerBlock

      public static void forEachFillerBlock(float threshold, int expand, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes, @Nonnull TriIntConsumer consumer)
    • forEachFillerBlock

      public static void forEachFillerBlock(float threshold, int expandX, int expandY, int expandZ, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes, @Nonnull TriIntConsumer consumer)
    • testFillerBlocks

      public static boolean testFillerBlocks(@Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes, @Nonnull TriIntPredicate predicate)
    • testFillerBlocks

      public static boolean testFillerBlocks(float threshold, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes, @Nonnull TriIntPredicate predicate)
    • packedMinCell

      public static int packedMinCell(@Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes)
      Returns the lowest cell of a footprint, packed with pack(int, int, int). Together with packedMaxCell(BlockBoundingBoxes.RotatedVariantBoxes) it gives the inclusive offset range that forEachFillerBlock(BlockBoundingBoxes.RotatedVariantBoxes, TriIntConsumer) walks.
    • packedMaxCell

      public static int packedMaxCell(@Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes)
      Returns the highest cell of a footprint, packed with pack(int, int, int).
    • multiCellFootprint

      @Nullable public static BlockBoundingBoxes.RotatedVariantBoxes multiCellFootprint(int blockId, int rotation)
      Returns the rotated boxes of a block whose hitbox protrudes past the unit cube (a multi-cell block), or null for single-cell blocks, unknown ids, or blocks without a hitbox. Callers use the result both to decide whether filler handling is required and to iterate the footprint via forEachFillerBlock(BlockBoundingBoxes.RotatedVariantBoxes, TriIntConsumer).
    • isFootprintFree

      public static boolean isFootprintFree(@Nonnull it.unimi.dsi.fastutil.longs.LongOpenHashSet occupied, int x, int y, int z, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes boxes)
      Tests whether every cell of the boxes footprint anchored at world (x,y,z) is absent from occupied. Used to tile multi-cell blocks within a single edit pass without overlap.
    • isFootprintFree

      public static boolean isFootprintFree(@Nonnull Int3OpenHashSet occupied, int x, int y, int z, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes boxes)
      Tests whether every cell of the boxes footprint anchored at world (x,y,z) is absent from occupied.

      BlockUtil.pack(int, int, int) cannot hold the Y of a cubic world, so an edit that reaches any Y keys its occupancy by coordinate instead.

    • markFootprint

      public static void markFootprint(@Nonnull it.unimi.dsi.fastutil.longs.LongOpenHashSet occupied, int x, int y, int z, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes boxes)
      Adds every cell of the boxes footprint anchored at world (x,y,z) to occupied so later placements in the same pass cannot land on it.
    • markFootprint

      public static void markFootprint(@Nonnull Int3OpenHashSet occupied, int x, int y, int z, @Nonnull BlockBoundingBoxes.RotatedVariantBoxes boxes)
      Adds every cell of the boxes footprint anchored at world (x,y,z) to occupied, keyed by coordinate as isFootprintFree(Int3OpenHashSet, int, int, int, BlockBoundingBoxes.RotatedVariantBoxes) describes.
    • validateBlock

      public static <A,B> FillerBlockUtil.ValidationResult validateBlock(int x, int y, int z, int blockId, int rotation, int filler, A a, B b, @Nonnull FillerBlockUtil.FillerFetcher<A,B> fetcher)
    • pack

      public static int pack(int x, int y, int z)
    • unpackX

      public static int unpackX(int val)
    • unpackY

      public static int unpackY(int val)
    • unpackZ

      public static int unpackZ(int val)
    • removeFillerBlocksAt

      public static void removeFillerBlocksAt(@Nonnull ComponentAccessor<ChunkStore> accessor, BlockSection blockSection, BlockComponentSection blockComponentSection, int x, int y, int z, int blockId, int filler, int rotation, FillerBlockUtil.ChangeReason changeReason)
      Removes all sibling filler blocks belonging to the same multi-block structure as the block at (x, y, z). The filler offset is unpacked to locate the base (origin) block, then every filler position in the hitbox bounding box is cleared — except the position being removed by the caller.

      Filler blocks in the same chunk section are removed synchronously via the provided blockSection. Filler blocks in other sections are removed synchronously if the section is already loaded, or asynchronously if it needs to be fetched.

      Parameters:
      accessor - component accessor for looking up chunk data
      blockSection - the block section containing the block at (x, y, z)
      x - world x coordinate of the block being removed
      y - world y coordinate of the block being removed
      z - world z coordinate of the block being removed
      blockId - the block type ID at (x, y, z), used to match sibling fillers
      filler - the packed filler offset of this block relative to the base block
      rotation - the rotation index of the multi-block structure
      changeReason - controls whether particles are spawned for removed fillers
    • setFillerBlocksAt

      public static void setFillerBlocksAt(@Nonnull ComponentAccessor<ChunkStore> accessor, @Nonnull Ref<ChunkStore> ref, BlockSection blockSection, BlockComponentSection blockComponentSection, int x, int y, int z, int blockId, int filler, int rotation, FillerBlockUtil.ChangeReason changeReason)
      Places all sibling filler blocks for the multi-block structure that the block at (x, y, z) belongs to. The filler offset is unpacked to locate the base (origin) block, then every filler position in the hitbox bounding box is written — except the caller's own position.

      Filler blocks in the same chunk section are placed synchronously via the provided blockSection. Filler blocks in other sections are placed synchronously if the section is already loaded, or asynchronously if it needs to be fetched.

      Parameters:
      accessor - component accessor for looking up chunk data
      ref - reference to the chunk section
      blockSection - the block section containing the block at (x, y, z)
      x - world x coordinate of the block being placed
      y - world y coordinate of the block being placed
      z - world z coordinate of the block being placed
      blockId - the block type ID at (x, y, z), written to all filler positions
      filler - the packed filler offset of this block relative to the base block
      rotation - the rotation index of the multi-block structure
      changeReason - controls whether particles are spawned when replacing existing blocks