Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.