Update Worldedit.js

This commit is contained in:
radmanplays 2024-09-12 09:46:49 +03:30 committed by GitHub
parent 359ecc0506
commit 3f2f312a97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,11 +1,28 @@
//WIP worldedit by radmanplays
ModAPI.addEventListener("lib:libcustomitems:loaded", () => {
console.log("Registered worldedit custom items.");
LibCustomItems.registerItem({
tag: "worledit:wand",
base: "wooden_axe",
name: "Wand",
qty: 1,
onRightClickGround: `/*/user, world, itemstack, blockpos/*/
itemstack.stackSize -= 1;
if (itemstack.stackSize < 1) {
user.inventory.mainInventory[user.inventory.currentItem] = null;
}
user.setHealth(2);
`
});
});
(() => {
const prefix = "[worldedit] "
PluginAPI.dedicatedServer.appendCode(function () {
PluginAPI.addEventListener("processcommand", (event) => {
if (event.command.toLowerCase().startsWith("//wand")) {
event.sender.sendChatMessage(ModAPI.util.str("/give @s wooden_axe"))
event.sender.sendChatMessage(ModAPI.util.str("/give @p wooden_axe 1 0 {display:{Name:"Wand",Lore:["worledit:wand"]}}"))
event.sender.addChatMessage(ModAPI.reflect.getClassById("net.minecraft.util.ChatComponentText").constructors[0](ModAPI.util.str(prefix + "a wand has been added to your inventory")));
event.preventDefault = true;
}