Skip to content

Commit f61b932

Browse files
committed
chore: update from api-13
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
2 parents 4220ac0 + c0f65a1 commit f61b932

File tree

6 files changed

+122
-3
lines changed

6 files changed

+122
-3
lines changed

src/main/java/org/spongepowered/api/block/transaction/NotificationTicket.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,60 @@
2828
import org.spongepowered.api.world.LocatableBlock;
2929
import org.spongepowered.math.vector.Vector3i;
3030

31+
/**
32+
* Represents a notification that is being proposed to the engine.
33+
*/
3134
public interface NotificationTicket {
3235

36+
/**
37+
* Gets the notifier block that scheduled this notification.
38+
*
39+
* @return The notifier block
40+
*/
3341
LocatableBlock notifier();
3442

43+
/**
44+
* Gets the notifier position that scheduled this notification.
45+
*
46+
* @return The notifier position
47+
*/
3548
default Vector3i notifierPosition() {
3649
return this.notifier().blockPosition();
3750
}
3851

52+
/**
53+
* Gets the target block of this notification.
54+
*
55+
* @return The target block
56+
*/
3957
BlockSnapshot target();
4058

59+
/**
60+
* Gets the target position of this notification.
61+
*
62+
* @return The target position
63+
*/
4164
default Vector3i targetPosition() {
4265
return this.target().position();
4366
}
4467

68+
/**
69+
* Gets whether this ticket is marked as valid.
70+
*
71+
* @return The valid state of this ticket
72+
*/
4573
boolean valid();
4674

75+
/**
76+
* Sets whether this ticket is valid or not.
77+
*
78+
* @param valid The valid state of this ticket
79+
*/
4780
void setValid(boolean valid);
4881

82+
/**
83+
* Invalidates this ticket.
84+
*/
4985
default void invalidate() {
5086
this.setValid(false);
5187
}

src/main/java/org/spongepowered/api/data/Keys.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@
289289
import org.spongepowered.api.world.weather.Weather;
290290
import org.spongepowered.api.world.weather.WeatherType;
291291
import org.spongepowered.api.world.weather.WeatherTypes;
292+
import org.spongepowered.math.matrix.Matrix4d;
292293
import org.spongepowered.math.vector.Vector2i;
293294
import org.spongepowered.math.vector.Vector3d;
294295
import org.spongepowered.math.vector.Vector3i;
@@ -576,6 +577,24 @@ public final class Keys {
576577
*/
577578
public static final Key<Value<BossBar>> BOSS_BAR = Keys.key(ResourceKey.sponge("boss_bar"), BossBar.class);
578579

580+
/**
581+
* The width of the interactable form of an {@link Entity}.
582+
*
583+
* <p>Together with {@link #BOUNDING_BOX_HEIGHT} this defines
584+
* the size of the {@link Entity}'s bounding box.</p>
585+
* Readonly(Entity.class) expect Interaction
586+
*/
587+
public static final Key<Value<Double>> BOUNDING_BOX_BASE_SIZE = Keys.key(ResourceKey.sponge("bounding_box_base_size"), Double.class);
588+
589+
/**
590+
* The height of the interactable form of an {@link Entity}.
591+
*
592+
* <p>Together with {@link #BOUNDING_BOX_BASE_SIZE} this defines
593+
* the size of the {@link Entity}'s bounding box.</p>
594+
* Readonly(Entity.class) expect Interaction
595+
*/
596+
public static final Key<Value<Double>> BOUNDING_BOX_HEIGHT = Keys.key(ResourceKey.sponge("bounding_box_height"), Double.class);
597+
579598
/**
580599
* The {@link BlockType}s able to be broken by an {@link ItemStack}.
581600
*/
@@ -2323,6 +2342,11 @@ public final class Keys {
23232342
*/
23242343
public static final Key<Value<ResourceKey>> MAP_WORLD = Keys.key(ResourceKey.sponge("map_world"), ResourceKey.class);
23252344

2345+
/**
2346+
* The {@link Matrix4d} of a {@link DisplayEntity}
2347+
*/
2348+
public static final Key<Value<Matrix4d>> MATRIX = Keys.key(ResourceKey.sponge("matrix"), Matrix4d.class);
2349+
23262350
/**
23272351
* The matter state of a {@link BlockState}
23282352
* Readonly

src/main/java/org/spongepowered/api/entity/Entity.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,4 +659,22 @@ default Optional<Value.Mutable<Double>> swiftness() {
659659

660660
@Override
661661
HoverEvent<HoverEvent.ShowEntity> asHoverEvent(final UnaryOperator<HoverEvent.ShowEntity> op);
662+
663+
/**
664+
* {@link Keys#BOUNDING_BOX_BASE_SIZE}
665+
*
666+
* @return The bounding box base size of the entity
667+
*/
668+
default Value.Mutable<Double> boundingBoxBaseSize() {
669+
return this.requireValue(Keys.BOUNDING_BOX_BASE_SIZE).asMutable();
670+
}
671+
672+
/**
673+
* {@link Keys#BOUNDING_BOX_HEIGHT}
674+
*
675+
* @return The bounding box height of the entity
676+
*/
677+
default Value.Mutable<Double> boundingBoxHeight() {
678+
return this.requireValue(Keys.BOUNDING_BOX_HEIGHT).asMutable();
679+
}
662680
}

src/main/java/org/spongepowered/api/entity/display/DisplayEntity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.spongepowered.api.entity.Entity;
2929
import org.spongepowered.api.util.Ticks;
3030
import org.spongepowered.api.util.Transform;
31+
import org.spongepowered.math.matrix.Matrix4d;
3132

3233
import java.util.Optional;
3334

@@ -125,6 +126,15 @@ default Double viewRange() {
125126
return this.require(Keys.VIEW_RANGE);
126127
}
127128

129+
/**
130+
* Returns the matrix.
131+
*
132+
* @return the matrix.
133+
*/
134+
default Matrix4d matrix() {
135+
return this.require(Keys.MATRIX);
136+
}
137+
128138
// TODO bounding box (maybe BASE_SIZE if this is not smth. else in the entity)
129139
// TODO glow_color_override -1 = use team color
130140

src/main/java/org/spongepowered/api/event/EventManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ public interface EventManager {
5151
* @param plugin The plugin container
5252
* @param obj The object
5353
* @return This manager, for fluency
54+
* @deprecated In order to be compatible with the JPMS, it is highly
55+
* recommended that plugins instead use the
56+
* {@link #registerListeners(PluginContainer, Object, MethodHandles.Lookup)} overload.
5457
*/
58+
@Deprecated(since = "13")
5559
EventManager registerListeners(PluginContainer plugin, Object obj);
5660

5761
/**

src/main/java/org/spongepowered/api/event/block/NotifyNeighborBlockEvent.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,50 @@
3333
import java.util.function.Predicate;
3434

3535
/**
36-
*
36+
* Fired when a neighbour notification is being proposed to the engine.
3737
*/
3838
public interface NotifyNeighborBlockEvent extends Event, Cancellable {
3939

40+
/**
41+
* Gets a list of the {@link NotificationTicket}s for this event.
42+
* If a ticket is requested to be marked as "invalid",
43+
* {@link NotificationTicket#setValid(boolean)} can be used.
44+
*
45+
* @return The unmodifiable list of tickets
46+
*/
4047
List<NotificationTicket> tickets();
4148

49+
/**
50+
* Applies the provided {@link Predicate} to the {@link List} of
51+
* {@link NotificationTicket}s from {@link #tickets()} such that
52+
* any time that {@link Predicate#test(Object)} returns {@code false}
53+
* on the location of the {@link NotificationTicket}, the
54+
* {@link NotificationTicket} is marked as "invalid".
55+
*
56+
* <p>{@link NotificationTicket#targetPosition()} is used to get the {@link Vector3i}</p>
57+
*
58+
* @param predicate The predicate to use for filtering
59+
*/
4260
default void filterTargetPositions(final Predicate<Vector3i> predicate) {
4361
this.tickets().forEach(ticket -> {
44-
if (predicate.test(ticket.targetPosition())) {
62+
if (!predicate.test(ticket.targetPosition())) {
4563
ticket.setValid(false);
4664
}
4765
});
4866
}
4967

68+
/**
69+
* Applies the provided {@link Predicate} to the {@link List} of
70+
* {@link NotificationTicket}s from {@link #tickets()} such that
71+
* any time that {@link Predicate#test(Object)} returns {@code false}
72+
* on the location of the {@link NotificationTicket}, the
73+
* {@link NotificationTicket} is marked as "invalid".
74+
*
75+
* @param predicate The predicate to use for filtering
76+
*/
5077
default void filterTickets(final Predicate<NotificationTicket> predicate) {
5178
this.tickets().forEach(ticket -> {
52-
if (predicate.test(ticket)) {
79+
if (!predicate.test(ticket)) {
5380
ticket.setValid(false);
5481
}
5582
});

0 commit comments

Comments
 (0)