So I've dabbled in Minecraft Modding in the past and just recently decided to give it another shot. I've watched and read a few tutorials about Key Binding and while trying to add a feature to armor that would allow you to change flight speed I've encountered a problem that I've looked around for some answers but haven't been able to find anything specific to my needs.
When using my Key Binding array in an IF statement whenever a game is loaded with the armor on I recieve a crash with the reason being a NPE and it points to my IF statement. I've attached the crash and the code in question and maybe someone who knows better will be able to help me out! If you need to see more code or have a question about the code or crash just lmk!
Code:
if (ClientProxy.keyBindings[0].isPressed())
{
if (player.capabilities.getFlySpeed() != 5)
{
player.capabilities.setFlySpeed(player.capabilities.getFlySpeed() + 1F);
} else {
player.capabilities.setFlySpeed(1F);
}
}
Crash Report:
[20:19:00] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[20:19:00] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// Don't do that.
Time: 9/7/19 8:19 PM
Description: Ticking player
java.lang.NullPointerException: Ticking player
at com.Frostdr4gon2.ThomassMods.util.handlers.EventsHandler.onEvent(EventsHandler.java:49)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_15_EventsHandler_onEvent_PlayerTickEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:365)
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:228)
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423)
at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307)
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
at java.lang.Thread.run(Unknown Source)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Client thread
Stacktrace:
at com.Frostdr4gon2.ThomassMods.util.handlers.EventsHandler.onEvent(EventsHandler.java:49)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_15_EventsHandler_onEvent_PlayerTickEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:365)
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:228)
-- Player being ticked --
Details:
Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)
Entity ID: 232
Entity Name: Player800
Entity's Exact location: -34.77, 78.00, 251.55
Entity's Block location: World: (-35,78,251), Chunk: (at 13,4,11 in -3,15; contains blocks -48,0,240 to -33,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Entity's Momentum: 0.00, -0.08, 0.00
Entity's Passengers: []
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423)
at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307)
-- Ticking connection --
Details:
Connection: net.minecraft.network.NetworkManager@5cba5302
Stacktrace:
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
at java.lang.Thread.run(Unknown Source)
-- System Details --
Details:
Minecraft Version: 1.12.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_211, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 600117072 bytes (572 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP 9.42 Powered by Forge 14.23.5.2768 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
| State | ID | Version | Source | Signature |
|:--------- |:--------- |:------------ |:-------------------------------- |:--------- |
| UCHIJAAAA | minecraft | 1.12.2 | minecraft.jar | None |
| UCHIJAAAA | mcp | 9.42 | minecraft.jar | None |
| UCHIJAAAA | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.5.2768.jar | None |
| UCHIJAAAA | forge | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None |
| UCHIJAAAA | tm | 0.3 | bin | None |
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['Player800'/232, l='New World', x=-34.77, y=78.00, z=251.55]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
[20:19:00] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2019-09-07_20.18.59-server.txt
[20:19:00] [Client Shutdown Thread/INFO] [minecraft/MinecraftServer]: Stopping server
[20:19:00] [Client Shutdown Thread/INFO] [minecraft/MinecraftServer]: Saving players
Again any help is appreciated!
Edit: Forgot to mention that I'm coding for Minecraft 1.12
So I've dabbled in Minecraft Modding in the past and just recently decided to give it another shot. I've watched and read a few tutorials about Key Binding and while trying to add a feature to armor that would allow you to change flight speed I've encountered a problem that I've looked around for some answers but haven't been able to find anything specific to my needs.
When using my Key Binding array in an IF statement whenever a game is loaded with the armor on I recieve a crash with the reason being a NPE and it points to my IF statement. I've attached the crash and the code in question and maybe someone who knows better will be able to help me out! If you need to see more code or have a question about the code or crash just lmk!
Code:
Crash Report:
Again any help is appreciated!
Edit: Forgot to mention that I'm coding for Minecraft 1.12