Posted March 6, 20169 yr Pls Help Me Quickly Forge Modding Pls Help me! I have A Custom Drop Event Handler But Every Join Game Crashing... DropHandler Class 1- package com.kodev.df.handlers; 2- 3- import java.util.Random; 4- 5-import com.kodev.df.main.ModRegister; 6- 7-import net.minecraft.init.Blocks; 8-import net.minecraft.init.Items; 9-import net.minecraft.item.ItemStack; 10-import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; 11-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 12-import net.minecraftforge.fml.relauncher.Side; 13-import net.minecraftforge.fml.relauncher.SideOnly; 14-@SideOnly(Side.CLIENT) 15-public class DropHandler { 16- @SubscribeEvent 17- public void LeavesDrop (HarvestDropsEvent event) { 18- if (event.state.getBlock() == Blocks.leaves) { 19- 20- Random rand = new Random(); 21- 22- ItemStack holding = event.harvester.inventory.getStackInSlot(event.harvester.inventory.currentItem); 23- if (holding != null) { 24- event.drops.add(new ItemStack(Items.stick, rand.nextInt(2))); 25- } 26- if (holding == null) { 27- event.drops.add(new ItemStack(Items.stick, rand.nextInt(2))); 28- } 29- 30- } 31- } 32- @SubscribeEvent 33- public void Leaves2Drop (HarvestDropsEvent event) { 34-if (event.state.getBlock() == Blocks.leaves2) { 35- Random rand = new Random(); 36- ItemStack holding = event.harvester.inventory.getStackInSlot(event.harvester.inventory.currentItem); 37- if (holding != null) { 38- event.drops.add(new ItemStack(Items.stick, rand.nextInt(2))); 39- } 40- if (holding == null) { 41- event.drops.add(new ItemStack(Items.stick, rand.nextInt(2))); 42- 43- 44- } 45- 46- } 47- } 48- 49- @SubscribeEvent 50- public void StoneDrop (HarvestDropsEvent event) { 51-if (event.state.getBlock() == Blocks.stone) { 52- Random rand = new Random(); 53- ItemStack holding = event.harvester.inventory.getStackInSlot(event.harvester.inventory.currentItem); 54- if (holding.getItem() == Items.wooden_pickaxe) { 55- event.drops.add(new ItemStack(ModRegister.stone_nugget, rand.nextInt(2))); 56- } 57- if (holding.getItem() == Items.stone_pickaxe) { 58- event.drops.add(new ItemStack(ModRegister.stone_nugget, rand.nextInt(2))); 59- } 60- if (holding.getItem() == Items.iron_pickaxe) { 61- event.drops.add(new ItemStack(ModRegister.stone_nugget, rand.nextInt(2))); 62- } 63- if (holding.getItem() == Items.golden_pickaxe) { 64- event.drops.add(new ItemStack(ModRegister.stone_nugget, rand.nextInt(2))); 65- } 66- if (holding.getItem() == Items.diamond_pickaxe) { 67- event.drops.add(new ItemStack(ModRegister.stone_nugget, rand.nextInt(2))); 68- } 69- 70- } 71- } 72- } Crah Report ---- Minecraft Crash Report ---- // You're mean. Time: 06.03.2016 20:26 Description: Exception ticking world java.lang.NullPointerException: Exception ticking world at com.kodev.df.handlers.DropHandler.LeavesDrop(DropHandler.java:22) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_DropHandler_LeavesDrop_HarvestDropsEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138) at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:186) at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:611) at net.minecraft.block.BlockLeaves.dropBlockAsItemWithChance(BlockLeaves.java:248) at net.minecraft.block.Block.dropBlockAsItem(Block.java:597) at net.minecraft.block.BlockLeaves.destroy(BlockLeaves.java:218) at net.minecraft.block.BlockLeaves.updateTick(BlockLeaves.java:198) at net.minecraft.block.Block.randomTick(Block.java:528) at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:467) at net.minecraft.world.WorldServer.tick(WorldServer.java:228) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:764) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) at java.lang.Thread.run(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.kodev.df.handlers.DropHandler.LeavesDrop(DropHandler.java:22) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_DropHandler_LeavesDrop_HarvestDropsEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138) at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:186) at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:611) at net.minecraft.block.BlockLeaves.dropBlockAsItemWithChance(BlockLeaves.java:248) at net.minecraft.block.Block.dropBlockAsItem(Block.java:597) at net.minecraft.block.BlockLeaves.destroy(BlockLeaves.java:218) at net.minecraft.block.BlockLeaves.updateTick(BlockLeaves.java:198) at net.minecraft.block.Block.randomTick(Block.java:528) at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:467) at net.minecraft.world.WorldServer.tick(WorldServer.java:228) -- Affected level -- Details: Level name: Kodev All players: 1 total; [EntityPlayerMP['Player983'/0, l='Kodev', x=-199,71, y=61,00, z=2888,95]] Chunk stats: ServerChunkCache: 564 Drop: 0 Level seed: 1355276509355184999 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: 3;minecraft:bedrock,3*minecraft:stone,52*minecraft:sandstone;2; Level spawn location: 26,00,4,00,275,00 - World: (26,4,275), Chunk: (at 10,0,3 in 1,17; contains blocks 16,0,272 to 31,255,287), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 263154 game time, 6000 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 48925 (now: false), thunder time: 1656 (now: true) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:764) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) at java.lang.Thread.run(Unknown Source) -- System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_66, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 831829280 bytes (793 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1502 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1502.jar) UCHIJAAAA Forge{11.14.3.1502} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1502.jar) UCHIJAAAA hardcore{2.1.12b} [§aHardcore Minecraft] (bin) UCHIJAAAA Waila{1.6.0} [Waila] (Waila-1.6.0-B2_1.8-dev.jar) Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Player983'/0, l='Kodev', x=-199,71, y=61,00, z=2888,95]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Developing Kodev Minecraft Hardcore Mod! If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod
March 6, 20169 yr Author Because I Was Getting A Server Crash Report. I Think If Add @SideOnly Maybe stop server crashing but it didn't stop. Developing Kodev Minecraft Hardcore Mod! If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod
March 6, 20169 yr 1) Why do you subscribe to the event multiple times? You know you can check for multiple blocks at once, right? 2) Why do you check to see if the player is holding a stack, or not holding a stack, and then do the same thing regardless? (for two of those handlers) Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 6, 20169 yr Author Please Write Correct Working Code I Need Help You! Developing Kodev Minecraft Hardcore Mod! If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod
March 6, 20169 yr Author Important And Need Quickly Release New Mod Version... Developing Kodev Minecraft Hardcore Mod! If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod
March 6, 20169 yr Author Why Pls Help Me Code I Need Quickly. Developing Kodev Minecraft Hardcore Mod! If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod
March 6, 20169 yr Author Okey! :'( Developing Kodev Minecraft Hardcore Mod! If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod
March 6, 20169 yr http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.