Posted May 28, 20169 yr 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.
May 28, 20169 yr 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.
May 28, 20169 yr 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.
May 28, 20169 yr 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.
May 28, 20169 yr 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.
May 28, 20169 yr 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.
May 28, 20169 yr 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.
May 28, 20169 yr 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.
May 28, 20169 yr Author boolean - will ne false. (generic) Boolean - will be null. (object) ah, ok. Thx. Developer of Primeval Forest.
May 28, 20169 yr Author boolean - will ne false. (generic) Boolean - will be null. (object) ah, ok. Thx. Developer of Primeval Forest.
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.