Class RegisteredStructureManager
java.lang.Object
com.minecolonies.core.colony.managers.RegisteredStructureManager
- All Implemented Interfaces:
ICommonRegisteredStructureManager<IBuilding,,ITownHall> IRegisteredStructureManager
-
Constructor Summary
ConstructorsConstructorDescriptionRegisteredStructureManager(Colony colony) Creates the BuildingManager for a colony. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddBuildingExtension(IBuildingExtension extension) Add a new building extension to the building manager.voidaddBuildingExtensionIfMissing(BuildingExtensionRegistries.BuildingExtensionEntry buildingExtensionEntry, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Add a building extension if it's missing.voidaddLeisureSite(net.minecraft.core.BlockPos pos) Register a new leisure site.addNewBuilding(@NotNull AbstractTileEntityColonyBuilding tileEntity, net.minecraft.world.level.Level world) Creates a building from a tile entity and adds it to the colony.booleancanPlaceAt(net.minecraft.world.level.block.Block block, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Checks whether we're allowed to place the block for a new buildingvoidcleanUpBuildings(@NotNull IColony colony) Clean up the buildings.voidClear the isDirty of the buildings.voidclearPendingPrestigeCalc(IBuilding building) Indicate to building manager that prestige just has been calculated.@NotNull List<IBuildingExtension> getBuildingExtensions(Predicate<IBuildingExtension> matcher) Get all the building extensions.Returns a map with all buildings within the colony.@Nullable IWareHousegetClosestWarehouseInColony(net.minecraft.core.BlockPos pos) Get the closest warehouse relative to a position.Get the colony from the manager.intGet the colony prestige.Get a house with a spare bed.List<net.minecraft.core.BlockPos> Get the leisure site positions.@Nullable IBuildingExtensionGet a building extension by id.Get a specific building extension on the given location.intGet the maximum level among built mystical sitesGet a list of the mystical sites in this colony.net.minecraft.core.BlockPosGet a random leisure site to go to.@Nullable ITownHallGet the townhall from the colony.Get a list of the warehouses in this colony.voidguardBuildingChangedAt(IBuilding guardBuilding, int newLevel) Event once a guard building changed at a certain level.booleanhasGuardBuildingNear(IBuilding building) Finds whether there is a guard building close to the given buildingbooleanCheck if the colony has a placed mystical site.booleanCheck if the colony has a placed townhall.booleanCheck if the colony has a placed warehouse.booleankeepChunkColonyLoaded(net.minecraft.world.level.chunk.LevelChunk chunk) Is this chunk claimed by enough buildings to keep it loaded.voidUpdates all subscribers of building extensions etc.voidMarks building data dirty.voidonBuildingUpgradeComplete(@Nullable IBuilding building, int level) Performed when a building of this colony finished his upgrade state.voidonColonyTick(IColony colony) Tick the buildings on colony tick.voidread(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound) Read the buildings from NBT.voidremoveBuilding(@NotNull IBuilding building, Set<net.minecraft.server.level.ServerPlayer> subscribers) Remove a IBuilding from the Colony (when it is destroyed).voidRemove a building extension from the building extension collection.voidremoveLeisureSite(net.minecraft.core.BlockPos pos) Remove a leisure site.voidremoveMysticalSite(IMysticalSite mysticalSite) Removes a warehouse from the BuildingManagervoidremoveWareHouse(IWareHouse wareHouse) Removes a warehouse from the BuildingManagervoidsendPackets(Set<net.minecraft.server.level.ServerPlayer> closeSubscribers, Set<net.minecraft.server.level.ServerPlayer> newSubscribers) Send packets of the buildings to the subscribers.voidsetTownHall(@Nullable ITownHall building) Set the townhall building.voidwrite(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound) Write the buildings to NBT.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.managers.interfaces.ICommonRegisteredStructureManager
getBestBuilding, getBestBuilding, getBestBuilding, getBestBuilding, getBuilding, getBuilding, getFirstBuildingMatching, getRandomBuilding, hasBuilding
-
Constructor Details
-
RegisteredStructureManager
Creates the BuildingManager for a colony.- Parameters:
colony- the colony.
-
-
Method Details
-
read
public void read(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Description copied from interface:IRegisteredStructureManagerRead the buildings from NBT.- Specified by:
readin interfaceIRegisteredStructureManager- Parameters:
compound- the compound.
-
write
public void write(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Description copied from interface:IRegisteredStructureManagerWrite the buildings to NBT.- Specified by:
writein interfaceIRegisteredStructureManager- Parameters:
compound- the compound.
-
clearDirty
public void clearDirty()Description copied from interface:IRegisteredStructureManagerClear the isDirty of the buildings.- Specified by:
clearDirtyin interfaceIRegisteredStructureManager
-
sendPackets
public void sendPackets(Set<net.minecraft.server.level.ServerPlayer> closeSubscribers, Set<net.minecraft.server.level.ServerPlayer> newSubscribers) Description copied from interface:IRegisteredStructureManagerSend packets of the buildings to the subscribers.- Specified by:
sendPacketsin interfaceIRegisteredStructureManager- Parameters:
closeSubscribers- the old subs.newSubscribers- new subs.
-
onColonyTick
Description copied from interface:IRegisteredStructureManagerTick the buildings on colony tick.- Specified by:
onColonyTickin interfaceIRegisteredStructureManager- Parameters:
colony- the event.
-
clearPendingPrestigeCalc
Description copied from interface:IRegisteredStructureManagerIndicate to building manager that prestige just has been calculated.- Specified by:
clearPendingPrestigeCalcin interfaceIRegisteredStructureManager- Parameters:
building- the building it happened for.
-
getColonyPrestige
public int getColonyPrestige()Description copied from interface:IRegisteredStructureManagerGet the colony prestige.- Specified by:
getColonyPrestigein interfaceIRegisteredStructureManager- Returns:
- the prestige.
-
markBuildingsDirty
public void markBuildingsDirty()Description copied from interface:IRegisteredStructureManagerMarks building data dirty.- Specified by:
markBuildingsDirtyin interfaceIRegisteredStructureManager
-
cleanUpBuildings
Description copied from interface:IRegisteredStructureManagerClean up the buildings.- Specified by:
cleanUpBuildingsin interfaceIRegisteredStructureManager- Parameters:
colony- at the worldTick event.
-
getLeisureSites
Description copied from interface:IRegisteredStructureManagerGet the leisure site positions.- Specified by:
getLeisureSitesin interfaceIRegisteredStructureManager- Returns:
- the list.
-
getRandomLeisureSite
public net.minecraft.core.BlockPos getRandomLeisureSite()Description copied from interface:IRegisteredStructureManagerGet a random leisure site to go to.- Specified by:
getRandomLeisureSitein interfaceIRegisteredStructureManager- Returns:
- the position of it.
-
addLeisureSite
public void addLeisureSite(net.minecraft.core.BlockPos pos) Description copied from interface:IRegisteredStructureManagerRegister a new leisure site.- Specified by:
addLeisureSitein interfaceIRegisteredStructureManager- Parameters:
pos- the position of it.
-
removeLeisureSite
public void removeLeisureSite(net.minecraft.core.BlockPos pos) Description copied from interface:IRegisteredStructureManagerRemove a leisure site.- Specified by:
removeLeisureSitein interfaceIRegisteredStructureManager- Parameters:
pos- the position of it.
-
getClosestWarehouseInColony
Description copied from interface:IRegisteredStructureManagerGet the closest warehouse relative to a position.- Specified by:
getClosestWarehouseInColonyin interfaceIRegisteredStructureManager- Parameters:
pos- the position,.- Returns:
- the closest warehouse.
-
keepChunkColonyLoaded
public boolean keepChunkColonyLoaded(net.minecraft.world.level.chunk.LevelChunk chunk) Description copied from interface:IRegisteredStructureManagerIs this chunk claimed by enough buildings to keep it loaded.- Specified by:
keepChunkColonyLoadedin interfaceIRegisteredStructureManager- Parameters:
chunk- the chunk to check- Returns:
- true if within.
-
getHouseWithSpareBed
Description copied from interface:IRegisteredStructureManagerGet a house with a spare bed.- Specified by:
getHouseWithSpareBedin interfaceIRegisteredStructureManager- Returns:
- the house or null.
-
getBuildings
Description copied from interface:ICommonRegisteredStructureManagerReturns a map with all buildings within the colony. Key is ID (Coordinates), value is building object.- Specified by:
getBuildingsin interfaceICommonRegisteredStructureManager<IBuilding,ITownHall> - Returns:
- Map with ID (coordinates) as key, and buildings as value.
-
getTownHall
Description copied from interface:ICommonRegisteredStructureManagerGet the townhall from the colony.- Specified by:
getTownHallin interfaceICommonRegisteredStructureManager<IBuilding,ITownHall> - Returns:
- the townhall building.
-
getMysticalSiteMaxBuildingLevel
public int getMysticalSiteMaxBuildingLevel()Description copied from interface:IRegisteredStructureManagerGet the maximum level among built mystical sites- Specified by:
getMysticalSiteMaxBuildingLevelin interfaceIRegisteredStructureManager- Returns:
- the max level among all mystical sites or zero if no mystical site built
-
hasWarehouse
public boolean hasWarehouse()Description copied from interface:ICommonRegisteredStructureManagerCheck if the colony has a placed warehouse.- Specified by:
hasWarehousein interfaceICommonRegisteredStructureManager<IBuilding,ITownHall> - Returns:
- true if so.
-
hasMysticalSite
public boolean hasMysticalSite()Description copied from interface:IRegisteredStructureManagerCheck if the colony has a placed mystical site.- Specified by:
hasMysticalSitein interfaceIRegisteredStructureManager- Returns:
- true if so.
-
hasTownHall
public boolean hasTownHall()Description copied from interface:ICommonRegisteredStructureManagerCheck if the colony has a placed townhall.- Specified by:
hasTownHallin interfaceICommonRegisteredStructureManager<IBuilding,ITownHall> - Returns:
- true if so.
-
addNewBuilding
public IBuilding addNewBuilding(@NotNull @NotNull AbstractTileEntityColonyBuilding tileEntity, net.minecraft.world.level.Level world) Description copied from interface:IRegisteredStructureManagerCreates a building from a tile entity and adds it to the colony.- Specified by:
addNewBuildingin interfaceIRegisteredStructureManager- Parameters:
tileEntity- Tile entity to build a building from.world- the world to add it to.- Returns:
- IBuilding that was created and added.
-
removeBuilding
public void removeBuilding(@NotNull @NotNull IBuilding building, Set<net.minecraft.server.level.ServerPlayer> subscribers) Description copied from interface:IRegisteredStructureManagerRemove a IBuilding from the Colony (when it is destroyed).- Specified by:
removeBuildingin interfaceIRegisteredStructureManager- Parameters:
building- IBuilding to remove.subscribers- the subscribers of the colony to message.
-
hasGuardBuildingNear
Finds whether there is a guard building close to the given building- Specified by:
hasGuardBuildingNearin interfaceIRegisteredStructureManager- Parameters:
building- the building to check.- Returns:
- false if no guard tower close, true in other cases
-
guardBuildingChangedAt
Description copied from interface:IRegisteredStructureManagerEvent once a guard building changed at a certain level.- Specified by:
guardBuildingChangedAtin interfaceIRegisteredStructureManager- Parameters:
guardBuilding- the guard building.newLevel- the level of it.
-
setTownHall
Description copied from interface:IRegisteredStructureManagerSet the townhall building.- Specified by:
setTownHallin interfaceIRegisteredStructureManager- Parameters:
building- the building to set.
-
getWareHouses
Description copied from interface:IRegisteredStructureManagerGet a list of the warehouses in this colony.- Specified by:
getWareHousesin interfaceIRegisteredStructureManager- Returns:
- the warehouse.
-
removeWareHouse
Description copied from interface:IRegisteredStructureManagerRemoves a warehouse from the BuildingManager- Specified by:
removeWareHousein interfaceIRegisteredStructureManager- Parameters:
wareHouse- the warehouse to remove.
-
getMysticalSites
Description copied from interface:IRegisteredStructureManagerGet a list of the mystical sites in this colony.- Specified by:
getMysticalSitesin interfaceIRegisteredStructureManager- Returns:
- the list of mistical sites.
-
removeMysticalSite
Description copied from interface:IRegisteredStructureManagerRemoves a warehouse from the BuildingManager- Specified by:
removeMysticalSitein interfaceIRegisteredStructureManager- Parameters:
mysticalSite- the warehouse to remove.
-
markBuildingExtensionsDirty
public void markBuildingExtensionsDirty()Updates all subscribers of building extensions etc.- Specified by:
markBuildingExtensionsDirtyin interfaceIRegisteredStructureManager
-
canPlaceAt
public boolean canPlaceAt(net.minecraft.world.level.block.Block block, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Description copied from interface:IRegisteredStructureManagerChecks whether we're allowed to place the block for a new building- Specified by:
canPlaceAtin interfaceIRegisteredStructureManager- Parameters:
block- Block to checkpos- positionplayer- the player trying to place- Returns:
- true if placement allowed
-
onBuildingUpgradeComplete
Description copied from interface:IRegisteredStructureManagerPerformed when a building of this colony finished his upgrade state.- Specified by:
onBuildingUpgradeCompletein interfaceIRegisteredStructureManager- Parameters:
building- The upgraded building.level- The new level.
-
getBuildingExtensions
@NotNull public @NotNull List<IBuildingExtension> getBuildingExtensions(Predicate<IBuildingExtension> matcher) Description copied from interface:ICommonRegisteredStructureManagerGet all the building extensions.- Specified by:
getBuildingExtensionsin interfaceICommonRegisteredStructureManager<IBuilding,ITownHall> - Parameters:
matcher- the building extension matcher predicate.- Returns:
- an unmodifiable collection of all building extensions.
-
getMatchingBuildingExtension
public Optional<IBuildingExtension> getMatchingBuildingExtension(Predicate<IBuildingExtension> matcher) Description copied from interface:IRegisteredStructureManagerGet a specific building extension on the given location.- Specified by:
getMatchingBuildingExtensionin interfaceIRegisteredStructureManager- Parameters:
matcher- the building extension matcher predicate.- Returns:
- the building extension, if any.
-
addBuildingExtension
Description copied from interface:IRegisteredStructureManagerAdd a new building extension to the building manager. If an identical building extension already exists, this building extension won't be added.- Specified by:
addBuildingExtensionin interfaceIRegisteredStructureManager- Parameters:
extension- the new building extension to add.- Returns:
- true if the building extension was added.
-
removeBuildingExtension
Description copied from interface:IRegisteredStructureManagerRemove a building extension from the building extension collection.- Specified by:
removeBuildingExtensionin interfaceIRegisteredStructureManager- Parameters:
matcher- the building extension matcher predicate.
-
getMatchingBuildingExtension
@Nullable public @Nullable IBuildingExtension getMatchingBuildingExtension(IBuildingExtension.ExtensionId extensionId) Description copied from interface:IRegisteredStructureManagerGet a building extension by id.- Specified by:
getMatchingBuildingExtensionin interfaceIRegisteredStructureManager- Parameters:
extensionId- the id of the extension.- Returns:
- the building extension or null.
-
addBuildingExtensionIfMissing
public void addBuildingExtensionIfMissing(BuildingExtensionRegistries.BuildingExtensionEntry buildingExtensionEntry, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Description copied from interface:IRegisteredStructureManagerAdd a building extension if it's missing.- Specified by:
addBuildingExtensionIfMissingin interfaceIRegisteredStructureManager- Parameters:
buildingExtensionEntry- the entry to create the extension from.pos- the pos it's at.
-
getColony
Description copied from interface:ICommonRegisteredStructureManagerGet the colony from the manager.- Specified by:
getColonyin interfaceICommonRegisteredStructureManager<IBuilding,ITownHall> - Returns:
- the IColony colony.
-