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

This cord set max health to 40.0f as I expected, but setHealth don't work.

Logger always says "Change to: 40.0 / 40.0" only in Server Thread.

I think setHealth calls only in Server Thread.

How do I fix?

@SubscribeEvent
  public static void respawnPlayer(PlayerEvent.PlayerRespawnEvent event) {
    player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).removeModifier(TestMaxHealthUUID);
    player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier(TestMaxHealthUUID, "TestMaxHealth", 2.0f - 1.0f, AttributeModifier.Operation.MULTIPLY_TOTAL));
    player.setHealth(40.0f);
    LOGGER.debug("change to: " + player.getHealth() + " / " + player.getMaxHealth());
  }

Edited by kyazuki

  • Author

I want to set max health to 40.0f as default value.

So I don't use effects of potions and equipments.

 

The game renders 20 hearts.

So the client knows my modified max health, didn't it?

Edited by kyazuki

  • Author

applyModifier works, but setHealth didn't works.

 

My mod gradually reduces the max health from 40.0 to 10.0.

Then, the player whose max health is 10.0 is killed.

I want to reset the player's max health to 40.0.

So, I calls my method when the player dies.

The method reset their max healths as I expected.

However, setHealth doesn't work in the client.

Health is same value before they die(ex. 10.0 / 40.0), but LOGGER says 40.0 / 40.0 in Server Thread.

Client's health isn't synced to Server's health.

Edited by kyazuki

  • Author

Sorry, I said 20 hearts as max health(include gray hearts)...

Edited by kyazuki

  • Author

I checked by debugger.

setHealth method works in Server Thread.

Should I check methods in Render Thread?

I don't know the method which health synced to the server.

  • Author

Hmm...

I can't find the method to sync.

Can you tell me methods which I should check using the debugger?

Edited by kyazuki

  • Author

I was mistaken about isRemote method.

I reduced their max health in Render Thread( if(isRemote()) ).

Thank you very much!

 

Could you answer to this topic?

Edited by kyazuki

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.