Skip to content

Commit 5f2e9d5

Browse files
committed
Migrate EMPTY methods to factories.
Signed-off-by: Chris Sanders <[email protected]>
1 parent 03e62d3 commit 5f2e9d5

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/main/java/org/spongepowered/api/block/BlockSnapshot.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,15 @@
4040

4141
import java.util.Optional;
4242
import java.util.UUID;
43-
import java.util.function.Supplier;
4443

4544
/**
4645
* An immutable representation of a {@link BlockState} and any extra data that
4746
* may be associated with it, including {@link BlockEntity} related data.
4847
*/
4948
public interface BlockSnapshot extends LocatableSnapshot<BlockSnapshot> {
5049

51-
/**
52-
* Represents a {@link BlockSnapshot} with the default state of
53-
* {@link BlockTypes#AIR} and a {@link ServerLocation} that cannot be determined.
54-
*/
55-
Supplier<BlockSnapshot> NONE = BlockSnapshot::empty;
56-
5750
static BlockSnapshot empty() {
58-
return Sponge.game().builderProvider().provide(Builder.class).empty();
51+
return Sponge.game().factoryProvider().provide(Factory.class).empty();
5952
}
6053

6154
/**
@@ -205,6 +198,9 @@ interface Builder extends SerializableDataHolderBuilder.Immutable<BlockSnapshot,
205198
* @return This builder, for chaining
206199
*/
207200
Builder notifier(UUID uuid);
201+
}
202+
203+
interface Factory {
208204

209205
BlockSnapshot empty();
210206
}

src/main/java/org/spongepowered/api/item/inventory/ItemStack.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.spongepowered.api.entity.attribute.AttributeModifier;
3838
import org.spongepowered.api.entity.attribute.type.AttributeType;
3939
import org.spongepowered.api.item.ItemType;
40-
import org.spongepowered.api.item.ItemTypes;
4140
import org.spongepowered.api.item.inventory.equipment.EquipmentType;
4241
import org.spongepowered.api.registry.DefaultedRegistryReference;
4342

@@ -59,6 +58,15 @@
5958
*/
6059
public interface ItemStack extends SerializableDataHolder.Mutable {
6160

61+
/**
62+
* Returns an empty {@link ItemStack}.
63+
*
64+
* @return The empty ItemStack
65+
*/
66+
static ItemStack empty() {
67+
return Sponge.game().factoryProvider().provide(Factory.class).empty();
68+
}
69+
6270
/**
6371
* Creates a new {@link Builder} to build an {@link ItemStack}.
6472
*
@@ -112,15 +120,6 @@ static ItemStack of(ItemType itemType) {
112120
return ItemStack.of(itemType, 1);
113121
}
114122

115-
/**
116-
* Returns an empty {@link ItemStack}.
117-
*
118-
* @return The empty ItemStack
119-
*/
120-
static ItemStack empty() {
121-
return ItemStack.builder().itemType(ItemTypes.AIR).build();
122-
}
123-
124123
/**
125124
* Gets the {@link ItemType} of this {@link ItemStack}.
126125
*
@@ -413,4 +412,9 @@ default Builder apply(Predicate<Builder> predicate, Consumer<Builder> consumer)
413412
@Override
414413
ItemStack build() throws IllegalStateException;
415414
}
415+
416+
interface Factory {
417+
418+
ItemStack empty();
419+
}
416420
}

0 commit comments

Comments
 (0)