A fully customizable auto kit script/Addon that automatically is fully functional, it has some enchants on the armor and tools. The Armor equips instantly and doesn't replace any armor previously equipped
it uses @server 2.4.0-beta and capabilities script_event & equipment
import { Player, system, world, ItemStack, ItemComponentTypes, ItemEnchantableComponent, EnchantmentType, EntityComponent, EntityEquippableComponent, EquipmentSlot, EntityComponentTypes } from "@minecraft/server";
console.info("item starter kit loaded (2.4.0-beta safe)."); /// you can remove this if you want
system.afterEvents.scriptEventReceive.subscribe(ev => {
/// sets the /scriptevent memo:starterkit thingy
if (ev.id !== "memo:starterkit") return;
/// player checker
const player = ev.sourceEntity;
if (!player || player.typeId !== "minecraft:player") {
console.warn("Event received but sender is not a player.");
return;
}
/// checks the person who the scriptevent was sent through
console.info("[memo:starterkit] Fired for:", player.name);
try
{ ///list of all the goodies you want the player to get
giveSword(player);
giveAxe(player);
givePickaxe(player);
giveSteak(player);
giveHelmet(player);
giveChestplate(player);
giveLeggings(player);
giveBoots(player);
} catch (err) {
/// this may list a error for 1 or more events
console.error("Item give failed:", err);
}
});
/// -[wooden sword] unb 3 shar 1 curse 1
/// -[wooden axe] unb 3 efic 2 curse 1
/// -[wooden pic] unb 3 efic 2 curse 1
/// -16 steak
/// -[leather cap] coast AT, redstone mat, gray dye, curse 1
/// -[leather chestplate] vet AT, redstone mat, gray dye, curse 1
/// -[leather leggings] ward AT, redstone mat, gray dye, curse 1
/// -[leather boots] wild AT, redstone mat, gray dye, curse 1
function giveSword(player) {
/// item identifier
const item = new ItemStack("minecraft:wooden_sword", 1);
const ec = item.getComponent(ItemComponentTypes.Enchantable);
const el =
[ /// list of enchantments
{ type: new EnchantmentType('sharpness'), level: 1 },
{ type: new EnchantmentType('unbreaking'), level: 3 },
{ type: new EnchantmentType('vanishing'), level: 1 }
];
/// adds the enchantments
if (ec) {ec.addEnchantments(el)};
/// gives the item
const inv = player.getComponent("minecraft:inventory").container;
let slot = -1;
for (let i = 0; i < inv.size; i++) {if (!inv.getItem(i)) { slot = i; break; }}
if (slot === -1) {
console.warn("Inventory full");
player.sendMessage("§cInventory full!"); return;}
inv.setItem(slot, item);
console.warn("Item given in slot:", slot);
}
function giveAxe(player) {
/// item identifier
const item = new ItemStack("minecraft:wooden_axe", 1);
const ec = item.getComponent(ItemComponentTypes.Enchantable);
const el =
[ /// list of enchantments
{ type: new EnchantmentType('efficiency'), level: 2 },
{ type: new EnchantmentType('unbreaking'), level: 3 },
{ type: new EnchantmentType('vanishing'), level: 1 }
];
/// adds the enchantments
if (ec) {ec.addEnchantments(el)};
/// gives the item
const inv = player.getComponent("minecraft:inventory").container;
let slot = -1;
for (let i = 0; i < inv.size; i++) {if (!inv.getItem(i)) { slot = i; break; }}
if (slot === -1) {
console.warn("Inventory full");
player.sendMessage("§cInventory full!"); return;}
inv.setItem(slot, item);
console.warn("Item given in slot:", slot);
}
function givePickaxe(player) {
/// item identifier
const item = new ItemStack("minecraft:wooden_pickaxe", 1);
const ec = item.getComponent(ItemComponentTypes.Enchantable);
const el =
[ /// list of enchantments
{ type: new EnchantmentType('efficiency'), level: 2 },
{ type: new EnchantmentType('unbreaking'), level: 3 },
{ type: new EnchantmentType('vanishing'), level: 1 }
];
/// adds the enchantments
if (ec) {ec.addEnchantments(el)};
/// gives the item
const inv = player.getComponent("minecraft:inventory").container;
let slot = -1;
for (let i = 0; i < inv.size; i++) {if (!inv.getItem(i)) { slot = i; break; }}
if (slot === -1) {
console.warn("Inventory full");
player.sendMessage("§cInventory full!"); return;}
inv.setItem(slot, item);
console.warn("Item given in slot:", slot);
}
function giveSteak(player) {
/// item identifier
const item = new ItemStack("minecraft:cooked_beef", 16);
/// gives the item
const inv = player.getComponent("minecraft:inventory").container;
let slot = -1;
for (let i = 0; i < inv.size; i++) {if (!inv.getItem(i)) { slot = i; break; }}
if (slot === -1) {
console.warn("Inventory full");
player.sendMessage("§cInventory full!"); return;}
inv.setItem(slot, item);
console.warn(item," given in slot:", slot);
}
function giveHelmet(player) {
/// item identifier
const item = new ItemStack("minecraft:leather_helmet", 1);
const ec = item.getComponent(ItemComponentTypes.Enchantable);
const el =
[ /// list of enchantments
{ type: new EnchantmentType('vanishing'), level: 1 }
];
/// adds the enchantments
if (ec) {ec.addEnchantments(el)};
/// equips the item
const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
if (equipmentCompPlayer) {
if (equipmentCompPlayer.getEquipment(EquipmentSlot.Head) == undefined) {
equipmentCompPlayer.setEquipment(EquipmentSlot.Head, item);
}
}
}
function giveChestplate(player) {
/// item identifier
const item = new ItemStack("minecraft:leather_chestplate", 1);
const ec = item.getComponent(ItemComponentTypes.Enchantable);
const el =
[ /// list of enchantments
{ type: new EnchantmentType('vanishing'), level: 1 }
];
/// adds the enchantments
if (ec) {ec.addEnchantments(el)};
/// equips the item
const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
if (equipmentCompPlayer) {
if (equipmentCompPlayer.getEquipment(EquipmentSlot.Chest) == undefined) {
equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, item);
}
}
}
function giveLeggings(player) {
/// item identifier
const item = new ItemStack("minecraft:leather_leggings", 1);
const ec = item.getComponent(ItemComponentTypes.Enchantable);
const el =
[ /// list of enchantments
{ type: new EnchantmentType('vanishing'), level: 1 }
];
/// adds the enchantments
if (ec) {ec.addEnchantments(el)};
/// equips the item
const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
if (equipmentCompPlayer) {
if (equipmentCompPlayer.getEquipment(EquipmentSlot.Legs) == undefined) {
equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, item);
}
}
}
function giveBoots(player) {
/// item identifier
const item = new ItemStack("minecraft:leather_boots", 1);
const ec = item.getComponent(ItemComponentTypes.Enchantable);
const el =
[ /// list of enchantments
{ type: new EnchantmentType('vanishing'), level: 1 }
];
/// adds the enchantments
if (ec) {ec.addEnchantments(el)};
/// equips the item
const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
if (equipmentCompPlayer) {
if (equipmentCompPlayer.getEquipment(EquipmentSlot.Feet) == undefined) {
equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, item);
}
}
}