sorazodia Posted July 27, 2014 Share Posted July 27, 2014 I've been trying to write a event where the player will get potion effects after he/she reaches a certain level. At first it worked, I was granted the water breathing effect after reaching level 10 but when I attempt to re-log into the test world I get this crash log. ---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 7/26/14 6:45 PM Description: Ticking memory connection java.lang.NullPointerException: Ticking memory connection at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:101) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:212) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:165) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:659) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:547) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:111) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:101) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:212) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@59d3789f Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:165) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:659) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:547) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:111) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.7.0_60, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 723101208 bytes (689 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.05 FML v7.10.18.1180 Minecraft Forge 10.13.0.1180 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{7.10.18.1180} [Forge Mod Loader] (forgeBin-1.7.10-10.13.0.1180.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.13.0.1180} [Minecraft Forge] (forgeBin-1.7.10-10.13.0.1180.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available RPG Intergation{1.0} [RPG Intergation] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' I suspect that I had missed a step when using the addPotionEffect() method as I rechecked my code and found that the world won't crash if I remove the addPotionEffect() before launching Minecraft in debug mode and add it back in after the world loads, the event would fire smoothly with no crashes. Was there anything I missed when using addPotionEffect()? Main Class: public class RPG { public static final String MODID = "RPG Intergation"; public static final String VERSION = "1.0"; @EventHandler //I had tried FMLInitialization and FMLPostInitialization but to no luck, the world would still crash public void Preinit(FMLPreInitializationEvent forge) { FMLLog.info("[RPG] Loading Events"); MinecraftForge.EVENT_BUS.register(new PlayerEvents()); FMLLog.info("[RPG] Events Loaded"); } Event Class: public class PlayerEvents { int tierI = 10; int tierII = 30; int tierIII = 50; int tierIV = 100; @SubscribeEvent public void xpBonus(PlayerEvent event){ int playerXP = event.entityPlayer.experienceLevel; if(playerXP >= tierI){ event.entityPlayer.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 10, 0)); } } } Quote Link to comment Share on other sites More sharing options...
sorazodia Posted July 28, 2014 Author Share Posted July 28, 2014 I knew that PlayerEvents was not the best choice, at that time I didn't find/know of any better event so I went on to use it... PlayerTickEvent works, thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.