Skip to content

feat(attribute): add attribute api#331

Closed
killcerr wants to merge 11 commits into
EndstoneMC:developfrom
killcerr:main
Closed

feat(attribute): add attribute api#331
killcerr wants to merge 11 commits into
EndstoneMC:developfrom
killcerr:main

Conversation

@killcerr

@killcerr killcerr commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

fix #293

@killcerr killcerr marked this pull request as ready for review February 14, 2026 02:53
wu-vincent added a commit that referenced this pull request Jun 2, 2026
Builds on the rebased #331 to complete and correct the attribute API:

- Move hasAttribute/getAttribute/getAttributes from Actor to Mob, matching
  Bukkit's Attributable (LivingEntity); non-living actors have no attribute map.
- Reconstruct the bedrock AttributeInstance modifier math faithfully from BDS
  (addModifier/removeModifier/getModifiers, _calculateValue, _sanitizeValue)
  instead of the previous hand-rolled approximation.
- AttributeModifier: keep it Bukkit-shaped (name/uuid/amount/operation); add the
  Bedrock-only `Cap` operation; drop the engine-internal operand (always CURRENT).
- AttributeInstance: add getMinValue/getMaxValue, getModifier(uuid),
  removeModifier(uuid), and addTransientModifier() (Bukkit's transient-vs-persistent
  split, instead of a serializable flag on the modifier); drop getDefaultValue
  (no distinct default on Bedrock).
- Wire Python bindings, stubs and tests to the above.
@wu-vincent wu-vincent closed this Jun 2, 2026
wu-vincent added a commit that referenced this pull request Jun 2, 2026
Builds on the rebased #331 to complete and correct the attribute API:

- Move hasAttribute/getAttribute/getAttributes from Actor to Mob, matching
  Bukkit's Attributable (LivingEntity); non-living actors have no attribute map.
- Reconstruct the bedrock AttributeInstance modifier math faithfully from BDS
  (addModifier/removeModifier/getModifiers, _calculateValue, _sanitizeValue)
  instead of the previous hand-rolled approximation.
- AttributeModifier: keep it Bukkit-shaped (name/uuid/amount/operation); add the
  Bedrock-only `Cap` operation; drop the engine-internal operand (always CURRENT).
- AttributeInstance: add getMinValue/getMaxValue, getModifier(uuid),
  removeModifier(uuid), and addTransientModifier() (Bukkit's transient-vs-persistent
  split, instead of a serializable flag on the modifier); drop getDefaultValue
  (no distinct default on Bedrock).
- Wire Python bindings, stubs and tests to the above.
wu-vincent added a commit that referenced this pull request Jun 2, 2026
Builds on the rebased #331 to complete and correct the attribute API:

- Move hasAttribute/getAttribute/getAttributes from Actor to Mob, matching
  Bukkit's Attributable (LivingEntity); non-living actors have no attribute map.
- Reconstruct the bedrock AttributeInstance modifier math faithfully from BDS
  (addModifier/removeModifier/getModifiers, _calculateValue, _sanitizeValue)
  instead of the previous hand-rolled approximation.
- AttributeModifier: identify modifiers by AttributeModifierId (a namespaced
  Identifier, the Endstone counterpart of Bukkit's NamespacedKey) rather than a
  UUID; the bedrock UUID is derived deterministically from the id. Add the
  Bedrock-only Cap operation; drop the engine-internal operand (always CURRENT).
- AttributeInstance: add getMinValue/getMaxValue, getModifier(id),
  removeModifier(id), and addTransientModifier() (Bukkit's transient-vs-persistent
  split); drop getDefaultValue (no distinct default on Bedrock).
- Wire Python bindings, stubs and tests to the above.
wu-vincent added a commit that referenced this pull request Jun 2, 2026
Builds on the rebased #331 to complete and correct the attribute API:

- Move hasAttribute/getAttribute/getAttributes from Actor to Mob, matching
  Bukkit's Attributable (LivingEntity); non-living actors have no attribute map.
- Reconstruct the bedrock AttributeInstance modifier math faithfully from BDS
  (addModifier/removeModifier/getModifiers, _calculateValue, _sanitizeValue)
  instead of the previous hand-rolled approximation.
- AttributeModifier: identify modifiers by AttributeModifierId (a namespaced
  Identifier, the Endstone counterpart of Bukkit's NamespacedKey) rather than a
  UUID; the bedrock UUID is derived deterministically from the id. Add the
  Bedrock-only Cap operation; drop the engine-internal operand (always CURRENT).
- AttributeInstance: add getMinValue/getMaxValue, getModifier(id),
  removeModifier(id), and addTransientModifier() (Bukkit's transient-vs-persistent
  split); drop getDefaultValue (no distinct default on Bedrock).
- Wire Python bindings, stubs and tests to the above.
@wu-vincent

Copy link
Copy Markdown
Member

Superseded by #411, which rebases this onto develop and finishes the attribute API. Your commits are squash-rebased into #411's first commit and you're credited as co-author — thank you for the original work! Closing in favor of #411.

wu-vincent added a commit that referenced this pull request Jun 2, 2026
* feat(attribute): add attribute API (rebased #331)

Squashed rebase of #331 by killcerr onto develop, with conflicts
resolved against develop's current API (as<T>() casting, ActorType
getType(), Identifier-based ids). This is a work-in-progress base for
finishing the attribute API; the design is reworked in follow-up commits.

Co-authored-by: killcerr <kill_cerr@outlook.com>

* feat(attribute): finish the attribute API

Builds on the rebased #331 to complete and correct the attribute API:

- Move hasAttribute/getAttribute/getAttributes from Actor to Mob, matching
  Bukkit's Attributable (LivingEntity); non-living actors have no attribute map.
- Reconstruct the bedrock AttributeInstance modifier math faithfully from BDS
  (addModifier/removeModifier/getModifiers, _calculateValue, _sanitizeValue)
  instead of the previous hand-rolled approximation.
- AttributeModifier: identify modifiers by AttributeModifierId (a namespaced
  Identifier, the Endstone counterpart of Bukkit's NamespacedKey) rather than a
  UUID; the bedrock UUID is derived deterministically from the id. Add the
  Bedrock-only Cap operation; drop the engine-internal operand (always CURRENT).
- AttributeInstance: add getMinValue/getMaxValue, getModifier(id),
  removeModifier(id), and addTransientModifier() (Bukkit's transient-vs-persistent
  split); drop getDefaultValue (no distinct default on Bedrock).
- Wire Python bindings, stubs and tests to the above.

* feat(attribute): allow setting an attribute's min and max value

Add setMinValue/setMaxValue to AttributeInstance (Bedrock-specific, no Bukkit
equivalent), so plugins can raise an attribute's cap - e.g. the maximum of
minecraft:player.hunger or minecraft:health. Mirrors the existing getMinValue/
getMaxValue getters and the bedrock setMinValue/setMaxValue already used by
Mob.setMaxHealth.

---------

Co-authored-by: killcerr <kill_cerr@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Attribute API

2 participants