Class AbstractBuilding
java.lang.Object
com.minecolonies.core.colony.buildings.AbstractSchematicProvider
com.minecolonies.core.colony.buildings.AbstractBuildingContainer
com.minecolonies.core.colony.buildings.AbstractBuilding
- All Implemented Interfaces:
IBuilding,IBuildingContainer,ICommonBuilding,ISchematicProvider,IBuildingModuleContainer,IModuleContainer<IBuildingModule>,IRequester,IRequestResolverProvider,net.minecraftforge.common.capabilities.ICapabilityProvider,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
AbstractBuildingGuards,AbstractBuildingStructureBuilder,BuildingAlchemist,BuildingArchery,BuildingBaker,BuildingBarracks,BuildingBeekeeper,BuildingBlacksmith,BuildingChickenHerder,BuildingCombatAcademy,BuildingComposter,BuildingConcreteMixer,BuildingCook,BuildingCowboy,BuildingCrusher,BuildingDeliveryman,BuildingDyer,BuildingEnchanter,BuildingFarmer,BuildingFisherman,BuildingFletcher,BuildingFlorist,BuildingGlassblower,BuildingGraveyard,BuildingHospital,BuildingKitchen,BuildingLibrary,BuildingLumberjack,BuildingMechanic,BuildingMysticalSite,BuildingNetherWorker,BuildingPlantation,BuildingRabbitHutch,BuildingSawmill,BuildingSchool,BuildingShepherd,BuildingSifter,BuildingSmeltery,BuildingStonemason,BuildingStoneSmeltery,BuildingSwineHerder,BuildingTownHall,BuildingUniversity,BuildingWareHouse,DefaultBuildingInstance,PostBox,Stash
Base building class, has all the foundation for what a building stores and does.
We suppress the warning which warns you about referencing child classes in the parent because that's how we register the instances of the childClasses to their views and blocks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ISettingKey<BoolSetting>Breeding setting.protected List<IBuildingModule>Set of building modules this building has.protected it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<IBuildingModule>static final ISettingKey<BoolSetting>Fields inherited from class com.minecolonies.core.colony.buildings.AbstractBuildingContainer
containerList, keepX, tileEntityFields inherited from class com.minecolonies.core.colony.buildings.AbstractSchematicProvider
cachedRotation, colonyFields inherited from interface com.minecolonies.api.colony.buildings.IBuilding
WOOD_HUT_LEVEL -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBuilding(@NotNull IColony colony, net.minecraft.core.BlockPos pos) Constructor for a AbstractBuilding. -
Method Summary
Modifier and TypeMethodDescriptionintbuildingRequiresCertainAmountOfItem(net.minecraft.world.item.ItemStack stack, List<ItemStorage> localAlreadyKept, boolean inventory, JobEntry jobEntry) Check if the worker requires a certain amount of that item and the alreadykept list contains it.voidCalculate all building corners from the schematic data.voidcalculatePrestige(com.ldtteam.structurize.blueprints.v1.Blueprint blueprint) Recalculate prestige for building.booleancanBeBuiltByBuilder(int newLevel) Method to define if a builder can build this although the builder is not level 1 yet.booleanCheck if the building should be gathered by the dman.voidcancelAllRequestsOfCitizenOrBuilding(@Nullable ICitizenData data) Cancel all requests of citizen or building (if citizen data is null)booleanCheck if this particular building can be deconstructed.final voidSets#dirtyto false, meaning that the instance is up to date.booleancreatePickupRequest(int qty, boolean force) Creates a pickup request for the building.<R extends IRequestable>
IToken<?>createRequest(@NotNull ICitizenData citizenData, R requested, boolean async) Create a request for a citizen.<R extends IRequestable>
IToken<?>createRequest(R requested, boolean async) Create a request for the building.com.google.common.collect.ImmutableCollection<IRequestResolver<?>>voidDeconstruct the building on destroyed.voiddeserializeNBT(net.minecraft.nbt.CompoundTag compound) voiddestroy()Destroys the block.@Nullable net.minecraft.world.item.ItemStackforceTransferStack(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level world) Try to transfer a stack to one of the inventories of the building and force the transfer.Get the set of all assigned citizens in the colony.@NotNull StringGetter for the custom name of a building.getCitizenForRequest(@NotNull IToken<?> token) intgetClaimRadius(int newLevel) Method to calculate the radius to be claimed by this building depending on the level.@NotNull Class<IBuildingModule>Get the class type of the module container.Collection<IRequest<?>>getCompletedRequestsOfCitizenOrBuilding(@Nullable ICitizenData data) Get completed requests for citizen or building (citizen independent, so if data is null)getCompletedRequestsOfCitizenOrBuilding(@Nullable ICitizenData citizenData, Predicate<IRequest<?>> selectionPredicate) Get a list of closed requests from the building that are filtered by a predicate for citizen or building (null citizen).<R> com.google.common.collect.ImmutableList<IRequest<? extends R>>getCompletedRequestsOfType(@NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType) <R> com.google.common.collect.ImmutableList<IRequest<? extends R>>getCompletedRequestsOfTypeFiltered(@NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType, Predicate<IRequest<? extends R>> filter) getCraftingModuleForRecipe(IToken<?> token) Get the right module for the recipe.@NotNull StringGetter for the custom name of a building.List<net.minecraftforge.items.IItemHandler>Get all handlers associated with this building.IToken<?>getId()Unique token identifying this provider inside the request management system.@NotNull ILocationMethod to get the location of this locatable.intChildren must return their max building level.getModule(int id) Get the first module with a particular class or interface.<M extends IBuildingModule,V extends IBuildingModuleView>
MgetModule(BuildingEntry.ModuleProducer<M, V> producer) Get the first module with a particular class or interface.@NotNull List<IBuildingModule>Get a list containing all modules registered to this container.Collection<IRequest<?>>getOpenRequests(int citizenId) protected Map<Integer,Collection<IToken<?>>> Map<com.google.common.reflect.TypeToken<?>,Collection<IToken<?>>> Get a map of all open requests by type.getOpenRequestsOfCitizenOrBuilding(int citizenId, Predicate<IRequest<?>> selectionPredicate) Get a list of open requests from the building that are filtered by a predicate for citizen id or building (-1).<R> com.google.common.collect.ImmutableList<IRequest<? extends R>>getOpenRequestsOfType(int citizenId, com.google.common.reflect.TypeToken<R> requestType) <R> com.google.common.collect.ImmutableList<IRequest<? extends R>>getOpenRequestsOfTypeFiltered(@NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType, Predicate<IRequest<? extends R>> filter) intGet the prestige value of the building.@NotNull net.minecraft.network.chat.MutableComponentgetRequesterDisplayName(@NotNull IRequestManager manager, @NotNull IRequest<?> request) Gets the name of the requester that requested the request given by the token.Override this method if you want to keep an amount of items in inventory.final com.google.common.collect.ImmutableCollection<IRequestResolver<?>>Method to get the resolvers that this provider provides.<T extends ISetting<S>,S>
TgetSetting(@NotNull ISettingKey<T> key) Get setting for key.<T extends ISetting<S>,S>
SgetSettingValueOrDefault(@NotNull ISettingKey<T> key, S def) Get setting value for key or some default.Returns the tile entity that belongs to the colony building.booleanhasCitizenCompletedRequests(@NotNull ICitizenData data) booleanhasCitizenCompletedRequestsToPickup(@NotNull ICitizenData data) booleanhasModule(BuildingEntry.ModuleProducer<?, ?> producer) Check if the object has a particular module.booleanhasOpenSyncRequest(@NotNull ICitizenData citizen) Checks whether the citizen has an open sync request, preventing it from workingbooleanhasWorkerOpenRequests(int citizenId) booleanhasWorkerOpenRequestsFiltered(int citizenId, @NotNull Predicate<IRequest<?>> selectionPredicate) <R> booleanhasWorkerOpenRequestsOfType(int citizenId, com.google.common.reflect.TypeToken<R> requestType) booleanisBuilt()Check if the building was built already.final booleanisDirty()Returns whether the instance is dirty or not.booleanWhether this building has a guard building nearbybooleanisItemStackInRequest(@Nullable net.minecraft.world.item.ItemStack stack) Check if a certain ItemStack is in the request of a worker.booleanisMatchingBlock(@NotNull net.minecraft.world.level.block.Block block) Checks if a block matches the current object.booleanChecks if this building have a work order.protected booleankeepFood()If the worker should keep some food in the inventory/building.final voidMarks the instance and the building dirty.voidmarkRequestAsAccepted(@NotNull ICitizenData data, @NotNull IToken<?> token) voidmoveToSyncCitizen(ICitizenData citizenData, IRequest<?> request) Move request from building (-1) to citizen and mark synchronous.voidonCleanUp(ICitizenData citizen) Executed every time when citizen finish inventory cleanup called after citizen got paused.voidonColonyTick(IColony colony) Regularly tick this building and check if we got the minimum stock(like once a minute is still fine) - If not: Check if there is a request for this already.voidvoidOn setting down the building.voidonPlayerEnterBuilding(net.minecraft.world.entity.player.Player player) Called when a player enters the building areavoidonPlayerEnterNearby(net.minecraft.world.entity.player.Player player) Called when a player comes close to the building.voidonRequestedRequestCancelled(@NotNull IRequestManager manager, @NotNull IRequest<?> request) Method called by the request system to notify this requester that a request has been overruled.voidonRequestedRequestComplete(@NotNull IRequestManager manager, @NotNull IRequest<?> request) Method called by the request system to notify this requester that a request is complete.voidonRestart(ICitizenData citizen) Executed when RestartCitizenMessage is called and worker is paused.voidonUpgradeComplete(@Nullable com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, int newLevel) Called upon completion of an upgrade process.voidonWakeUp()Executed when a new day start.booleanoverruleNextOpenRequestOfCitizenWithStack(@NotNull ICitizenData citizenData, @NotNull net.minecraft.world.item.ItemStack stack) voidoverruleNextOpenRequestWithStack(@NotNull net.minecraft.world.item.ItemStack stack) Overrule the next open request with a give stack.voidpickUp(net.minecraft.world.entity.player.Player player) Pickup the building including the level and put it in the players inv.voidprocessOfflineTime(long time) Process time the colony was offline.voidregisterBlockPosition(@NotNull net.minecraft.world.level.block.state.BlockState blockState, @NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.Level world) Register a blockState and position.voidregisterModule(@NotNull IBuildingModule module) Register a specific module to the object.voidRemove the work order for the building.voidrequestRemoval(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos builder) Requests a removal for the current building.voidrequestRepair(net.minecraft.core.BlockPos builder) Requests a repair for the current building.voidrequestUpgrade(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos builder) Requests an upgrade for the current building.protected voidrequestWorkOrder(WorkOrderType type, net.minecraft.core.BlockPos builder) Adds work orders to theColony.getWorkManager().reservedStacksExcluding(@NotNull IRequest<? extends IDeliverable> excluded) Calculate the number of reserved stacks the resolver can't touch.voidRequests recalculation of whether this building has a guard building nearbynet.minecraft.nbt.CompoundTagvoidserializeToView(@NotNull net.minecraft.network.FriendlyByteBuf buf, boolean fullSync) Serializes to view.voidsetCustomBuildingName(String name) Set the custom building name of the building.protected voidprotected voidwriteRequestSystemToNBT(net.minecraft.nbt.CompoundTag compound) Methods inherited from class com.minecolonies.core.colony.buildings.AbstractBuildingContainer
addContainerPosition, alterPickUpPriority, getCapability, getContainers, getFirstLocationFromTag, getLocationsFromTag, getPickUpPriority, registerBlockPosition, removeContainerPosition, setTileEntityMethods inherited from class com.minecolonies.core.colony.buildings.AbstractSchematicProvider
asyncPrestigeRecalc, equals, getBlueprintPath, getBuildingLevel, getBuildingType, getChildren, getColony, getCorners, getID, getParent, getPosition, getRotation, getStructurePack, hashCode, hasParent, isDeconstructed, isInBuilding, isMirrored, onUpgradeSchematicTo, safeUpdateTEDataFromSchematic, setBlueprintPath, setBuildingLevel, setBuildingType, setCorners, setDeconstructed, setIsMirrored, setParent, setStructurePack, upgradeBuildingLevelToSchematicDataMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.buildings.IBuilding
buildingRequiresCertainAmountOfItem, canAssignCitizens, canEat, canSort, getMaxEquipmentLevel, sortMethods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapabilityMethods inherited from interface com.minecolonies.api.colony.buildings.ICommonBuilding
getBuildingLevelEquivalentMethods inherited from interface com.minecolonies.api.colony.modules.IModuleContainer
getFirstModuleOccurance, getModule, getModule, getModule, getModuleMatching, getModules, getModules, getModules, getModulesByType, hasModule, hasModule, hasModuleMethods inherited from interface com.minecolonies.api.colony.buildings.ISchematicProvider
getBlueprintPath, getChildren, getCorners, getID, getParent, getRotation, getSchematicName, getStructurePack, hasParent, isDeconstructed, isMirrored, onUpgradeSchematicTo, setBlueprintPath, setBuildingLevel, setCorners, setDeconstructed, setIsMirrored, setParent, setStructurePack
-
Field Details
-
BREEDING
Breeding setting. -
USE_SHEARS
-
modules
Set of building modules this building has. -
modulesMap
-
-
Constructor Details
-
AbstractBuilding
Constructor for a AbstractBuilding.- Parameters:
colony- Colony the building belongs to.pos- Location of the building (it's Hut Block).
-
-
Method Details
-
getModules
Description copied from interface:IModuleContainerGet a list containing all modules registered to this container.- Returns:
- the list of all modules.
-
getClassType
Description copied from interface:IModuleContainerGet the class type of the module container.- Returns:
- the class type.
-
hasModule
Description copied from interface:IBuildingModuleContainerCheck if the object has a particular module.- Parameters:
producer- the module producer for the module- Returns:
- true if so.
-
getModule
public <M extends IBuildingModule,V extends IBuildingModuleView> M getModule(BuildingEntry.ModuleProducer<M, V> producer) Description copied from interface:IBuildingModuleContainerGet the first module with a particular class or interface.- Returns:
- the module or empty if not existent.
-
getModule
Description copied from interface:IBuildingModuleContainerGet the first module with a particular class or interface.- Returns:
- the module or empty if not existent.
-
registerModule
Description copied from interface:IBuildingModuleContainerRegister a specific module to the object.- Parameters:
module- the module to register.
-
getCustomName
Getter for the custom name of a building.- Returns:
- the custom name.
-
getBuildingDisplayName
Getter for the custom name of a building. Returns either the custom name (if any) or the translation key.- Returns:
- the custom name or the schematic name.
-
onWakeUp
public void onWakeUp()Executed when a new day start. -
onCleanUp
Executed every time when citizen finish inventory cleanup called after citizen got paused. Use for cleaning a state only.- Parameters:
citizen- cleanup for citizen.
-
onRestart
Executed when RestartCitizenMessage is called and worker is paused. Use for reseting, onCleanUp is called before this- Parameters:
citizen- the citizen assigned to the building.
-
onPlayerEnterBuilding
public void onPlayerEnterBuilding(net.minecraft.world.entity.player.Player player) Description copied from interface:IBuildingCalled when a player enters the building area- Parameters:
player- entering player
-
onPlayerEnterNearby
public void onPlayerEnterNearby(net.minecraft.world.entity.player.Player player) Description copied from interface:IBuildingCalled when a player comes close to the building.- Parameters:
player- entering player
-
onPlacement
public void onPlacement()On setting down the building. -
isMatchingBlock
public boolean isMatchingBlock(@NotNull @NotNull net.minecraft.world.level.block.Block block) Checks if a block matches the current object.- Parameters:
block- Block you want to know whether it matches this class or not.- Returns:
- True if the block matches this class, otherwise false.
-
deserializeNBT
public void deserializeNBT(net.minecraft.nbt.CompoundTag compound) - Specified by:
deserializeNBTin interfaceIBuildingContainer- Specified by:
deserializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
deserializeNBTin classAbstractBuildingContainer
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT()- Specified by:
serializeNBTin interfaceIBuildingContainer- Specified by:
serializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
serializeNBTin classAbstractBuildingContainer
-
destroy
public void destroy()Destroys the block. CallsonDestroyed(). -
onDestroyed
public void onDestroyed() -
requestWorkOrder
Adds work orders to theColony.getWorkManager().- Parameters:
type- what to do with the work orderbuilder- the assigned builder.
-
canDeconstruct
public boolean canDeconstruct()Check if this particular building can be deconstructed.- Returns:
- true if so.
-
canBeBuiltByBuilder
public boolean canBeBuiltByBuilder(int newLevel) Method to define if a builder can build this although the builder is not level 1 yet.- Parameters:
newLevel- the new level of the building.- Returns:
- true if so.
-
markDirty
public final void markDirty()Description copied from interface:ISchematicProviderMarks the instance and the building dirty. -
isDirty
public final boolean isDirty()Description copied from interface:ISchematicProviderReturns whether the instance is dirty or not.- Returns:
- true if dirty, false if not.
-
clearDirty
public final void clearDirty()Description copied from interface:ISchematicProviderSets#dirtyto false, meaning that the instance is up to date. -
processOfflineTime
public void processOfflineTime(long time) Description copied from interface:IBuildingProcess time the colony was offline.- Parameters:
time- the time in seconds.
-
isPendingConstruction
public boolean isPendingConstruction()Checks if this building have a work order.- Returns:
- true if the building is building, upgrading or repairing.
-
removeWorkOrder
public void removeWorkOrder()Remove the work order for the building.Remove either the upgrade or repair work order
-
getAllAssignedCitizen
Description copied from interface:IBuildingGet the set of all assigned citizens in the colony.- Returns:
- the list
-
getClaimRadius
public int getClaimRadius(int newLevel) Method to calculate the radius to be claimed by this building depending on the level.- Parameters:
newLevel- the new level of the building.- Returns:
- the radius.
-
serializeToView
public void serializeToView(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf, boolean fullSync) Serializes to view.- Parameters:
buf- FriendlyByteBuf to write to.fullSync- Whether it's a full sync
-
onColonyTick
Regularly tick this building and check if we got the minimum stock(like once a minute is still fine) - If not: Check if there is a request for this already. -- If not: Create a request. - If so: Check if there is a request for this still. -- If so: cancel it.- Specified by:
onColonyTickin interfaceIBuilding- Overrides:
onColonyTickin classAbstractSchematicProvider
-
setCustomBuildingName
Set the custom building name of the building.- Parameters:
name- the name to set.
-
canBeGathered
public boolean canBeGathered()Check if the building should be gathered by the dman.- Returns:
- true if so.
-
requestUpgrade
public void requestUpgrade(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos builder) Requests an upgrade for the current building.- Parameters:
player- the requesting player.builder- the assigned builder.
-
requestRemoval
public void requestRemoval(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos builder) Description copied from interface:IBuildingRequests a removal for the current building.- Parameters:
player- the requesting player.builder- the assigned builder.
-
pickUp
public void pickUp(net.minecraft.world.entity.player.Player player) Description copied from interface:IBuildingPickup the building including the level and put it in the players inv.- Parameters:
player- the player picking it up.
-
requestRepair
public void requestRepair(net.minecraft.core.BlockPos builder) Requests a repair for the current building.- Parameters:
builder- the assigned builder.
-
isBuilt
public boolean isBuilt()Check if the building was built already.- Returns:
- true if so.
-
deconstruct
public void deconstruct()Deconstruct the building on destroyed. -
getTileEntity
Description copied from interface:IBuildingContainerReturns the tile entity that belongs to the colony building.- Returns:
AbstractTileEntityColonyBuildingobject of the building.
-
onUpgradeComplete
public void onUpgradeComplete(@Nullable @Nullable com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, int newLevel) Description copied from interface:IBuildingCalled upon completion of an upgrade process. We suppress this warning since this parameter will be used in child classes which override this method.newLevel- The new level.
-
calculatePrestige
public void calculatePrestige(com.ldtteam.structurize.blueprints.v1.Blueprint blueprint) Description copied from interface:IBuildingRecalculate prestige for building.- Parameters:
blueprint- the blueprint as a basis.
-
calculateCorners
public void calculateCorners()Description copied from interface:IBuildingCalculate all building corners from the schematic data. -
isGuardBuildingNear
public boolean isGuardBuildingNear()Description copied from interface:IBuildingWhether this building has a guard building nearby- Returns:
- true/false
-
resetGuardBuildingNear
public void resetGuardBuildingNear()Description copied from interface:IBuildingRequests recalculation of whether this building has a guard building nearby -
buildingRequiresCertainAmountOfItem
public int buildingRequiresCertainAmountOfItem(net.minecraft.world.item.ItemStack stack, List<ItemStorage> localAlreadyKept, boolean inventory, JobEntry jobEntry) Description copied from interface:IBuildingCheck if the worker requires a certain amount of that item and the alreadykept list contains it. Always leave one stack behind if the worker requires a certain amount of it. Just to be sure.- Parameters:
stack- the stack to check it with.localAlreadyKept- already kept items.inventory- if it should be in the inventory or in the building.jobEntry- the job entry trying to dump.- Returns:
- the amount which can get dumped or 0 if not.
-
getRequiredItemsAndAmount
public Map<Predicate<net.minecraft.world.item.ItemStack>,net.minecraft.util.Tuple<Integer, getRequiredItemsAndAmount()Boolean>> Override this method if you want to keep an amount of items in inventory. When the inventory is full, everything get's dumped into the building chest. But you can use this method to hold some stacks back.- Returns:
- a list of objects which should be kept.
-
getPrestige
public int getPrestige()Description copied from interface:ICommonBuildingGet the prestige value of the building.- Returns:
- the prestige value.
-
getMaxBuildingLevel
public int getMaxBuildingLevel()Description copied from interface:ISchematicProviderChildren must return their max building level.- Returns:
- Max building level.
-
getHandlers
Description copied from interface:IBuildingGet all handlers associated with this building.- Returns:
- the handlers of the building + citizen.
-
getSetting
Description copied from interface:IBuildingGet setting for key. Utility function.- Type Parameters:
T- the key type.- Parameters:
key- the key.- Returns:
- the setting.
-
getSettingValueOrDefault
public <T extends ISetting<S>,S> S getSettingValueOrDefault(@NotNull @NotNull ISettingKey<T> key, @NotNull S def) Description copied from interface:IBuildingGet setting value for key or some default. Utility function.- Type Parameters:
T- the key type.- Parameters:
key- the key.def- the default.- Returns:
- the setting.
-
getCraftingModuleForRecipe
Get the right module for the recipe.- Parameters:
token- the recipe trying to be fulfilled.- Returns:
- the matching module.
-
keepFood
protected boolean keepFood()If the worker should keep some food in the inventory/building.- Returns:
- true if so.
-
forceTransferStack
@Nullable public @Nullable net.minecraft.world.item.ItemStack forceTransferStack(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level world) Try to transfer a stack to one of the inventories of the building and force the transfer.- Parameters:
stack- the stack to transfer.world- the world to do it in.- Returns:
- the itemStack which has been replaced or the itemStack which could not be transfered
-
isItemStackInRequest
public boolean isItemStackInRequest(@Nullable @Nullable net.minecraft.world.item.ItemStack stack) Description copied from interface:IBuildingCheck if a certain ItemStack is in the request of a worker.- Parameters:
stack- the stack to chest.- Returns:
- true if so.
-
writeRequestSystemToNBT
protected void writeRequestSystemToNBT(net.minecraft.nbt.CompoundTag compound) -
setupRsDataStore
protected void setupRsDataStore() -
getOpenRequestsByRequestableType
public Map<com.google.common.reflect.TypeToken<?>,Collection<IToken<?>>> getOpenRequestsByRequestableType()Description copied from interface:IBuildingGet a map of all open requests by type.- Returns:
- the map.
-
getOpenRequestsByCitizen
-
createRequest
public <R extends IRequestable> IToken<?> createRequest(@NotNull @NotNull ICitizenData citizenData, @NotNull R requested, boolean async) Create a request for a citizen.- Type Parameters:
R- the type of the request.- Parameters:
citizenData- the data of the citizen.requested- the request to create.async- if async or not.- Returns:
- the Token of the request.
-
createRequest
Create a request for the building.- Type Parameters:
R- the type of the request.- Parameters:
requested- the request to create.async- if async or not.- Returns:
- the Token of the request.
-
registerBlockPosition
public void registerBlockPosition(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState blockState, @NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.level.Level world) Description copied from interface:IBuildingContainerRegister a blockState and position. We suppress this warning since this parameter will be used in child classes which override this method.- Specified by:
registerBlockPositionin interfaceIBuildingContainer- Overrides:
registerBlockPositionin classAbstractBuildingContainer- Parameters:
blockState- to be registeredpos- of the blockStateworld- world to register it at.
-
hasWorkerOpenRequests
public boolean hasWorkerOpenRequests(int citizenId) -
getOpenRequests
-
hasWorkerOpenRequestsFiltered
-
hasOpenSyncRequest
Description copied from interface:IBuildingChecks whether the citizen has an open sync request, preventing it from working- Parameters:
citizen- citizen data to check- Returns:
- true if an open non async request exists
-
hasWorkerOpenRequestsOfType
public <R> boolean hasWorkerOpenRequestsOfType(int citizenId, com.google.common.reflect.TypeToken<R> requestType) -
getOpenRequestsOfType
public <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getOpenRequestsOfType(int citizenId, com.google.common.reflect.TypeToken<R> requestType) -
createPickupRequest
public boolean createPickupRequest(int qty, boolean force) Description copied from interface:IBuildingCreates a pickup request for the building. It will make sure that only one pickup request exists per building, so it's safe to call multiple times. The call will return false if a pickup request already exists, or if the priority is not within the proper range, or if the pickup priority is set to NEVER (0).- Parameters:
qty- the qty of items to be picked up.force- if the pickup should be forced.- Returns:
- true if a pickup request could be created, false if not.
-
hasCitizenCompletedRequests
-
hasCitizenCompletedRequestsToPickup
-
getCompletedRequestsOfCitizenOrBuilding
public Collection<IRequest<?>> getCompletedRequestsOfCitizenOrBuilding(@Nullable @Nullable ICitizenData data) Description copied from interface:IBuildingGet completed requests for citizen or building (citizen independent, so if data is null)- Parameters:
data- the citizen data (or null).- Returns:
- a collection of request.
-
getCompletedRequestsOfType
public <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getCompletedRequestsOfType(@NotNull @NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType) -
getCompletedRequestsOfTypeFiltered
public <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getCompletedRequestsOfTypeFiltered(@NotNull @NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType, Predicate<IRequest<? extends R>> filter) -
markRequestAsAccepted
public void markRequestAsAccepted(@NotNull @NotNull ICitizenData data, @NotNull @NotNull IToken<?> token) -
cancelAllRequestsOfCitizenOrBuilding
Description copied from interface:IBuildingCancel all requests of citizen or building (if citizen data is null)- Parameters:
data- the citizen data (or null).
-
overruleNextOpenRequestWithStack
public void overruleNextOpenRequestWithStack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack) Overrule the next open request with a give stack.We squid:s135 which takes care that there are not too many continue statements in a loop since it makes sense here out of performance reasons.
- Parameters:
stack- the stack.
-
getOpenRequestsOfTypeFiltered
public <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getOpenRequestsOfTypeFiltered(@NotNull @NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType, Predicate<IRequest<? extends R>> filter) -
overruleNextOpenRequestOfCitizenWithStack
public boolean overruleNextOpenRequestOfCitizenWithStack(@NotNull @NotNull ICitizenData citizenData, @NotNull @NotNull net.minecraft.world.item.ItemStack stack) -
getId
Description copied from interface:IRequestResolverProviderUnique token identifying this provider inside the request management system.- Returns:
- the token.
-
getResolvers
Description copied from interface:IRequestResolverProviderMethod to get the resolvers that this provider provides.- Returns:
- a list of resolvers.
-
createResolvers
-
getRequester
-
getLocation
Description copied from interface:IRequesterMethod to get the location of this locatable.- Returns:
- the location.
-
onRequestedRequestComplete
public void onRequestedRequestComplete(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request) Description copied from interface:IRequesterMethod called by the request system to notify this requester that a request is complete.- Parameters:
manager- the request manager.request- the request.
-
onRequestedRequestCancelled
public void onRequestedRequestCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request) Description copied from interface:IRequesterMethod called by the request system to notify this requester that a request has been overruled.- Parameters:
manager- the request manager.request- the request.
-
getRequesterDisplayName
@NotNull public @NotNull net.minecraft.network.chat.MutableComponent getRequesterDisplayName(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request) Description copied from interface:IRequesterGets the name of the requester that requested the request given by the token.- Parameters:
manager- the request manager.request- the request for which the name of the requester is retrieved- Returns:
- The display name of the requester.
-
getCitizenForRequest
-
reservedStacksExcluding
public Map<ItemStorage,Integer> reservedStacksExcluding(@NotNull @NotNull IRequest<? extends IDeliverable> excluded) Description copied from interface:IBuildingCalculate the number of reserved stacks the resolver can't touch.- Parameters:
excluded- ignore reservations that would exist for the current request.- Returns:
- a list of itemstorages.
-
getOpenRequestsOfCitizenOrBuilding
public List<IRequest<?>> getOpenRequestsOfCitizenOrBuilding(int citizenId, Predicate<IRequest<?>> selectionPredicate) Get a list of open requests from the building that are filtered by a predicate for citizen id or building (-1).- Parameters:
citizenId- the citizen id to include.selectionPredicate- the selection predicate.- Returns:
- the list.
-
getCompletedRequestsOfCitizenOrBuilding
public List<IRequest<?>> getCompletedRequestsOfCitizenOrBuilding(@Nullable @Nullable ICitizenData citizenData, Predicate<IRequest<?>> selectionPredicate) Get a list of closed requests from the building that are filtered by a predicate for citizen or building (null citizen).- Parameters:
citizenData- the citizen to include.selectionPredicate- the selection predicate.- Returns:
- the list.
-
moveToSyncCitizen
Move request from building (-1) to citizen and mark synchronous.- Parameters:
citizenData- the citizen to move it to.request- the request to move.
-