Package com.minecolonies.api.colony
Interface IColonyManager
- All Known Implementing Classes:
ColonyManager
public interface IColonyManager
-
Method Summary
Modifier and TypeMethodDescription@Nullable IColonycreateColony(@NotNull net.minecraft.world.level.Level w, net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.entity.player.Player player, @NotNull String colonyName, @NotNull String pack) Create a new Colony in the given world and at that location.voiddeleteColonyByDimension(int id, boolean canDestroy, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Delete the colony by dimension.voiddeleteColonyByWorld(int id, boolean canDestroy, net.minecraft.world.level.Level world) Delete the colony in a world.Get all colonies in all worlds.getBuilding(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.core.BlockPos pos) Get a AbstractBuilding by a World and coordinates.getBuildingView(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension, net.minecraft.core.BlockPos pos) Get a AbstractBuilding by position.getClosestColony(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.core.BlockPos pos) Get closest colony by x,y,z.@Nullable IColonyViewgetClosestColonyView(@Nullable net.minecraft.world.level.Level w, @Nullable net.minecraft.core.BlockPos pos) Returns the closest viewgetColonyView(net.minecraft.world.level.Level, net.minecraft.core.BlockPos).@Nullable IColonygetClosestIColony(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.core.BlockPos pos) Side neutral method to get colony.getColonies(@NotNull net.minecraft.world.level.Level w) Get all colonies in this world.getColoniesAbandonedSince(int abandonedSince) Get all colonies in all worlds.@Nullable IColonygetColonyByDimension(int id, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Get Colony by UUID.getColonyByPosFromDim(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, @NotNull net.minecraft.core.BlockPos pos) Get colony that contains a given coordinate from dimension.@Nullable IColonygetColonyByPosFromWorld(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.core.BlockPos pos) Get colony that contains a given coordinate from world.@Nullable IColonygetColonyByWorld(int id, net.minecraft.world.level.Level world) Get Colony by UUID.getColonyView(int id, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Get IColonyView by ID.getColonyView(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.core.BlockPos pos) Gets the colony view aat the given position@NotNull List<IColonyView>getColonyViews(@NotNull net.minecraft.world.level.Level w) Get all colony views in this world known to the current player.Get an instance of the compatibilityManager.getIColonies(@NotNull net.minecraft.world.level.Level w) Get all colonies in this world.@Nullable IColonygetIColony(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.core.BlockPos pos) Side neutral method to get colony.@Nullable IColonygetIColonyByOwner(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.world.entity.player.Player owner) Side neutral method to get colony.@Nullable IColonygetIColonyByOwner(@NotNull net.minecraft.world.level.Level w, UUID owner) Side neutral method to get colony.static IColonyManagerintReturns the minimum distance between two town halls, to not make colonies collide.Getter for the recipeManager.intGet the top colony id of all colonies.voidhandleColonyBuildingViewMessage(int colonyId, net.minecraft.core.BlockPos buildingId, @NotNull net.minecraft.network.FriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView#handleColonyBuildingViewMessage(BlockPos, FriendlyByteBuf)ifgetColonyView(int, ResourceKey)gives a not-null result.voidhandleColonyViewCitizensMessage(int colonyId, int citizenId, net.minecraft.network.FriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handleColonyViewCitizensMessage(int, FriendlyByteBuf)ifgetColonyView(int, ResourceKey)gives a not-null result.voidhandleColonyViewMessage(int colonyId, @NotNull net.minecraft.network.FriendlyByteBuf colonyData, @NotNull net.minecraft.world.level.Level world, boolean isNewSubscription, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Sends view message to the right view.voidhandleColonyViewRemoveBuildingMessage(int colonyId, net.minecraft.core.BlockPos buildingId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView#handleColonyViewRemoveBuildingMessage(BlockPos)ifgetColonyView(int, ResourceKey)gives a not-null result.voidhandleColonyViewRemoveCitizenMessage(int colonyId, int citizenId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handleColonyViewRemoveCitizenMessage(int)ifgetColonyView(int, ResourceKey)gives a not-null result.voidhandleColonyViewRemoveWorkOrderMessage(int colonyId, int workOrderId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handleColonyViewRemoveWorkOrderMessage(int)ifgetColonyView(int, ResourceKey)gives a not-null result.voidhandleColonyViewWorkOrderMessage(int colonyId, net.minecraft.network.FriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handleColonyViewWorkOrderMessage(FriendlyByteBuf)(int, ByteBuf)} ifgetColonyView(int, ResourceKey)gives a not-null result.voidhandlePermissionsViewMessage(int colonyID, @NotNull net.minecraft.network.FriendlyByteBuf data, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handlePermissionsViewMessage(FriendlyByteBuf)ifgetColonyView(int, ResourceKey).booleanisCoordinateInAnyColony(@NotNull net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Check if a given coordinate is inside any other colony.booleanisFarEnoughFromColonies(@NotNull net.minecraft.world.level.Level w, @NotNull net.minecraft.core.BlockPos pos) Check if a position is too close to another colony to found a new colony.booleanWhether or not a new schematic have been downloaded.voidonClientTick(net.minecraftforge.event.TickEvent.ClientTickEvent event) On Client tick, clears views when player left.voidonServerTick(net.minecraftforge.event.TickEvent.ServerTickEvent event) On server tick, tick every Colony.voidonWorldLoad(@NotNull net.minecraft.world.level.Level world) When a world is loaded, Colonies in that world need to grab the reference to the World.voidonWorldTick(net.minecraftforge.event.TickEvent.LevelTickEvent event) On world tick, tick every Colony in that world.voidonWorldUnload(@NotNull net.minecraft.world.level.Level world) When a world unloads, all colonies in that world are informed.voidopenReactivationWindow(net.minecraft.core.BlockPos pos) Open the new reactivation window.voidread(@NotNull net.minecraft.nbt.CompoundTag compound) Read Colonies from saved NBT data.voidremoveColonyView(int id, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Removes a colony viewvoidReset all colony views on login to new world.voidSets the cap for this world to loadedvoidsetSchematicDownloaded(boolean downloaded) Set the schematic downloadedvoidwrite(@NotNull net.minecraft.nbt.CompoundTag compound) Write colonies to NBT data for saving.
-
Method Details
-
getInstance
-
createColony
@Nullable @Nullable IColony createColony(@NotNull @NotNull net.minecraft.world.level.Level 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.world.level.Level 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
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
Get all colonies in this world.- Parameters:
w- World.- Returns:
- a list of colonies.
-
getAllColonies
Get all colonies in all worlds.- Returns:
- a list of colonies.
-
getColoniesAbandonedSince
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:
pos- Block position.dimension- the dimension it is in.- Returns:
- Returns the view belonging to the building at (x, y, z).
-
getIColonies
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) Returns the closest viewgetColonyView(net.minecraft.world.level.Level, net.minecraft.core.BlockPos).- 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- Worldowner- 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.minecraftforge.event.TickEvent.ServerTickEvent event) On server tick, tick every Colony. NOTE: Review this for performance.- Parameters:
event-TickEvent.ServerTickEvent
-
write
void write(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Write colonies to NBT data for saving.- Parameters:
compound- NBT-Tag.
-
read
void read(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Read Colonies from saved NBT data.- Parameters:
compound- NBT Tag.
-
onClientTick
void onClientTick(@NotNull net.minecraftforge.event.TickEvent.ClientTickEvent event) On Client tick, clears views when player left.- Parameters:
event-TickEvent.ClientTickEvent.
-
onWorldTick
void onWorldTick(@NotNull net.minecraftforge.event.TickEvent.LevelTickEvent 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.
-
setCapLoaded
void setCapLoaded()Sets the cap for this world to loaded -
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.FriendlyByteBuf colonyData, @NotNull @NotNull net.minecraft.world.level.Level world, 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-FriendlyByteBufwith colony data.isNewSubscription- whether this is a new subscription or not.dim- the dimension.world- the world it is in.
-
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.FriendlyByteBuf data, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handlePermissionsViewMessage(FriendlyByteBuf)ifgetColonyView(int, ResourceKey). gives a not-null result. IfgetColonyView(int, ResourceKey)is null, returns null.- Parameters:
colonyID- ID of the colony.data-FriendlyByteBufwith colony data.dim- the dimension.
-
handleColonyViewCitizensMessage
void handleColonyViewCitizensMessage(int colonyId, int citizenId, net.minecraft.network.FriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handleColonyViewCitizensMessage(int, FriendlyByteBuf)ifgetColonyView(int, ResourceKey)gives a not-null result. IfgetColonyView(int, ResourceKey)is null, returns null.- Parameters:
colonyId- ID of the colony.citizenId- ID of the citizen.buf-FriendlyByteBufwith colony data.dim- the dimension.
-
handleColonyViewWorkOrderMessage
void handleColonyViewWorkOrderMessage(int colonyId, net.minecraft.network.FriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handleColonyViewWorkOrderMessage(FriendlyByteBuf)(int, ByteBuf)} ifgetColonyView(int, ResourceKey)gives a not-null result. IfgetColonyView(int, ResourceKey)is null, returns null.- Parameters:
colonyId- ID of the colony.buf-FriendlyByteBufwith colony data.dim- the dimension.
-
handleColonyViewRemoveCitizenMessage
void handleColonyViewRemoveCitizenMessage(int colonyId, int citizenId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView.handleColonyViewRemoveCitizenMessage(int)ifgetColonyView(int, ResourceKey)gives a not-null result. IfgetColonyView(int, ResourceKey)is null, returns null.- 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.FriendlyByteBuf buf, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Returns result ofIColonyView#handleColonyBuildingViewMessage(BlockPos, FriendlyByteBuf)ifgetColonyView(int, ResourceKey)gives a not-null result. IfgetColonyView(int, ResourceKey)is null, returns null.- Parameters:
colonyId- ID of the colony.buildingId- ID of the building.buf-FriendlyByteBufwith 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 ofIColonyView#handleColonyViewRemoveBuildingMessage(BlockPos)ifgetColonyView(int, ResourceKey)gives a not-null result. IfgetColonyView(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) Returns result ofIColonyView.handleColonyViewRemoveWorkOrderMessage(int)ifgetColonyView(int, ResourceKey)gives a not-null result. IfgetColonyView(int, ResourceKey)is null, returns null.- 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.
-