Crops
Class path: mods.botanypots.Crop
Use
To use, import the class with import mods.botanypots.Crop;
at the beginning of your script.
Create A Crop
Crop.create(id, seed, display, tickRate, categories);
id
<string> The id of the crop. This is a namespaced id an must be in the validnamespace:path
format.seed
<IIngredient> The item used to plant the crop.display
<MCBlockState> The block to display when rendering the crop.tickRate
<int> One of the factors for how long a crop takes to grow.categories
<string[]> An array of soil categories this crop can be grown in.
This can be used to create a new crop. Keep in mind that drops need to be added separately.
Crop.create("examplepack:gold", <item:minecraft:gold_nugget>, <blockstate:minecraft:gold_block>, 3000, 2, ["stone"]);
Remove A Crop
Crop.remove(id);
id
<string> The id of the crop to remove. This is a namespaced id an must be in the validnamespace:path
format.
Removes a crop based on it’s id.
Crop.remove("botanypots:crop/wheat");
Set Seed Item
Crop.setSeed(id, seed);
id
<string> The id of the crop. This is a namespaced id an must be in the validnamespace:path
format.seed
<IIngredient> The item used to plant the crop.
Sets the item used to plant the crop.
Crop.setSeed("botanypots:crop/wheat", <item:minecraft:diamond>);
Set Display Block
Crop.setDisplay(id, state);
id
<string> The id of the crop. This is a namespaced id an must be in the validnamespace:path
format.display
<MCBlockState> The block to display when rendering the crop.
Sets the block rendered for the crop.
Crop.setDisplay("botanypots:crop/wheat", <blockstate:minecraft:snow_block>);
Set Tick Rate
Crop.setTickRate(id, tickRate);
id
<string> The id of the crop. This is a namespaced id an must be in the validnamespace:path
format.tickRate
<int> The updated tick rate. One of the factors for how long a crop takes to grow.
Sets the crop tick factor.
Crop.setTickRate("botanypots:crop/wheat", 5000);
Changing Crop Categories
Changes the categories associated with the crop. Categories are used to match the valid soils to the crop.
Add a Category to a Crop
Crop.addCategory(id, categoriesToAdd);
id
<string> The id of the crop. This is a namespaced id an must be in the validnamespace:path
format.categoriesToAdd
<string[]> An array of categories to associate with the crop.
Crop.addCategory("botanypots:crop/wheat", ["stone", "snow"]);
Remove a Category From a Crop
Crop.removeCategory(id, categoriesToRemove);
id
<string> The id of the crop. This is a namespaced id an must be in the validnamespace:path
format.categoriesToRemove
<string[]> An array of categories to dissociate with the crop.
Crop.removeCategory("botanypots:crop/wheat", ["dirt"]);
Clear All Categories From a Crop
Crop.clearCategories(id);
id
<string> The id of the crop. This is a namespaced id an must be in the validnamespace:path
format.
Crop.clearCategories("botanypots:crop/wheat");
Crop Drops
Adding Drops
Crop.addDrop(id, drop, chance, min, max);
id
<string> The id of the crop to add a drop to. This is a namespaced id an must be in the validnamespace:path
format.drop
<IItemStack> The item to drop.chance
<float> The chance it drops.min
<int> The min amount of that item to give.max
<int> The max amount of that item to give.
This adds a new potential drop to the crop.
Crop.addDrop("botanypots:crop/wheat", <item:minecraft:diamond>, 0.05, 1, 1);
Removing Drops
Crop.removeDrop(id, toRemove);
id
<string> The id of the crop to remove a drop from. This is a namespaced id an must be in the validnamespace:path
format.toRemove
<IIngredient> The ingredient to match against for removal
Removes any drops that have a matching item.
Crop.removeDrop("botanypots:crop/wheat", <item:minecraft:wheat_seeds>);
Getting All Ids
Crop.getAllIds();
- Returns: <string[]> An array of all known crop ids at the time this is ran.
This will give you an array of all the known crop ids at the time.
// Log all ids to the crafttweaker.log filefor cropId in Crop.getAllIds() { println(cropId);}
Removing All Crops
This will completely remove all the crops currently registered. This is useful for if you want to recreate all the data from scratch through scripts.
Crop.removeAll();