Jump to content

onLivingUpdate does not appear to be triggering


Acrogenous
 Share

Recommended Posts

I have created an entity, an explosive to be precise, but the function onLivingUpdate does not appear to be firing at all. I have a println on the initiating of the class saying it has worked and then 2 more print lines in the onLivingUpdate section, these dont seem to be firing however, what am I doing wrong?

public class EntityExplosive extends EntityPig {
    int fuse;
    EntityPlayer player;
    BlockPos coords;
    float explosion;
    World world;



    public EntityExplosive(World getworld, BlockPos getcoords, EntityPlayer getplayer, float getexplosion, int getfuse)
    {

        super(getworld);
        System.out.println("it worked");
        this.fuse = getfuse;
        this.player = getplayer;
        this.coords = getcoords;
        this.explosion = getexplosion;
        this.world = getworld;
    }
    @Override
    public void onLivingUpdate() {
        System.out.println(this.fuse);
        if(this.fuse != 0)
        {
            this.fuse --;
            System.out.println("counting down");
        }
        if(this.fuse < 1)
        {
            this.world.createExplosion(this.player,this.coords.getX(),this.coords.getY(),this.coords.getZ(),this.explosion,true);
            this.setDead();
            return;

        }
        super.onLivingUpdate();
    }


}

It extends EntityPig so I didn't have to construct the rest of the class.  the variables passed on creation of the EntityExplosive are: the world, the blockpos, the player, 10 and 100.

thank you in advance.

Link to comment
Share on other sites

if I want the entity to have those variables passed on to it when it is created, how would I go about doing that?

 

I seem to be getting a problem with a ticking entity.  saying there is a nullPointer on the "createExplosion" line. why is this?

 

the problem in fact seems to lie in the entity not existing past 1 tick...

Edited by Acrogenous
Link to comment
Share on other sites

On 29.6.2017 at 2:11 AM, Acrogenous said:

if I want the entity to have those variables passed on to it when it is created, how would I go about doing that?

A class can have more than one constructor.

 

On 29.6.2017 at 2:11 AM, Acrogenous said:

I seem to be getting a problem with a ticking entity.  saying there is a nullPointer on the "createExplosion" line. why is this?

Post the stacktrace and your code.

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

 Share



×
×
  • Create New...

Important Information

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