Class Prefetch

java.lang.Object
com.hypixel.hytale.builtin.buildertools.world.Prefetch

public final class Prefetch extends Object
Loads the chunks an edit reads or writes, and holds them on a PrefetchLease until the edit runs.

A load asks for the column and for every section the edit touches. The column unload gate reads only the column's own keep-loaded flag, so a held section does not keep its column resident on its own.

  • Field Details

    • DEFAULT_MAX_PREFETCH_COLUMNS

      public static final int DEFAULT_MAX_PREFETCH_COLUMNS
      How many columns an area may cover before it is held as it is instead of loaded.

      A selection reaches MAX_EDIT_BLOCK_COUNT cells, over sixty thousand columns for a flat box, which costs far more memory than the streaming window a player is served.

      See Also:
    • DEFAULT_MAX_PREFETCH_SECTIONS

      public static final int DEFAULT_MAX_PREFETCH_SECTIONS
      How many sections an area may cover before it is held as it is instead of loaded.

      A cubic world stacks sections without a ceiling, so a box of a few columns still reaches any amount of work through its Y span.

      See Also:
    • MASK_SHELL

      public static final int MASK_SHELL
      How far outside the cells it writes an edit reads. A mask filter judges a cell by the one next to it, so the box an edit walks is loaded with a shell this thick around it.
      See Also:
  • Method Details

    • forArea

      @Nonnull public static CompletableFuture<Void> forArea(@Nonnull World world, @Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, @Nonnull PrefetchLease lease, @Nonnull Prefetch.Budget budget)
      Loads the columns and the sections covering the inclusive box, and holds them on the lease. A box over the budget loads nothing, and holds only what is already in memory.
    • forArea

      @Nonnull public static CompletableFuture<Void> forArea(@Nonnull World world, @Nonnull Prefetch.Area area, @Nonnull PrefetchLease lease, @Nonnull Prefetch.Budget budget)
    • lineArea

      @Nonnull public static Prefetch.Area lineArea(int startX, int startY, int startZ, int endX, int endY, int endZ, int width, int height, @Nonnull BrushOrigin origin)
      The box an edit along a line reads and writes: the line, half the brush on every side, and the shift the origin setting applies. The Y reach is not symmetric, because an origin other than the centre moves the whole stamp a half height off the line.
    • grownArea

      @Nonnull public static Prefetch.Area grownArea(@Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, int amount)
      The inclusive box grown by amount on every side, ordered low to high. Growth stops at the coordinate range rather than wrapping.

      An edit reads a shell around the cells it writes. Mask filters of the above, below, adjacent and neighbour kinds judge a cell by the one next to it, and absent storage reads as air, so a shell left out makes the mask decide differently than it would with the world loaded.

    • brushOriginOffset

      public static int brushOriginOffset(@Nonnull BrushOrigin origin, int halfHeight)
      How far along Y a brush stamp sits from the cell it was aimed at. A stamp anchored at its bottom rests on top of that cell, and one anchored at its top hangs under it.
    • faceArea

      @Nonnull public static Prefetch.Area faceArea(int targetX, int targetY, int targetZ, int depth, int width, int length)
      The box a face edit reads and writes. The walk reaches its own half extent plus the depth away from the target, which is the reach the tool caches.
    • allSections

      @Nonnull public static CompletableFuture<Void> allSections(@Nonnull ChunkStore chunkStore, @Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, @Nonnull PrefetchLease lease)
      Loads every section covering the inclusive box, however many there are. The caller loads the columns itself.

      The count is not capped, so this is for a caller that writes the whole box to a file, where a section left out would reach the file as a hole. An edit goes through forArea(World, Vector3ic, Vector3ic, PrefetchLease, Prefetch.Budget), which stops at a limit and reports what it skipped.

    • forAreas

      @Nonnull public static CompletableFuture<Void> forAreas(@Nonnull World world, @Nonnull List<Prefetch.Area> areas, @Nonnull PrefetchLease lease, @Nonnull Prefetch.Budget budget)
      Loads the columns and the sections covering every box. An edit whose source and destination lie far apart passes them as separate boxes, so the empty space between them is not loaded.
    • loadsArea

      public static boolean loadsArea(@Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, @Nonnull Prefetch.Budget budget)
      Whether forArea(World, Vector3ic, Vector3ic, PrefetchLease, Prefetch.Budget) loads the box, or leaves it to be read as it is. A caller with a smaller area to fall back on asks this first, because an area over a limit loads nothing at all rather than as much as it can.
    • forMovedArea

      @Nonnull public static CompletableFuture<Void> forMovedArea(@Nonnull World world, @Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, int offsetX, int offsetY, int offsetZ, @Nonnull PrefetchLease lease, @Nonnull Prefetch.Budget budget)
      Loads the inclusive box together with the same box moved by the offset. The two boxes are loaded on their own, so a move over a long distance does not load the ground it passes over.
    • forExtrudedArea

      @Nonnull public static CompletableFuture<Void> forExtrudedArea(@Nonnull World world, @Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, @Nonnull org.joml.Vector3ic direction, int depth, int spacing, @Nonnull PrefetchLease lease, @Nonnull Prefetch.Budget budget)
      Loads the inclusive box together with everywhere an extrude of it copies to. A run whose last copy leaves the coordinate range loads nothing, and copiesWithinLimit(Vector3ic, Vector3ic, Vector3ic, int, int, Prefetch.Budget) refuses that depth as well.
    • copiesWithinLimit

      public static int copiesWithinLimit(@Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, @Nonnull org.joml.Vector3ic direction, int depth, int spacing, @Nonnull Prefetch.Budget budget)
      How many copies of an extrude stay within the load limits. The copies tile the space between the source box and the last one, so the run grows one stride at a time and a binary search finds the count.
    • copiesInMemory

      public static int copiesInMemory(@Nonnull World world, @Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max, @Nonnull org.joml.Vector3ic direction, int depth, int spacing, @Nonnull Prefetch.Budget budget)
      How many copies of an extrude the world already holds, counted outward from the source box. A run over the column limit is not loaded first, so this says whether it can go ahead on what is resident.
    • forSelection

      @Nonnull public static CompletableFuture<Void> forSelection(@Nonnull World world, @Nonnull BlockSelection selection, int originX, int originY, int originZ, @Nonnull PrefetchLease lease, @Nonnull Prefetch.Budget budget)
      Loads the region the selection covers when it is placed at the given origin.
    • forSnapshots

      @Nonnull public static CompletableFuture<Void> forSnapshots(@Nonnull World world, @Nonnull List<SelectionSnapshot<?>> snapshots, @Nonnull PrefetchLease lease)
      Loads the region every block selection in the snapshots covers. A snapshot restores at its own position.

      The limits an edit works under do not apply here. A restore cannot refuse or shrink itself the way an edit can, and a region left out would reach the world as a hole in the state the player asked to come back.