Class path: mods.botanypots.Crop

To use, import the class with import mods.botanypots.Crop; at the beginning of your script.

Crop.create(id, seed, display, tickRate, multiplier, categories);

  • id <string> The id of the crop. This is a namespaced id an must be in the valid namespace: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.
  • multiplier <float> Another factor for how long the 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.

ZenScript
Copy
Crop.create("examplepack:gold", <item:minecraft:gold_nugget>, <blockstate:minecraft:gold_block>, 3000, 2, ["stone"]);

Crop.remove(id);

  • id <string> The id of the crop to remove. This is a namespaced id an must be in the valid namespace:path format.

Removes a crop based on it's id.

ZenScript
Copy
Crop.remove("botanypots:crop/wheat");

Crop.setSeed(id, seed);

  • id <string> The id of the crop. This is a namespaced id an must be in the valid namespace:path format.
  • seed <IIngredient> The item used to plant the crop.

Sets the item used to plant the crop.

ZenScript
Copy
Crop.setSeed("botanypots:crop/wheat", <item:minecraft:diamond>);

Set Display Block

Link to set-display-block

Crop.setDisplay(id, state);

  • id <string> The id of the crop. This is a namespaced id an must be in the valid namespace:path format.
  • display <MCBlockState> The block to display when rendering the crop.

Sets the block rendered for the crop.

ZenScript
Copy
Crop.setDisplay("botanypots:crop/wheat", <blockstate:minecraft:snow_block>);

Crop.setTickRate(id, tickRate);

  • id <string> The id of the crop. This is a namespaced id an must be in the valid namespace: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.

ZenScript
Copy
Crop.setTickRate("botanypots:crop/wheat", 5000);

Set Growth Multiplier

Link to set-growth-multiplier

Crop.setGrowthModifier(id, multiplier);

  • id <string> The id of the crop. This is a namespaced id an must be in the valid namespace:path format.
  • multiplier <float> The updated multiplier. Another factor for how long the crop takes to grow.

Sets the growth multiplier/modifier for the crop.

ZenScript
Copy
Crop.setGrowthMofieir("botanypots:crop/wheat", 1.8);

Changing Crop Categories

Link to 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

Link to 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 valid namespace:path format.
  • categoriesToAdd <string[]> An array of categories to associate with the crop.
ZenScript
Copy
Crop.addCategory("botanypots:crop/wheat", ["stone", "snow"]);

Remove a Category From a Crop

Link to 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 valid namespace:path format.
  • categoriesToRemove <string[]> An array of categories to dissociate with the crop.
ZenScript
Copy
Crop.removeCategory("botanypots:crop/wheat", ["dirt"]);

Clear All Categories From a Crop

Link to 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 valid namespace:path format.
ZenScript
Copy
Crop.clearCategories("botanypots:crop/wheat");

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 valid namespace: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.

ZenScript
Copy
Crop.addDrop("botanypots:crop/wheat", <item:minecraft:diamond>, 0.05, 1, 1);

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 valid namespace:path format.
  • toRemove <IIngredient> The ingredient to match against for removal

Removes any drops that have a matching item.

ZenScript
Copy
Crop.removeDrop("botanypots:crop/wheat", <item:minecraft:wheat_seeds>);

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.

ZenScript
Copy
// Log all ids to the crafttweaker.log file
for cropId in Crop.getAllIds() {
    println(cropId);
}

Removing All Crops

Link to 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.

ZenScript
Copy
Crop.removeAll();