Skip to content

Post 1.4.9

Mrbysco edited this page Mar 27, 2024 · 4 revisions

Importing the package

To start adding/removing Spoiling you should import:
import mods.spoiled.SpoilingManager; And create a variable of the IRecipeManager:
var spoilManager = <recipetype:spoiled:spoil_recipe>;

Adding Spoiling

The syntax for adding spoiling would is the following:
spoilManager.addSpoiling(String name, IIngredient originalFood, IItemStack resultStack, int spoilTime
An example would be:
spoilManager.addSpoiling("dirt_to_diamond", <item:minecraft:dirt>, <item:minecraft:diamond_block>, 120) (Which would register the example variable above)

The syntax for adding spoiling to every food item from a mod is the following:
spoilManager.addModSpoiling(String mod_id, IItemStack spoilStack, int spoilTime); (Syntax)
An example would be:
spoilManager.addModSpoiling("simplefarming", <item:minecraft:rotten_flesh>, 120); (An example that will add spoiling to all food items from simplefarming) (turning them into rotten flesh when spoiled)

There are multiple syntaxes for removing spoiling:
spoilManager.removeRecipeByInput(IItemStack input); (1.16 only) (Which would remove the spoiling if the input contains the given IItemStack)

spoilManager.removeByName(String recipeName); (Which would remove the spoiling known by the recipeName)
spoilManager.removeByInput(IItemStack input); (Which would remove the spoiling if the input contains the given IItemStack)
spoilManager.remove(IIngredient output); (Which would remove the spoiling based on the output matching the IIngredient. If wanted)
spoilManager.removeAll(); (Which would remove all spoiling)

Remove item after spoilage

If you want the item to disappear after spoiling you need to set the result stack to <item:minecraft:air>

Example script

An example script that makes dirt spoil into diamond blocks after 12 tries can be found Here

Clone this wiki locally