Error creating item - NullPointerException: null
mibby opened this issue ยท 21 comments
Magic dev 3522
I have a custom GUI from the plugin BossShopPro that when you interact with an item, it runs the command /mgive <name>
to give the player the item. Recent dev builds of Magic seem to break this and now output an error.
[05:13:09] [Server thread/INFO]: mibby issued server command: /hats
[05:13:11] [Server thread/INFO]: Gave 1 Test Hat to mibby
[05:13:11] [Server thread/WARN]: [Magic] Error creating item: hat_test
java.lang.NullPointerException: null
at com.elmakers.mine.bukkit.wand.Wand.doShowBoundInstructions(Wand.java:926) ~[?:?]
at com.elmakers.mine.bukkit.wand.Wand.takeOwnership(Wand.java:1009) ~[?:?]
at com.elmakers.mine.bukkit.wand.Wand.tryToOwn(Wand.java:899) ~[?:?]
at com.elmakers.mine.bukkit.magic.Mage.tryGiveItem(Mage.java:3823) ~[?:?]
at com.elmakers.mine.bukkit.magic.Mage.tryGiveItem(Mage.java:3771) ~[?:?]
at com.elmakers.mine.bukkit.magic.Mage.giveItem(Mage.java:3746) ~[?:?]
at com.elmakers.mine.bukkit.magic.Mage.giveItem(Mage.java:3765) ~[?:?]
at com.elmakers.mine.bukkit.magic.command.MagicGiveCommandExecutor$1.updated(MagicGiveCommandExecutor.java:136) ~[?:?]
at com.elmakers.mine.bukkit.magic.MagicController.createItem(MagicController.java:5832) ~[?:?]
at com.elmakers.mine.bukkit.magic.command.MagicGiveCommandExecutor.onCommand(MagicGiveCommandExecutor.java:126) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:172) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:806) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at org.bukkit.Bukkit.dispatchCommand(Bukkit.java:758) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at org.black_ixx.bossshop.core.rewards.BSRewardTypeCommand.giveReward(BSRewardTypeCommand.java:43) ~[?:?]
at org.black_ixx.bossshop.core.BSBuy.purchase(BSBuy.java:507) ~[?:?]
at org.black_ixx.bossshop.core.BSBuy.purchaseTask(BSBuy.java:449) ~[?:?]
at org.black_ixx.bossshop.core.BSBuy.purchaseTry(BSBuy.java:423) ~[?:?]
at org.black_ixx.bossshop.core.BSBuy.click(BSBuy.java:392) ~[?:?]
at org.black_ixx.bossshop.listeners.InventoryListener.purchase(InventoryListener.java:189) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor791.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:611) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:2643) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:32) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:10) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:43) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1220) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1213) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1189) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1029) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:176) ~[1.16.5-patched.jar:git-Yatopia-dev/threaded-worldgen-"9b84e5e"]
at java.lang.Thread.run(Thread.java:832) [?:?]
[05:13:11] [Server thread/INFO]: Unknown item type hat_test
Edit: Magic dev 3521 works fine.
Sorry about that, seems like it's a problem with the bind_on_give
config option, which I'm guessing you have set to true?
I'll get this fixed in the next dev build.
That's correct, bind_on_give: true
is set. No worries though, I'll just stay 1 dev build behind for now.
I do have it fixed already, just polishing up some other things before I push, but the next dev build will fix it up.
One thing I noticed though (that I think is not new), giving items that way won't show most of the wand instructions if you're using class wands, since the wand won't have any spells or mana configured when it is bound. Not sure I can fix that, but maybe you're not using class wands?
Probably not. I just have simple wand setups with a MagicHat spell bound to equip the hat on wand use.
I might have discovered another bug as well a couple weeks ago. The target_self: true
spell param seems to trigger pvp checks. This was causing the MagicHat particles to appear where the player was looking when they interacted with the wand instead of the smoke particles appearing around them as they equipped the item.
I had to grant everyone the permission Magic.bypass_pvp
so the particle worked fine again. Did something change around this param logic?
Full spell configuration;
magichat:
icon: diamond_axe{CustomModelData:138}
icon_disabled: diamond_pickaxe{CustomModelData:138}
hidden: true
icon_url: http://textures.minecraft.net/texture/2abee4fe341011b9a0ae2fb83644f695521fd4e4c6198fe23112f1acbf38369
category: utility
worth: 100
actions:
cast:
- class: Delay
delay: 1
- class: Hat
- class: CheckRequirements
fail:
- class: Command
effects:
cast:
- class: EffectSingle
location: target
effectlib:
class: SphereEffect
iterations: 4
particle: smoke_large
parameters:
target_self: true
use_item: true
reason: custom
cooldown: 1000
range: 1
allow_max_range: true
console: true
command: lp user @uuid permission set hat.example
requirement:
permission: hat.example
Edit: Might have worked around this problem by adding bypass_pvp: true
to the spell params instead of using the bypass permission.
I did re-arrange the targeting checks, but I don't think a player should need pvp to target themselves. Are you sure that's what is happening? The way that spell is set up, the smoke should always appear one block in front of the player since it is set to location: target
I can try it out.
And I don't thinktarget_self: true
needs to be in there for you, it is in the base spell because there is an AreaOfEffect that we want to be able to effect the caster.
Well some quick testing shows that something is in fact broken and probably has been for a while.. players can no longer target themselves if they can't pvp. I'll fix that for the next dev build too.
Testing as of Magic dev 3527;
The NPE seems fixed now. No more error when trying to spawn from a GUI with bind_on_give: true.
The PVP issue I think is fixed? It's hard to tell. I have to use target_self: true
otherwise the hat spell does not equip the item. I'm noticing a problem with the fix that wasn't present before, unless it's a 3rd issue that just got introduced.
The particle does not appear around you / on the player target when you equip if you look at a certain far block at an angle. It appears more than a block away. My intention is for the effect to appear at the target, which is the player. This seems to occur regardless if bypass_pvp: true
is set on the spell or not. I do not remember it functioning like this with earlier dev builds.
magichat:
icon: diamond_axe{CustomModelData:138}
icon_disabled: diamond_pickaxe{CustomModelData:138}
hidden: true
icon_url: http://textures.minecraft.net/texture/2abee4fe341011b9a0ae2fb83644f695521fd4e4c6198fe23112f1acbf38369
category: utility
worth: 100
actions:
cast:
- class: Delay
delay: 1
- class: Hat
- class: CheckRequirements
fail:
- class: Command
effects:
cast:
- class: EffectSingle
location: target
effectlib:
class: SphereEffect
iterations: 4
particle: smoke_large
parameters:
target_self: true
use_item: true
reason: custom
cooldown: 1000
range: 1
allow_max_range: true
console: true
command: lp user @uuid permission set hat.example
requirement:
permission: hat.example
I am, yes. It occurs when looking at certain angles, such as diagonally and far away blocks / air. As well as when using the wand while moving.
I figured location: target
would use the target of the player with target_self: true
. Is there a way to specify the player position as the target instead?
You can do target: self
to target yourself. That does sound odd though- I'll play with it a bit in the default configs, maybe there's some case there were targeting goes weird.
target: self
seems to occur where the item is in your holding hand rather than the player head position. Is there any way to change that?
effects:
cast:
- class: EffectSingle
target: self
effectlib:
class: SphereEffect
iterations: 4
particle: smoke_large
Casts come from the wand item, you can change its location in the wand config with
cast_location: 0,0,0
which will be at the eyes, you can apply relative offsets from there.
Great thanks! That actually does solve it.
Doing some more testing with the targeting oddity, it seems to be technically one block but appears very misleading. If you are on the very corner diagonally of one block and aim across, the cast appears at the very furthest edge of the next block over. Technically 1 block distance apart and appearing higher upwards in the air, but might as well be 2 blocks.
i.e.
X = -13.993
Y = 52
Z = 0.984
Cast appearing
X = -12.037
Y = 55
Z = -0.994
The target there is not the player, though, as I tried to explain before- the particles should always appear about 1 block in front of where you are looking. Are you seeing them appear a lot farther away than that?
That sounds like 1 block away though?
It doesn't mean like "target the next block in front of you", it means "target 1 meter in front of you", (1 block = 1 meter distance) - does that sound like what's it's doing?
Not if the meter is suppose to be the exact same distance regardless of the direction you are targeting when using. If it's always suppose to be say exactly 1 block in distance or 0.5 coordinate offset from current position, that's not how it is functioning. The distance is variable and seems to appear closer or further apart (smoke puff in this case) depending on angle when you use the item.
Tested with nothing surrounding me, just right clicking in the air.
That does sound wrong then, or else I'm misunderstanding, but I'll do some testing :)
exactly 1 block in distance or 0.5 coordinate offset from current position,
These are two different things though- it should be exactly 1 meter in the distance, but that's no the same as 0.5 coordinate offset (Pythagorus would like a word)
0.5 was just an example. I assume the cast offset would be an exact approximation from your current position to the direction you are looking. :)
Well to be clear it's also 1 meter maximum - if you're looking at a block that is closer to you than 1 meter it will target the spot on that block you're looking at.