StaticgetArray of all registered delivery type handles.
This function can't be called in early-execution mode.
StaticgetArray of all registered effect type handles.
This function can't be called in early-execution mode.
StaticgetA type handle wrapping the valid delivery id, or undefined for an invalid delivery id.
This function can't be called in early-execution mode.
StaticgetA valid potion effect id. See @minecraft/vanilla-data.MinecraftPotionEffectTypes
A type handle wrapping the valid effect id, or undefined for an invalid effect id.
This function can't be called in early-execution mode.
StaticresolveThis function can't be called in early-execution mode.
import { Player, Potions, system } from "@minecraft/server";
// Run `/scriptevent example:giveharmingsplashpotion` in chat to get a splash potion of harming.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:giveharmingsplashpotion" || !(sourceEntity instanceof Player)) return;
const inventory = sourceEntity.getComponent("minecraft:inventory");
if (!inventory?.container) return;
const effectType = Potions.getEffectType("minecraft:harming");
const deliveryType = Potions.getDeliveryType("ThrownSplash");
if (!effectType || !deliveryType) return;
const potion = Potions.resolve(effectType, deliveryType);
inventory.container.addItem(potion);
sourceEntity.sendMessage("You received a splash potion of harming.");
});
import { Player, Potions, system } from "@minecraft/server";
// Run `/scriptevent example:giveregularfireresistancepotion` in chat to get a fire resistance potion.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:giveregularfireresistancepotion" || !(sourceEntity instanceof Player)) return;
const inventory = sourceEntity.getComponent("minecraft:inventory");
if (!inventory?.container) return;
const effectType = Potions.getEffectType("minecraft:fire_resistance");
const deliveryType = Potions.getDeliveryType("Consume");
if (!effectType || !deliveryType) return;
const potion = Potions.resolve(effectType, deliveryType);
inventory.container.addItem(potion);
sourceEntity.sendMessage("You received a potion of fire resistance.");
});
import { Player, Potions, system } from "@minecraft/server";
// Run `/scriptevent example:giveregularwaterbreathingpotion` in chat to get a water breathing potion.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:giveregularwaterbreathingpotion" || !(sourceEntity instanceof Player)) return;
const inventory = sourceEntity.getComponent("minecraft:inventory");
if (!inventory?.container) return;
const effectType = Potions.getEffectType("minecraft:water_breathing");
const deliveryType = Potions.getDeliveryType("Consume");
if (!effectType || !deliveryType) return;
const potion = Potions.resolve(effectType, deliveryType);
inventory.container.addItem(potion);
sourceEntity.sendMessage("You received a potion of water breathing.");
});
Used for accessing all potion effect types, delivery types, and creating potions.
Source