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

 I've an idea but for exact explanation I need the full code of the entity.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

  • Author

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

  • Author
6 minutes ago, diesieben07 said:

isDaytime only works on the server. You need to check if you are on the server before despawning anyways.

Oops! That makes sense. Fixed it, thanks :)

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.