Jump to content

[1.7.2][SOLVED]Trying to get the current item held by the player


Recommended Posts

Posted

I have a KeyInputHandler where i check for two inputs, when the player presser O and P

 

package com.crax.portalgunmod;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.crax.portalgunmod.resources.KeyBindings;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;

public class KeyInputHandler {
//if(player.getHeldItem().equals(new ItemStack(Items.diamond)))

@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event){

	//if(portalGunMod.player.getHeldItem().equals(new ItemStack(portalGunMod.portalGunItem))){
		if(KeyBindings.leftMouse.isPressed()){
			System.out.println("Shooting left portal!");
		}
		if(KeyBindings.rightMouse.isPressed()){
			System.out.println("Shooting right portal!");
		//}
	}
}
}

 

And this is my main class:

package com.crax.portalgunmod;

import java.rmi.registry.Registry;

import com.crax.portalgunmod.resources.KeyBindings;
import com.crax.portalgunmod.resources.Resources;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid=Resources.modid, name="PortalMod", version="0.0.1")

public class portalGunMod {
public static Item portalGunItem;
public static EntityPlayer player = Minecraft.getMinecraft().thePlayer;
//ItemStack actualHeldObject = portalGunMod.player.inventory.getCurrentItem();
@Instance(value=Resources.modid)
public static portalGunMod instance;

@SidedProxy(clientSide="com.crax.portalgunmod.client.ClientProxy", serverSide="com.crax.portalgunmod.server.CommonProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event){
	portalGunItem = new PortalGunItem();
	GameRegistry.registerItem(portalGunItem, "portalGunItem");
}

@EventHandler
public void load(FMLInitializationEvent event){
	KeyBindings.init();
	}

@EventHandler
public void postInit(FMLPostInitializationEvent event){

}

}

 

I need to do the actions binded in the keybindings only when the player helds a portalgun item

 

I tried with getting these lines of code:

//in portalGunMod, after the player declaration
ItemStack actualHeldObject = portalGunMod.player.getItemInUse();



//in KeyInputHandler class
if(portalGunMod.player.getHeldItem().equals(new ItemStack(portalGunMod.portalGunItem))){
		if(KeyBindings.leftMouse.isPressed()){
			//System.out.println("Shooting left portal!"+ actualHeldObject.getUnlocalizedName());
		}
		if(KeyBindings.rightMouse.isPressed()){
			System.out.println("Shooting right portal!");
		}



 

I need help, i almost lost my voice for all the curses when the game crashes

Posted

player#getCurrentEquippedItem()

 

Also your KeyBindings are purely client-side, just as a note, so you have to send packets when trying to change something on the server.

This also means that your KeyBindings.init(); method should be called in your client proxy.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

player#getCurrentEquippedItem()

 

Also your KeyBindings are purely client-side, just as a note, so you have to send packets when trying to change something on the server.

This also means that your KeyBindings.init(); method should be called in your client proxy.

 

So, this is how i corrected the KeyInputClass

package com.crax.portalgunmod;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.crax.portalgunmod.resources.KeyBindings;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;

public class KeyInputHandler {
//if(player.getHeldItem().equals(new ItemStack(Items.diamond)))

@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event){

	//if(portalGunMod.player.getHeldItem().equals(new ItemStack(portalGunMod.portalGunItem))){
		if(KeyBindings.leftMouse.isPressed()){
			System.out.println("Shooting left portal!" + portalGunMod.player.getCurrentEquippedItem().getDisplayName());
		}
		if(KeyBindings.rightMouse.isPressed()){
			System.out.println("Shooting right portal!");
		//}
	}
}
}

 

It keeps crashing.

Posted

"It crashes" tells us nothing. Post the crash report.

 

uh, sorry, my bad

Here's my last Crash Report

It gets triggered when i press the O during gameplay

---- Minecraft Crash Report ----
// Don't be sad. I'll do better next time, I promise!

Time: 12/11/14 14.41
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at com.crax.portalgunmod.KeyInputHandler.onKeyInput(KeyInputHandler.java:21)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_KeyInputHandler_onKeyInput_KeyInputEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:539)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1919)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:985)
at net.minecraft.client.Minecraft.run(Minecraft.java:900)
at net.minecraft.client.main.Main.main(Main.java:112)
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:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at com.crax.portalgunmod.KeyInputHandler.onKeyInput(KeyInputHandler.java:21)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_KeyInputHandler_onKeyInput_KeyInputEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:539)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player328'/418, l='MpServer', x=471,35, y=77,86, z=263,73]]
Chunk stats: MultiplayerChunkCache: 140, 140
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (461,64,265), Chunk: (at 13,4,9 in 28,16; contains blocks 448,0,256 to 463,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 1723 game time, 1723 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: 166 total; [EntitySquid['Squid'/275, l='MpServer', x=503,45, y=46,12, z=225,95], EntitySquid['Squid'/274, l='MpServer', x=509,48, y=46,66, z=231,23], EntitySquid['Squid'/273, l='MpServer', x=497,89, y=39,76, z=233,76], EntitySquid['Squid'/272, l='MpServer', x=505,65, y=47,38, z=236,62], EntitySquid['Squid'/279, l='MpServer', x=505,74, y=51,47, z=237,28], EntitySquid['Squid'/278, l='MpServer', x=507,20, y=52,36, z=230,33], EntitySquid['Squid'/277, l='MpServer', x=499,56, y=41,99, z=237,54], EntitySquid['Squid'/276, l='MpServer', x=505,15, y=47,17, z=236,03], EntitySquid['Squid'/283, l='MpServer', x=506,05, y=43,33, z=242,72], EntitySquid['Squid'/282, l='MpServer', x=509,13, y=49,36, z=231,28], EntitySquid['Squid'/281, l='MpServer', x=504,62, y=52,15, z=237,67], EntitySquid['Squid'/280, l='MpServer', x=510,43, y=50,36, z=237,31], EntityZombie['Zombie'/287, l='MpServer', x=508,50, y=14,00, z=301,50], EntityZombie['Zombie'/286, l='MpServer', x=508,50, y=14,00, z=302,50], EntitySquid['Squid'/285, l='MpServer', x=506,74, y=47,37, z=249,52], EntitySquid['Squid'/284, l='MpServer', x=511,56, y=47,31, z=246,28], EntitySquid['Squid'/266, l='MpServer', x=506,41, y=51,35, z=210,13], EntitySquid['Squid'/267, l='MpServer', x=511,04, y=49,83, z=218,59], EntitySquid['Squid'/264, l='MpServer', x=507,07, y=41,33, z=216,66], EntitySquid['Squid'/265, l='MpServer', x=506,94, y=50,97, z=217,25], EntitySquid['Squid'/270, l='MpServer', x=502,51, y=50,35, z=208,06], EntitySquid['Squid'/271, l='MpServer', x=507,06, y=45,28, z=237,99], EntitySquid['Squid'/268, l='MpServer', x=510,33, y=51,45, z=212,64], EntitySquid['Squid'/269, l='MpServer', x=508,45, y=50,44, z=212,79], EntitySquid['Squid'/313, l='MpServer', x=514,12, y=45,81, z=212,83], EntitySquid['Squid'/312, l='MpServer', x=515,87, y=45,38, z=219,10], EntitySquid['Squid'/315, l='MpServer', x=516,00, y=50,99, z=217,61], EntitySpider['Spider'/314, l='MpServer', x=520,56, y=32,00, z=208,28], EntitySkeleton['Skeleton'/46, l='MpServer', x=404,78, y=48,00, z=200,75], EntitySquid['Squid'/317, l='MpServer', x=523,23, y=58,15, z=214,00], EntitySquid['Squid'/47, l='MpServer', x=414,27, y=52,39, z=230,94], EntitySquid['Squid'/316, l='MpServer', x=520,49, y=59,26, z=220,79], EntityZombie['Zombie'/44, l='MpServer', x=409,64, y=43,10, z=189,51], EntitySquid['Squid'/319, l='MpServer', x=525,13, y=57,00, z=209,34], EntityCreeper['Creeper'/45, l='MpServer', x=411,47, y=45,00, z=205,66], EntitySquid['Squid'/318, l='MpServer', x=516,40, y=48,96, z=216,50], EntitySquid['Squid'/51, l='MpServer', x=408,94, y=49,57, z=256,32], EntitySkeleton['Skeleton'/288, l='MpServer', x=506,50, y=14,00, z=304,50], EntityCreeper['Creeper'/289, l='MpServer', x=498,50, y=18,00, z=310,50], EntityCreeper['Creeper'/290, l='MpServer', x=497,50, y=18,00, z=311,50], EntityZombie['Zombie'/291, l='MpServer', x=497,59, y=26,00, z=314,59], EntitySkeleton['Skeleton'/292, l='MpServer', x=498,50, y=18,00, z=330,50], EntitySquid['Squid'/54, l='MpServer', x=414,31, y=51,67, z=242,11], EntitySquid['Squid'/53, l='MpServer', x=412,25, y=52,36, z=247,44], EntitySquid['Squid'/294, l='MpServer', x=501,55, y=59,59, z=326,86], EntitySquid['Squid'/57, l='MpServer', x=410,97, y=42,41, z=266,23], EntitySquid['Squid'/63, l='MpServer', x=408,94, y=47,14, z=269,64], EntitySquid['Squid'/62, l='MpServer', x=410,65, y=45,34, z=266,37], EntitySquid['Squid'/61, l='MpServer', x=413,96, y=41,41, z=266,38], EntitySquid['Squid'/70, l='MpServer', x=408,72, y=53,86, z=312,88], EntitySquid['Squid'/71, l='MpServer', x=415,02, y=57,30, z=310,90], EntitySquid['Squid'/67, l='MpServer', x=414,53, y=55,70, z=318,86], EntitySquid['Squid'/76, l='MpServer', x=414,26, y=57,37, z=324,76], EntitySquid['Squid'/349, l='MpServer', x=530,75, y=50,30, z=215,51], EntitySquid['Squid'/348, l='MpServer', x=529,72, y=60,43, z=225,13], EntitySquid['Squid'/72, l='MpServer', x=415,98, y=57,29, z=317,96], EntitySquid['Squid'/345, l='MpServer', x=532,86, y=57,89, z=219,82], EntityZombie['Zombie'/326, l='MpServer', x=518,50, y=13,00, z=301,50], EntitySquid['Squid'/85, l='MpServer', x=418,94, y=53,55, z=232,47], EntityZombie['Zombie'/327, l='MpServer', x=519,50, y=13,00, z=301,50], EntitySquid['Squid'/324, l='MpServer', x=522,34, y=49,39, z=242,61], EntitySquid['Squid'/87, l='MpServer', x=417,27, y=50,95, z=245,31], EntityZombie['Zombie'/325, l='MpServer', x=518,94, y=14,00, z=302,50], EntitySquid['Squid'/86, l='MpServer', x=416,68, y=50,13, z=239,26], EntitySquid['Squid'/322, l='MpServer', x=517,32, y=47,80, z=236,23], EntitySquid['Squid'/323, l='MpServer', x=515,23, y=49,57, z=232,88], EntitySquid['Squid'/320, l='MpServer', x=527,31, y=57,25, z=216,50], EntitySquid['Squid'/321, l='MpServer', x=512,29, y=43,38, z=227,08], EntitySquid['Squid'/93, l='MpServer', x=431,07, y=39,20, z=293,62], EntitySquid['Squid'/92, l='MpServer', x=432,11, y=43,79, z=273,13], EntityCreeper['Creeper'/332, l='MpServer', x=515,41, y=15,00, z=337,00], EntitySquid['Squid'/95, l='MpServer', x=419,91, y=54,28, z=303,65], EntitySquid['Squid'/94, l='MpServer', x=429,38, y=43,38, z=290,53], EntityCreeper['Creeper'/330, l='MpServer', x=518,41, y=14,00, z=336,00], EntitySquid['Squid'/89, l='MpServer', x=424,25, y=45,01, z=281,10], EntitySquid['Squid'/88, l='MpServer', x=422,99, y=42,93, z=276,13], EntityCreeper['Creeper'/328, l='MpServer', x=512,50, y=37,00, z=296,50], EntitySquid['Squid'/91, l='MpServer', x=429,37, y=43,90, z=284,71], EntityCreeper['Creeper'/329, l='MpServer', x=524,69, y=15,00, z=309,05], EntitySquid['Squid'/90, l='MpServer', x=430,43, y=43,38, z=285,38], EntitySquid['Squid'/102, l='MpServer', x=424,10, y=54,77, z=309,46], EntitySquid['Squid'/103, l='MpServer', x=421,03, y=54,67, z=315,07], EntitySquid['Squid'/100, l='MpServer', x=428,04, y=56,40, z=314,98], EntitySquid['Squid'/101, l='MpServer', x=426,43, y=56,41, z=312,36], EntitySquid['Squid'/98, l='MpServer', x=422,95, y=55,82, z=313,32], EntitySquid['Squid'/99, l='MpServer', x=418,47, y=51,96, z=310,02], EntitySquid['Squid'/96, l='MpServer', x=426,00, y=54,75, z=310,82], EntitySquid['Squid'/97, l='MpServer', x=422,36, y=52,28, z=309,80], EntitySquid['Squid'/110, l='MpServer', x=429,88, y=54,83, z=322,30], EntitySquid['Squid'/111, l='MpServer', x=427,08, y=55,78, z=325,16], EntitySquid['Squid'/108, l='MpServer', x=423,84, y=52,01, z=327,46], EntitySquid['Squid'/109, l='MpServer', x=421,59, y=53,22, z=325,16], EntitySquid['Squid'/107, l='MpServer', x=417,68, y=54,37, z=328,90], EntitySquid['Squid'/104, l='MpServer', x=420,07, y=52,41, z=311,61], EntitySquid['Squid'/105, l='MpServer', x=426,99, y=41,00, z=325,45], EntityCreeper['Creeper'/356, l='MpServer', x=540,50, y=27,00, z=338,50], EntitySquid['Squid'/116, l='MpServer', x=420,95, y=53,13, z=321,35], EntitySquid['Squid'/115, l='MpServer', x=423,69, y=55,91, z=321,65], EntitySquid['Squid'/352, l='MpServer', x=536,30, y=55,98, z=224,64], EntitySquid['Squid'/114, l='MpServer', x=426,28, y=53,94, z=321,34], EntitySquid['Squid'/113, l='MpServer', x=417,27, y=58,37, z=329,21], EntitySquid['Squid'/112, l='MpServer', x=417,30, y=60,34, z=321,10], EntitySquid['Squid'/127, l='MpServer', x=437,74, y=40,23, z=282,74], EntityBat['Bat'/126, l='MpServer', x=444,23, y=16,01, z=286,54], EntityBat['Bat'/125, l='MpServer', x=437,59, y=22,47, z=286,48], EntityWitch['Witch'/124, l='MpServer', x=443,69, y=19,00, z=281,31], EntitySkeleton['Skeleton'/123, l='MpServer', x=448,00, y=18,00, z=284,44], EntitySquid['Squid'/137, l='MpServer', x=434,99, y=54,02, z=317,96], EntitySquid['Squid'/136, l='MpServer', x=440,55, y=52,74, z=307,49], EntitySquid['Squid'/139, l='MpServer', x=431,54, y=55,87, z=321,26], EntitySquid['Squid'/138, l='MpServer', x=438,26, y=47,25, z=316,51], EntitySquid['Squid'/140, l='MpServer', x=439,69, y=43,89, z=324,57], EntitySquid['Squid'/142, l='MpServer', x=441,37, y=52,96, z=329,31], EntityBat['Bat'/129, l='MpServer', x=441,92, y=17,72, z=294,48], EntityCreeper['Creeper'/128, l='MpServer', x=447,50, y=17,00, z=294,50], EntitySquid['Squid'/131, l='MpServer', x=434,47, y=43,93, z=292,47], EntitySquid['Squid'/130, l='MpServer', x=445,53, y=43,44, z=296,96], EntitySquid['Squid'/133, l='MpServer', x=440,63, y=44,19, z=320,07], EntitySquid['Squid'/132, l='MpServer', x=436,42, y=43,44, z=295,74], EntitySquid['Squid'/135, l='MpServer', x=441,84, y=44,40, z=317,20], EntitySquid['Squid'/134, l='MpServer', x=444,94, y=43,47, z=316,85], EntityCreeper['Creeper'/155, l='MpServer', x=449,50, y=18,00, z=285,50], EntityZombie['Zombie'/156, l='MpServer', x=450,50, y=17,00, z=286,50], EntitySkeleton['Skeleton'/157, l='MpServer', x=456,50, y=21,00, z=300,50], EntityCreeper['Creeper'/158, l='MpServer', x=455,72, y=20,00, z=294,41], EntitySpider['Spider'/159, l='MpServer', x=452,38, y=22,00, z=295,88], EntitySkeleton['Skeleton'/390, l='MpServer', x=551,50, y=33,00, z=328,50], EntitySquid['Squid'/171, l='MpServer', x=455,01, y=43,36, z=313,89], EntitySkeleton['Skeleton'/170, l='MpServer', x=463,50, y=30,00, z=308,50], EntitySkeleton['Skeleton'/169, l='MpServer', x=461,16, y=30,00, z=305,50], EntityBat['Bat'/168, l='MpServer', x=448,82, y=13,85, z=317,31], EntitySquid['Squid'/172, l='MpServer', x=450,83, y=47,17, z=308,38], EntityBat['Bat'/163, l='MpServer', x=461,82, y=22,86, z=292,41], EntityZombie['Zombie'/162, l='MpServer', x=462,36, y=23,00, z=289,95], EntityEnderman['Enderman'/161, l='MpServer', x=451,41, y=29,00, z=296,06], EntityCreeper['Creeper'/160, l='MpServer', x=455,50, y=30,00, z=302,50], EntityBat['Bat'/167, l='MpServer', x=447,39, y=19,38, z=293,75], EntityBat['Bat'/166, l='MpServer', x=460,77, y=23,84, z=289,77], EntityBat['Bat'/165, l='MpServer', x=463,67, y=24,61, z=300,42], EntityBat['Bat'/164, l='MpServer', x=459,68, y=26,35, z=298,49], EntityClientPlayerMP['Player328'/418, l='MpServer', x=471,35, y=77,86, z=263,73], EntitySkeleton['Skeleton'/205, l='MpServer', x=479,75, y=26,00, z=306,22], EntityCreeper['Creeper'/204, l='MpServer', x=475,03, y=28,00, z=312,41], EntityZombie['Zombie'/207, l='MpServer', x=474,53, y=21,00, z=332,16], EntityBat['Bat'/206, l='MpServer', x=473,50, y=25,10, z=323,78], EntitySquid['Squid'/201, l='MpServer', x=471,97, y=56,28, z=209,48], EntityZombie['Zombie'/203, l='MpServer', x=476,09, y=44,00, z=264,34], EntitySquid['Squid'/202, l='MpServer', x=476,12, y=52,31, z=208,65], EntitySquid['Squid'/198, l='MpServer', x=478,16, y=54,86, z=201,63], EntitySquid['Squid'/223, l='MpServer', x=492,93, y=41,43, z=223,24], EntitySkeleton['Skeleton'/208, l='MpServer', x=473,50, y=22,00, z=325,50], EntitySpider['Spider'/209, l='MpServer', x=476,29, y=23,00, z=324,53], EntitySkeleton['Skeleton'/210, l='MpServer', x=469,50, y=27,00, z=338,50], EntitySkeleton['Skeleton'/211, l='MpServer', x=469,31, y=28,00, z=339,53], EntityBat['Bat'/233, l='MpServer', x=488,61, y=25,00, z=329,46], EntitySkeleton['Skeleton'/232, l='MpServer', x=486,46, y=23,00, z=326,34], EntitySkeleton['Skeleton'/231, l='MpServer', x=487,13, y=23,00, z=328,03], EntityEnderman['Enderman'/230, l='MpServer', x=484,56, y=23,00, z=328,13], EntitySkeleton['Skeleton'/229, l='MpServer', x=489,22, y=22,00, z=321,53], EntityBat['Bat'/228, l='MpServer', x=485,59, y=15,10, z=327,75], EntityCreeper['Creeper'/227, l='MpServer', x=487,50, y=13,00, z=327,50], EntityCreeper['Creeper'/226, l='MpServer', x=487,63, y=42,00, z=312,03], EntitySkeleton['Skeleton'/225, l='MpServer', x=480,66, y=22,00, z=318,50], EntityBat['Bat'/224, l='MpServer', x=491,65, y=22,24, z=314,78], EntitySquid['Squid'/243, l='MpServer', x=488,62, y=48,15, z=326,47], EntitySquid['Squid'/240, l='MpServer', x=490,32, y=61,45, z=321,28]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:410)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2510)
at net.minecraft.client.Minecraft.run(Minecraft.java:929)
at net.minecraft.client.main.Main.main(Main.java:112)
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:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.7.0_71, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 477514296 bytes (455 MB) / 738197504 bytes (704 MB) up to 3791650816 bytes (3616 MB)
JVM Flags: 0 total; 
AABB Pool Size: 17315 (969640 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.03 FML v7.2.211.1121 Minecraft Forge 10.12.2.1121 4 mods loaded, 4 mods active
mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.211.1121} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.2.1121} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
craxportalgun{0.0.1} [PortalMod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.7.2
LWJGL: 2.9.0
OpenGL: GeForce GTX 770/PCIe/SSE2 GL version 4.4.0 NVIDIA 344.65, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: ~~ERROR~~ NullPointerException: null
Profiler Position: N/A (disabled)
Vec3 Pool Size: 15181 (850136 bytes; 0 MB) allocated, 22 (1232 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

Posted

You need to check if the item held is null, If the hands are empty -> held item is null

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

You need to check if the item held is null, If the hands are empty -> held item is null

 

AAARGH ç.ç

 

I tried this :


	//if(portalGunMod.player.getHeldItem().equals(new ItemStack(portalGunMod.portalGunItem))){
	if(portalGunMod.player.getCurrentEquippedItem()!= null )
		if(KeyBindings.leftMouse.isPressed()){
			System.out.println("Shooting left portal!" );
		}
		if(KeyBindings.rightMouse.isPressed()){
			System.out.println("Shooting right portal!");
		//}
	}

and this:

public void onKeyInput(InputEvent.KeyInputEvent event){

	//if(portalGunMod.player.getHeldItem().equals(new ItemStack(portalGunMod.portalGunItem))){
	if(!portalGunMod.player.getCurrentEquippedItem().equals(null))
		if(KeyBindings.leftMouse.isPressed()){
			System.out.println("Shooting left portal!" );
		}
		if(KeyBindings.rightMouse.isPressed()){
			System.out.println("Shooting right portal!");
		//}
	}
}

 

But nothing! I always crash!

 

Crash Log:

v---- Minecraft Crash Report ----
// Ouch. That hurt 

Time: 12/11/14 16.05
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at com.crax.portalgunmod.KeyInputHandler.onKeyInput(KeyInputHandler.java:20)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_KeyInputHandler_onKeyInput_KeyInputEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:539)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1919)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:985)
at net.minecraft.client.Minecraft.run(Minecraft.java:900)
at net.minecraft.client.main.Main.main(Main.java:112)
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:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at com.crax.portalgunmod.KeyInputHandler.onKeyInput(KeyInputHandler.java:20)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_KeyInputHandler_onKeyInput_KeyInputEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:539)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player453'/409, l='MpServer', x=471,35, y=77,86, z=263,73]]
Chunk stats: MultiplayerChunkCache: 225, 225
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (461,64,265), Chunk: (at 13,4,9 in 28,16; contains blocks 448,0,256 to 463,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 2278 game time, 2278 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: 172 total; [EntitySquid['Squid'/275, l='MpServer', x=506,27, y=44,34, z=247,86], EntitySquid['Squid'/274, l='MpServer', x=504,26, y=47,37, z=246,64], EntitySquid['Squid'/273, l='MpServer', x=508,14, y=48,98, z=236,20], EntitySquid['Squid'/272, l='MpServer', x=504,06, y=49,38, z=229,75], EntityZombie['Zombie'/279, l='MpServer', x=510,56, y=13,00, z=300,59], EntityZombie['Zombie'/278, l='MpServer', x=508,50, y=14,00, z=303,50], EntitySquid['Squid'/277, l='MpServer', x=507,21, y=49,15, z=239,28], EntitySquid['Squid'/276, l='MpServer', x=509,36, y=44,20, z=242,01], EntitySquid['Squid'/283, l='MpServer', x=508,22, y=53,84, z=313,86], EntityCreeper['Creeper'/282, l='MpServer', x=497,50, y=18,00, z=310,56], EntityCreeper['Creeper'/281, l='MpServer', x=510,00, y=36,00, z=293,59], EntitySkeleton['Skeleton'/280, l='MpServer', x=509,31, y=13,00, z=301,50], EntitySquid['Squid'/284, l='MpServer', x=503,28, y=43,43, z=329,61], EntitySquid['Squid'/259, l='MpServer', x=509,78, y=50,44, z=207,67], EntitySquid['Squid'/262, l='MpServer', x=504,76, y=47,28, z=222,66], EntitySquid['Squid'/263, l='MpServer', x=499,30, y=51,45, z=218,32], EntitySquid['Squid'/260, l='MpServer', x=501,03, y=39,19, z=220,45], EntitySquid['Squid'/261, l='MpServer', x=512,45, y=42,81, z=208,40], EntitySquid['Squid'/266, l='MpServer', x=505,29, y=40,78, z=225,68], EntitySquid['Squid'/267, l='MpServer', x=505,13, y=40,97, z=227,48], EntitySquid['Squid'/264, l='MpServer', x=505,30, y=41,13, z=232,69], EntitySquid['Squid'/265, l='MpServer', x=503,28, y=39,34, z=226,31], EntitySquid['Squid'/270, l='MpServer', x=494,68, y=39,30, z=239,30], EntitySquid['Squid'/271, l='MpServer', x=502,15, y=45,91, z=230,28], EntitySquid['Squid'/268, l='MpServer', x=510,85, y=44,15, z=237,44], EntitySquid['Squid'/269, l='MpServer', x=503,55, y=38,89, z=233,57], EntitySquid['Squid'/305, l='MpServer', x=513,50, y=53,87, z=222,27], EntitySquid['Squid'/304, l='MpServer', x=514,24, y=49,18, z=213,54], EntitySquid['Squid'/307, l='MpServer', x=513,43, y=41,34, z=230,96], EntitySquid['Squid'/306, l='MpServer', x=511,26, y=38,10, z=233,60], EntitySquid['Squid'/309, l='MpServer', x=511,65, y=47,38, z=221,81], EntitySquid['Squid'/308, l='MpServer', x=513,76, y=46,39, z=237,43], EntitySquid['Squid'/311, l='MpServer', x=530,77, y=55,38, z=231,55], EntitySquid['Squid'/310, l='MpServer', x=513,22, y=43,97, z=224,39], EntityZombie['Zombie'/313, l='MpServer', x=519,50, y=13,00, z=301,50], EntitySquid['Squid'/312, l='MpServer', x=521,50, y=46,26, z=251,29], EntityZombie['Zombie'/40, l='MpServer', x=411,50, y=40,00, z=187,91], EntityCreeper['Creeper'/315, l='MpServer', x=524,94, y=15,00, z=308,91], EntitySkeleton['Skeleton'/41, l='MpServer', x=404,53, y=49,00, z=201,72], EntityZombie['Zombie'/314, l='MpServer', x=513,91, y=11,00, z=303,66], EntitySquid['Squid'/46, l='MpServer', x=417,44, y=50,39, z=229,26], EntityCreeper['Creeper'/317, l='MpServer', x=518,41, y=14,00, z=336,00], EntitySquid['Squid'/47, l='MpServer', x=417,06, y=50,69, z=230,47], EntityZombie['Zombie'/316, l='MpServer', x=516,50, y=11,00, z=305,50], EntitySquid['Squid'/49, l='MpServer', x=409,07, y=48,18, z=242,51], EntitySquid['Squid'/55, l='MpServer', x=409,86, y=45,99, z=267,33], EntitySquid['Squid'/54, l='MpServer', x=414,97, y=37,91, z=259,81], EntitySquid['Squid'/52, l='MpServer', x=412,59, y=42,22, z=267,81], EntitySpider['Spider'/296, l='MpServer', x=525,03, y=31,00, z=207,38], EntitySquid['Squid'/59, l='MpServer', x=417,61, y=42,31, z=273,51], EntitySquid['Squid'/58, l='MpServer', x=410,12, y=41,34, z=274,36], EntitySquid['Squid'/56, l='MpServer', x=414,48, y=42,31, z=267,80], EntitySquid['Squid'/63, l='MpServer', x=417,50, y=39,83, z=288,59], EntitySquid['Squid'/301, l='MpServer', x=520,97, y=41,38, z=222,51], EntitySquid['Squid'/302, l='MpServer', x=519,44, y=45,26, z=208,27], EntitySquid['Squid'/303, l='MpServer', x=516,94, y=40,05, z=215,97], EntitySquid['Squid'/68, l='MpServer', x=417,81, y=52,29, z=327,31], EntitySquid['Squid'/343, l='MpServer', x=526,66, y=52,03, z=216,89], EntitySquid['Squid'/341, l='MpServer', x=527,86, y=55,37, z=217,08], EntitySquid['Squid'/340, l='MpServer', x=534,45, y=49,07, z=223,50], EntitySquid['Squid'/339, l='MpServer', x=529,49, y=56,32, z=214,47], EntitySquid['Squid'/65, l='MpServer', x=414,88, y=51,19, z=309,53], EntitySquid['Squid'/338, l='MpServer', x=535,88, y=51,96, z=216,66], EntitySquid['Squid'/67, l='MpServer', x=416,09, y=51,94, z=326,50], EntityCreeper['Creeper'/351, l='MpServer', x=542,80, y=26,00, z=338,03], EntitySquid['Squid'/76, l='MpServer', x=425,41, y=40,17, z=270,21], EntitySquid['Squid'/77, l='MpServer', x=419,00, y=38,78, z=267,21], EntitySquid['Squid'/78, l='MpServer', x=430,73, y=39,36, z=275,69], EntityBat['Bat'/79, l='MpServer', x=436,30, y=16,84, z=289,08], EntitySquid['Squid'/74, l='MpServer', x=423,37, y=47,41, z=253,34], EntitySquid['Squid'/75, l='MpServer', x=420,79, y=50,37, z=247,71], EntitySquid['Squid'/85, l='MpServer', x=423,31, y=54,34, z=296,80], EntitySquid['Squid'/84, l='MpServer', x=427,88, y=47,84, z=290,49], EntitySquid['Squid'/87, l='MpServer', x=420,78, y=44,10, z=310,42], EntitySquid['Squid'/86, l='MpServer', x=430,75, y=52,36, z=302,25], EntitySkeleton['Skeleton'/322, l='MpServer', x=516,56, y=34,00, z=343,94], EntitySquid['Squid'/81, l='MpServer', x=422,56, y=38,39, z=304,48], EntitySquid['Squid'/80, l='MpServer', x=417,53, y=42,15, z=294,91], EntityCreeper['Creeper'/320, l='MpServer', x=515,09, y=15,00, z=343,44], EntitySquid['Squid'/83, l='MpServer', x=432,34, y=43,25, z=291,13], EntitySquid['Squid'/82, l='MpServer', x=431,69, y=40,37, z=291,77], EntitySquid['Squid'/334, l='MpServer', x=534,75, y=52,84, z=201,51], EntitySquid['Squid'/93, l='MpServer', x=425,01, y=50,28, z=311,02], EntitySquid['Squid'/335, l='MpServer', x=534,50, y=53,94, z=206,51], EntitySquid['Squid'/92, l='MpServer', x=420,13, y=48,69, z=306,88], EntitySquid['Squid'/95, l='MpServer', x=414,67, y=48,16, z=311,08], EntitySquid['Squid'/94, l='MpServer', x=420,36, y=51,17, z=313,07], EntitySquid['Squid'/89, l='MpServer', x=426,18, y=52,28, z=310,78], EntitySquid['Squid'/88, l='MpServer', x=416,70, y=50,34, z=310,55], EntitySquid['Squid'/91, l='MpServer', x=432,74, y=56,48, z=318,88], EntitySquid['Squid'/90, l='MpServer', x=420,14, y=51,14, z=311,69], EntitySquid['Squid'/103, l='MpServer', x=427,67, y=50,38, z=321,57], EntitySquid['Squid'/100, l='MpServer', x=421,11, y=55,35, z=323,41], EntitySquid['Squid'/98, l='MpServer', x=420,18, y=38,42, z=321,42], EntitySquid['Squid'/96, l='MpServer', x=414,98, y=50,25, z=318,30], EntitySquid['Squid'/97, l='MpServer', x=415,40, y=51,43, z=321,40], EntitySquid['Squid'/106, l='MpServer', x=418,15, y=56,31, z=319,49], EntitySquid['Squid'/107, l='MpServer', x=431,92, y=52,28, z=319,18], EntitySquid['Squid'/104, l='MpServer', x=428,24, y=53,33, z=322,67], EntitySquid['Squid'/105, l='MpServer', x=416,88, y=60,43, z=325,01], EntitySquid['Squid'/119, l='MpServer', x=440,50, y=40,09, z=283,11], EntityZombie['Zombie'/118, l='MpServer', x=447,31, y=17,00, z=284,41], EntityBat['Bat'/117, l='MpServer', x=441,86, y=20,71, z=287,74], EntityCreeper['Creeper'/116, l='MpServer', x=444,09, y=16,00, z=288,30], EntityBat['Bat'/115, l='MpServer', x=443,91, y=16,52, z=283,61], EntityWitch['Witch'/114, l='MpServer', x=443,50, y=19,00, z=281,91], EntitySkeleton['Skeleton'/113, l='MpServer', x=446,09, y=16,00, z=284,66], EntitySquid['Squid'/127, l='MpServer', x=442,42, y=49,66, z=317,46], EntitySquid['Squid'/126, l='MpServer', x=432,50, y=44,31, z=312,45], EntitySquid['Squid'/125, l='MpServer', x=446,69, y=42,13, z=310,59], EntitySquid['Squid'/124, l='MpServer', x=437,26, y=41,39, z=314,99], EntitySquid['Squid'/123, l='MpServer', x=434,47, y=38,94, z=293,07], EntityBat['Bat'/122, l='MpServer', x=437,01, y=22,79, z=286,50], EntitySquid['Squid'/121, l='MpServer', x=435,50, y=35,00, z=285,72], EntitySquid['Squid'/120, l='MpServer', x=434,93, y=36,16, z=285,44], EntityClientPlayerMP['Player453'/409, l='MpServer', x=471,35, y=77,86, z=263,73], EntitySquid['Squid'/143, l='MpServer', x=460,40, y=52,39, z=200,06], EntitySquid['Squid'/129, l='MpServer', x=431,53, y=50,29, z=312,32], EntitySquid['Squid'/128, l='MpServer', x=441,73, y=49,66, z=305,95], EntitySquid['Squid'/133, l='MpServer', x=434,29, y=50,87, z=320,26], EntitySquid['Squid'/132, l='MpServer', x=442,19, y=51,38, z=323,19], EntitySquid['Squid'/135, l='MpServer', x=435,77, y=55,44, z=322,48], EntityBat['Bat'/152, l='MpServer', x=451,46, y=23,70, z=285,57], EntityBat['Bat'/153, l='MpServer', x=454,69, y=13,26, z=318,51], EntitySkeleton['Skeleton'/154, l='MpServer', x=463,72, y=31,00, z=311,16], EntitySkeleton['Skeleton'/155, l='MpServer', x=458,06, y=30,00, z=306,44], EntityBat['Bat'/156, l='MpServer', x=459,47, y=20,85, z=306,50], EntitySquid['Squid'/157, l='MpServer', x=455,15, y=39,00, z=314,49], EntitySquid['Squid'/158, l='MpServer', x=446,56, y=44,38, z=308,77], EntitySquid['Squid'/159, l='MpServer', x=449,38, y=39,13, z=319,51], EntityCreeper['Creeper'/144, l='MpServer', x=448,69, y=16,00, z=286,31], EntitySkeleton['Skeleton'/145, l='MpServer', x=456,50, y=21,00, z=300,50], EntityCreeper['Creeper'/146, l='MpServer', x=458,34, y=21,00, z=301,06], EntitySpider['Spider'/147, l='MpServer', x=449,28, y=17,00, z=294,02], EntityCreeper['Creeper'/148, l='MpServer', x=455,50, y=30,00, z=302,50], EntityEnderman['Enderman'/149, l='MpServer', x=452,50, y=29,00, z=297,31], EntityBat['Bat'/150, l='MpServer', x=463,27, y=23,00, z=294,73], EntityBat['Bat'/151, l='MpServer', x=458,75, y=20,00, z=292,75], EntitySquid['Squid'/160, l='MpServer', x=445,57, y=39,33, z=313,04], EntitySquid['Squid'/191, l='MpServer', x=477,44, y=48,24, z=218,25], EntitySkeleton['Skeleton'/201, l='MpServer', x=465,38, y=26,00, z=343,34], EntityBat['Bat'/200, l='MpServer', x=487,15, y=23,92, z=327,97], EntitySkeleton['Skeleton'/202, l='MpServer', x=469,06, y=28,00, z=339,41], EntityZombie['Zombie'/197, l='MpServer', x=472,88, y=21,00, z=335,31], EntityBat['Bat'/196, l='MpServer', x=473,50, y=25,10, z=323,78], EntitySkeleton['Skeleton'/199, l='MpServer', x=476,31, y=22,00, z=321,25], EntitySpider['Spider'/198, l='MpServer', x=477,28, y=20,00, z=331,59], EntityZombie['Zombie'/193, l='MpServer', x=468,03, y=25,00, z=291,66], EntityZombie['Zombie'/192, l='MpServer', x=476,09, y=44,00, z=264,34], EntitySkeleton['Skeleton'/195, l='MpServer', x=479,75, y=26,00, z=306,22], EntityCreeper['Creeper'/194, l='MpServer', x=470,47, y=28,00, z=314,63], EntityZombie['Zombie'/220, l='MpServer', x=494,44, y=25,00, z=308,41], EntityCreeper['Creeper'/221, l='MpServer', x=488,06, y=42,00, z=310,63], EntitySquid['Squid'/222, l='MpServer', x=480,47, y=59,32, z=317,39], EntityCreeper['Creeper'/223, l='MpServer', x=487,50, y=13,00, z=327,50], EntitySquid['Squid'/217, l='MpServer', x=488,85, y=41,01, z=217,55], EntitySkeleton['Skeleton'/218, l='MpServer', x=480,91, y=23,00, z=315,50], EntityCreeper['Creeper'/219, l='MpServer', x=490,78, y=17,00, z=319,22], EntitySquid['Squid'/213, l='MpServer', x=481,05, y=47,13, z=208,76], EntitySquid['Squid'/214, l='MpServer', x=478,35, y=51,85, z=203,11], EntitySquid['Squid'/215, l='MpServer', x=486,38, y=50,07, z=201,28], EntitySquid['Squid'/237, l='MpServer', x=485,69, y=57,27, z=320,09], EntitySquid['Squid'/235, l='MpServer', x=486,58, y=50,13, z=326,66], EntitySquid['Squid'/234, l='MpServer', x=489,50, y=48,00, z=324,50], EntitySquid['Squid'/231, l='MpServer', x=492,72, y=43,39, z=326,33], EntitySkeleton['Skeleton'/230, l='MpServer', x=480,13, y=22,00, z=335,31], EntityBat['Bat'/229, l='MpServer', x=485,47, y=22,62, z=314,60], EntitySkeleton['Skeleton'/228, l='MpServer', x=494,72, y=20,00, z=320,25], EntitySkeleton['Skeleton'/227, l='MpServer', x=491,94, y=17,00, z=328,47], EntitySkeleton['Skeleton'/226, l='MpServer', x=486,50, y=23,00, z=325,38], EntityEnderman['Enderman'/225, l='MpServer', x=482,56, y=24,00, z=328,15], EntityBat['Bat'/224, l='MpServer', x=485,59, y=15,10, z=327,75]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:410)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2510)
at net.minecraft.client.Minecraft.run(Minecraft.java:929)
at net.minecraft.client.main.Main.main(Main.java:112)
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:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.7.0_71, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 398391152 bytes (379 MB) / 738197504 bytes (704 MB) up to 3791650816 bytes (3616 MB)
JVM Flags: 0 total; 
AABB Pool Size: 17315 (969640 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.03 FML v7.2.211.1121 Minecraft Forge 10.12.2.1121 4 mods loaded, 4 mods active
mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.211.1121} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.2.1121} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
craxportalgun{0.0.1} [PortalMod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.7.2
LWJGL: 2.9.0
OpenGL: GeForce GTX 770/PCIe/SSE2 GL version 4.4.0 NVIDIA 344.65, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: ~~ERROR~~ NullPointerException: null
Profiler Position: N/A (disabled)
Vec3 Pool Size: 33496 (1875776 bytes; 1 MB) allocated, 22 (1232 bytes; 0 MB) used
Anisotropic Filtering: Off (1)
#@!@# Game crashed! Crash report saved to: #@!@# D:\Documenti vari\GitHub\PortalGunModMinecraft\.\crash-reports\crash-2014-11-12_16.05.51-client.txt
[16:05:51] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[16:05:51] [Client thread/INFO] [FML]: Server terminated.
AL lib: (EE) alc_cleanup: 1 device not closed
[0x7FFE9CFA0150] ANOMALY: meaningless REX prefix used
[0x7FFE9CF88E00] ANOMALY: meaningless REX prefix used

 

P.S How do i decrypt those crash reports?

Posted

Show your KeyBindings class.

 

Edit: portalGunMod.player is null you need to ether get the player when the key input event is fired or add the following method to your portalGunMod class and use it to get the player.

 

public static EntityClientPlayerMP getClientPlayer(){
return Minecraft.getMinecraft().thePlayer;
}

 

Regarding your current setup im not sure exactly how it works but i think the player field is being initialized during the mod construction faze during which time the player dose not exist. The player dosnt exist until you log into the world.

Also if you were to store the player in a field such as that i believe it would become null the next time the player dies (but im not sure about that)

 

Edit 2: A good way to track down a problem like that is to add some println's to find out what is null and where things go wrong . Also "java.lang.NullPointerException: Unexpected error" Is telling you that a value is null.

"at com.crax.portalgunmod.KeyInputHandler.onKeyInput(KeyInputHandler.java:20)" Is telling you the class and line on which the error occurred. Usually you can click on it and it will take you to the error then you just have to figure out what you did wrong.

I am the author of Draconic Evolution

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.