Who is this plugin intended for?
Have you invested a lot of time in creating farms that can produce large numbers of resources only to find that now you spend all of your time manually crafting the raw resources into items you can use? If this sucks the joy out of the game for you, this plugin can help. It provides the mechanisms to automate the crafting of items.
What does this plugin do?
This plugin implements an automatic crafting system (aka autocrafter). That is, a player no longer needs to interact directly with a workbench to craft large numbers of items. The player can no arrange a series of blocks, specify a recipe and the blocks will convert raw ingredients into new crafted items, automatically.
First you must configure a dropper as a "crafting block". To do this, place an item frame on a dropper and place a crafting table in the item frame. At that point, the item frame will become invisible and the "crafting block" can be configured to craft items automatically once a recipe is set and raw ingredients are provided.
Now place an "output" container (chest, barrel, shulkerbox, hopper, etc) in front of the crafting block/dropper (that is, adjacent to the dropper's face). This is where the crafting block will place items after it crafts them. Finally, on the side of the dropper opposite that of the "output" container place an "input"/"ingredients" container. This is where the crafting block will look for suitable crafting ingredients each crafting tick to craft a new item or block.
How do you configure the crafting recipe?
Once the the dropper has been configured as a crafting block with suitable input and output containers, interact with the crafting block like a workbench. Right-click on it an the player will see the traditional workbench GUI. Fill the crafting block's inventory with the ingredients of the recipe you wish to craft exactly as you would if you were using a recipe on a crafting table. Close the crafting block's inventory without pulling the crafted item from the result slot. At this point, you have an operational "automatic crafting block". Every crafting tick (20 game ticks by default), the crafting block will try to pull ingredients from the ingredients container to satisfy the requirements of the recipe and if successful, convert the ingredients into the crafted item, placing the new item in the output container. If there is not enough room in the output container, no items will be crafted.
Every time a new item is crafted, the crafting table previously placed in the item frame will rotate once clockwise to provide feedback that the crafting block is working. (If this item is removed from the frame, the crafting block will revert back to an ordinary dropper.)
If the ingredients container is a trapped chest, the crafting block will never pull the last item from an inventory slot. This behavior allows you to reserve slots in the trapped chest for particular ingredients and is very useful when recipes require a mix of ingredients and you do not want one hopper feeding into the chest using up all of the slots leaving no room for the other ingredients needed for the recipe.
Which recipes are supported?
Most recipes are supported, even those added using data packs. However, some recipes are not currently supported. The Minecraft server implements some recipes as special cases that are not crafted using the normal crafting mechanics. These recipes are described at
https://minecraft.fandom.com/wiki/Recipe#crafting_special_.2A.
To make these work, they must be emulated in the plugin. Currently, fireworks, suspicious stew, tipped arrows, dyeing shulker boxes and applying banners to shields are emulated. Other special recipes will be added as time and interest permit.
Also, when honey blocks are crafted the empty glass bottles are placed in the output container along with the honey block.
How much load does it place on the server?
Much time has been spent to reduce the overhead of this plugin, both as direct processing time and memory pressure that leads to larger garbage collection overhead. The server load will depend on how busy the crafting blocks are. Even so, on my test server, with a number of farms continuously producing blocks, the load remains below 1% of the server tick. When the crafting blocks are idle, the plugin often does not show up in /timings unless you show all activity in the report.
CONFIGURATION (config.yml)
When the plugin starts, it will create its configuration file, config.yml in its configuration directory, Craftmatic, if it does not already exist. The plugin will never modify an existing config.yml even when new configuration options are added to the plugin. (This is so that any helpful comments that an administrator has added to config.yml are not lost as Spigot's API for modifying configuration does not preserve comments.) Even so, the plugin will create/overwrite a config.default.yml every time it starts. An administrator should never modify this file as changes will be overwritten. This latter file serves as documentation of all configuration items that the current version of the plugin supports (and there default values if unspecified.)
KNOWN ISSUES
- It may still happen that changing the containers on either side of the crafting block, may cause the crafting block to stop crafting in some edge-case scenarios. However, if you then open and close the dropper's inventory or click on the crafting table in the item frame, it will start crafting again.
- Minecraft accepts shaped recipes even if they are mirrored left to right in the workbench. The plugin does not currently support this. The layout of items in the crafting block must match the recipe exactly for shaped recipes.
- For unknown reasons if a player is viewing into a double chest that is the output of a crafting block, the player's view will close immediately after the crafting block places a new item in the double chest on 1.17. This does not happen in 1.16 or with other containers.
KNOWN ISSUES WITH LWC PLUGIN
The behaviors of the craftmatic plugin interacts with the behavior of the LWC plugin. Specifically, the craftmatic plugin generates an InventoryMoveItem event when it crafts an item making it appear as if items are moving from the source/input container directly to the destination/output container. LWC protects chests in part by selectively canceling these types of events.
During my testing, normal functionality of both plugins occurs if the player tells the LWC plugin that hoppers should be allowed to place blocks into the output container. This is necessary even if the input container is not a hopper. That is, the player should execute "/lwc flag hopperin on" and left-click on the output container and then the crafting block should be able to place crafted items in the output container.
Controlling Use Through Permissions
The plugin itself does not attempt to implement strong control over use of crafting blocks using permissions. Instead, for situations in which more control is needed, the plugin can be configured to be activated only using a custom, uncraftable, block instead of the default crafting table item. Then the server administrator would use other resources to control the creation and distribution of these activation blocks.
If you wish to strongly control who can create crafting blocks then you will want to choose an activation item (the item placed in the item frame) that cannot be gathered or crafted from the world through normal means. In this case, you can set the activation item to a serialized ItemStack specification in the config.yml. Below is an example that forces the use of a crafting table with a specific descriptive "lore" and plugin-specific NBT data. Use the /craftmatic:give command to get this block in-game. The use of the give command itself is controlled with the craftmatic.command.give permission.
Code (Text):
activationItem:
==: org.bukkit.inventory.ItemStack
v: 2730
type: CRAFTING_TABLE
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: '"craftmatic activator"'
lore:
- '{"text":"activates one automatic crafting block","color":"yellow","italic":false}'
PublicBukkitValues:
craftmatic:valid: 1i
NOTE: The above has only been tested on 1.17 so far. The serialized form can change with each Spigot version and may necessarily be different on 1.16.5.
Although the activationItem configuration item can be created and edited by hand, it is not recommended. Instead, the admin should create the item in-game using other plugins to edit the item name and lore as desired. The "/craftmatic item mark" command can also be used to add additional NBT data to the item that cannot easily be manipulated by other plugins. Once the item has been completed as desired, use the "/craftmatic item show" command to generate and display the necessary org.bukkit.inventory.ItemStack value for the activationItem configuration. The admin can then copy and paste the generated value into config.yml.
COMMANDS and PERMISSIONS
All commands are implemented as sub-commands of the /craftmatic command.
permission:
craftmatic.commands.use
This command does nothing without further arguments. However, a player must have the required permission to use any craftmatic commands and for the command to show up in the player's available command list.
Code (Text):
/craftmatic item give
permission:
craftmatic.command.item-give
This command gives the player one of the activation items defined in the configuration file that must be placed in the item frame to create a crafting block.
Code (Text):
/craftmatic item mark
permission:
craftmatic.command.item-mark
This command adds Craftmatic-specific metadata to the item in hand to essentially create a unique item. Useful when ops construct custom activation items for use with the plugin.
Code (Text):
/craftmatic item show
permission:
craftmatic.command.item-show
This command displays in the player's chat the serialized form of the item in-hand. This serialized form is suitable for including in the plugin's configuration file to redefine the activation item.
Code (Text):
/craftmatic reload
permission:
craftmatic.command.reload
This command directs the plugin to reload its configuration from disk and perform a new search for active crafting blocks.
Code (Text):
/craftmatic show [player]...
permission:
craftmatic.command.show
This command displays in the player's chat all active crafting blocks (that is, those in loaded chunks), what their recipes are, and the rate at which they have been crafting items. If player names are provided with the command, only the crafting blocks for those players will be displayed.