Skip to content

Per-recipe permissions, item NBT support, customizable recipes, and bug fixes

Latest
Compare
Choose a tag to compare
@2008Choco 2008Choco released this 16 May 00:05
· 5 commits to main since this release
1de4842

IMPORTANT: This update adds new custom Metrics charts. While I encourage you to keep these charts enabled (as it helps me understand where I need to focus my efforts when it comes to new features - seeing how people use the plugin), I understand that some feel uncomfortable sending statistics, even if they are anonymous. If you are one of these people, please pay attention to the Metrics-related changes/additions.

Changelog

  • Recipes now support item NBT formats equivalent to the /give command (1.18.2+). See below for changes
  • Recipe results now support a "type" much like ingredients do, though alchema:item is the only natively supported result type
    • This allows third-party plugins to register their own result types which may be used in recipe files
    • All default recipe files have had "type": "alchema:item" added to their "result" object for the sake of consistency
  • Added permissions to craft each individual recipe
    • Recipe permission are automatically generated and follow the format alchema.craft.<namespace>.<recipe_id>. Examples:
      • The default gravel.json permission would be alchema.craft.alchema.gravel
      • The default ores/coal_ore.json permission would be alchema.craft.alchema.ores.coal_ore (note that forward slashes are replaced with dots)
    • Every permission is a child of alchema.craft and are therefore all granted by default. To prevent a player from crafting a recipe, you must negate the recipe's permission (i.e. set it to false). Refer to your permission plugin's documentation
    • If a player attempts to craft a recipe to which they do not have permission, the cauldron will drop all ingredients for the player to pick up and they will be informed that they do not have permission to craft that recipe
  • Added new configuration options to customize the recipe of empty vials
    • VialOfEssence.Recipe.Enabled: Whether or not the recipe is enabled. If set to false, the recipe will not be registered
    • VialOfEssence.Recipe.Yield: The amount of vials given in the recipe
    • VialOfEssence.Recipe.Shape: A list of strings determining the shape of the recipe (MUST have 3 entries, EACH a length of 3 characters)
    • VialOfEssence.Recipe.Ingredients: A section mapping the characters defined in the shape to one or more materials
  • Added 5 new bStats Metrics charts. This data is sent anonymously.
    • loaded_cauldrons: A pie chart showing how many cauldrons are loaded on the server
    • cauldron_recipes: A pie chart showing how many cauldron recipes are loaded on the server
    • cauldron_crafts: A line chart showing how many crafts have been successfully completed in a cauldron
    • cauldron_recipe_ingredient_types: A pie chart showing how many of each recipe ingredient type is used
    • cauldron_recipe_result_types: A pie chart showing how many of each recipe result type is used
    • These statistics can always be viewed at https://bstats.org/plugin/bukkit/Alchema and are 100% anonymous. See below for more control over what is anonymized
  • Added 2 new options in the config.yml:
    • Metrics.Enabled: Replaces Metrics boolean, defaults to true (be sure to update this if you had it set to false before)
    • Metrics.AnonymousCustomRecipeTypes: Marks and anonymizes any non-native recipe result or ingredient types (e.g. anything that isn't Alchema or MMOItems) as "Third-Party Ingredient Type" (or "Result Type") when being sent to bStats. Defaults to false
      • Set this to true if you have a custom plugin that registers custom Alchema recipe ingredients and you do not want this plugin to be publicly displayed. Otherwise, the name of the plugin will be on a bStats chart
  • Ender Dragons and Giants now have corresponding entity essence
  • Optimized how and when cauldrons check for heat sources and bubble. Performance should be improved by about 50%
  • Improved item serialization for cauldrons between restarts and reloads
  • The entity names shown in the player's action bar when collecting essence from an entity now use translatable components rather than a best-attempt name based on its registry key
  • (For developers) Alchemical cauldrons now have 2 metadata values associated with them:
    • alchema:alchemical_cauldron: Whether or not the block is an alchemical cauldron. Value is always true
    • alchema:alchemical_cauldron_bubbling: Whether or not the alchemical cauldron is boiling. Value is lazy, but never caches. Can be either true or false
  • Fixed Metrics: false not actually disabling metrics, even if set to false. (Please update your config according to the changes mentioned above)
  • Fixed killed entities dropping essence (either via loot or directly into a cauldron) even if they recently had their essence collected with a vial
  • Fixed /givevial throwing an exception if no entities were selected
  • Fixed /givevial throwing an exception if provided an invalid entity selector
  • Fixed some items losing data if they were still in a cauldron when the server shut down
  • Removed the example_item.json file as it is no longer relevant
  • Removed the "shameless self-promotion" of AlchemicalArrows when running /alchema integrations
  • Removed the Metrics boolean option in the config.yml. It has now been moved to Metrics.Enabled

Item NBT In Recipe Files

Recipe files have gotten a huge upgrade. Prior to this version, custom data for ingredients and results (such as names, lore, enchantments, etc.) all had to be done with a relatively undocumented JSON format. This format was incomplete and often lacked support for NBT of newer items. Now, for any ingredient or result with type: "alchema:item", the "item" field now accepts a /give-compliant item argument (i.e. the same sort of argument you would supply to a Minecraft /give command to get an item).

  • More familiar for most server owners (assuming they've written a /give command before)
  • Allows for custom NBT values which better supports third-party plugins
  • Will always be up-to-date and support modern NBT values that Minecraft adds in the future

An example recipe file may now look like this:

{
    "result": {
        "type": "alchema:item",
        "item": "netherite_sword{display:{Name:\"{\\\"text\\\":\\\"Hello World\\\"}\"},Enchantments:[{id:\"minecraft:sharpness\",lvl:10}]}"
    },
    "ingredients": [
        {
            "type": "alchema:entity_essence",
            "entity": "minecraft:blaze",
            "amount": 250
        },
        {
            "type": "alchema:item",
            "item": "minecraft:netherite_ingot{CustomModelData:1}"
        },
        {
            "type": "alchema:material",
            "item": "minecraft:stick"
        }
    ]
}

As you can see, the ingredient requires two netherite ingots with CustomModelData 1, and the result will be a netherite sword with the name "Hello World" and Sharpness X. You must be very careful with the quotation marks, however. They should be escaped correctly or items will fail to load (notice how the "Name" in the result has to triple escape (\\\)).

NOTE: This only works on modern version of Minecraft 1.18.2. While Alchema still supports 1.17.x+, the API to support this functionality was only added in April of 2022. If you are still unable to use this functionality on 1.18.2, update your server and you should be able to use it.

API Changes

  • Added CauldronRecipeResult, an interface similar to CauldronIngredient that may be implemented by third party plugins to create custom result types
    • Only one native implementation of this interface, RecipeResultItemStack
    • Custom result types may be registered via CauldronRecipeRegistry#registerResultType()
  • Added CauldronRecipe#getCraftingPermission()
  • CauldronDropItemsEvent may now be forced to ignore its cancellation state. A new reason was added, NO_PERMISSION, which uses this state. AlchemicalCauldron#dropItems() has a new overload that accepts a boolean whether or not to ignore the cancellation state of this event
  • DefaultEntityEffects is now package-private. It is not meant for public use
  • Fixed items removed from CauldronIngredientsDropEvent#getItems() not actually being removed properly, or if the event was cancelled
  • Added AlchemicalCauldron#isValid() to check whether or not a cauldron is still a valid alchemical cauldron
  • Deprecation policies have been clarified on more methods, as well as mutability of collections, among other useful Jetbrains annotations

Deprecations

  • All current deprecations are expected to be removed by the next major release, 1.4.0. Please move to the provided alternatives as soon as possible.
  • ItemUtil has been marked as internal and should not be expected to maintain compatibility beyond this release. It has no API contract and should be avoided at all costs
  • CauldronRecipe#getResult() has been deprecated and replaced with CauldronRecipe#getRecipeResult()
  • CauldronItemCraftEvent#getResult() and #setResult(ItemStack) have been deprecated and replaced with getRecipeResult() and setRecipeResult(CauldronRecipeResult)