Both .getSpawnedType() and .setSpawnedType() throws exceptions
Java code throwing the exception:
@Override public ItemStack toItem() { ItemStack itemStack = new ItemStack(Material.SPAWNER); ItemMeta itemMeta = itemStack.getItemMeta(); if (itemMeta == null) return itemStack; if (!(itemMeta instanceof BlockStateMeta)) return itemStack; BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; CreatureSpawner creatureSpawner = (CreatureSpawner) blockStateMeta.getBlockState(); try { creatureSpawner.setSpawnedType(entity); } catch (Throwable t) { t.printStackTrace(); } blockStateMeta.setDisplayName(creatureSpawner.getSpawnedType()+" Spawner"); blockStateMeta.setBlockState(creatureSpawner); itemStack.setItemMeta(itemMeta); return itemStack; }
Stack trace for it:
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.MobSpawnerData.a()" because "net.minecraft.world.level.block.entity.TileEntityMobSpawner.d().f" is null
at org.bukkit.craftbukkit.v1_19_R2.block.CraftCreatureSpawner.getSpawnedType(CraftCreatureSpawner.java:19) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at com.moyskleytech.obsidian.material.implementations.SpawnerMaterial.toItem(SpawnerMaterial.java:75) ~[?:?]
at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:74) ~[?:?]
at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:95) ~[?:?]
at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:118) ~[?:?]
at com.iridium.iridiumskyblock.gui.ShopOverviewGUI.addContent(ShopOverviewGUI.java:47) ~[?:?]
at com.iridium.iridiumskyblock.IridiumSkyblock.lambda$onEnable$3(IridiumSkyblock.java:214) ~[?:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) ~[?:?]
at com.iridium.iridiumskyblock.IridiumSkyblock.lambda$onEnable$4(IridiumSkyblock.java:211) ~[?:?]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:82) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:415) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1249) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:388) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1201) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1017) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:301) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[13:24:29] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.GeneratorAccess.s_()" because the return value of "org.bukkit.craftbukkit.v1_19_R2.block.CraftCreatureSpawner.getWorldHandle()" is null
[13:24:29] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_19_R2.block.CraftCreatureSpawner.setSpawnedType(CraftCreatureSpawner.java:29)
[13:24:29] [Server thread/WARN]: at com.moyskleytech.obsidian.material.implementations.SpawnerMaterial.toItem(SpawnerMaterial.java:71)
[13:24:29] [Server thread/WARN]: at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:74)
[13:24:29] [Server thread/WARN]: at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:95)
[13:24:29] [Server thread/WARN]: at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:118)
[13:24:29] [Server thread/WARN]: at com.iridium.iridiumskyblock.gui.ShopOverviewGUI.addContent(ShopOverviewGUI.java:47)
[13:24:29] [Server thread/WARN]: at com.iridium.iridiumskyblock.IridiumSkyblock.lambda$onEnable$3(IridiumSkyblock.java:214)
[13:24:29] [Server thread/WARN]: at java.base/java.lang.Iterable.forEach(Iterable.java:75)
[13:24:29] [Server thread/WARN]: at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092)
[13:24:29] [Server thread/WARN]: at com.iridium.iridiumskyblock.IridiumSkyblock.lambda$onEnable$4(IridiumSkyblock.java:211)
[13:24:29] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:82)
[13:24:29] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:415)
[13:24:29] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1249)
[13:24:29] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:388)
[13:24:29] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1201)
[13:24:29] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1017)
[13:24:29] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:301)
[13:24:29] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:833)
[13:24:29] [Server thread/WARN]: [IridiumSkyblock] Task #13 for IridiumSkyblock v3.2.10-S1-OM generated an exception
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.MobSpawnerData.a()" because "net.minecraft.world.level.block.entity.TileEntityMobSpawner.d().f" is null
at org.bukkit.craftbukkit.v1_19_R2.block.CraftCreatureSpawner.getSpawnedType(CraftCreatureSpawner.java:19) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at com.moyskleytech.obsidian.material.implementations.SpawnerMaterial.toItem(SpawnerMaterial.java:75) ~[?:?]
at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:74) ~[?:?]
at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:95) ~[?:?]
at com.iridium.iridiumcore.utils.ItemStackUtils.makeItem(ItemStackUtils.java:118) ~[?:?]
at com.iridium.iridiumskyblock.gui.ShopOverviewGUI.addContent(ShopOverviewGUI.java:47) ~[?:?]
at com.iridium.iridiumskyblock.IridiumSkyblock.lambda$onEnable$3(IridiumSkyblock.java:214) ~[?:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) ~[?:?]
at com.iridium.iridiumskyblock.IridiumSkyblock.lambda$onEnable$4(IridiumSkyblock.java:211) ~[?:?]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:82) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:415) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1249) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:388) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1201) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1017) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:301) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3617-Spigot-d90018e-4fa7e1c]
at java.lang.Thread.run(Thread.java:833) ~[?:?]