Class ChunkDataHelper

java.lang.Object
com.minecolonies.core.util.ChunkDataHelper

public final class ChunkDataHelper extends Object
Class to take care of chunk data helper.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canClaimChunksInRange(net.minecraft.world.level.Level w, net.minecraft.core.BlockPos pos, int range)
    Check if all chunks within a certain range can be claimed, if range is too big this might require to load chunks.
    static void
    claimBuildingChunks(Colony colony, boolean add, net.minecraft.core.BlockPos center, int range, @Nullable net.minecraft.util.Tuple<net.minecraft.core.BlockPos,net.minecraft.core.BlockPos> corners)
    Notify all chunks in the range of the colony about the colony.
    static void
    claimColonyChunks(net.minecraft.server.level.ServerLevel world, boolean add, Colony colony, net.minecraft.core.BlockPos center)
    Notify all chunks in the range of the colony about the colony.
    static void
    loadChunk(net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.server.level.ServerLevel world)
    Load the colony info for a certain chunk.
    static void
    staticClaimInRange(Colony colony, boolean add, net.minecraft.core.BlockPos center, int range, net.minecraft.server.level.ServerLevel world, boolean forceOwnerChange)
    Claim a number of chunks in a certain range around a position.
    static boolean
    tryClaim(net.minecraft.server.level.ServerLevel world, net.minecraft.core.BlockPos chunkBlockPos, boolean add, Colony colony, boolean forceOwnerChange)
    Add the data to the chunk directly.
    static boolean
    tryClaimBuilding(net.minecraft.server.level.ServerLevel world, net.minecraft.world.level.ChunkPos chunkBlockPos, boolean add, Colony colony, net.minecraft.core.BlockPos buildingPos)
    Add the data to the chunk directly for dynamic claiming.
    static void
    unloadChunk(net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.world.level.Level world)
    Called when a chunk is unloaded

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • loadChunk

      public static void loadChunk(net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.server.level.ServerLevel world)
      Load the colony info for a certain chunk.
      Parameters:
      chunk - the chunk.
      world - the worldg to.
    • unloadChunk

      public static void unloadChunk(net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.world.level.Level world)
      Called when a chunk is unloaded
      Parameters:
      chunk - the chunk that is unloading.
      world - the world it is unloading in.
    • claimColonyChunks

      public static void claimColonyChunks(net.minecraft.server.level.ServerLevel world, boolean add, Colony colony, net.minecraft.core.BlockPos center)
      Notify all chunks in the range of the colony about the colony.
      Parameters:
      world - the world.
      add - if add or remove.
      colony - the colony.
      center - the center chunk.
    • claimBuildingChunks

      public static void claimBuildingChunks(Colony colony, boolean add, net.minecraft.core.BlockPos center, int range, @Nullable @Nullable net.minecraft.util.Tuple<net.minecraft.core.BlockPos,net.minecraft.core.BlockPos> corners)
      Notify all chunks in the range of the colony about the colony.

      --- This is only for dynamic claiming ---

      Parameters:
      colony - the colony to claim for
      add - if add or remove.
      center - the center position of the colony.
      range - the range to claim.
      corners - also (un)claim all chunks intersecting this box (if not null)
    • canClaimChunksInRange

      public static boolean canClaimChunksInRange(net.minecraft.world.level.Level w, net.minecraft.core.BlockPos pos, int range)
      Check if all chunks within a certain range can be claimed, if range is too big this might require to load chunks. Use carefully.

      --- This is only for dynamic claiming ---

      Parameters:
      w - the world.
      pos - the center position.
      range - the range to check.
      Returns:
      true if possible.
    • staticClaimInRange

      public static void staticClaimInRange(Colony colony, boolean add, net.minecraft.core.BlockPos center, int range, net.minecraft.server.level.ServerLevel world, boolean forceOwnerChange)
      Claim a number of chunks in a certain range around a position.
      Parameters:
      colony - the colony.
      add - if claim or unclaim.
      center - the center position to be claimed.
      range - the range.
      world - the world.
    • tryClaim

      public static boolean tryClaim(net.minecraft.server.level.ServerLevel world, net.minecraft.core.BlockPos chunkBlockPos, boolean add, Colony colony, boolean forceOwnerChange)
      Add the data to the chunk directly.
      Parameters:
      world - the world.
      chunkBlockPos - the position.
      add - if add or delete.
      colony - the colony.
      Returns:
      true if successful.
    • tryClaimBuilding

      public static boolean tryClaimBuilding(net.minecraft.server.level.ServerLevel world, net.minecraft.world.level.ChunkPos chunkBlockPos, boolean add, Colony colony, net.minecraft.core.BlockPos buildingPos)
      Add the data to the chunk directly for dynamic claiming.

      ----- Only for dynamic claiming -----

      Parameters:
      world - the world.
      chunkBlockPos - the position.
      add - if add or delete.
      colony - the colony.
      buildingPos - the building pos.
      Returns:
      true if successful.