Class Tool
java.lang.Object
com.minecolonies.api.colony.requestsystem.requestable.Tool
- All Implemented Interfaces:
IDeliverable,IRequestable,IRetryable
Class used to represent equipment inside the request system.
-
Constructor Summary
ConstructorsConstructorDescriptionTool(@NotNull EquipmentTypeEntry equipmentType, @NotNull Integer minLevel, @NotNull Integer maxLevel) Tool(@NotNull EquipmentTypeEntry equipmentType, @NotNull Integer minLevel, @NotNull Integer maxLevel, @NotNull net.minecraft.world.item.ItemStack result) -
Method Summary
Modifier and TypeMethodDescriptioncopyWithCount(int newCount) Creates a new instance of this requestable with the given count.static @NotNull Tooldeserialize(IFactoryController controller, net.minecraft.nbt.CompoundTag nbt) Static method that constructs an instance from NBT.static Tooldeserialize(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.@NotNull EquipmentTypeEntryReturns the equipment type that is requested.@NotNull IntegerThe maximum equipment level requested.intMethod called to get the minimum amount required to fulfill this request.@NotNull IntegerThe minimal equipment level requested.@NotNull net.minecraft.world.item.ItemStackThe resulting stack if set during creation, else ItemStack.Empty.Set<com.google.common.reflect.TypeToken<?>>Get the super classes associated to this request type.inthashCode()booleanisArmor()Check if the equipment is armor.booleanmatches(@NotNull net.minecraft.world.item.ItemStack stack) Method called to check if a given stack matches this deliverable.static @NotNull net.minecraft.nbt.CompoundTagserialize(IFactoryController controller, Tool equipment) Serializes this equipment into NBT.static voidserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer, Tool input) Serialize the deliverable.voidsetResult(@NotNull net.minecraft.world.item.ItemStack result) Method to set the result of a delivery.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.requestsystem.requestable.IDeliverable
canBeResolvedByBuilding
-
Constructor Details
-
Tool
public Tool(@NotNull @NotNull EquipmentTypeEntry equipmentType, @NotNull @NotNull Integer minLevel, @NotNull @NotNull Integer maxLevel) -
Tool
public Tool(@NotNull @NotNull EquipmentTypeEntry equipmentType, @NotNull @NotNull Integer minLevel, @NotNull @NotNull Integer maxLevel, @NotNull @NotNull net.minecraft.world.item.ItemStack result)
-
-
Method Details
-
serialize
@NotNull public static @NotNull net.minecraft.nbt.CompoundTag serialize(IFactoryController controller, Tool equipment) Serializes this equipment into NBT.- Parameters:
controller- The IFactoryController used to serialize sub types.equipment- the equipment to serialize.- Returns:
- The CompoundTag containing the equipment data.
-
getEquipmentType
Returns the equipment type that is requested.- Returns:
- The equipment type that is requested.
-
getMinLevel
The minimal equipment level requested.- Returns:
- The minimal equipment level requested.
-
getMaxLevel
The maximum equipment level requested.- Returns:
- The maximum equipment level requested.
-
deserialize
@NotNull public static @NotNull Tool deserialize(IFactoryController controller, net.minecraft.nbt.CompoundTag nbt) Static method that constructs an instance from NBT.- Parameters:
controller- TheIFactoryControllerto deserialize components with.nbt- The nbt to serialize from.- Returns:
- An instance of equipment with the data contained in the given NBT.
-
serialize
public static void serialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer, Tool input) Serialize the deliverable.- Parameters:
controller- the controller.buffer- the the buffer to write to.input- the input to serialize.
-
deserialize
public static Tool 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.
-
getResult
@NotNull public @NotNull net.minecraft.world.item.ItemStack getResult()The resulting stack if set during creation, else ItemStack.Empty.- Specified by:
getResultin interfaceIDeliverable- Returns:
- The resulting stack.
-
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.
-
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.
-
isArmor
public boolean isArmor()Check if the equipment is armor.- Returns:
- true if so.
-
hashCode
public int hashCode() -
equals
-
getSuperClasses
Description copied from interface:IRequestableGet the super classes associated to this request type.- Specified by:
getSuperClassesin interfaceIRequestable- Returns:
- the type.
-