HarryPotterSpells

HarryPotterSpells

59.3k Downloads

Replace MiscUtilities with non NMS solution to make item stack glow

jacklin213 opened this issue ยท 1 comments

commented

Currently the MiscUtilities.makeGlow and MiscUtilities.stopGlow helpers cause an error when /wand is run on Paper

[10:49:51 ERROR]: Encountered an unexpected exception
java.lang.ExceptionInInitializerError: null
        at HarryPotterSpells.jar/com.hpspells.core.WandManager.generateLore(WandManager.java:214) ~[HarryPotterSpells.jar:?]
        at HarryPotterSpells.jar/com.hpspells.core.WandManager.getWand(WandManager.java:95) ~[HarryPotterSpells.jar:?]
        at HarryPotterSpells.jar/com.hpspells.core.command.Wand.giftWand(Wand.java:92) ~[HarryPotterSpells.jar:?]
        at HarryPotterSpells.jar/com.hpspells.core.command.Wand.giftWand(Wand.java:100) ~[HarryPotterSpells.jar:?]
        at HarryPotterSpells.jar/com.hpspells.core.command.Wand.onCommand(Wand.java:31) ~[HarryPotterSpells.jar:?]
        at HarryPotterSpells.jar/com.hpspells.core.HPS$HackyCommand.execute(HPS.java:364) ~[HarryPotterSpells.jar:?]
        at io.papermc.paper.command.brigadier.bukkit.BukkitCommandNode$BukkitBrigCommand.run(BukkitCommandNode.java:82) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.3.10.jar:?]
        at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:31) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:19) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.execution.UnboundEntryAction.lambda$bind$0(UnboundEntryAction.java:8) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.execution.CommandQueueEntry.execute(CommandQueueEntry.java:5) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.execution.ExecutionContext.runCommandQueue(ExecutionContext.java:103) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:456) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.Commands.performCommand(Commands.java:363) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.Commands.performCommand(Commands.java:350) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.commands.Commands.performCommand(Commands.java:345) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.performUnsignedChatCommand(ServerGamePacketListenerImpl.java:2319) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$15(ServerGamePacketListenerImpl.java:2293) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:154) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1620) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:207) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:128) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1597) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1590) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:117) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1740) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1368) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:343) ~[purpur-1.21.3.jar:1.21.3-2349-2b6f273]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
        at HarryPotterSpells.jar/com.hpspells.core.util.SVPBypass.getCurrentPackageVersion(SVPBypass.java:21) ~[HarryPotterSpells.jar:?]
        at HarryPotterSpells.jar/com.hpspells.core.util.SVPBypass.getCurrentCBClass(SVPBypass.java:33) ~[HarryPotterSpells.jar:?]
        at HarryPotterSpells.jar/com.hpspells.core.util.MiscUtilities.<clinit>(MiscUtilities.java:14) ~[HarryPotterSpells.jar:?]

Action

Replace the NMS glow effect with a non NMS equivalent. Could use the same glow effect we currently apply to wands:

if (wandCreationEvent.hasEnchantmentEffect()) {
try {
// wand = MiscUtilities.makeGlow(wand);
meta.addEnchant(Enchantment.LURE, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
} catch (Exception e) {
HPS.PM.debug(HPS.Localisation.getTranslation("errEnchantmentEffect"));
HPS.PM.debug(e);
}
}

commented

Can be replaced with itemMeta.setEnchantmentGlintOverride once plugin is upgraded to using Spigot version greater than 1.20.5