mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-24 22:51:18 -09:00
Update Worldedit.js
This commit is contained in:
parent
b01e156806
commit
b72bc1a932
@ -31,38 +31,38 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => {
|
|||||||
(() => {
|
(() => {
|
||||||
PluginAPI.dedicatedServer.appendCode(function () {
|
PluginAPI.dedicatedServer.appendCode(function () {
|
||||||
PluginAPI.addEventListener("processcommand", (event) => {
|
PluginAPI.addEventListener("processcommand", (event) => {
|
||||||
if (!ModAPI.reflect.getClassById("net.minecraft.entity.player.EntityPlayerMP").instanceOf(event.sender.getRef())) {return}
|
|
||||||
if (event.command.toLowerCase().startsWith("//wand")) {
|
if (event.command.toLowerCase().startsWith("//wand")) {
|
||||||
// Create a new ItemStack for the custom item
|
// Create a new ItemStack for the custom item
|
||||||
const ItemStackClass = ModAPI.reflect.getClassById("net.minecraft.item.ItemStack");
|
const ItemStackClass = ModAPI.reflect.getClassById("net.minecraft.item.ItemStack");
|
||||||
const itemStack = ItemStackClass.constructors[4](
|
const itemStack = ItemStackClass.constructors[4](
|
||||||
ModAPI.items["wooden_axe"].getRef(), 1
|
ModAPI.items["wooden_axe"].getRef(), 1
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create NBT data for the item
|
// Create NBT data for the item
|
||||||
const NBTTagCompoundClass = ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagCompound");
|
const NBTTagCompoundClass = ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagCompound");
|
||||||
itemStack.$stackTagCompound = NBTTagCompoundClass.constructors[0]();
|
itemStack.$stackTagCompound = NBTTagCompoundClass.constructors[0]();
|
||||||
const displayTag = NBTTagCompoundClass.constructors[0]();
|
const displayTag = NBTTagCompoundClass.constructors[0]();
|
||||||
itemStack.$stackTagCompound.$setTag(ModAPI.util.str("display"), displayTag);
|
itemStack.$stackTagCompound.$setTag(ModAPI.util.str("display"), displayTag);
|
||||||
|
|
||||||
// Set item name
|
// Set item name
|
||||||
displayTag.$setString(ModAPI.util.str("Name"), ModAPI.util.str("Wand"));
|
displayTag.$setString(ModAPI.util.str("Name"), ModAPI.util.str("Wand"));
|
||||||
|
|
||||||
// Set item lore
|
// Set item lore
|
||||||
var loreList = ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagList").constructors[0]();
|
var loreList = ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagList").constructors[0]();
|
||||||
loreList.$appendTag(ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagString").constructors.filter(x => { return x.length === 1 })[0](ModAPI.util.str("worldedit:wand")));
|
loreList.$appendTag(ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagString").constructors.filter(x => { return x.length === 1 })[0](ModAPI.util.str("worldedit:wand")));
|
||||||
displayTag.$setTag(ModAPI.util.str("Lore"), loreList);
|
displayTag.$setTag(ModAPI.util.str("Lore"), loreList);
|
||||||
|
|
||||||
// Add the item to the sender's inventory
|
// Add the item to the sender's inventory
|
||||||
const player = event.sender;
|
const player = event.sender;
|
||||||
player.inventory.addItemStackToInventory(itemStack);
|
player.inventory.addItemStackToInventory(itemStack);
|
||||||
|
|
||||||
// Notify the sender
|
// Notify the sender
|
||||||
const prefix = "§7[§4worldedit§7] ";
|
const prefix = "§7[§4worldedit§7] ";
|
||||||
const ChatComponentTextClass = ModAPI.reflect.getClassById("net.minecraft.util.ChatComponentText");
|
const ChatComponentTextClass = ModAPI.reflect.getClassById("net.minecraft.util.ChatComponentText");
|
||||||
player.addChatMessage(ChatComponentTextClass.constructors[0](ModAPI.util.str(prefix + "A wand has been added to your inventory.")));
|
player.addChatMessage(ChatComponentTextClass.constructors[0](ModAPI.util.str(prefix + "A wand has been added to your inventory!")));
|
||||||
|
player.addChatMessage(ChatComponentTextClass.constructors[0](ModAPI.util.str(prefix + "Left click: select pos #1; Right click: select pos #2")));
|
||||||
event.preventDefault = true;
|
|
||||||
|
event.preventDefault = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user