BananaPuncher714 / NBTEditor

A single class NBT editor for items, skulls, mobs, and tile entities
MIT License
136 stars 30 forks source link

1.16.5 not working with catserver #35

Open BackdevHong opened 1 month ago

BackdevHong commented 1 month ago

My Log

using core : CatServer-1.16.5-1d8d6313-server using version : 1.16.5

BackdevHong commented 1 month ago

CommandClass

override fun onCommand(p0: CommandSender, p1: Command, p2: String, p3: Array<out String>?): Boolean {
        val job = mutableListOf(
            "spy"
        )

        val type = mutableListOf(
            "helmet",
            "chestplate",
            "leggings",
            "boots",
            "sword"
        )

        job.forEach { j ->
            type.forEach { type ->
                val item = CustomStack.getInstance("customarmor:${j}_${type}")?.itemStack
                val compound = NBTEditor.getNBTCompound(item)

                when (j) {
                    "spy" -> {
                        when (type) {
                            "helmet" -> {
                                item?.let {
                                    val i = ArmorManager().setArmor(compound, 3.0, 3.0, "head")
                                    (p0 as Player).inventory.addItem(i)
                                }
                            }
                            "chestplate" -> {
                                item?.let {
                                    val i = ArmorManager().setArmor(compound, 8.0, 3.0, "head")
                                    (p0 as Player).inventory.addItem(i)
                                }
                            }
                            "leggings" -> {
                                item?.let {
                                    val i = ArmorManager().setArmor(compound, 6.0, 3.0, "head")
                                    (p0 as Player).inventory.addItem(i)
                                }
                            }
                            "boots" -> {
                                item?.let {
                                    val i = ArmorManager().setArmor(compound, 3.0, 3.0, "head")
                                    (p0 as Player).inventory.addItem(i)
                                }
                            }
                            "sword" -> {
                                item?.let {
                                    val i = ArmorManager().setSword(compound, 12.0)
                                    (p0 as Player).inventory.addItem(i)
                                }
                            }
                        }
                    }
                }
            }
        }
        return true
    }

ArmorManager

class ArmorManager {
    fun setArmor(compound: NBTCompound, v1: Double, v2: Double, slot: String) : ItemStack {
        compound.set(
            "generic.armor",
            "tag",
            "AttributeModifiers",
            NBTEditor.NEW_ELEMENT,
            "AttributeName"
        )
        compound.set(slot, "tag", "AttributeModifiers", 0, "Slot")
        compound.set(0, "tag", "AttributeModifiers", 0, "Operation")
        compound.set(v1, "tag", "AttributeModifiers", 0, "Amount")
        compound.set(intArrayOf(0, 0, 0, 0), "tag", "AttributeModifiers", 0, "UUID")
        compound.set(99L, "tag", "AttributeModifiers", 0, "UUIDMost")
        compound.set(77530600L, "tag", "AttributeModifiers", 0, "UUIDLeast")

        compound.set(
            "generic.armor_toughness",
            "tag",
            "AttributeModifiers",
            NBTEditor.NEW_ELEMENT,
            "AttributeName"
        )
        compound.set(slot, "tag", "AttributeModifiers", 0, "Slot")
        compound.set(0, "tag", "AttributeModifiers", 0, "Operation")
        compound.set(v2, "tag", "AttributeModifiers", 0, "Amount")
        compound.set(intArrayOf(0, 0, 0, 0), "tag", "AttributeModifiers", 0, "UUID")
        compound.set(99L, "tag", "AttributeModifiers", 0, "UUIDMost")
        compound.set(77530600L, "tag", "AttributeModifiers", 0, "UUIDLeast")

        return NBTEditor.getItemFromTag( compound );
    }

    fun setSword(compound: NBTCompound, v: Double) : ItemStack {
        compound.set(
            "generic.attack_damage",
            "tag",
            "AttributeModifiers",
            NBTEditor.NEW_ELEMENT,
            "AttributeName"
        )
        compound.set("mainhand", "tag", "AttributeModifiers", 0, "Slot")
        compound.set(0, "tag", "AttributeModifiers", 0, "Operation")
        compound.set(v, "tag", "AttributeModifiers", 0, "Amount")
        compound.set(intArrayOf(0, 0, 0, 0), "tag", "AttributeModifiers", 0, "UUID")
        compound.set(99L, "tag", "AttributeModifiers", 0, "UUIDMost")
        compound.set(77530600L, "tag", "AttributeModifiers", 0, "UUIDLeast")

        return NBTEditor.getItemFromTag( compound );
    }
}
BananaPuncher714 commented 1 month ago

What error is there?

BackdevHong commented 1 month ago

[01:17:42] [Server thread/WARN] []: java.lang.NoSuchMethodException: net.minecraft.nbt.ListNBT.add(net.minecraft.nbt.INBT)
--
62 | [01:17:42] [Server thread/WARN] []:    at java.base/java.lang.Class.getMethod(Class.java:2108)
63 | [01:17:42] [Server thread/WARN] []:    at catserver.server.remapper.proxy.ProxyReflection.getMethod(ProxyReflection.java:125)
64 | [01:17:42] [Server thread/WARN] []:    at io.github.bananapuncher714.nbteditor.NBTEditor$ReflectionTarget.fetchMethod(NBTEditor.java:1623)
65 | [01:17:42] [Server thread/WARN] []:    at io.github.bananapuncher714.nbteditor.NBTEditor.getMethod(NBTEditor.java:232)
66 | [01:17:42] [Server thread/WARN] []:    at io.github.bananapuncher714.nbteditor.NBTEditor.setTag(NBTEditor.java:1246)
67 | [01:17:42] [Server thread/WARN] []:    at io.github.bananapuncher714.nbteditor.NBTEditor.access$000(NBTEditor.java:39)
68 | [01:17:42] [Server thread/WARN] []:    at io.github.bananapuncher714.nbteditor.NBTEditor$NBTCompound.set(NBTEditor.java:1393)
69 | [01:17:42] [Server thread/WARN] []:    at org.server.sleepblue.util.ArmorManager.setArmor(ArmorManager.kt:16)
70 | [01:17:42] [Server thread/WARN] []:    at org.server.sleepblue.command.GetItem.onCommand(GetItem.kt:35)
71 | [01:17:42] [Server thread/WARN] []:    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
72 | [01:17:42] [Server thread/WARN] []:    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:156)
73 | [01:17:42] [Server thread/WARN] []:    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:680)
74 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.network.play.ServerPlayNetHandler.func_147361_d(ServerPlayNetHandler.java:1796)
75 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.network.play.ServerPlayNetHandler.func_244548_c(ServerPlayNetHandler.java:1649)
76 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.network.play.ServerPlayNetHandler.func_147354_a(ServerPlayNetHandler.java:1603)
77 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.network.play.client.CChatMessagePacket.func_148833_a(CChatMessagePacket.java:38)
78 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.network.play.client.CChatMessagePacket.func_148833_a(CChatMessagePacket.java:8)
79 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.network.PacketThreadUtil.func_225383_a(PacketThreadUtil.java:22)
80 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.util.concurrent.TickDelayedTask.run(SourceFile:18)
81 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(SourceFile:144)
82 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.util.concurrent.RecursiveEventLoop.func_213166_h(SourceFile:23)
83 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.server.MinecraftServer.func_213166_h(MinecraftServer.java:885)
84 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.server.MinecraftServer.func_213166_h(MinecraftServer.java:169)
85 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(SourceFile:118)
86 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:868)
87 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.server.MinecraftServer.func_213168_p(MinecraftServer.java:862)
88 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213161_c(SourceFile:127)
89 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.server.MinecraftServer.func_213202_o(MinecraftServer.java:848)
90 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:779)
91 | [01:17:42] [Server thread/WARN] []:    at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:265)
92 | [01:17:42] [Server thread/WARN] []:    at java.base/java.lang.Thread.run(Thread.java:829)

[01:17:42] [Server thread/WARN] []: java.lang.NoSuchMethodException: net.minecraft.nbt.ListNBT.add(net.minecraft.nbt.INBT)
[01:17:42] [Server thread/WARN] []:     at java.base/java.lang.Class.getMethod(Class.java:2108)
[01:17:42] [Server thread/WARN] []:     at catserver.server.remapper.proxy.ProxyReflection.getMethod(ProxyReflection.java:125)
[01:17:42] [Server thread/WARN] []:     at io.github.bananapuncher714.nbteditor.NBTEditor$ReflectionTarget.fetchMethod(NBTEditor.java:1[62](https://mclo.gs/6UhQ4KT#L62)3)
[01:17:42] [Server thread/WARN] []:     at io.github.bananapuncher714.nbteditor.NBTEditor.getMethod(NBTEditor.java:232)
[01:17:42] [Server thread/WARN] []:     at io.github.bananapuncher714.nbteditor.NBTEditor.setTag(NBTEditor.java:1246)
[01:17:42] [Server thread/WARN] []:     at io.github.bananapuncher714.nbteditor.NBTEditor.access$000(NBTEditor.java:39)
[01:17:42] [Server thread/WARN] []:     at io.github.bananapuncher714.nbteditor.NBTEditor$NBTCompound.set(NBTEditor.java:1393)
[01:17:42] [Server thread/WARN] []:     at org.server.sleepblue.util.ArmorManager.setArmor(ArmorManager.kt:16)
[01:17:42] [Server thread/WARN] []:     at org.server.sleepblue.command.GetItem.onCommand(GetItem.kt:35)
[01:17:42] [Server thread/WARN] []:     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[01:17:42] [Server thread/WARN] []:     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:156)
[01:17:42] [Server thread/WARN] []:     at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:680)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.network.play.ServerPlayNetHandler.func_147361_d(ServerPlayNetHandler.java:1796)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.network.play.ServerPlayNetHandler.func_244548_c(ServerPlayNetHandler.java:1[64](https://mclo.gs/6UhQ4KT#L64)9)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.network.play.ServerPlayNetHandler.func_147354_a(ServerPlayNetHandler.java:1603)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.network.play.client.CChatMessagePacket.func_148833_a(CChatMessagePacket.java:38)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.network.play.client.CChatMessagePacket.func_148833_a(CChatMessagePacket.java:8)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.network.PacketThreadUtil.func_225383_a(PacketThreadUtil.java:22)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.util.concurrent.TickDelayedTask.run(SourceFile:18)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(SourceFile:144)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.util.concurrent.RecursiveEventLoop.func_213166_h(SourceFile:23)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.server.MinecraftServer.func_213166_h(MinecraftServer.java:885)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.server.MinecraftServer.func_213166_h(MinecraftServer.java:169)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(SourceFile:118)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:868)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.server.MinecraftServer.func_213168_p(MinecraftServer.java:862)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213161_c(SourceFile:127)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.server.MinecraftServer.func_213202_o(MinecraftServer.java:848)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:779)
[01:17:42] [Server thread/WARN] []:     at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:2[65](https://mclo.gs/6UhQ4KT#L65))
[01:17:42] [Server thread/WARN] []:     at java.base/java.lang.Thread.run(Thread.java:829)