Skip to content

Commit

Permalink
Update Worldedit.js
Browse files Browse the repository at this point in the history
  • Loading branch information
radmanplays authored Sep 12, 2024
1 parent 359ecc0 commit 3f2f312
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion examplemods/Worldedit.js
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down

0 comments on commit 3f2f312

Please sign in to comment.