Skip to content

Commit c3d36c2

Browse files
committed
chore: merge api-14 for updates
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
2 parents 7394a7b + cb15506 commit c3d36c2

File tree

6 files changed

+101
-13
lines changed

6 files changed

+101
-13
lines changed

src/main/java/org/spongepowered/api/command/registrar/tree/CommandTreeNodeTypes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* The known {@link CommandTreeNodeType types} available on the vanilla client.
3838
*/
3939
@SuppressWarnings("unused")
40-
@RegistryScopes(scopes = RegistryScope.GAME)
40+
@RegistryScopes(scopes = RegistryScope.ENGINE)
4141
public final class CommandTreeNodeTypes {
4242

4343
// @formatter:off
@@ -134,10 +134,10 @@ private CommandTreeNodeTypes() {
134134
}
135135

136136
public static Registry<CommandTreeNodeType<?>> registry() {
137-
return Sponge.game().registry(RegistryTypes.COMMAND_TREE_NODE_TYPE);
137+
return Sponge.server().registry(RegistryTypes.COMMAND_TREE_NODE_TYPE);
138138
}
139139

140140
private static <T extends CommandTreeNode<T>> DefaultedRegistryReference<CommandTreeNodeType<T>> key(final ResourceKey location) {
141-
return RegistryKey.of(RegistryTypes.COMMAND_TREE_NODE_TYPE, location).asDefaultedReference(Sponge::game);
141+
return RegistryKey.of(RegistryTypes.COMMAND_TREE_NODE_TYPE, location).asDefaultedReference(Sponge::server);
142142
}
143143
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public final class Keys {
558558
public static final Key<Value<Integer>> BLOCK_LIGHT = Keys.key(ResourceKey.sponge("block_light"), Integer.class);
559559

560560
/**
561-
* The {@link BlockState} of a {@link BlockOccupiedMinecart} or {@link FallingBlock}.
561+
* The {@link BlockState} of a {@link BlockOccupiedMinecart}, {@link FallingBlock} or {@link Piston moving Piston}.
562562
*/
563563
public static final Key<Value<BlockState>> BLOCK_STATE = Keys.key(ResourceKey.sponge("block_state"), BlockState.class);
564564

@@ -1770,8 +1770,8 @@ public final class Keys {
17701770
public static final Key<Value<Boolean>> IS_ELYTRA_FLYING = Keys.key(ResourceKey.sponge("is_elytra_flying"), Boolean.class);
17711771

17721772
/**
1773-
* Whether a piston {@link BlockState} is currently extended.
1774-
* TODO {@link Piston}?
1773+
* Whether a piston {@link BlockState} is currently extended or
1774+
* {@link Piston moving Piston} is extending.
17751775
*/
17761776
public static final Key<Value<Boolean>> IS_EXTENDED = Keys.key(ResourceKey.sponge("is_extended"), Boolean.class);
17771777

src/main/java/org/spongepowered/api/event/item/inventory/container/InteractContainerEvent.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,27 @@ public interface InteractContainerEvent extends Event, Cancellable {
5656
interface Open extends InteractContainerEvent {}
5757

5858
/**
59-
* The target container was closed.
59+
* Base event when a {@link Container} is closed.
6060
*/
61-
interface Close extends ChangeInventoryEvent, InteractContainerEvent {}
61+
interface Close extends InteractContainerEvent {
62+
63+
/**
64+
* Fired before the {@link Container} is closed.
65+
*
66+
* <p>Cancelling this event will prevent the {@link Container}
67+
* from being closed.</p>
68+
*/
69+
interface Pre extends Close {
70+
}
71+
72+
/**
73+
* Fired after the {@link Container} was closed.
74+
*
75+
* <p>Cancelling this event will rollback the content
76+
* of the {@link Container} that was mutated during
77+
* the close.</p>
78+
*/
79+
interface Post extends Close, ChangeInventoryEvent {
80+
}
81+
}
6282
}

src/main/java/org/spongepowered/api/registry/RegistryTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public final class RegistryTypes {
208208

209209
// @formatter:off
210210

211-
public static final DefaultedRegistryType<Advancement> ADVANCEMENT = RegistryTypes.spongeKeyInGame("advancement");
211+
public static final DefaultedRegistryType<Advancement> ADVANCEMENT = RegistryTypes.spongeKeyInServer("advancement");
212212

213213
public static final DefaultedRegistryType<ArtType> ART_TYPE = RegistryTypes.minecraftKeyInServer("painting_variant");
214214

@@ -487,7 +487,7 @@ public final class RegistryTypes {
487487

488488
public static final DefaultedRegistryType<RailDirection> RAIL_DIRECTION = RegistryTypes.spongeKeyInGame("rail_direction");
489489

490-
public static final DefaultedRegistryType<Recipe<?>> RECIPE = RegistryTypes.spongeKeyInGame("recipe");
490+
public static final DefaultedRegistryType<Recipe<?>> RECIPE = RegistryTypes.spongeKeyInServer("recipe");
491491

492492
public static final DefaultedRegistryType<ValueParameter<?>> REGISTRY_KEYED_VALUE_PARAMETER = RegistryTypes.spongeKeyInGame("value_parameter");
493493

src/main/java/org/spongepowered/api/world/generation/config/flat/FlatGeneratorConfigs.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* <!-- This file is automatically generated. Any manual changes will be overwritten. -->
3838
*/
3939
@SuppressWarnings("unused")
40-
@RegistryScopes(scopes = RegistryScope.GAME)
40+
@RegistryScopes(scopes = RegistryScope.ENGINE)
4141
public final class FlatGeneratorConfigs {
4242

4343
public static final DefaultedRegistryReference<FlatGeneratorConfig> BOTTOMLESS_PIT = FlatGeneratorConfigs.key(ResourceKey.minecraft("bottomless_pit"));
@@ -62,10 +62,10 @@ private FlatGeneratorConfigs() {
6262
}
6363

6464
public static Registry<FlatGeneratorConfig> registry() {
65-
return Sponge.game().registry(RegistryTypes.FLAT_GENERATOR_CONFIG);
65+
return Sponge.server().registry(RegistryTypes.FLAT_GENERATOR_CONFIG);
6666
}
6767

6868
private static DefaultedRegistryReference<FlatGeneratorConfig> key(final ResourceKey location) {
69-
return RegistryKey.of(RegistryTypes.FLAT_GENERATOR_CONFIG, location).asDefaultedReference(Sponge::game);
69+
return RegistryKey.of(RegistryTypes.FLAT_GENERATOR_CONFIG, location).asDefaultedReference(Sponge::server);
7070
}
7171
}

src/main/java/org/spongepowered/api/world/volume/entity/EntityVolume.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,74 @@ default <E extends Entity> E createEntityNaturally(Supplier<EntityType<E>> type,
397397
*/
398398
Collection<Entity> spawnEntities(Iterable<? extends Entity> entities);
399399

400+
/**
401+
* Applies the provided {@link Predicate} to the
402+
* {@link Entity entities} such that any time that
403+
* {@link Predicate#test(Object)} returns {@code false} on the
404+
* {@link Entity}, the storage performs implementation dependant
405+
* removal of it.
406+
*
407+
* @param predicate The predicate to use for filtering
408+
*/
409+
default void filterEntities(Predicate<? super Entity> predicate) {
410+
this.entities().forEach(e -> {
411+
if (!predicate.test(e)) {
412+
e.remove();
413+
}
414+
});
415+
}
416+
417+
/**
418+
* Performs implementation dependant removal of all
419+
* the {@link Entity entities} that intersect the
420+
* bounding box.
421+
*
422+
* @param box The intersection box
423+
*/
424+
default void filterEntities(AABB box) {
425+
this.filterEntities(box, e -> false);
426+
}
427+
428+
/**
429+
* Applies the provided {@link Predicate} to the {@link Entity entities}
430+
* that intersect the bounding box such that any time that
431+
* {@link Predicate#test(Object)} returns {@code false} on the
432+
* {@link Entity}, the storage performs implementation dependant
433+
* removal of it.
434+
*
435+
* @param box The intersection box
436+
* @param predicate The predicate to use for filtering
437+
*/
438+
default void filterEntities(AABB box, Predicate<? super Entity> predicate) {
439+
this.entities(box, predicate.negate()).forEach(Entity::remove);
440+
}
441+
442+
/**
443+
* Performs implementation dependant removal of all
444+
* the {@link Entity entities} that match the given type
445+
* and intersect the bounding box.
446+
*
447+
* @param entityClass The entity type
448+
* @param box The intersection box
449+
*/
450+
default <T extends Entity> void filterEntities(Class<? extends T> entityClass, AABB box) {
451+
this.filterEntities(entityClass, box, null);
452+
}
453+
454+
/**
455+
* Applies the provided {@link Predicate} to the {@link Entity entities}
456+
* that match the given type and intersect the bounding box such that
457+
* any time that {@link Predicate#test(Object)} returns {@code false}
458+
* on the {@link Entity}, the storage performs implementation dependant
459+
* removal of it.
460+
*
461+
* @param entityClass The entity type
462+
* @param box The intersection box
463+
* @param predicate The predicate to use for filtering
464+
*/
465+
default <T extends Entity> void filterEntities(Class<? extends T> entityClass, AABB box, @Nullable Predicate<? super T> predicate) {
466+
this.entities(entityClass, box, predicate != null ? predicate.negate() : null).forEach(Entity::remove);
467+
}
400468
}
401469

402470
interface Mutable extends Modifiable<Mutable> {

0 commit comments

Comments
 (0)