Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.14 #263

Open
wants to merge 14 commits into
base: 1.14_eol
Choose a base branch
from
6 changes: 0 additions & 6 deletions docs/examples.md

This file was deleted.

8 changes: 7 additions & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
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!
27 changes: 27 additions & 0 deletions docs/recipes/adding_recipes/blast_furnace.md
Original file line number Diff line number Diff line change
@@ -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", <item:minecraft:diamond>, <item:minecraft:iron_ore>, 1.0, 200);
```
What you see here is that smelting an iron ore would award a diamond.
27 changes: 27 additions & 0 deletions docs/recipes/adding_recipes/campfire.md
Original file line number Diff line number Diff line change
@@ -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", <item:minecraft:glowstone>, <item:minecraft:glowstone_dust>, 10.0, 150);
```
What you see here is that smelting a glowstone dust would award a glowstone.
95 changes: 95 additions & 0 deletions docs/recipes/adding_recipes/crafting_table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Crafting Table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation for the crafting table has been added here.

I think some decisions should be made as to how the documentation should be structured. @jaredlll08 when you have some time, I think it would be good to draft up a general concept for contributors to follow and add it to the README.



## 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 `<item:modid:itemname>`. The `<>` and `item:` are required. An example would look like this: `<item:minecraft:arrow>`
`ingredients` is where the fun part comes in. The `IIngredient` is presented as a matrix, which would look something like this:

3x3
```zenscript
[[<item>, <item>, <item>],
[<item>, <item>, <item>],
[<item>, <item>, <item>]]
```

2x2
```zenscript
[[<item>, <item>],
[<item>, <item>]]
```


### 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", <item:minecraft:arrow>, [
[<item:minecraft:air>, <item:minecraft:air>, <item:minecraft:iron_ingot>],
[<item:minecraft:air>, <item:minecraft:stick>, <item:minecraft:air>],
[<item:minecraft:feather>, <item:minecraft:air>, <item:minecraft:air>]
]);
```
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", <item:minecraft:arrow>, [
[<item:minecraft:air>, <item:minecraft:air>, <item:minecraft:iron_ingot>],
[<item:minecraft:air>, <item:minecraft:stick>, <item:minecraft:air>],
[<item:minecraft:feather>, <item:minecraft:air>, <item:minecraft:air>]
]);
```
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", <item:minecraft:arrow>, [
[<item:minecraft:iron_ingot>, <item:minecraft:air>],
[<item:minecraft:stick>,<item:minecraft:feather>]
]);
```
This script would allow arrows to be crafted in a 2x2 grid by just throwing in those items anywhere.
27 changes: 27 additions & 0 deletions docs/recipes/adding_recipes/furnace.md
Original file line number Diff line number Diff line change
@@ -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", <item:minecraft:spectral_arrow>, <item:minecraft: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.
27 changes: 27 additions & 0 deletions docs/recipes/adding_recipes/smoker.md
Original file line number Diff line number Diff line change
@@ -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", <item:minecraft:diamond>, <item:minecraft:raw_porkchop>, 1.0, 100);
```
What you see here is that smelting a raw porkchop would award a diamond.
19 changes: 19 additions & 0 deletions docs/recipes/adding_recipes/stonecutter.md
Original file line number Diff line number Diff line change
@@ -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", <item:minecraft:spectral_arrow>, <item:minecraft:arrow>);
```
What you see here is that "stonecutting" an arrow would award a spectral arrow.
20 changes: 0 additions & 20 deletions docs/recipes/crafting_table.md

This file was deleted.

27 changes: 0 additions & 27 deletions docs/recipes/recipe_managers.md

This file was deleted.

63 changes: 63 additions & 0 deletions docs/recipes/removing_recipes.md
Original file line number Diff line number Diff line change
@@ -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(<item:minecraft:arrow>);
```
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script will remove a(ll)
Should the a(ll) just be all?

```zenscript
removeRecipe(<item:minecraft:arrow>);
```
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 `<modid>: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.
10 changes: 10 additions & 0 deletions docs/syntax.md
Original file line number Diff line number Diff line change
@@ -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 `<>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement feels a bit miss-leading, as you could also later reference an item using a variable, which would not need to be surrounded with brackets.

- `<item:modID:itemID>`
10 changes: 10 additions & 0 deletions docs/vanilla/stations.md
Original file line number Diff line number Diff line change
@@ -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*
Loading