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

Currently everything I have is handled by PlayerExtended which is wrapped EntityPlayer and contains player stats, levelHistory, quests, everything.

Most is synced by packets on-request (e.g if you want to see stats you send request to server when opening GUI, but in combat, client itself never have values like dodge %, it's all on server). Only stuff send onTick are basic values (used by ClientGuis, like mana).

Now I've been thinking - why not adding health value to this (like mana) and just intercept HURT event like:

PSEUDO
LivingHurtEvent event; if (player)
PlayerExtended.wrap(player).hurtPlayer(event.amount, event.source)

And rest of it handle on my own (ofc. when CustomHealth <= 0 player.setDead)

 

Question is: How un-/safe is this? Is there ANY way that player can get damage without calling this event? What about knockback?

 

What would be a better way - I guess SharedMonsterAttributes, but I have no idea how they are synced, how saved and how to edit/add them?

 

 

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Let's just put it this way: How the hell can I set players max HP based on my "I want", but in a way that it won't be a const value. (MaxHP = Str*5 + premiumHP + something + whatever)

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Aww... it's probably me being stupid, sry.

 

So normally player HP is defined by:

public final float getMaxHealth()
    {
        return (float)this.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue();
    }

 

And from what I know "maxHealth" is a const.

 

I don't want it to be const. I want maxHP to be value dependent on my player stats. And "I want" means "I want it to be x on this tick, but on next tick it will be y"

 

So since I alredy have huge player handler I though why not making customHealth just some next value like mana, but just track hurt event to instead hurt normal HP, make it hurt customHP and if it's == 0 set player dead.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I'll just end my overthinking and ask:

 

How they are synced, how saved and how to edit them? Also same question for custom-made IAttributes. (Till now i didn't think they are entity-specified, but SHARED)

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Okay so I gotten around with that system and it all would be nice and tidy, but still (also thanks for your help so far):

 

My EntityPlayer's maxHP is influenced by:

Level (50 levels), PlayerStats (2 stats), Inventory (12 items), Generics (1-3 extra values, something like race/class), EffectsMap (effects that are currently on player).

 

Now from what I see - I could leave base health to be 20 and do rest by adding Modifiers, but that would leave me with UP TO DOZEN of those (counting situations like all my 12 items give some health buff and player has few health buffs on him).

1. Is having so many Modifiers good? (note: All of them would be marked isSaved = false, because everything from Level to EffectsMap is alredy saved and only loaded on startup)

 

2. So Attributes are static (not synced) on both client and server, how about Modifiers? Does client know about Modifiers or it just receives final value?

1.7.10 is no longer supported by forge, you are on your own.

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.