diff --git a/docs/examples.md b/docs/examples.md deleted file mode 100644 index de82bb86c615..000000000000 --- a/docs/examples.md +++ /dev/null @@ -1,6 +0,0 @@ -# Examples -Script examples can be found here: - -[Examples](https://github.com/CraftTweaker/CraftTweaker-Examples/tree/master/1.14) - -These are the scripts that have been used to test CraftTweaker in 1.14, they should all work and load just fine, you can use them to get familiarized with the new syntax \ No newline at end of file diff --git a/docs/getting_started.md b/docs/getting_started.md index 0ad02f376a97..982a37ea170e 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -71,4 +71,10 @@ a multiline comment! */ ``` -Just note, that `#` comments are also used for PreProcessors (TODO link to PreProcessors when they are documented), so while they are still valid comments, they could cause unwanted side effects. \ No newline at end of file +Just note, that `#` comments are also used for PreProcessors (TODO link to PreProcessors when they are documented), so while they are still valid comments, they could cause unwanted side effects. + +## Live Editing + +You can use the command `/reload` in CraftTweaker to reload all of your scripts in-game! This feature was deprecated in 1.12.2 but was brought back in 1.14.4 due to a change in when scripts were loaded in in Forge! Use this feature to your advantage to save a lot of time. + +When you feel comfortable with the basics of scripts, feel free to navigate to Recipes to learn how to edit recipes. diff --git a/docs/index.md b/docs/index.md index 4c7469e95936..bb8594cda7e7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,4 +4,4 @@ CraftTweaker is a Minecraft mod that allows modpack authors to customize the gam CraftTweaker uses a custom scripting language called ZenScript, which is a fairly easy to learn language that fits CraftTweaker's needs more than an already existing language would (such as JavaScript). -This site will hopefully help guide you through everything that is possible with CraftTweaker, all that would be left is for you to use the knowledge and create something amazing! \ No newline at end of file +This site will hopefully help guide you through everything that is possible with CraftTweaker, all that would be left is for you to use the knowledge and create something amazing! diff --git a/docs/recipes/adding_recipes/blast_furnace.md b/docs/recipes/adding_recipes/blast_furnace.md new file mode 100644 index 000000000000..b112d3cb9b61 --- /dev/null +++ b/docs/recipes/adding_recipes/blast_furnace.md @@ -0,0 +1,27 @@ +# Blast Furnace + + +## Syntax +Blast Furnaces use several different new syntax that you will be using: +```zenscript +addRecipe(recipeName as String, output as crafttweaker.api.item.IItemStack, input as crafttweaker.api.item.IIngredient, xp as float, cookTime as int); +``` +Just like before, let's break this down: +```zenscript +addRecipe(recipeName, output, input, xp, cookTime); +``` + +| Name | Function | Data Type | Required | +|------|----------|-----------|----------| +| recipeName | name of the new recipe | string | yes | +| output | IItemStack output of the recipe | IItemStack | yes | +| input | IIngredient input of the recipe | IIngredient | yes | +| xp | how much xp the player gets | float | yes | +| cookTime | how long it takes to cook | integer | yes | + +Here is an example: + +```zenscript +addRecipe("diamond_ingot", , , 1.0, 200); +``` +What you see here is that smelting an iron ore would award a diamond. \ No newline at end of file diff --git a/docs/recipes/adding_recipes/campfire.md b/docs/recipes/adding_recipes/campfire.md new file mode 100644 index 000000000000..1f025b60557d --- /dev/null +++ b/docs/recipes/adding_recipes/campfire.md @@ -0,0 +1,27 @@ +# Campfire + + +## Syntax +Campfires use several different new syntax that you will be using: +```zenscript +addRecipe(recipeName as String, output as crafttweaker.api.item.IItemStack, input as crafttweaker.api.item.IIngredient, xp as float, cookTime as int); +``` +Just like before, let's break this down: +```zenscript +addRecipe(recipeName, output, input, xp, cookTime); +``` + +| Name | Function | Data Type | Required | +|------|----------|-----------|----------| +| recipeName | name of the new recipe | string | yes | +| output | IItemStack output of the recipe | IItemStack | yes | +| input | IIngredient input of the recipe | IIngredient | yes | +| xp | how much xp the player gets | float | yes | +| cookTime | how long it takes to cook | integer | yes | + +Here is an example: + +```zenscript +addRecipe("cooked_glowstone", , , 10.0, 150); +``` +What you see here is that smelting a glowstone dust would award a glowstone. \ No newline at end of file diff --git a/docs/recipes/adding_recipes/crafting_table.md b/docs/recipes/adding_recipes/crafting_table.md new file mode 100644 index 000000000000..5054a59fe5ab --- /dev/null +++ b/docs/recipes/adding_recipes/crafting_table.md @@ -0,0 +1,95 @@ +# Crafting Table + + +## Introduction + +There are three main types of recipes for a crafting table. Each one serves a similar but very distinct purpose. + +| Name | Function | +|------|----------| +| addShaped | A shaped recipe. A shaped recipe is a recipe like a pickaxe, in which the ingredients have to be arranged in a specific way or the recipe will not produce. | +| addShapedMirrored | A shaped(mirrored) recipe. This is a recipe that is shaped, but will also work flipped, like when you craft an axe. | +| addShapeless | This is the recipe type when you put a flower in your crafting table and it gives you dye. It doesnt matter where the flower goes, as long as its just the flower. | + +Some things to note: +- The 2x2 crafting grid located in the inventory is considered a `craftingTable` + + +## Syntax: +```zenscript +craftingTable.addShaped(String recipeName, IItemStack output, IIngredient[][] ingredients, @ZenCodeType.Optional RecipeFunctionMatrix recipeFunction); +``` +Okay, that's the technical syntax. Let's digest that into its most basic: +```zenscript +craftingTable.addShaped(recipeName, output, ingredients, recipeFunction); +``` + +Now what does all that mean? + +| Name | Function | Data Type | Required | +|------|----------|-----------|----------| +| recipeName | Used to create an identifier for your recipe. Must be unique for and from each recipe | String | Yes | +| output | This value is what item you want the recipe to make. | IIngredient | Yes | +| ingredients | The actual recipe | Matrix | Yes | +| recipeFunction | ? | ? | No | + +`recipeName` is presented as a string in lowercase, such as `"my_new_recipe"`. It is good practice to create a relevant name, like `"custom_arrow_recipe"` for an Arrow recipe. +`output` is presented as ``. The `<>` and `item:` are required. An example would look like this: `` +`ingredients` is where the fun part comes in. The `IIngredient` is presented as a matrix, which would look something like this: + +3x3 +```zenscript +[[, , ], +[, , ], +[, , ]] +``` + +2x2 +```zenscript +[[, ], +[, ]] +``` + + +### Add Shaped Recipe +```zenscript +craftingTable.addShaped(String recipeName, IItemStack output, IIngredient[][] ingredients, @ZenCodeType.Optional RecipeFunctionMatrix recipeFunction); +``` +This script will add a shaped recipe to the game. Example: +```zenscript +craftingTable.addShaped("iron_tipped_arrow", , [ +[, , ], +[, , ], +[, , ] +]); +``` +This script would create a recipe that not only allows arrows to be crafted diagonally, but with an iron ingot in place of the typical flint. + + +### Add Shaped(Mirrored) Recipe +```zenscript +addShapedMirrored(String recipeName, IItemStack output, IIngredient[][] ingredients, @ZenCodeType.Optional RecipeFunctionMatrix recipeFunction); +``` +This script will add a shaped(mirrored) recipe to the game. Example: +```zenscript +craftingTable.addShapedMirrored("iron_tipped_arrow", , [ +[, , ], +[, , ], +[, , ] +]); +``` +This script is almost identical to the example provided for a `shapedRecipe`, except now, the recipe can be input from both diagonals and still give the output. Good for recipes like axes, arrows, bows, and fishing rods that commonly get flipped around. + + +### Add Shapeless Recipe +```zenscript +addShapeless(String recipeName, IItemStack output, IIngredient[] ingredients, @ZenCodeType.Optional RecipeFunctionArray recipeFunction); +``` +This script will add a shapeless recipe to the game. I will provide a 2x2 example, however this would work in a 3x3 as well: +```zenscript +craftingTable.addShapeless("iron_tipped_arrow", , [ +[, ], +[,] +]); +``` +This script would allow arrows to be crafted in a 2x2 grid by just throwing in those items anywhere. \ No newline at end of file diff --git a/docs/recipes/adding_recipes/furnace.md b/docs/recipes/adding_recipes/furnace.md new file mode 100644 index 000000000000..5f0ff5433b1e --- /dev/null +++ b/docs/recipes/adding_recipes/furnace.md @@ -0,0 +1,27 @@ +# Furnace + + +## Syntax +Furnaces use several different new syntax that you will be using: +```zenscript +addRecipe(recipeName as String, output as crafttweaker.api.item.IItemStack, input as crafttweaker.api.item.IIngredient, xp as float, cookTime as int); +``` +Just like before, let's break this down: +```zenscript +addRecipe(recipeName, output, input, xp, cookTime); +``` + +| Name | Function | Data Type | Required | +|------|----------|-----------|----------| +| recipeName | name of the new recipe | string | yes | +| output | IItemStack output of the recipe | IItemStack | yes | +| input | IIngredient input of the recipe | IIngredient | yes | +| xp | how much xp the player gets | float | yes | +| cookTime | how long it takes to cook | integer | yes | + +Here is an example: + +```zenscript +addRecipe("arrow_to_glowing_arrow", , , 7283.0, 9999); +``` +What you see here is that smelting an arrow would award a spectral arrow, a extremely huge amount of exp, in exchange for a very large cook time. \ No newline at end of file diff --git a/docs/recipes/adding_recipes/smoker.md b/docs/recipes/adding_recipes/smoker.md new file mode 100644 index 000000000000..a5e28e6fda73 --- /dev/null +++ b/docs/recipes/adding_recipes/smoker.md @@ -0,0 +1,27 @@ +# Smoker + + +## Syntax +Smokers use several different new syntax that you will be using: +```zenscript +addRecipe(recipeName as String, output as crafttweaker.api.item.IItemStack, input as crafttweaker.api.item.IIngredient, xp as float, cookTime as int); +``` +Just like before, let's break this down: +```zenscript +addRecipe(recipeName, output, input, xp, cookTime); +``` + +| Name | Function | Data Type | Required | +|------|----------|-----------|----------| +| recipeName | name of the new recipe | string | yes | +| output | IItemStack output of the recipe | IItemStack | yes | +| input | IIngredient input of the recipe | IIngredient | yes | +| xp | how much xp the player gets | float | yes | +| cookTime | how long it takes to cook | integer | yes | + +Here is an example: + +```zenscript +addRecipe("cooked_diamond", , , 1.0, 100); +``` +What you see here is that smelting a raw porkchop would award a diamond. \ No newline at end of file diff --git a/docs/recipes/adding_recipes/stonecutter.md b/docs/recipes/adding_recipes/stonecutter.md new file mode 100644 index 000000000000..928c5e035236 --- /dev/null +++ b/docs/recipes/adding_recipes/stonecutter.md @@ -0,0 +1,19 @@ +# Stonecutter + + +## Syntax +Stonecutters use similar syntax to a furnace, with a few key omissions: +```zenscript +addRecipe(recipeName as String, output as crafttweaker.api.item.IItemStack, input as crafttweaker.api.item.IIngredient); +``` +Just like before, let's break this down: +```zenscript +addRecipe(recipeName, output, input); +``` + +Here is an example: + +```zenscript +addRecipe("arrow_to_glowing_arrow", , ); +``` +What you see here is that "stonecutting" an arrow would award a spectral arrow. \ No newline at end of file diff --git a/docs/recipes/crafting_table.md b/docs/recipes/crafting_table.md deleted file mode 100644 index d79a29dea6ac..000000000000 --- a/docs/recipes/crafting_table.md +++ /dev/null @@ -1,20 +0,0 @@ -# Crafting Table - -### Addition: -```zenscript -craftingTable.addShaped(String recipeName, IItemStack output, IIngredient[][] ingredients, @ZenCodeType.Optional RecipeFunctionMatrix recipeFunction); - -craftingTable.addShaped("shaped_mirror_test", , [[, ], [, ], [, ]], null); - -``` - -```zenscript -addShapedMirrored(String recipeName, IItemStack output, IIngredient[][] ingredients, @ZenCodeType.Optional RecipeFunctionMatrix recipeFunction); - -``` - -```zenscript -addShapeless(String recipeName, IItemStack output, IIngredient[] ingredients, @ZenCodeType.Optional RecipeFunctionArray recipeFunction); - -``` - diff --git a/docs/recipes/recipe_managers.md b/docs/recipes/recipe_managers.md deleted file mode 100644 index 740deeb1228c..000000000000 --- a/docs/recipes/recipe_managers.md +++ /dev/null @@ -1,27 +0,0 @@ -# Recipe managers - - -All recipe related globals extend from this class, and have all of these methods. - -```zenscript -removeRecipe(IItemStack output); -``` - -```zenscript -removeByName(String name); -``` - -```zenscript -removeByModid(String modid); -``` - -```zenscript -removeByRegex(String regex); -``` - -```zenscript -removeAll(); -``` - - - diff --git a/docs/recipes/removing_recipes.md b/docs/recipes/removing_recipes.md new file mode 100644 index 000000000000..c9990d7c6332 --- /dev/null +++ b/docs/recipes/removing_recipes.md @@ -0,0 +1,63 @@ +# Removing Recipes +In order to remove recipes from the game, you will use the desired stationID followed by any of the below functions. All recipe-related globals in CraftTweaker use these following functions, meaning these scripts will work for removing recipes for every vanilla and modded crafting station. +**- THESE FUNCTIONS WILL NOT WORK BY THEMSELVES.** In order to use the listed functions, each script will have to start with the stationID that you want to remove the recipe from. For instance: +```zenscript +craftingTable.removeRecipe(); +``` +Would remove the arrow recipe from a crafting table, but if you could craft it in a smoker, it wont remove it from there. Any and all scripts listed below will not include the stationID. You can find a list of all stationIDs at [INSERT]. + + + +## Functions: + + +### Remove a Recipe +```zenscript +removeRecipe(IItemStack output); +``` +This script will remove a(ll) recipes for a referenced item. For instance, typing +```zenscript +removeRecipe(); +``` +will remove all recipes for a normal Arrow. + + +### Remove by Name +```zenscript +removeByName(String name); +``` +This script will remove every recipe for every item that has the input name. For instance, +```zenscript +removeByName("minecraft:arrow"); +``` +will remove the vanilla recipe for an Arrow. In function, this is identical to the script you were just showed, but this one is better for removing a *certain* recipe instead of all of an items recipes because you can replace `minecraft:arrow` with `:arrow` to ONLY remove that mods recipe for an Arrow. + + +### Remove by Mod ID +```zenscript +removeByModid(String modid); +``` +This script will remove every recipe from a single mod by referencing its `id`. For instance, Minecraft has an id of `minecraft`, so typing +```zenscript +removebyModid("minecraft"); +``` +would remove *every* recipe in Vanilla minecraft, but not recipes added by other mods. + + +### Remove by Regex +```zenscript +removeByRegex(String regex); +``` +This script will remove every recipe that contains the given string somewhere in its name. For instance, +```zenscript +removeByRegex(".*arrow.*"); +``` +would remove every recipe, added by every mod, for every item whose recipe contains the string "arrow". This one is a bit more complex to understand, but try running that example script and then use a mod like `JEI` to try and find recipes for an arrow. +**Note: The `.*` tag searches anywhere in the recipe name. Without it, the string would have to be an exact match. Then it isnt very helpful, because a normal `removeRecipe` would do the same trick.** + + +### Remove All +```zenscript +removeAll(); +``` +This script will remove every recipe from the game. It isnt recommended for general use, but its an option. \ No newline at end of file diff --git a/docs/syntax.md b/docs/syntax.md new file mode 100644 index 000000000000..c03326a8699e --- /dev/null +++ b/docs/syntax.md @@ -0,0 +1,10 @@ +# Syntax + +## Avoiding Script Errors +- Every function in your script has to end with a semicolon (`;`). You will see this inside examples and you will get used to doing it very quickly. +- Use proper brackets. + - Remember to close your brackets. Most text editors come with either a bracket pair highlighting or automatically creating a closing bracket. + +## Referencing +- Every reference to an item in game **must** be referenced with `<>`. + - `` diff --git a/docs/vanilla/stations.md b/docs/vanilla/stations.md new file mode 100644 index 000000000000..ae2632ce0de6 --- /dev/null +++ b/docs/vanilla/stations.md @@ -0,0 +1,10 @@ +## Stations + +Crafting Table - `craftingTable` +Furnace - `furnace` +Smoker - `smoker` +Blast Furnace - `blastFurnace` +Stonecutter - `stoneCutter` +Campfire - `campfire` + +*As more managers are added, more stations will be added* \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 7943a8325267..938b420f300e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -2,14 +2,21 @@ pages: - Home: 'index.md' - Getting Started With Scripts: 'getting_started.md' - - Commands: "commands.md" - - Examples: "examples.md" + - Syntax: 'syntax.md' + - Commands: 'commands.md' - Recipes: - - Recipe Managers: "recipes/recipe_managers.md" - - Crafting Table: "recipes/crafting_table.md" + - Removing Recipes: "recipes/removing_recipes.md" + - Adding Recipes: + - Blast Furnace: "recipes/adding_recipes/blast_furnace.md" + - Campfire: "recipes/adding_recipes/campfire.md" + - Crafting Table: "recipes/adding_recipes/crafting_table.md" + - Furnace: "recipes//adding_recipes/furnace.md" + - Smoker: "recipes/adding_recipes/smoker.md" + - Stone Cutter: "recipes/adding_recipes/stonecutter.md" - Vanilla: - How to: - How to: 'vanilla/how_to/how_to.md' + - Stations: "vanilla/stations.md" - Api: - Block: - Material: