Interface IColonyManager

All Known Implementing Classes:
ColonyManager

public interface IColonyManager
  • Method Details

    • getInstance

      static IColonyManager getInstance()
    • createColony

      @Nullable @Nullable IColony createColony(@NotNull @NotNull net.minecraft.server.level.ServerLevel w, net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull String colonyName, @NotNull @NotNull String pack)
      Create a new Colony in the given world and at that location.
      Parameters:
      w - World of the colony.
      pos - Coordinate of the center of the colony.
      player - the player that creates the colony - owner.
      colonyName - the initial colony name.
      pack - the default pack of the colony.
      Returns:
      the created colony instance.
    • deleteColonyByWorld

      void deleteColonyByWorld(int id, boolean canDestroy, net.minecraft.server.level.ServerLevel world)
      Delete the colony in a world.
      Parameters:
      id - the id of it.
      canDestroy - if can destroy the buildings.
      world - the world.
    • deleteColonyByDimension

      void deleteColonyByDimension(int id, boolean canDestroy, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
      Delete the colony by dimension.
      Parameters:
      id - the id of it.
      canDestroy - if can destroy the buildings.
      dimension - the dimension.
    • removeColonyView

      void removeColonyView(int id, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
      Removes a colony view
      Parameters:
      id - the id of the colony.
      dimension - the dimension it is in.
    • getColonyByWorld

      @Nullable @Nullable IColony getColonyByWorld(int id, net.minecraft.world.level.Level world)
      Get Colony by UUID.
      Parameters:
      id - ID of colony.
      world - the world it is in.
      Returns:
      Colony with given ID.
    • getColonyByDimension

      @Nullable @Nullable IColony getColonyByDimension(int id, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
      Get Colony by UUID.
      Parameters:
      id - ID of colony.
      dimension - the dimension it is in.
      Returns:
      Colony with given ID.
    • getBuilding

      IBuilding getBuilding(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Get a AbstractBuilding by a World and coordinates.
      Parameters:
      w - World.
      pos - Block position.
      Returns:
      AbstractBuilding at the given location.
    • getColonyByPosFromWorld

      @Nullable @Nullable IColony getColonyByPosFromWorld(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Get colony that contains a given coordinate from world.
      Parameters:
      w - World.
      pos - coordinates.
      Returns:
      Colony at the given location.
    • getColonyByPosFromDim

      IColony getColonyByPosFromDim(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Get colony that contains a given coordinate from dimension.
      Parameters:
      dim - the dimension.
      pos - coordinates.
      Returns:
      Colony at the given location.
    • isFarEnoughFromColonies

      boolean isFarEnoughFromColonies(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Check if a position is too close to another colony to found a new colony.
      Parameters:
      w - World.
      pos - coordinates.
      Returns:
      true if so.
    • getColonies

      @NotNull @NotNull List<IColony> getColonies(@NotNull @NotNull net.minecraft.world.level.Level w)
      Get all colonies in this world.
      Parameters:
      w - World.
      Returns:
      a list of colonies.
    • getAllColonies

      @NotNull @NotNull List<IColony> getAllColonies()
      Get all colonies in all worlds.
      Returns:
      a list of colonies.
    • getColoniesAbandonedSince

      @NotNull @NotNull List<IColony> getColoniesAbandonedSince(int abandonedSince)
      Get all colonies in all worlds.
      Parameters:
      abandonedSince - time in hours since the last contact.
      Returns:
      a list of colonies.
    • getBuildingView

      IBuildingView getBuildingView(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension, net.minecraft.core.BlockPos pos)
      Get a AbstractBuilding by position.
      Parameters:
      dimension - the dimension it is in.
      pos - Block position.
      Returns:
      Returns the view belonging to the building at (x, y, z).
    • getIColonies

      @NotNull @NotNull List<IColony> getIColonies(@NotNull @NotNull net.minecraft.world.level.Level w)
      Get all colonies in this world. (Side neutral; on clients it returns the subset of views known to the player.)
      Parameters:
      w - World.
      Returns:
      a list of colonies.
    • getIColony

      @Nullable @Nullable IColony getIColony(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Side neutral method to get colony. On clients it returns the view. On servers it returns the colony itself.
      Parameters:
      w - World.
      pos - coordinates.
      Returns:
      View of colony or colony itself depending on side.
    • getColonyViews

      @NotNull @NotNull List<IColonyView> getColonyViews(@NotNull @NotNull net.minecraft.world.level.Level w)
      Get all colony views in this world known to the current player.
      Parameters:
      w - World.
      Returns:
      a list of colony views.
    • getColonyView

      IColonyView getColonyView(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Gets the colony view aat the given position
      Parameters:
      w -
      pos -
      Returns:
      IColonyView
    • getClosestIColony

      @Nullable @Nullable IColony getClosestIColony(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Side neutral method to get colony. On clients it returns the view. On servers it returns the colony itself. getClosestColony(Level, BlockPos)
      Parameters:
      w - World.
      pos - Block position.
      Returns:
      View of colony or colony itself depending on side, closest to coordinates.
    • getClosestColonyView

      @Nullable @Nullable IColonyView getClosestColonyView(@Nullable @Nullable net.minecraft.world.level.Level w, @Nullable @Nullable net.minecraft.core.BlockPos pos)
      Parameters:
      w - World.
      pos - Block Position.
      Returns:
      View of the closest colony.
    • getClosestColony

      IColony getClosestColony(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Get closest colony by x,y,z.
      Parameters:
      w - World.
      pos - coordinates.
      Returns:
      Colony closest to coordinates.
    • getIColonyByOwner

      @Nullable @Nullable IColony getIColonyByOwner(@NotNull @NotNull net.minecraft.world.level.Level w, @NotNull @NotNull net.minecraft.world.entity.player.Player owner)
      Side neutral method to get colony. On clients it returns the view. On servers it returns the colony itself.

      Returns a colony or view with the given Player as owner.

      Parameters:
      w - World.
      owner - Entity Player.
      Returns:
      IColony belonging to specific player.
    • getIColonyByOwner

      @Nullable @Nullable IColony getIColonyByOwner(@NotNull @NotNull net.minecraft.world.level.Level w, UUID owner)
      Side neutral method to get colony. On clients it returns the view. On servers it returns the colony itself.

      Returns a colony or view with given Player as owner.

      Parameters:
      w - World
      owner - UUID of the owner.
      Returns:
      IColony belonging to specific player.
    • getMinimumDistanceBetweenTownHalls

      int getMinimumDistanceBetweenTownHalls()
      Returns the minimum distance between two town halls, to not make colonies collide.
      Returns:
      Minimum town hall distance.
    • onServerTick

      void onServerTick(@NotNull net.neoforged.neoforge.event.tick.ServerTickEvent.Pre event)
      On server tick, tick every Colony. NOTE: Review this for performance.
      Parameters:
      event - ServerTickEvent
    • write

      void write(net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Write colonies to NBT data for saving.
      Parameters:
      compound - NBT-Tag.
    • read

      void read(net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Read Colonies from saved NBT data.
      Parameters:
      compound - NBT Tag.
    • onClientTick

      void onClientTick(@NotNull net.neoforged.neoforge.client.event.ClientTickEvent.Pre event)
      On Client tick, clears views when player left.
      Parameters:
      event - ClientTickEvent.
    • onWorldTick

      void onWorldTick(@NotNull net.neoforged.neoforge.event.tick.LevelTickEvent.Pre event)
      On world tick, tick every Colony in that world. NOTE: Review this for performance.
    • onWorldLoad

      void onWorldLoad(@NotNull @NotNull net.minecraft.world.level.Level world)
      When a world is loaded, Colonies in that world need to grab the reference to the World. Additionally, when loading the first world, load the manager data.
      Parameters:
      world - World.
    • onWorldUnload

      void onWorldUnload(@NotNull @NotNull net.minecraft.world.level.Level world)
      When a world unloads, all colonies in that world are informed. Additionally, when the last world is unloaded, delete all colonies.
      Parameters:
      world - World.
    • handleColonyViewMessage

      void handleColonyViewMessage(int colonyId, @NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf colonyData, boolean isNewSubscription, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Sends view message to the right view.
      Parameters:
      colonyId - ID of the colony.
      colonyData - RegistryFriendlyByteBuf with colony data.
      isNewSubscription - whether this is a new subscription or not.
      dim - the dimension.
    • getColonyView

      IColonyView getColonyView(int id, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
      Get IColonyView by ID.
      Parameters:
      id - ID of colony.
      dimension - the dimension id.
      Returns:
      The IColonyView belonging to the colony.
    • handlePermissionsViewMessage

      void handlePermissionsViewMessage(int colonyID, @NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf data, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Parameters:
      colonyID - ID of the colony.
      data - RegistryFriendlyByteBuf with colony data.
      dim - the dimension.
    • handleColonyViewCitizensMessage

      void handleColonyViewCitizensMessage(int colonyId, int citizenId, net.minecraft.network.RegistryFriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Parameters:
      colonyId - ID of the colony.
      citizenId - ID of the citizen.
      buf - RegistryFriendlyByteBuf with colony data.
      dim - the dimension.
    • handleColonyViewWorkOrderMessage

      void handleColonyViewWorkOrderMessage(int colonyId, net.minecraft.network.RegistryFriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Returns result of IColonyView.handleColonyViewWorkOrderMessage(RegistryFriendlyByteBuf) (int, ByteBuf)} if getColonyView(int, ResourceKey) gives a not-null result. If getColonyView(int, ResourceKey) is null, returns null.
      Parameters:
      colonyId - ID of the colony.
      buf - RegistryFriendlyByteBuf with colony data.
      dim - the dimension.
    • handleColonyViewRemoveCitizenMessage

      void handleColonyViewRemoveCitizenMessage(int colonyId, int citizenId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Parameters:
      colonyId - ID of the colony.
      citizenId - ID of the citizen.
      dim - the dimension.
    • handleColonyBuildingViewMessage

      void handleColonyBuildingViewMessage(int colonyId, net.minecraft.core.BlockPos buildingId, @NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Returns result of
      invalid reference
      IColonyView#handleColonyBuildingViewMessage(BlockPos, RegistryFriendlyByteBuf)
      if getColonyView(int, ResourceKey) gives a not-null result. If getColonyView(int, ResourceKey) is null, returns null.
      Parameters:
      colonyId - ID of the colony.
      buildingId - ID of the building.
      buf - RegistryFriendlyByteBuf with colony data.
      dim - the dimension.
    • handleColonyViewRemoveBuildingMessage

      void handleColonyViewRemoveBuildingMessage(int colonyId, net.minecraft.core.BlockPos buildingId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Returns result of
      invalid reference
      IColonyView#handleColonyViewRemoveBuildingMessage(BlockPos)
      if getColonyView(int, ResourceKey) gives a not-null result. If getColonyView(int, ResourceKey) is null, returns null.
      Parameters:
      colonyId - ID of the colony.
      buildingId - ID of the building.
      dim - the dimension.
    • handleColonyViewRemoveWorkOrderMessage

      void handleColonyViewRemoveWorkOrderMessage(int colonyId, int workOrderId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Parameters:
      colonyId - ID of the colony.
      workOrderId - ID of the workOrder.
      dim - the dimension.
    • isSchematicDownloaded

      boolean isSchematicDownloaded()
      Whether or not a new schematic have been downloaded.
      Returns:
      True if a new schematic have been received.
    • setSchematicDownloaded

      void setSchematicDownloaded(boolean downloaded)
      Set the schematic downloaded
      Parameters:
      downloaded - True if a new schematic have been received.
    • isCoordinateInAnyColony

      boolean isCoordinateInAnyColony(@NotNull @NotNull net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
      Check if a given coordinate is inside any other colony.
      Parameters:
      world - the world to check in.
      pos - the position to check.
      Returns:
      true if a colony has been found.
    • getCompatibilityManager

      ICompatibilityManager getCompatibilityManager()
      Get an instance of the compatibilityManager.
      Returns:
      the manager.
    • getRecipeManager

      IRecipeManager getRecipeManager()
      Getter for the recipeManager.
      Returns:
      an IRecipeManager.
    • getTopColonyId

      int getTopColonyId()
      Get the top colony id of all colonies.
      Returns:
      the top id.
    • resetColonyViews

      void resetColonyViews()
      Reset all colony views on login to new world.
    • openReactivationWindow

      void openReactivationWindow(net.minecraft.core.BlockPos pos)
      Open the new reactivation window.
      Parameters:
      pos - the pos to open it at.
    • addColonyDirect

      void addColonyDirect(IColony colony, net.minecraft.server.level.ServerLevel world)
      Adds colony directly to cap. Use only during loading!
      Parameters:
      colony - loaded colony
    • addClaimData

      void addClaimData(IColony colony, it.unimi.dsi.fastutil.longs.Long2ObjectMap<ChunkClaimData> claimData)
      Add claim data of a colony.
      Parameters:
      colony - the colony from which to add the claim data.
      claimData - the claim data to add.
    • getClaimData

      Map<net.minecraft.world.level.ChunkPos,IChunkClaimData> getClaimData(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
      Get the claim data for the whole dimension.
      Parameters:
      dimension - the dim.
      Returns:
      the claim data.
    • getClaimData

      IChunkClaimData getClaimData(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension, net.minecraft.world.level.ChunkPos pos)
      Get the claim data for a dimension and pos.
      Parameters:
      dimension - the dim.
      pos - the pos.
      Returns:
      the claim data.
    • addNewChunk

      void addNewChunk(Colony colony, net.minecraft.world.level.ChunkPos pos, ChunkClaimData chunkClaimData)
      New chunk to track claim of.
      Parameters:
      colony - the colony claiming it.
      pos - the chunk pos.
      chunkClaimData - the claim data to track.