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.

Why does it need to be in a double and static or final when using numbers in when applying health to mob

Featured Replies

Posted

Ok, I have a mob that is divided to 7 different breeds or kinds, I want these breeds to have different healths, I cannot use static because I cannot override a subclass especially final using a switch won't work either. I found some mods that made it possible yet using json files?

54 minutes ago, TheRPGAdventurer said:

Ok, I have a mob that is divided to 7 different breeds or kinds, I want these breeds to have different healths, I cannot use static because I cannot override a subclass especially final using a switch won't work either. I found some mods that made it possible yet using json files?

Why dont you define your Maxhealth in the constructor? Please post some code to help us understand

  • Author
18 hours ago, ArmamentHaki said:

Why dont you define your Maxhealth in the constructor? Please post some code to help us understand

Sorry, I am locked with my github account, just gonna upload tommorow or next day

  • Author
Just now, diesieben07 said:

I am assuming you are talking about getBreedHealth? If so, just make it not-static and you can override it. You know what static means, right?

I tried using it without static and it gave me 1 health instead of the one I made it to

  • Author
Just now, diesieben07 said:

I am assuming you are talking about getBreedHealth? If so, just make it not-static and you can override it. You know what static means, right?

If it's not static or final, it just won't spawn or give me 1 HP

  • Author
Just now, diesieben07 said:

Where do you call this method? Where do you apply this health value?

 

Just now, diesieben07 said:

Where do you call this method? Where do you apply this health value?

I was applying it in apply entity attribute  but removed it lately, 

  • Author
Just now, diesieben07 said:

What is "it"? Assuming by "me" you mean the player? If so, you must apply something to the player health, somewhere, right? Where is that code?

me I mean the dragon. It shows me 1 HP for the dragon

  • Author
Just now, diesieben07 said:

Ok. Where is the code that spawns the dragon? Where is the health value set?

gonna update it back to where I was trying to do it, dragon is spawned via dragonegg block remember? DragonMounts? (DragonEggBlockHandler) sorry for typing too fast, my mom doesn't wanna see me something that has do with minecraft kinda personal, she's gone now tho.

  • Author
Just now, diesieben07 said:

Ok. Where is the code that spawns the dragon? Where is the health value set?

ok got it! You just need to ensure it's static or final when applying health to mobs or other attributes

    public static double getBreedHealth() {   	
    	EnumDragonBreed end = EnumDragonBreed.END;
    	EnumDragonBreed nether = EnumDragonBreed.NETHER;
    	if(end != null) {
    		return 100;
    	} else if(nether != null) {
    		return 95;
    	}
    	return 85.0D;	
    }

 

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.