CraftingTable constructor
CraftingTable({
- String name = 'craft',
- int id = 0,
- List<
Recipe> ? recipes, - String? recipeSource,
- String? recipeResultSource,
- Item? placeholder,
- Item? blockModel,
- TextComponent? displayName,
- bool giveCommandFunction = false,
- Widget? onDestroy,
- Item? guiModel,
- List<
Widget> ? main, - bool useBarrel = false,
- bool invisibleHitbox = true,
The CraftingTable is the core widget to instantiate a custom crafter. It generates a pack(with a custom namespace) itself as well as the needed functions depending on the inputs. The Crafter is a modified chest with an armorstand inside to implement the logic.
Constructor | (all optional) |
---|---|
name | your custom namespace for the pack and all the scores |
displayName | a TextComponent for the name that is displayed in the GUI |
id | the starting id of your recipes(automatically increases) |
recipes | a list of your recipes |
recipeSource | another file location for a recipe function |
recipeResultSource | another file location for the result function |
placeholder | an Item that blocks all the slots that are not used |
guiModel | an Item that is retextured to display a GUI; replaces a placeholder by specifing the Slot of the Item |
blockModel | replaces the head slot of the Armorstand to display a model for the block |
invisibleHitbox | bool whether to include code to make the chest invisible(default = true) |
useBarrel | set to true if you want to use a barrel instead |
giveCommandFunction | bool whether to include a function to generate recipes in minecraft |
main | a List of Widgets that are executed every tick |
onDestroy | a Widget that is executed when the crafting table is destroyed |
After you specified all your wanted options and visuals, you get a fully working datapack.
Ingame run the set
function to create a new craftingtable at the current location. Obviously you can also trigger this with other packs as well.
In this craftingtable you can then use your specified recipes.
Implementation
CraftingTable({
this.name = 'craft',
this.id = 0,
this.recipes,
this.recipeSource,
this.recipeResultSource,
this.placeholder,
this.blockModel,
this.displayName,
this.giveCommandFunction = false,
this.onDestroy,
this.guiModel,
this.main,
this.useBarrel = false,
this.invisibleHitbox = true,
}) {
displayName ??= TextComponent('Custom Crafting Table');
}