Jump to content

Null Pointer with EntityItem


Recommended Posts

Hey everyone, I have a strange problem with my Tile Entities. I recently changed my Fish Mod (yes, it a silly mod I'm making for practice) to use Tile Entities for the fish dirt rather than a tick handler. The only problem is, I get a NPE 5-30 seconds after placing the block:


The Entity that throws the NPE on move varies from EntityITem to EntityFallingSand each time. If I make the Tile Entity not shoot out fish, it doesn't cause a crash. I suspect something with bounding boxes but I'm not really sure how to fix it.


Here is all the relevant code:




@Mod(modid="FishMod", name="Fish Mod", version="1.0")
public class FishMod{

public final ItemStack fishRod = new ItemStack(new FishGodRod(900));
public final ItemStack diamondFishingRod = new ItemStack(new DiamondFishingRod(901));
public final Block fishDirt = new FishGodDirt(902);
public final Random random = new Random();

@Instance(value = "FishMod")
public static FishMod instance;

public void preInit(FMLPreInitializationEvent e){


public void load(FMLInitializationEvent e){
	GameRegistry.registerBlock(this.fishDirt, "FishGodDirt");
	GameRegistry.registerTileEntity(TileEntityFishGodDirt.class, "fishGodDirtTileEntity");
	LanguageRegistry.addName(this.diamondFishingRod, "Diamond Fishing Rod");
	LanguageRegistry.addName(this.fishRod, "Great Rod of the Fish God");
	LanguageRegistry.addName(this.fishDirt, "Great Dirt of the Fish God");
	GameRegistry.addRecipe(this.fishRod, "  x", " y ", 'x', new ItemStack(Item.fishRaw), 'y', new ItemStack(Item.stick));
	GameRegistry.addRecipe(new ItemStack(this.fishDirt), "xxx", "xyx", "xxx", 'x', new ItemStack(Item.fishRaw), 'y', new ItemStack(Block.dirt));

public void postInit(FMLPostInitializationEvent e){





public class FishGodDirt extends BlockContainer{

public FishGodDirt(int par1) {
	super(par1, Material.ground);

public TileEntity createNewTileEntity(World world) {
	return new TileEntityFishGodDirt();





public class ItemFakeFish extends EntityItem{

public ItemFakeFish(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) {
	super(par1World, par2, par4, par6, par8ItemStack);

public void moveEntity(double par1, double par3, double par5){
	super.moveEntity(par1, par3, par5);





public class TileEntityFishGodDirt extends TileEntity{

public TileEntityFishGodDirt(){
	this.blockType = FishMod.instance.fishDirt;

public void updateEntity(){
	if(this.worldObj.isRemote || this.isInvalid())
	Entity ent = new ItemFakeFish(Minecraft.getMinecraft().theWorld, this.xCoord+0.5, this.yCoord+1.3, this.zCoord+0.5, new ItemStack(Item.fishRaw));
	Vec3 vec = Vec3.createVectorHelper(FishMod.instance.random.nextInt(10)-5, 10, FishMod.instance.random.nextInt(10)-5).normalize();
	ent.setVelocity(vec.xCoord, vec.yCoord, vec.zCoord);




Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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