Class BuildingResourcesModule
java.lang.Object
com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
com.minecolonies.core.colony.buildings.modules.BuildingResourcesModule
- All Implemented Interfaces:
IBuildingModule,IPersistentModule,IHasDirty
The structureBuilder building.
-
Field Summary
Fields inherited from class com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
building, isDirty -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNeededResource(@Nullable net.minecraft.world.item.ItemStack res, int amount) Add a new resource to the needed list.voidcheckOrRequestBucket(@Nullable BuilderBucket requiredResources, ICitizenData worker) Check or request if the contents of a specific batch are in the inventory of the building.voiddeserializeNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Deserialize the module.Get the needed resources for the current build.@Nullable BuilderBucketReturn the next bucket to work on.@Nullable BuilderBucketGet the needed resources for the current build.Get the resource from the identifier.voidGo to the next stage.voidreduceNeededResource(net.minecraft.world.item.ItemStack res, int amount) Reduce a resource of the needed list.booleanrequiresResourceForBuilding(net.minecraft.world.item.ItemStack stack) Check if the structureBuilder requires a certain ItemStack for the current construction.voidResets the needed resources completely.voidserializeNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Serialize the module from a compound.voidserializeToView(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Method to serialize data to send it to the view.voidsetTotalStages(int total) Set the total number of stages.Methods inherited from class com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
checkDirty, clearDirty, getBuilding, getProducer, markDirty, setBuilding, setProducerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.buildings.modules.IBuildingModule
getBuilding, getProducer, serializeToView, setBuilding, setProducerMethods inherited from interface com.minecolonies.api.util.IHasDirty
checkDirty, clearDirty, markDirty
-
Constructor Details
-
BuildingResourcesModule
public BuildingResourcesModule()
-
-
Method Details
-
deserializeNBT
public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Description copied from interface:IPersistentModuleDeserialize the module.- Specified by:
deserializeNBTin interfaceIPersistentModule- Parameters:
compound- the nbt compound.
-
serializeNBT
public void serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Description copied from interface:IPersistentModuleSerialize the module from a compound.- Specified by:
serializeNBTin interfaceIPersistentModule- Parameters:
compound- the compound.
-
serializeToView
public void serializeToView(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Method to serialize data to send it to the view.- Specified by:
serializeToViewin interfaceIBuildingModule- Parameters:
buf- the used ByteBuffer.
-
getNeededResources
Get the needed resources for the current build.- Returns:
- a new Hashmap.
-
getRequiredResources
Get the needed resources for the current build.- Returns:
- the bucket.
-
getResourceFromIdentifier
Get the resource from the identifier.- Parameters:
res- the resource to get.- Returns:
- the resource.
-
addNeededResource
public void addNeededResource(@Nullable @Nullable net.minecraft.world.item.ItemStack res, int amount) Add a new resource to the needed list.- Parameters:
res- the resource.amount- the amount.
-
reduceNeededResource
public void reduceNeededResource(net.minecraft.world.item.ItemStack res, int amount) Reduce a resource of the needed list.- Parameters:
res- the resource.amount- the amount.
-
resetNeededResources
public void resetNeededResources()Resets the needed resources completely. -
requiresResourceForBuilding
public boolean requiresResourceForBuilding(net.minecraft.world.item.ItemStack stack) Check if the structureBuilder requires a certain ItemStack for the current construction.- Parameters:
stack- the stack to test.- Returns:
- true if so.
-
checkOrRequestBucket
public void checkOrRequestBucket(@Nullable @Nullable BuilderBucket requiredResources, ICitizenData worker) Check or request if the contents of a specific batch are in the inventory of the building. This ignores the worker inventory (that is remaining stuff from previous rounds, or already belongs to another bucket)- Parameters:
requiredResources- the bucket to check and request.worker- the worker.
-
nextStage
public void nextStage()Go to the next stage. -
setTotalStages
public void setTotalStages(int total) Set the total number of stages.- Parameters:
total- the total.
-
getNextBucket
Return the next bucket to work on.- Returns:
- the next bucket or a tuple with null inside if non available.
-