Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8]Make booleans stay after quitting Minecraft


Trusak
 Share

Recommended Posts

Because it's only in Local Scope.

So how can I make it work?

 

Make your config variable exist outside local scope.

Ok so that is what I have right now:

protected void actionPerformed(GuiButton button) throws IOException {
	if(button == GUI.GUI.button2) {
		Minecraft.getMinecraft().displayGuiScreen(new GUI2());
		Property prop = config1.get("Booleans", "PMs", false);
		boolean PMs = prop.getBoolean();
		prop.set(!PMs);;
		config1.save();
	}
}

What to do now? Also how can I make that

public static boolean PMs;
public static boolean PMsEnabled(){
    return (PMs = !PMs);
}

get it's state from the config?

Link to comment
Share on other sites

  • Replies 103
  • Created
  • Last Reply

Top Posters In This Topic

What to do now? Also how can I make that

public static boolean PMs;
public static boolean PMsEnabled(){
    return (PMs = !PMs);
}

get it's state from the config?

 

Well that will never be true.

true != false

or

false != true

 

Think about what you're doing for a minute, then stop being an idiot.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Think about what you're doing for a minute, then stop being an idiot.

He is not checking equality.

 

Ah, you are correct.  But yes, still nonsense.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Think about what you're doing for a minute, then stop being an idiot.

He is not checking equality.

 

Ah, you are correct.  But yes, still nonsense.

I am not sure what I am doing wrong. It works fine in-game.

The name of your method (PmsEnabled) sounds like a getter method. IE it should just return PMs, but instead it switches the value and returns the new value.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Think about what you're doing for a minute, then stop being an idiot.

He is not checking equality.

 

Ah, you are correct.  But yes, still nonsense.

I am not sure what I am doing wrong. It works fine in-game.

The name of your method (PmsEnabled) sounds like a getter method. IE it should just return PMs, but instead it switches the value and returns the new value.

Yeah I have two of them, PmsEnabled and PmsInfo, I actually want it to be like that :)

public static boolean PMs;
public static boolean PMsEnabled(){
    return (PMs = !PMs);
}
public static boolean PMsInfo(){
    return (PMs);
}

I still don't know what to do with

Because it's only in Local Scope.

So how can I make it work?

 

Make your config variable exist outside local scope.

Ok so that is what I have right now:

protected void actionPerformed(GuiButton button) throws IOException {
	if(button == GUI.GUI.button2) {
		Minecraft.getMinecraft().displayGuiScreen(new GUI2());
		Property prop = config1.get("Booleans", "PMs", false);
		boolean PMs = prop.getBoolean();
		prop.set(!PMs);;
		config1.save();
	}
}

What to do now? Also how can I make that

public static boolean PMs;
public static boolean PMsEnabled(){
    return (PMs = !PMs);
}

get it's state from the config?

now anyway :(.
Link to comment
Share on other sites

Think about what you're doing for a minute, then stop being an idiot.

He is not checking equality.

 

Ah, you are correct.  But yes, still nonsense.

I am not sure what I am doing wrong. It works fine in-game.

The name of your method (PmsEnabled) sounds like a getter method. IE it should just return PMs, but instead it switches the value and returns the new value.

So is there anything wrong with my method?

Link to comment
Share on other sites

PmsEnabled

would be better named

togglePMs

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

PmsEnabled

would be better named

togglePMs

I know but it is only the name so I don't think I should care about it too much. Can you help me with the config itself? I still don't know what to change and how to change from property to boolean

...Looks at code in earlier post...

boolean PMs = prop.getBoolean();

Also remembers...

Make your config variable exist outside local scope.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

PmsEnabled

would be better named

togglePMs

I know but it is only the name so I don't think I should care about it too much. Can you help me with the config itself? I still don't know what to change and how to change from property to boolean

...Looks at code in earlier post...

boolean PMs = prop.getBoolean();

Also remembers...

Make your config variable exist outside local scope.

But where do I put which boolean I want it to get?

Link to comment
Share on other sites

This isn't that hard. You have the piece you want to use and you have a place you want to use it.

Stick Tab A into Slot B.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

In the class where you have your config loading.

Like that:

protected void actionPerformed(GuiButton button) throws IOException {
	if(button == GUI.GUI.button2) {
		Minecraft.getMinecraft().displayGuiScreen(new GUI2());
		Property prop = config1.get("Booleans", "PMs", false);
		boolean PMs = prop.getBoolean();
		prop.set(!PMs);;
		config1.save();
	}
}

?

Link to comment
Share on other sites

This isn't that hard. You have the piece you want to use and you have a place you want to use it.

Stick Tab A into Slot B.

Like that:

protected void actionPerformed(GuiButton button) throws IOException {
	if(button == GUI.GUI.button2) {
		Minecraft.getMinecraft().displayGuiScreen(new GUI2());
		Property prop = config1.get("Booleans", "PMs", false);
		boolean PMs = prop.getBoolean();
		prop.set(!PMs);;
		config1.save();
	}
}

?

Link to comment
Share on other sites

Uh huh.  So what's wrong?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Property#getBoolean()

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Property#getBoolean()

That is what I have:

{

	Configuration config1= new Configuration(event.getSuggestedConfigurationFile());
	config1.load();
	Property PMs = config1.get("Booleans", "PMs", false);
                config1.save();

and

public static boolean PMs;
public static boolean PMsEnabled(){
    return (PMs = !PMs);
}

. Also the boolean in the config isn't changing when I use the button

Link to comment
Share on other sites

prop.png

 

How does the value of #1 get into #2?

 

Hint:

It doesn't

 

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

This line gets the property from the config:

Property PMs = config1.get("Booleans", "PMs", false);

 

The property contains the boolean value you want. So you 'get' the boolean from the property like this:

PMs.getBoolean()

 

And assign that value to your stored field. You can do it all in one line like this:

PMs = config1.get("Booleans", "PMs", false).getBoolean();

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.

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

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.