Class AbstractAutoCrafter
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem
io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractAutoCrafter
- All Implemented Interfaces:
EnergyNetComponent,ItemAttribute,Placeable
- Direct Known Subclasses:
SlimefunAutoCrafter,VanillaAutoCrafter
This is the abstract super class for our auto crafters.
- Author:
- TheBusyBiscuit
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int[]protected final NamespacedKeyTheNamespacedKeyused to determine whether the recipe is enabled.protected final NamespacedKeyTheNamespacedKeyused to store recipe data.Fields inherited from class io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem
addon, disenchantable, enchantable, hidden, recipeOutput, useableInWorkbench -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) -
Method Summary
Modifier and TypeMethodDescriptionbooleancraft(Inventory inv, AbstractRecipe recipe) This method performs a crafting operation.intThis method returns the max amount of electricity this machine can hold.final EnergyNetComponentTypeThis method returns the Type ofEnergyNetComponentTypethisSlimefunItemrepresents.intThis method returns the amount of energy that is consumed per operation.abstract AbstractRecipeThis method returns the currently selectedAbstractRecipefor the givenBlock.protected booleanisValidInventory(Block block) protected booleanprotected booleanvoidonRightClick(Block b, Player p) This method handles our right-clicking behaviour.voidregister(SlimefunAddon addon) This method registers thisSlimefunItem.final AbstractAutoCraftersetCapacity(int capacity) This sets the energy capacity for this machine.final AbstractAutoCraftersetEnergyConsumption(int energyConsumption) This method sets the energy consumed by this machine per tick.protected voidsetSelectedRecipe(Block b, AbstractRecipe recipe) This method sets the selectedAbstractRecipefor the givenBlock.protected voidshowRecipe(Player p, Block b, AbstractRecipe recipe) This shows the givenAbstractRecipeto thePlayerin a preview window.protected voidThis method performs one tick for theAbstractAutoCrafter.protected abstract voidupdateRecipe(Block b, Player p) This method is called when aPlayerright clicks theAbstractAutoCrafterwhile holding the shift button.Methods inherited from class io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem
addItemHandler, addItemSetting, addOfficialWikipage, callItemHandler, canUse, equals, error, getAddon, getBlockTicker, getById, getByItem, getDrops, getDrops, getHandlers, getId, getItem, getItemGroup, getItemName, getItemSetting, getItemSettings, getOptionalById, getOptionalByItem, getRecipe, getRecipeOutput, getRecipeType, getResearch, getState, getWikipage, hashCode, hasResearch, info, isDisabled, isDisabledIn, isDisenchantable, isEnchantable, isHidden, isItem, isItemStackImmutable, isTicking, isUseableInWorkbench, load, postRegister, preRegister, sendDeprecationWarning, setHidden, setItemGroup, setRecipe, setRecipeOutput, setRecipeType, setResearch, setUseableInWorkbench, toString, warnMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent
addCharge, getCharge, getCharge, isChargeable, removeCharge, setChargeMethods inherited from interface io.github.thebusybiscuit.slimefun4.core.attributes.ItemAttribute
getIdMethods inherited from interface io.github.thebusybiscuit.slimefun4.core.attributes.Placeable
useVanillaBlockBreaking
-
Field Details
-
recipeStorageKey
TheNamespacedKeyused to store recipe data. -
recipeEnabledKey
TheNamespacedKeyused to determine whether the recipe is enabled. -
background
protected final int[] background
-
-
Constructor Details
-
AbstractAutoCrafter
@ParametersAreNonnullByDefault protected AbstractAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe)
-
-
Method Details
-
onRightClick
This method handles our right-clicking behaviour.Do not call this method directly, see our
AutoCrafterListenerfor the intended use case. -
tick
This method performs one tick for theAbstractAutoCrafter.- Parameters:
b- The block for thisAbstractAutoCrafterdata- The data stored on this block
-
isValidInventory
-
getSelectedRecipe
This method returns the currently selectedAbstractRecipefor the givenBlock.- Parameters:
b- TheBlock- Returns:
- The currently selected
AbstractRecipeor null
-
updateRecipe
This method is called when aPlayerright clicks theAbstractAutoCrafterwhile holding the shift button. Use it to choose theAbstractRecipe. -
setSelectedRecipe
This method sets the selectedAbstractRecipefor the givenBlock. The recipe will be stored using thePersistentDataAPI.- Parameters:
b- TheBlockto store the data onrecipe- TheAbstractRecipeto select
-
showRecipe
This shows the givenAbstractRecipeto thePlayerin a preview window.- Parameters:
p- ThePlayerb- TheBlockof theAbstractAutoCrafterrecipe- TheAbstractRecipeto show them
-
matches
-
matchesAny
-
craft
This method performs a crafting operation. It will attempt to fulfill the providedAbstractRecipeusing the givenInventory. This will consume items and add the result to theInventory. This method does not handle energy consumption.- Parameters:
inv- TheInventoryto take resources fromrecipe- TheAbstractRecipeto craft- Returns:
- Whether this crafting operation was successful or not
-
getCapacity
public int getCapacity()This method returns the max amount of electricity this machine can hold.- Specified by:
getCapacityin interfaceEnergyNetComponent- Returns:
- The max amount of electricity this Block can store.
-
getEnergyConsumption
public int getEnergyConsumption()This method returns the amount of energy that is consumed per operation.- Returns:
- The rate of energy consumption
-
setCapacity
This sets the energy capacity for this machine. This method must be called before registering the item and only before registering.- Parameters:
capacity- The amount of energy this machine can store- Returns:
- This method will return the current instance of
AContainer, so that it can be chained.
-
setEnergyConsumption
This method sets the energy consumed by this machine per tick.- Parameters:
energyConsumption- The energy consumed per tick- Returns:
- This method will return the current instance of
AContainer, so that it can be chained.
-
register
Description copied from class:SlimefunItemThis method registers thisSlimefunItem. Always call this method after yourSlimefunItemhas been initialized. Never call it more than once!- Overrides:
registerin classSlimefunItem- Parameters:
addon- TheSlimefunAddonthat thisSlimefunItembelongs to.
-
getEnergyComponentType
Description copied from interface:EnergyNetComponentThis method returns the Type ofEnergyNetComponentTypethisSlimefunItemrepresents. It describes how this Block will interact with anEnergyNet.- Specified by:
getEnergyComponentTypein interfaceEnergyNetComponent- Returns:
- The
EnergyNetComponentTypethisSlimefunItemrepresents.
-