Skip to content

Commit

Permalink
Add Keys.BOUNDING_BOX_BASE_SIZE and Keys.BOUNDING_BOX_HEIGHT
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Nov 24, 2024
1 parent 529eaa9 commit f695db1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/org/spongepowered/api/data/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,24 @@ public final class Keys {
*/
public static final Key<Value<BossBar>> BOSS_BAR = Keys.key(ResourceKey.sponge("boss_bar"), BossBar.class);

/**
* The width of the interactable form of an {@link Entity}.
*
* <p>Together with {@link #BOUNDING_BOX_HEIGHT} this defines
* the size of the {@link Entity}'s bounding box.</p>
* Readonly(Entity.class) expect Interaction
*/
public static final Key<Value<Double>> BOUNDING_BOX_BASE_SIZE = Keys.key(ResourceKey.sponge("bounding_box_base_size"), Double.class);

This comment has been minimized.

Copy link
@Yeregorix

Yeregorix Nov 25, 2024

Member

Why not BOUNDING_BOX_WIDTH? I think this would be a better fit.
As stated in the javadoc, size is the combination of width and height.

This comment has been minimized.

Copy link
@aromaa

aromaa Nov 25, 2024

Author Member

We already have BASE_SIZE so just following the convention.

This comment has been minimized.

Copy link
@Yeregorix

Yeregorix Nov 25, 2024

Member

Oh, I didn't know. Indeed, that makes sense then.


/**
* The height of the interactable form of an {@link Entity}.
*
* <p>Together with {@link #BOUNDING_BOX_BASE_SIZE} this defines
* the size of the {@link Entity}'s bounding box.</p>
* Readonly(Entity.class) expect Interaction
*/
public static final Key<Value<Double>> BOUNDING_BOX_HEIGHT = Keys.key(ResourceKey.sponge("bounding_box_height"), Double.class);

/**
* The {@link BlockType}s able to be broken by an {@link ItemStack}.
*/
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/spongepowered/api/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,22 @@ default Optional<Value.Mutable<Double>> swiftness() {

@Override
HoverEvent<HoverEvent.ShowEntity> asHoverEvent(final UnaryOperator<HoverEvent.ShowEntity> op);

/**
* {@link Keys#BOUNDING_BOX_BASE_SIZE}
*
* @return The bounding box base size of the entity
*/
default Value.Mutable<Double> boundingBoxBaseSize() {
return this.requireValue(Keys.BOUNDING_BOX_BASE_SIZE).asMutable();
}

/**
* {@link Keys#BOUNDING_BOX_HEIGHT}
*
* @return The bounding box height of the entity
*/
default Value.Mutable<Double> boundingBoxHeight() {
return this.requireValue(Keys.BOUNDING_BOX_HEIGHT).asMutable();
}
}

0 comments on commit f695db1

Please sign in to comment.