Posted June 12, 201510 yr Hey im trying to place a different block depending on the different nbt's but it crashes. Method: public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { itemstack.getTagCompound().setString("effect", "No effect"); } else if (player.canPlayerEdit(pos.up(), side, itemstack)) { if (itemstack.getTagCompound().getString("effect") == "Toxic") { world.setBlockState(pos.up(+1), BioWarfareBlocks.block_BacteriaTestToxic.getDefaultState(), 3); --itemstack.stackSize; return true; } if (itemstack.getTagCompound().getString("effect") == "InvertedVision") { world.setBlockState(pos.up(+1), BioWarfareBlocks.block_BacteriaTestInvertedVision.getDefaultState(), 3); --itemstack.stackSize; return true; } if (itemstack.getTagCompound().getString("effect") == "BlurredVision") { world.setBlockState(pos.up(+1), BioWarfareBlocks.block_BacteriaTestBlurredVision.getDefaultState(), 3); --itemstack.stackSize; return true; } if (itemstack.getTagCompound().getString("effect") == "XPDrain") { world.setBlockState(pos.up(+1), BioWarfareBlocks.block_BacteriaTestXPDrain.getDefaultState(), 3); --itemstack.stackSize; return true; } if (itemstack.getTagCompound().getString("effect") == "Rooted") { world.setBlockState(pos.up(+1), BioWarfareBlocks.block_BacteriaTestRooted.getDefaultState(), 3); --itemstack.stackSize; return true; } if (itemstack.getTagCompound().getString("effect") == "Diarrhea") { world.setBlockState(pos.up(+1), BioWarfareBlocks.block_BacteriaTestDiarrhea.getDefaultState(), 3); --itemstack.stackSize; return true; } } return false; } BioWarfare Mod: http://goo.gl/BYWQty
June 12, 201510 yr Author [20:07:10] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 1 [20:07:10] [Netty Server IO #1/INFO] [FML]: Client protocol version 1 [20:07:10] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : [email protected],[email protected],[email protected],[email protected] [20:07:10] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established [20:07:10] [server thread/INFO] [FML]: [server thread] Server side modded connection established [20:07:10] [server thread/INFO]: Player924[local:E:f6e82718] logged in with entity id 392 at (7.484981286012351, 70.30318144372347, -61.335787954741555) [20:07:10] [server thread/INFO]: Player924 joined the game [20:07:13] [server thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.7.0_51] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.7.0_51] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:710) [FMLCommonHandler.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.7.0_51] Caused by: java.lang.NullPointerException at com.looke81.biowarfare.items.ContainedUnknownPathogen.onItemUse(ContainedUnknownPathogen.java:35) ~[ContainedUnknownPathogen.class:?] at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:570) ~[ForgeHooks.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:146) ~[itemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:488) ~[itemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:624) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:67) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:114) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.7.0_51] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.7.0_51] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:709) ~[FMLCommonHandler.class:?] ... 5 more [20:07:13] [server thread/INFO]: Stopping server [20:07:13] [server thread/INFO]: Saving players [20:07:13] [server thread/INFO]: Saving worlds [20:07:13] [server thread/INFO]: Saving chunks for level 'BioWarfare Test World #1'/Overworld [20:07:13] [server thread/INFO]: Saving chunks for level 'BioWarfare Test World #1'/Nether [20:07:13] [server thread/INFO]: Saving chunks for level 'BioWarfare Test World #1'/The End [20:07:14] [server thread/INFO] [FML]: Unloading dimension 0 [20:07:14] [server thread/INFO] [FML]: Unloading dimension -1 [20:07:14] [server thread/INFO] [FML]: Unloading dimension 1 [20:07:14] [server thread/INFO] [FML]: Applying holder lookups [20:07:14] [server thread/INFO] [FML]: Holder lookups applied [20:07:14] [Client thread/FATAL]: Unreported exception thrown! java.lang.NullPointerException at com.looke81.biowarfare.items.ContainedUnknownPathogen.onItemUse(ContainedUnknownPathogen.java:35) ~[ContainedUnknownPathogen.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:147) ~[itemStack.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.func_178890_a(PlayerControllerMP.java:442) ~[PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1564) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:2123) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] [20:07:14] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: ---- Minecraft Crash Report ---- // I just don't know what went wrong Time: 12/06/15 20:07 Description: Unexpected error java.lang.NullPointerException: Unexpected error at com.looke81.biowarfare.items.ContainedUnknownPathogen.onItemUse(ContainedUnknownPathogen.java:35) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:147) at net.minecraft.client.multiplayer.PlayerControllerMP.func_178890_a(PlayerControllerMP.java:442) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1564) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2123) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) at net.minecraft.client.Minecraft.run(Minecraft.java:376) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.looke81.biowarfare.items.ContainedUnknownPathogen.onItemUse(ContainedUnknownPathogen.java:35) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:147) at net.minecraft.client.multiplayer.PlayerControllerMP.func_178890_a(PlayerControllerMP.java:442) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1564) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player924'/392, l='MpServer', x=7.48, y=70.30, z=-61.34]] Chunk stats: MultiplayerChunkCache: 25, 25 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: -148.00,64.00,236.00 - World: (-148,64,236), Chunk: (at 12,4,12 in -10,14; contains blocks -160,0,224 to -145,255,239), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 243876 game time, 74480 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 34 total; [EntityRabbit['Rabbit'/410, l='MpServer', x=49.19, y=64.02, z=-79.59], EntityCow['Cow'/411, l='MpServer', x=22.64, y=69.00, z=-26.46], EntitySquid['Squid'/408, l='MpServer', x=-22.53, y=61.63, z=-73.57], EntitySquid['Squid'/409, l='MpServer', x=-15.66, y=60.30, z=-74.49], EntityCow['Cow'/414, l='MpServer', x=12.84, y=68.00, z=-111.59], EntityCow['Cow'/415, l='MpServer', x=15.94, y=69.00, z=-96.06], EntityCow['Cow'/412, l='MpServer', x=-31.84, y=63.00, z=-29.34], EntityCow['Cow'/413, l='MpServer', x=-42.34, y=65.00, z=-51.56], EntityCow['Cow'/402, l='MpServer', x=8.09, y=70.00, z=-20.81], EntityRabbit['Rabbit'/403, l='MpServer', x=-12.53, y=69.00, z=-19.13], EntityCow['Cow'/400, l='MpServer', x=34.59, y=68.00, z=-48.66], EntitySheep['Sheep'/401, l='MpServer', x=33.31, y=66.00, z=-61.88], EntitySquid['Squid'/406, l='MpServer', x=-21.69, y=61.59, z=-72.27], EntitySquid['Squid'/407, l='MpServer', x=-26.52, y=62.00, z=-66.57], EntityCow['Cow'/404, l='MpServer', x=-28.78, y=63.00, z=-47.69], EntityCow['Cow'/405, l='MpServer', x=-20.13, y=67.00, z=-45.41], EntityPlayerSP['Player924'/392, l='MpServer', x=7.48, y=70.30, z=-61.34], EntityRabbit['Rabbit'/394, l='MpServer', x=9.20, y=70.19, z=-59.32], EntityCow['Cow'/393, l='MpServer', x=11.84, y=70.00, z=-52.97], EntityCow['Cow'/399, l='MpServer', x=1.81, y=67.00, z=-83.59], EntitySheep['Sheep'/398, l='MpServer', x=0.44, y=64.00, z=-94.97], EntityCow['Cow'/397, l='MpServer', x=-2.69, y=69.00, z=-62.36], EntityCow['Cow'/396, l='MpServer', x=-10.63, y=69.00, z=-67.81], EntityCreeper['Creeper'/425, l='MpServer', x=62.91, y=54.00, z=-110.56], EntityCow['Cow'/424, l='MpServer', x=-32.47, y=65.00, z=-83.77], EntityCow['Cow'/426, l='MpServer', x=57.09, y=67.00, z=-108.81], EntityCreeper['Creeper'/417, l='MpServer', x=-46.44, y=13.00, z=-73.59], EntitySkeleton['Skeleton'/416, l='MpServer', x=-44.50, y=13.00, z=-68.50], EntitySheep['Sheep'/419, l='MpServer', x=17.47, y=69.00, z=-104.50], EntityCow['Cow'/418, l='MpServer', x=-34.28, y=68.00, z=-77.47], EntitySheep['Sheep'/421, l='MpServer', x=49.13, y=71.00, z=-71.97], EntityCow['Cow'/420, l='MpServer', x=29.16, y=71.00, z=-104.84], EntityZombie['Zombie'/423, l='MpServer', x=-40.06, y=30.00, z=-92.72], EntityCow['Cow'/422, l='MpServer', x=51.59, y=65.00, z=-79.78]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2600) at net.minecraft.client.Minecraft.run(Minecraft.java:405) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) -- System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 756718192 bytes (721 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.10 FML v8.0.37.1334 Minecraft Forge 11.14.1.1334 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{8.0.37.1334} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{11.14.1.1334} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available biowarfare{1.0} [bioWarfare] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Loaded coremods (and transformers): Launched Version: 1.8 LWJGL: 2.9.1 OpenGL: Intel® HD Graphics 2000 GL version 3.1.0 - Build 9.17.10.3517, Intel GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) [20:07:14] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Daniel\Desktop\BioWarfare 1.8\eclipse\.\crash-reports\crash-2015-06-12_20.07.14-client.txt AL lib: (EE) alc_cleanup: 1 device not closed BioWarfare Mod: http://goo.gl/BYWQty
June 12, 201510 yr getString("effect") == "Toxic" That is not how you compare strings. == is comprasion of 2 objects. you need to use string.equals() EDIT Also - after decrementing stack's size you need to MANUALLY check if its == 0 and set stack to null (from player.inventory level). 1.7.10 is no longer supported by forge, you are on your own.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.