Interface IRequest<R extends IRequestable>
- Type Parameters:
R- The type of request, eg ItemStack, FluidStack etc.
- All Known Implementing Classes:
AbstractRequest,StandardRequests.AbstractCraftingRequest,StandardRequests.BurnableRequest,StandardRequests.DeliveryRequest,StandardRequests.FoodRequest,StandardRequests.ItemStackListRequest,StandardRequests.ItemStackRequest,StandardRequests.ItemTagRequest,StandardRequests.MinStackRequest,StandardRequests.PickupRequest,StandardRequests.PrivateCraftingRequest,StandardRequests.PublicCraftingRequest,StandardRequests.SmeltAbleOreRequest,StandardRequests.ToolRequest
public interface IRequest<R extends IRequestable>
Used to represent requests, of type R, made to the internal market of the colony.
-
Method Summary
Modifier and TypeMethodDescription<T extends IToken<?>>
voidaddChild(T child) Method used to add a single Child.<T extends IToken<?>>
voidaddChildren(@NotNull Collection<T> children) Method to add multiple children in a single call.<T extends IToken<?>>
voidaddChildren(T... children) Method to add multiple children in a single call.voidaddDelivery(@NotNull List<net.minecraft.world.item.ItemStack> list) Adds a list of stacks as a delivery to this request.voidaddDelivery(@NotNull net.minecraft.world.item.ItemStack stack) Adds a single stack as a delivery to this request.booleanMethod used to indicate that the result of this request can be delivered.voidchildStateUpdated(@NotNull IRequestManager manager, @NotNull IToken<?> child) Method called by a child state to indicate that its state has been updated.@NotNull com.google.common.collect.ImmutableCollection<IToken<?>> Method to get the children of this request.@NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> Method to get the ItemStacks used for the delivery.@NotNull net.minecraft.resources.ResourceLocationMethod used to get a ResourceLocation that is displayed instead of thegetDisplayStacks(), whengetDisplayStacks()returns an empty list.@NotNull List<net.minecraft.world.item.ItemStack> Method used to get a List of ItemStacks that represents the stack.<T extends IToken<?>>
TgetId()The unique token representing the request outside of the management system.@NotNull net.minecraft.network.chat.ComponentMethod used to get aComponentthat can be displayed to the Player and describes so that the player can complete it.<T extends IToken<?>>
TReturns the parent of this request.Return the object that is actually requested.@NotNull IRequesterThe element of the colony that requested this request.<T> @NotNull Optional<T> getRequestOfType(Class<T> tClass) Get a request of a specific type.List<net.minecraft.network.chat.MutableComponent> getResolverToolTip(IColonyView colony) Get the resolver tooltip for a request.Returns the result of this request.@NotNull net.minecraft.network.chat.ComponentMethod used to get aComponentthat can be displayed to the Player and describes the request in short.@NotNull RequestStategetState()Returns the current state of the request.default AssigningStrategyMethod to get the assigning strategy for this request.Set<com.google.common.reflect.TypeToken<?>> Get all super classes of this type (cached value).@NotNull com.google.common.reflect.TypeToken<? extends R> getType()Used to determine which type of request this is.booleanMethod to check if this request has children.booleanReturns true if this request has a parent, false if not.booleanMethod used to check if the result has been set.voidoverrideCurrentDeliveries(@NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> stacks) Sets the deliveries of this request to the given stacks<T extends IToken<?>>
voidremoveChild(T child) Method used to remove a single Child.<T extends IToken<?>>
voidremoveChildren(@NotNull Collection<T> children) Method to remove multiple children in a single call.<T extends IToken<?>>
voidremoveChildren(T... children) Method to remove multiple children in a single call.voidReset the deliveries of the request.<T extends IToken<?>>
voidsetParent(T parent) Method used to set the parent of a request.voidSetter for the result of the request.voidsetState(@NotNull IRequestManager manager, @NotNull RequestState state) Setter for the current state of this request.
-
Method Details
-
getStrategy
Method to get the assigning strategy for this request.- Returns:
- The assigning strategy for this request.
-
getId
The unique token representing the request outside of the management system.- Type Parameters:
T- generic token.- Returns:
- the token representing the request outside of the management system.
-
getType
Used to determine which type of request this is. Only RequestResolvers for this Type are then used to resolve the this.- Returns:
- The class that represents this Type of Request.
-
getState
Returns the current state of the request.- Returns:
- The current state.
-
setState
Setter for the current state of this request. It is not recommended to call this method from outside of the request management system.- Parameters:
manager- the request manager.state- The new state of this request.
-
getRequester
The element of the colony that requested this request.- Returns:
- The requester of this request.
-
getRequest
Return the object that is actually requested. A RequestResolver can compare this object however way it sees fit.During the resolving process this object is called multiple times. But at least twice. A cached implementation is preferred.
- Returns:
- The object that is actually requested.
-
getResult
Returns the result of this request.- Returns:
- The result of this request, or null if it is not available.
-
setResult
Setter for the result of the request.- Parameters:
result- The new result of this request.
-
hasResult
boolean hasResult()Method used to check if the result has been set.- Returns:
- True when the result has been set, false when not.
-
getParent
Returns the parent of this request. If this is set it means that this request is part of request chain.- Type Parameters:
T- generic token.- Returns:
- The parent of this request, or null if it has no parent.
-
setParent
Method used to set the parent of a request.- Type Parameters:
T- generic token.- Parameters:
parent- The new parent, or null to clear the existing one.
-
hasParent
boolean hasParent()Returns true if this request has a parent, false if not.- Returns:
- true if this request has a parent, false if not.
-
addChild
Method used to add a single Child.- Type Parameters:
T- generic token.- Parameters:
child- The new child request to add.
-
addChildren
Method to add multiple children in a single call.- Type Parameters:
T- generic token.- Parameters:
children- An array of children to add.
-
addChildren
Method to add multiple children in a single call.- Type Parameters:
T- generic token.- Parameters:
children- A collection of children to add.
-
removeChild
Method used to remove a single Child.- Type Parameters:
T- generic token.- Parameters:
child- The new child request to remove.
-
removeChildren
Method to remove multiple children in a single call.- Type Parameters:
T- generic token.- Parameters:
children- An array of children to remove.
-
removeChildren
Method to remove multiple children in a single call.- Type Parameters:
T- generic token.- Parameters:
children- A collection of children to remove.
-
hasChildren
boolean hasChildren()Method to check if this request has children.- Returns:
- true if it has children.
-
getChildren
Method to get the children of this request. Immutable.- Returns:
- An immutable collection of the children of this request.
-
childStateUpdated
void childStateUpdated(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IToken<?> child) Method called by a child state to indicate that its state has been updated.- Parameters:
manager- The manager that caused the update on the child.child- The child that was updated.
-
canBeDelivered
boolean canBeDelivered()Method used to indicate that the result of this request can be delivered.- Returns:
- True for requests that can be delivered, false when not.
-
getDeliveries
@NotNull @NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> getDeliveries()Method to get the ItemStacks used for the delivery.- Returns:
- The ItemStacks that the Deliveryman transports around.
AbstractCollection.isEmpty()means no delivery possible.
-
overrideCurrentDeliveries
void overrideCurrentDeliveries(@NotNull @NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> stacks) Sets the deliveries of this request to the given stacks- Parameters:
stacks- The stacks that will be the deliveries.
-
addDelivery
void addDelivery(@NotNull @NotNull net.minecraft.world.item.ItemStack stack) Adds a single stack as a delivery to this request.- Parameters:
stack- The stack that should be treated as a new delivery.
-
addDelivery
Adds a list of stacks as a delivery to this request.- Parameters:
list- The list of stacks that should be treated as a new delivery.
-
getShortDisplayString
@NotNull @NotNull net.minecraft.network.chat.Component getShortDisplayString()Method used to get aComponentthat can be displayed to the Player and describes the request in short. Should represent the request, in case the player needs to fulfill it, or information about this request is required.- Returns:
- The text that describes this Request.
-
getLongDisplayString
@NotNull @NotNull net.minecraft.network.chat.Component getLongDisplayString()Method used to get aComponentthat can be displayed to the Player and describes so that the player can complete it. Should represent the request, in case the player needs to fulfill it, or information about this request is required.- Returns:
- The text that describes this Request.
-
getDisplayStacks
Method used to get a List of ItemStacks that represents the stack. This list is used in GUI to show what the request is. If an empty list is returned then no stack is shown. If a list with multiple stacks is returned it will switch between the stacks once every second unless the player holds the shift key.- Returns:
- A List of ItemStacks that represents this request.
-
getDisplayIcon
@NotNull @NotNull net.minecraft.resources.ResourceLocation getDisplayIcon()Method used to get a ResourceLocation that is displayed instead of thegetDisplayStacks(), whengetDisplayStacks()returns an empty list.- Returns:
- The ResourceLocation of the Image dat is displayed when their are no DisplayStacks.
-
getRequestOfType
Get a request of a specific type.- Type Parameters:
T- the type.- Parameters:
tClass- the class of it.- Returns:
- the request of this particular type.
-
getSuperClasses
Set<com.google.common.reflect.TypeToken<?>> getSuperClasses()Get all super classes of this type (cached value).- Returns:
- an immutable copy of the set.
-
getResolverToolTip
Get the resolver tooltip for a request.- Parameters:
colony- the colony view to obtain information if necessary.- Returns:
- a list of strings or empty.
-
resetDeliveries
void resetDeliveries()Reset the deliveries of the request.
-