4

How do I make a custom potion with Minecraft addons?

I have seen others do it (at MCPEDL, which is a site that you can post addons, resource packs, and maps).

I don't want to make a "potion" crafted at a crafting table, which isn't really a potion, and is counted as a food.

This is not similar to this question because that requires command blocks, I would like to use add-ons/behavior packs.

8
  • This seems like a pretty simple question to me, what's unclear? (for close-voters)
    – Penguin
    Commented Jun 30, 2021 at 1:10
  • 4
    This is not simillar, because that requires command blocks. I want to do custom potions with addons. Not command blocks!
    – Jmooroof
    Commented Jul 10, 2021 at 16:51
  • Then you have to specify in your question that you don't want command blocks - it just happens to be an answer to your question. Asking for recommendations for add-ons is also off-topic.
    – Joachim
    Commented Jul 10, 2021 at 17:55
  • @joachim where do I ask about making addons?
    – Jmooroof
    Commented Jul 11, 2021 at 21:18
  • 3
    Vote to reopen please because: ADDONS vs COMMANDS. Not the same. Please inspect the tags first before closing at the very least because I'm still not sure what part is being confused. They are both requesting different methods, and he isn't asking for either-or he wants a specific one.
    – Penguin
    Commented Jul 12, 2021 at 2:43

1 Answer 1

2

In 1.20.30 (not sure about earlier versions), it is possible to add custom potions with a Minecraft Addon, which are craftable with the brewing stand. The recipe should be tagged with "tags": ["brewing_stand"] instead of "tags": ["crafting_table"].

The Bedrock Wiki has documentation on brewing recipes here (scroll to the bottom of the page): https://wiki.bedrock.dev/loot/recipes.html

Implementing a functional custom potion requires multiple files to be set up in your addon's resource and behavior packs. So, I've linked a downloadable demo pack (on MediaFire) which you can use as a template for your own custom potions.


To avoid having a link-only answer, here is an overview of what's in the template addon:

The custom Potion of Anchoring sets the player's spawn point to the location where the potion is consumed, only if the player is standing on a solid block in the Overworld. The functionality is accomplished using server-side scripting (tutorial here: https://learn.microsoft.com/en-us/minecraft/creator/documents/scriptingintroduction?view=minecraft-bedrock-stable, reference here: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/minecraft-server?view=minecraft-bedrock-stable), but if you don't want to use this in your addon, you might use item events (documentation here: https://wiki.bedrock.dev/items/items-16.html) as an alternative.

The potion item itself is made consumable using the "minecraft:food" component, but note that it does not give nutrition/saturation points, and can be consumed even if the player's hunger bar is full. When used, it plays the "drink" (not "eat") animation. So, even though the custom potion is technically a food item, I believe it still should satisfy OP's requirement of being a "real" potion.

BP/items/potion_of_anchoring.item.json

{  
  "format_version": "1.20.30",  
  "minecraft:item": {  
        "description": {  
            "identifier": "template:potion_of_anchoring",  
            "menu_category": {  
                // Make the potion findable next to the other (vanilla) potions
                "category": "equipment",
                "group": "itemGroup.name.potion"
            }  
        },  
        "components": {         
            "minecraft:max_stack_size": 1,
            // This is the color used for rare items like the Enchanted Golden Apple
            "minecraft:hover_text_color": "light_purple",
            "minecraft:glint": true, // Gives it that shimmering effect that all the useful potions have
            "minecraft:icon": {  
                "texture": "potion_of_anchoring"  
            },  
            "minecraft:display_name": {  
                "value": "Potion of Anchoring"  
            },
            // This component is only present so that the custom potion item becomes consumable.
            // The potion does not give nutrition/saturation points, ignores the player being full,
            // and has its effects applied entirely by server-side scripting.
            "minecraft:food": {
                "nutrition": 0,
                "saturation_modifier": 0,
                "can_always_eat": true,
                "using_converts_to": "minecraft:glass_bottle"
            },
            // Here is a reference for the different animations: https://wiki.bedrock.dev/items/items-intro.html
            "minecraft:use_animation": "drink",
            "minecraft:use_duration": 2 // 2 seconds
        }
    }
}

BP/recipes/anchoring_potion.item.json

{
    "format_version": "1.20.30",
    // Reference (scroll to the bottom of the page for brewing stand recipes): https://wiki.bedrock.dev/loot/recipes.html
    "minecraft:recipe_brewing_mix": {
        "description": {
            "identifier": "template:anchoring_potion"
        },
        "tags": ["brewing_stand"],
        "input": "minecraft:potion", // A vanilla water bottle
        "reagent": "minecraft:obsidian",
        "output": "template:potion_of_anchoring"
    }
}

RP/textures/item_texture.json

{
    "resource_pack_name": "customPotionRP",
    "texture_name": "atlas.items",
    "texture_data": {
        "potion_of_anchoring": {
            "textures": "textures/items/potion_of_anchoring"
        }
    }
}

BP/scripts/main.js

import { world, system } from "@minecraft/server"

// Useful Reference: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/minecraft-server?view=minecraft-bedrock-stable

// Use Custom Potion: Potion of Anchoring -- Sets player's spawn point to the block you're currently standing on
world.afterEvents.itemCompleteUse.subscribe(event => {
    // Not "itemUse", "itemCompleteUse"! This is important if you don't want the effect to happen until the item is consumed.
    if (event.itemStack.typeId === "template:potion_of_anchoring") {
        const player = event.source;
        const d = player.dimension;
        
        // Only set the player's spawn point to the current location if the player is in the Overworld and is standing on a solid block
        if (d.id === "minecraft:overworld" && player.isOnGround) {
            var at = player.location;
            
            (async () => {
                // Generate spawnpoint command for the player having consumed the potion, at the block on which the potion was consumed, using string concatenation
                await d.runCommandAsync("spawnpoint " + player.name + " " + Math.round(at.x) + " " + Math.round(at.y) + " " + Math.round(at.z));
            })();
        }
    }
});
1
  • Edited the BP .json file so that consuming the custom potion now leaves an empty glass bottle behind in the player's inventory, the same as for vanilla potions. Commented Jan 17 at 22:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .