Jump to content

[Solved] world.isDaytime() does not seem to work


jt9

Recommended Posts

I have an entity that uses world.isDaytime() to check whether it should despawn, however it does not seem to work since they despawn at night. 

From my entity class:

    public void onUpdate()
    {
        super.onUpdate();
        this.motionY *= 0.6000000238418579D;

        if(this.world.isDaytime())
        {
        	if(this.rand.nextInt(1000) == 0)
        	{
        		this.setDead();
        		System.out.println("despawn");
        	}
        }
    }

The console gets flooded with the test message "despawn" during night. Beds use the same boolean so it is clearly working...but not with this entity? 

 

SOLVED, solution by diesieben07:

it only works on the server side, added check for !this.world.isRemote

Edited by jt9
Link to comment
Share on other sites

This is the only relevant piece of code in the entity class. Given that 

System.out.println("despawn");

is constantly being executed, it shows that the if statement isn't working correctly. I can see the mobs die as soon as I spawn them

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.

Announcements



×
×
  • Create New...

Important Information

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