Class Stack
java.lang.Object
com.minecolonies.api.colony.requestsystem.requestable.Stack
- All Implemented Interfaces:
IConcreteDeliverable,IDeliverable,IRequestable,IRetryable
- Direct Known Subclasses:
MinimumStack
Deliverable that can only be fulfilled by a single stack with a given minimal amount of items.
-
Constructor Summary
ConstructorsConstructorDescriptionStack(@NotNull ItemStorage itemStorage) Transform an itemStorage into this predicate.Stack(@NotNull net.minecraft.world.item.ItemStack stack) Create a Stack deliverable.Stack(@NotNull net.minecraft.world.item.ItemStack stack, boolean matchDurability) Create a Stack deliverable.Stack(@NotNull net.minecraft.world.item.ItemStack stack, boolean matchDamage, boolean matchNBT, @NotNull net.minecraft.world.item.ItemStack result, int count, int minCount) Create a Stack deliverable.Stack(@NotNull net.minecraft.world.item.ItemStack stack, int count, int minCount) Create a Stack deliverable.Stack(@NotNull net.minecraft.world.item.ItemStack stack, int count, int minCount, boolean matchNBT) Create a Stack deliverable with variable nbt.Stack(net.minecraft.world.item.ItemStack stack, boolean matchDamage, boolean matchNBT, net.minecraft.world.item.ItemStack result, int count, int minCount, boolean canBeResolvedByBuilding) Create a Stack deliverable. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCan this type of request be resolved by the building, or only by external resolvers.copyWithCount(int newCount) Creates a new instance of this requestable with the given count.static Stackdeserialize(IFactoryController controller, net.minecraft.nbt.CompoundTag compound) Deserialize the deliverable.static Stackdeserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer) Deserialize the deliverable.booleanintgetCount()Method called to get the amount of items that need to be in the stack.intMethod called to get the minimum amount required to fulfill this request.List<net.minecraft.world.item.ItemStack>Get a list of concrete items requested by this deliverable@NotNull net.minecraft.world.item.ItemStackMethod to get the result of the delivery.@NotNull net.minecraft.world.item.ItemStackgetStack()Set<com.google.common.reflect.TypeToken<?>>Get the super classes associated to this request type.inthashCode()booleanCheck if damage should be matched.booleanmatches(@NotNull net.minecraft.world.item.ItemStack stack) Method called to check if a given stack matches this deliverable.booleanmatchNBT()Check if nbt should be matched.static net.minecraft.nbt.CompoundTagserialize(IFactoryController controller, Stack input) Serialize the deliverable.static voidserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer, Stack input) Serialize the deliverable.voidsetCanBeResolvedByBuilding(boolean canBeResolvedByBuilding) voidsetResult(@NotNull net.minecraft.world.item.ItemStack result) Method to set the result of a delivery.
-
Constructor Details
-
Stack
public Stack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack) Create a Stack deliverable.- Parameters:
stack- the required stack.
-
Stack
public Stack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, boolean matchDurability) Create a Stack deliverable.- Parameters:
stack- the required stack.matchDurability- whether or not to match Durability
-
Stack
public Stack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, int count, int minCount) Create a Stack deliverable.- Parameters:
stack- the required stack.count- the count.minCount- the min count.
-
Stack
Transform an itemStorage into this predicate.- Parameters:
itemStorage- the storage to use.
-
Stack
public Stack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, int count, int minCount, boolean matchNBT) Create a Stack deliverable with variable nbt.- Parameters:
stack- the stack to deliver.count- the count.minCount- the min count.matchNBT- if nbt has to match.
-
Stack
public Stack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, boolean matchDamage, boolean matchNBT, @NotNull @NotNull net.minecraft.world.item.ItemStack result, int count, int minCount) Create a Stack deliverable.- Parameters:
stack- the required stack.matchDamage- if damage has to be matched.matchNBT- if NBT has to be matched.result- the result stack.count- the count.minCount- the min count.
-
Stack
public Stack(net.minecraft.world.item.ItemStack stack, boolean matchDamage, boolean matchNBT, net.minecraft.world.item.ItemStack result, int count, int minCount, boolean canBeResolvedByBuilding) Create a Stack deliverable.- Parameters:
stack- the required stack.matchDamage- if damage has to be matched.matchNBT- if NBT has to be matched.result- the result stack.count- the count.minCount- the min count.canBeResolvedByBuilding- if can be resolved by building.
-
-
Method Details
-
serialize
Serialize the deliverable.- Parameters:
controller- the controller.input- the input.- Returns:
- the compound.
-
deserialize
public static Stack deserialize(IFactoryController controller, net.minecraft.nbt.CompoundTag compound) Deserialize the deliverable.- Parameters:
controller- the controller.compound- the compound.- Returns:
- the deliverable.
-
serialize
public static void serialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer, Stack input) Serialize the deliverable.- Parameters:
controller- the controller.buffer- the the buffer to write to.input- the input to serialize.
-
deserialize
public static Stack deserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer) Deserialize the deliverable.- Parameters:
controller- the controller.buffer- the buffer to read.- Returns:
- the deliverable.
-
matches
public boolean matches(@NotNull @NotNull net.minecraft.world.item.ItemStack stack) Description copied from interface:IDeliverableMethod called to check if a given stack matches this deliverable. The first stack that returns true from this method is returned as a Deliverable.- Specified by:
matchesin interfaceIDeliverable- Parameters:
stack- The stack to test.- Returns:
- true when the stack matches. False when not.
-
getCount
public int getCount()Description copied from interface:IDeliverableMethod called to get the amount of items that need to be in the stack.- Specified by:
getCountin interfaceIDeliverable- Returns:
- The amount of items.
-
getMinimumCount
public int getMinimumCount()Description copied from interface:IDeliverableMethod called to get the minimum amount required to fulfill this request.- Specified by:
getMinimumCountin interfaceIDeliverable- Returns:
- the minimum amount.
-
getStack
@NotNull public @NotNull net.minecraft.world.item.ItemStack getStack() -
setResult
public void setResult(@NotNull @NotNull net.minecraft.world.item.ItemStack result) Description copied from interface:IDeliverableMethod to set the result of a delivery.- Specified by:
setResultin interfaceIDeliverable- Parameters:
result- The result of the delivery.
-
matchNBT
public boolean matchNBT()Check if nbt should be matched.- Returns:
- true if so.
-
matchDamage
public boolean matchDamage()Check if damage should be matched.- Returns:
- true if so.
-
copyWithCount
Description copied from interface:IDeliverableCreates a new instance of this requestable with the given count.- Specified by:
copyWithCountin interfaceIDeliverable- Parameters:
newCount- The new requestable, with the requested count.- Returns:
- the deliverable.
-
getResult
@NotNull public @NotNull net.minecraft.world.item.ItemStack getResult()Description copied from interface:IDeliverableMethod to get the result of the delivery.- Specified by:
getResultin interfaceIDeliverable- Returns:
- The result of the delivery.
-
equals
-
hashCode
public int hashCode() -
canBeResolvedByBuilding
public boolean canBeResolvedByBuilding()Description copied from interface:IDeliverableCan this type of request be resolved by the building, or only by external resolvers.- Specified by:
canBeResolvedByBuildingin interfaceIDeliverable- Returns:
- true if so.
-
setCanBeResolvedByBuilding
public void setCanBeResolvedByBuilding(boolean canBeResolvedByBuilding) -
getRequestedItems
Description copied from interface:IConcreteDeliverableGet a list of concrete items requested by this deliverable- Specified by:
getRequestedItemsin interfaceIConcreteDeliverable- Returns:
-
getSuperClasses
Description copied from interface:IRequestableGet the super classes associated to this request type.- Specified by:
getSuperClassesin interfaceIRequestable- Returns:
- the type.
-