Jump to content

[1.12.2] Make entity check for configuration changes and apply those changes to itself


NovaViper

Recommended Posts

The title itself sounds a bit confusion but here's a more explained version of it. Basically, I added in code that would give the dogs in the DoggyTalents mod genders. I have all of that working however, I want to have it togglable, in case some people do not like having genders in the game, so I added a configuration to it aswell. I have the configurations and checking system working.. but when I switch off the setting, the dogs that have a gender do not "lose" their gender, they still maintain it, as well as if I go and turn the switch on, the dogs that didn't have a gender at all does not get a gender at all. So far, what I have done to get the gender randomization system going was a simple if statement that would check to see if configuration for allowing genders was set to true, then check if datatracker had any gender names in. If it was empty (it's empty when the entity first spawns in), it will randomly pick between male and female. It looks like this:

	private void randomizeGender() {
		if(Constants.DOG_GENDER == true) {
        	if (this.getGender() == "") {
        		if (rand.nextInt(2) == 0) {
        			this.setGender("male");
        		}
        		else {
        			this.setGender("female");
        		}
        	}
        }else{
        	this.setGender("");
        }
	}

 

The entirety of the class right now looks like this

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

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.