Posted October 3, 201312 yr 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: http://paste.minecraftforge.net/view/40bb4ec6 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: FishMod @Mod(modid="FishMod", name="Fish Mod", version="1.0") @NetworkMod(clientSideRequired=true) 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; @cpw.mods.fml.common.Mod.EventHandler public void preInit(FMLPreInitializationEvent e){ } @cpw.mods.fml.common.Mod.EventHandler 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)); } @cpw.mods.fml.common.Mod.EventHandler public void postInit(FMLPostInitializationEvent e){ } } FishGodDirt: public class FishGodDirt extends BlockContainer{ public FishGodDirt(int par1) { super(par1, Material.ground); setTextureName("firstmod:fishdirt"); setStepSound(Block.soundGrassFootstep); setUnlocalizedName("FishDirt"); setCreativeTab(CreativeTabs.tabBlock); setLightValue(1F); } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityFishGodDirt(); } } ItemFakeFish: 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); if(this.isCollided){ this.worldObj.removeEntity(this); } } } TileEntityFishGodDirt: public class TileEntityFishGodDirt extends TileEntity{ public TileEntityFishGodDirt(){ this.blockType = FishMod.instance.fishDirt; } @Override public void updateEntity(){ if(this.worldObj.isRemote || this.isInvalid()) return; Entity ent = new ItemFakeFish(Minecraft.getMinecraft().theWorld, this.xCoord+0.5, this.yCoord+1.3, this.zCoord+0.5, new ItemStack(Item.fishRaw)); this.worldObj.spawnEntityInWorld(ent); 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); } } Thanks! http://i.imgur.com/nVI9Y.png[/img]
October 3, 201312 yr Author That was left over from me being a noob about the integrated server thing. That appears to have fixed it. Could you explain why? http://i.imgur.com/nVI9Y.png[/img]
October 4, 201312 yr Author Yeah, I know that. I was wondering how that would translate through to a NPE. http://i.imgur.com/nVI9Y.png[/img]
October 6, 201312 yr It would help if you pasted the ENTIRE error report, please. The small bit you included wasn't enough for me to diagnose the problem. There's no mention of your classes anywhere, so I can't pinpoint where the problem is.
October 6, 201312 yr The issue has been fixed. The author had a conflict with server side by using client side only code where he shouldn't have.
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.