Skip to content

Pre 1.4

Mrbysco edited this page Mar 27, 2024 · 2 revisions

SpoilData

An SpoilData Object consists of the spoiling data.

Importing the package

To properly use the Object you should import the package using the following import:
import mods.spoiled.SpoilData;

Constructing SpoilData

To construct an SpoilData Object you need to insert the following parameters (spoilTime is in seconds)
String uniqueID, IItemStack foodStack, IItemStack spoilStack, int spoilTime

An example would be the following:
var BeefToRotten = new SpoilData("BeefToRotten", <item:minecraft:beef>, <item:minecraft:rotten_flesh>, 1200);
Which would cause Beef to turn into Rotten Flesh after 1 minecraft day. (1200 seconds / 60 = 20 minutes)

Registering

To register the SpoilData object you can should import the ChangeSpoiling package using:
import mods.spoiled.ChangeSpoiling;

An example would be:
ChangeSpoiling.addSpoiling(BeefToRotten); (Which would register the example variable above)

ChangeSpoiling.addModSpoiling(String modID, IItemStack spoilStack, int spoilTime); (Syntax)

ChangeSpoiling.addModSpoiling("simplefarming", <item:minecraft:rotten_flesh>, 1200); (An example that will add spoiling to all food items from simplefarming) (turning them into rotten flesh when spoiled)

ChangeSpoiling.replaceSpoiling(BeefToRotten); (Which would replace the known SpoilData Object with the same UniqueID with the constructed one in the example above)

ChangeSpoiling.removeSpoiling("BeefToRotten"); (Which would remove the SpoilData known by the ID BeefToRotten from the example above)

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