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

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.

  • Author

Ah! that makes sense. I did do that before (I was following some code form DefenseTech) but didn't think it was necessary, thank you very much!

  • Author

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

  • Author

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

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.