Contents
- Description
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- getComponentType()
- hasBenchSet()
- setBench(int, int, int, BlockType)
- clearBench(Ref, ComponentAccessor)
- craftItem(Ref, ComponentAccessor, CraftingRecipe, int, ItemContainer)
- queueCraft(Ref, ComponentAccessor, CraftingWindow, int, CraftingRecipe, int, ItemContainer, CraftingManager.InputRemovalType)
- getRemainingQueueSize()
- tick(Ref, ComponentAccessor, float)
- cancelAllCrafting(Ref, ComponentAccessor)
- getOutputItemStacks(CraftingRecipe)
- getOutputItemStacks(CraftingRecipe, int)
- getOutputItemStack(MaterialQuantity, String)
- getOutputItemStack(MaterialQuantity, int)
- getInputMaterials(CraftingRecipe)
- getInputMaterials(CraftingRecipe, int)
- matches(MaterialQuantity, ItemStack)
- generateInventoryHints(List, int, ItemContainer)
- matchesAnyRecipe(List, int, ItemStack)
- startTierUpgrade(Ref, ComponentAccessor, BenchWindow)
- feedExtraResourcesSection(World, int, int, int, BlockType, int, Bench, int, MaterialExtraResourcesSection)
- toString()
- clone()
Class CraftingManager
java.lang.Object
com.hypixel.hytale.builtin.crafting.component.CraftingManager
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
Crafting Manager
A component that handles the queueing and processing of crafting recipes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDetermines the fashion in which inputs are removed during a craft. -
Field Summary
Fields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancancelAllCrafting(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Called to cancel all crafting within this crafting manager.booleanclearBench(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Called to clear this bench, cancelling all queued crafts.clone()booleancraftItem(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor, CraftingRecipe recipe, int requestedQuantity, ItemContainer itemContainer) Called to instantly craft the given item for the given quantity.static intfeedExtraResourcesSection(World world, int x, int y, int z, BlockType blockType, int rotationIndex, Bench benchAsset, int tierLevel, MaterialExtraResourcesSection extraResourcesSection) Feeds the extra resources section with the contents of chests around the bench.static com.google.gson.JsonArraygenerateInventoryHints(List<CraftingRecipe> recipes, int inputSlotIndex, ItemContainer container) Generates and returns inventory hints for the given recipes.static ComponentType<EntityStore, CraftingManager> static List<MaterialQuantity> getInputMaterials(CraftingRecipe recipe) Fetches a list of material quantities affiliated with the given recipe.static List<MaterialQuantity> getInputMaterials(CraftingRecipe recipe, int quantity) Fetches a list of material quantities affiliated with the given recipe, for the given quantity.static ItemStackgetOutputItemStack(MaterialQuantity outputMaterial, int quantity) Fetches a list of item stacks as the output item stacks for the given output material, for the given quantity.static ItemStackgetOutputItemStack(MaterialQuantity outputMaterial, String id) Fetches a list of item stacks as the output item stacks for the given output material.getOutputItemStacks(CraftingRecipe recipe) Fetches a list of item stacks as the output item stacks for the given recipe.getOutputItemStacks(CraftingRecipe recipe, int quantity) Fetches a list of item stacks as the output item stacks for the given recipe, for the given quantity.intbooleanstatic booleanmatches(MaterialQuantity craftingMaterial, ItemStack itemStack) Determines whether the given crafting material matches the given item stack.static booleanmatchesAnyRecipe(List<CraftingRecipe> recipes, int inputSlotIndex, ItemStack slotItemStack) Determines whether the given item stack matches any of the provided bench recipes.booleanqueueCraft(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor, CraftingWindow window, int transactionId, CraftingRecipe recipe, int requestedQuantity, ItemContainer inputItemContainer, CraftingManager.InputRemovalType inputRemovalType) Called to queue a recipe to be crafted.voidCalled to set the current bench being used for crafting.booleanstartTierUpgrade(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor, BenchWindow window) Called to attempt to start a bench tier upgrade for the affiliated entity.voidtick(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor, float dt) Called to tick and update this crafting manager.toString()Methods inherited from interface Component
cloneSerializable
-
Constructor Details
-
CraftingManager
public CraftingManager()Empty Constructor for aCraftingManagerinstance.Used to initialize the component on an entity.
-
-
Method Details
-
getComponentType
- Returns:
- the component type for the
CraftingManagercomponent.
-
hasBenchSet
public boolean hasBenchSet()- Returns:
trueif the crafting manager has an active bench,falseotherwise.
-
setBench
Called to set the current bench being used for crafting.- Parameters:
x- The X position of the crafting bench.y- The Y position of the crafting bench.z- The Z position of the crafting bench.blockType- The block type of the crafting bench.
-
clearBench
public boolean clearBench(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to clear this bench, cancelling all queued crafts.- Parameters:
ref- The reference of the affiliated entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- True if a craft was cancelled, false otherwise.
-
craftItem
public boolean craftItem(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nonnull CraftingRecipe recipe, int requestedQuantity, @Nonnull ItemContainer itemContainer) Called to instantly craft the given item for the given quantity.- Parameters:
ref- The entity ref of the affiliated entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.recipe- The recipe to craft.requestedQuantity- The quantity of item to craft, before it is resolved against the player's game mode.itemContainer- The container to pick items from.
-
queueCraft
public boolean queueCraft(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nonnull CraftingWindow window, int transactionId, @Nonnull CraftingRecipe recipe, int requestedQuantity, @Nonnull ItemContainer inputItemContainer, @Nonnull CraftingManager.InputRemovalType inputRemovalType) Called to queue a recipe to be crafted.- Parameters:
ref- The entity ref of the affiliated entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.window- The crafting window for this queued craft.transactionId- The transaction id for this queued craft.recipe- The recipe to craft.requestedQuantity- The quantity of item to craft, before it is resolved against the player's game mode.inputItemContainer- The target input item container.
-
getRemainingQueueSize
public int getRemainingQueueSize() -
tick
public void tick(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor, float dt) Called to tick and update this crafting manager.- Parameters:
ref- A reference to the entity affiliated with this crafting manager.componentAccessor- TheComponentAccessor<EntityStore>for component access.dt- The delta time of this tick.
-
cancelAllCrafting
public boolean cancelAllCrafting(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to cancel all crafting within this crafting manager.- Parameters:
ref- The entity ref of the affiliated entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- True if a craft was cancelled, false otherwise.
-
getOutputItemStacks
Fetches a list of item stacks as the output item stacks for the given recipe.- Parameters:
recipe- The recipe that we are fetching the output item stacks for.- Returns:
- a list of
ItemStackinstances as the output items.
-
getOutputItemStacks
@Nonnull public static List<ItemStack> getOutputItemStacks(@Nonnull CraftingRecipe recipe, int quantity) Fetches a list of item stacks as the output item stacks for the given recipe, for the given quantity.- Parameters:
recipe- The recipe that we are fetching the output item stacks for.quantity- The number of the output item stacks to return.- Returns:
- a list of
ItemStackinstances as the output items.
-
getOutputItemStack
@Nullable public static ItemStack getOutputItemStack(@Nonnull MaterialQuantity outputMaterial, @Nonnull String id) Fetches a list of item stacks as the output item stacks for the given output material.- Parameters:
outputMaterial- The output material that we are fetching the output item stacks for.id- The ID of the recipe that the output material is affiliated with.- Returns:
- a list of
ItemStackinstances as the output items.
-
getOutputItemStack
@Nullable public static ItemStack getOutputItemStack(@Nonnull MaterialQuantity outputMaterial, int quantity) Fetches a list of item stacks as the output item stacks for the given output material, for the given quantity.- Parameters:
outputMaterial- The output material that we are fetching the output item stacks for.quantity- The quantity of the item stack to return to the entities inventory.- Returns:
- a list of
ItemStackinstances as the output items, ornullif the output material has no item ID.
-
getInputMaterials
Fetches a list of material quantities affiliated with the given recipe.- Parameters:
recipe- The recipe that we are fetching the material quantities for.- Returns:
- a list of
MaterialQuantityinstances for the given recipe.
-
getInputMaterials
@Nonnull public static List<MaterialQuantity> getInputMaterials(@Nonnull CraftingRecipe recipe, int quantity) Fetches a list of material quantities affiliated with the given recipe, for the given quantity.- Parameters:
recipe- The recipe that we are fetching the material quantities for.quantity- The quantity of the material quantities to return.- Returns:
- a list of
MaterialQuantityinstances for the given recipe.
-
matches
public static boolean matches(@Nonnull MaterialQuantity craftingMaterial, @Nonnull ItemStack itemStack) Determines whether the given crafting material matches the given item stack.- Parameters:
craftingMaterial- The crafting material that we are matching.itemStack- The item stack that we are matching.- Returns:
trueif they match,falseotherwise.
-
generateInventoryHints
@Nonnull public static com.google.gson.JsonArray generateInventoryHints(@Nonnull List<CraftingRecipe> recipes, int inputSlotIndex, @Nonnull ItemContainer container) Generates and returns inventory hints for the given recipes.- Parameters:
recipes- Given list of bench recipes to generate inventory hints for.inputSlotIndex- The index of the current input slot.container- The target item containers.- Returns:
- a new
JsonArrayinstance, populated with the appropriate inventory hints.
-
matchesAnyRecipe
public static boolean matchesAnyRecipe(@Nonnull List<CraftingRecipe> recipes, int inputSlotIndex, @Nonnull ItemStack slotItemStack) Determines whether the given item stack matches any of the provided bench recipes.- Parameters:
recipes- Given list of recipes to match against.inputSlotIndex- The current input slot index.slotItemStack- The item stack to match.- Returns:
trueif the item stack matches any of the given recipes,falseotherwise.
-
startTierUpgrade
public boolean startTierUpgrade(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nonnull BenchWindow window) Called to attempt to start a bench tier upgrade for the affiliated entity.- Parameters:
ref- The entity reference of the instigating player entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.window- The associated bench window.- Returns:
trueif the upgrade was started,falseotherwise.
-
feedExtraResourcesSection
public static int feedExtraResourcesSection(@Nonnull World world, int x, int y, int z, @Nonnull BlockType blockType, int rotationIndex, @Nonnull Bench benchAsset, int tierLevel, @Nonnull MaterialExtraResourcesSection extraResourcesSection) Feeds the extra resources section with the contents of chests around the bench.- Parameters:
world- The world containing the bench.x- The X position of the bench.y- The Y position of the bench.z- The Z position of the bench.blockType- The block type of the bench.rotationIndex- The rotation index of the bench.tierLevel- The current tier level of the bench.extraResourcesSection- The section to populate.- Returns:
- The number of chests found around the bench.
-
toString
-
clone
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-