Jump to content

Recommended Posts

Posted

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.

Posted (edited)

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
Posted

I have since deleted the class as I found an alternative way to get to a solution. I may re-implement this entity at a later date and if I get the same problem I shall post the code and stacktrace here

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.

Announcements



×
×
  • Create New...

Important Information

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