Jump to content

Error when adding dataWatcher objects from another class


ashjack

Recommended Posts

I am trying to use another class to hold the code that adds objects to the dataWatcher of an entity, but when I try to call the function in the other class in the entityInit() function in my entity, I get this error:

 

 

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.lang.reflect.InvocationTargetException

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Constructor.newInstance(Unknown Source)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.EntityList.createEntityByID(EntityList.java:221)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.item.ItemMonsterPlacer.spawnCreature(ItemMonsterPlacer.java:173)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.item.ItemMonsterPlacer.onItemUse(ItemMonsterPlacer.java:79)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:507)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:142)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:422)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.NullPointerException

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at ashjack.evolve.entity.EvolvingEntity.entityInit(EvolvingEntity.java:55)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.Entity.<init>(Entity.java:220)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:155)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:78)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.EntityCreature.<init>(EntityCreature.java:36)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.EntityAgeable.<init>(EntityAgeable.java:17)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.passive.EntityAnimal.<init>(EntityAnimal.java:34)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at ashjack.evolve.entity.EntityAnimalMob.<init>(EntityAnimalMob.java:22)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at ashjack.evolve.entity.EvolvingEntity.<init>(EvolvingEntity.java:38)

[20:34:56] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: ... 20 more

 

 

Here is my code:

 

MyEntity.java

public DataWatcher dataWatcher = this.dataWatcher;
public List<Gene> entityGenes = new ArrayList<Gene>();
public void entityInit()
    {
	for(int i=0; i<entityGenes.size(); i++) //<---The error point to this line of code
	{
		entityGenes.get(i).entityInit();
	}

	/*this.dataWatcher.addObject(16, Byte.valueOf((byte) - 1));
	this.dataWatcher.addObject(17, Byte.valueOf((byte)0));               <---Adding the objects like this is fine
	this.dataWatcher.addObject(18, Byte.valueOf((byte)0));*/
        super.entityInit();
    }

 

GeneExplosive.java

public class GeneExplosive extends Gene
{
        public void entityInit()
{
                owner.dataWatcher.addObject(16, Byte.valueOf((byte) - 1));
                owner.dataWatcher.addObject(17, Byte.valueOf((byte)0));
                owner.dataWatcher.addObject(18, Byte.valueOf((byte)0));
	super.entityInit();
}
}

 

Gene.java

public abstract class Gene 
{
       public void entityInit()
{

}
}

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.

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.



×
×
  • Create New...

Important Information

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