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

Hi,

 

I've got a small problem.

I want to have a random boolean in my tile entity which get's saved, but I don't know where

to initialize the random boolean.

 

It could be done in the constructor, but the constructor get's called when an object get's created. So wouldn't then be a new

random boolean created when for example MC get's restarted instead of using the saved one?

 

Thx in advance.

Bektor

Developer of Primeval Forest.

  • Author

Hi,

 

I've got a small problem.

I want to have a random boolean in my tile entity which get's saved, but I don't know where

to initialize the random boolean.

 

It could be done in the constructor, but the constructor get's called when an object get's created. So wouldn't then be a new

random boolean created when for example MC get's restarted instead of using the saved one?

 

Thx in advance.

Bektor

Developer of Primeval Forest.

Make global PRIVATE Boolean. In your read/write NBTmethods make "this.bool = nbt.getBoolean("B");" and "nbt.setBoolean("B");".

Create getter for said boolean such as:

private static Random RAND = new Random();

public boolean getBool()
{
    if (this.bool == null)
    {
        this.bool = RAND.nextBoolean();
    }
    return this.bool;
}

1.7.10 is no longer supported by forge, you are on your own.

Make global PRIVATE Boolean. In your read/write NBTmethods make "this.bool = nbt.getBoolean("B");" and "nbt.setBoolean("B");".

Create getter for said boolean such as:

private static Random RAND = new Random();

public boolean getBool()
{
    if (this.bool == null)
    {
        this.bool = RAND.nextBoolean();
    }
    return this.bool;
}

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Make global PRIVATE boolean. In your read/write NBTmethods make "this.bool = nbt.getBoolean("B");" and "nbt.setBoolean("B");".

Create getter for said boolean such as:

private static Random RAND = new Random();

public boolean getBool()
{
    if (this.bool == null)
    {
        this.bool = RAND.nextBoolean();
    }
    return this.bool;
}

There is just one problem. A boolean is NEVER null. If it has no value, it gets assigned I think true.

Developer of Primeval Forest.

  • Author

Make global PRIVATE boolean. In your read/write NBTmethods make "this.bool = nbt.getBoolean("B");" and "nbt.setBoolean("B");".

Create getter for said boolean such as:

private static Random RAND = new Random();

public boolean getBool()
{
    if (this.bool == null)
    {
        this.bool = RAND.nextBoolean();
    }
    return this.bool;
}

There is just one problem. A boolean is NEVER null. If it has no value, it gets assigned I think true.

Developer of Primeval Forest.

boolean - will ne false. (generic primitive) (I messed up)

Boolean - will be null. (object)

1.7.10 is no longer supported by forge, you are on your own.

boolean - will ne false. (generic primitive) (I messed up)

Boolean - will be null. (object)

1.7.10 is no longer supported by forge, you are on your own.

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.