Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for DataHolder & ItemStackSnapshot #4182

Open
wants to merge 2 commits into
base: api-12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SpongeAPI
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ default <E, V extends Value<E>> Optional<V> getValue(final Key<V> key) {
default Set<Key<?>> getKeys() {
return this.impl$delegateDataHolder().stream()
.flatMap(dh -> this.impl$getAllProviders(dh).stream()
.filter(provider -> provider.get(dh).isPresent()).map(DataProvider::key))
.map(DataProvider::key))
.filter(this::supports)
.collect(ImmutableSet.toImmutableSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public class SpongeItemStackSnapshot implements ItemStackSnapshot {
private final int damageValue;
private final ImmutableList<DataManipulator.Immutable> manipulators;
private final transient ItemStack privateStack; // only for internal use since the processors have a huge say
private final ImmutableSet<Key<?>> keys;
private final ImmutableSet<org.spongepowered.api.data.value.Value.Immutable<?>> values;
private final Set<Key<?>> keys;
private final Set<org.spongepowered.api.data.value.Value.Immutable<?>> values;
private final DataComponentPatch components;
private @Nullable UUID creatorUniqueId;

Expand All @@ -95,17 +95,13 @@ public SpongeItemStackSnapshot(final ItemStack itemStack) {
this.itemType = itemStack.type();
this.quantity = itemStack.quantity();
final ImmutableList.Builder<DataManipulator.Immutable> builder = ImmutableList.builder();
final ImmutableSet.Builder<Key<?>> keyBuilder = ImmutableSet.builder();
final ImmutableSet.Builder<org.spongepowered.api.data.value.Value.Immutable<?>> valueBuilder = ImmutableSet.builder();
final DataManipulator.Mutable customData = ((SpongeDataHolderBridge) itemStack).bridge$getManipulator();
builder.add(customData.asImmutable());
keyBuilder.addAll(customData.getKeys());
valueBuilder.addAll(customData.getValues());
this.damageValue = ItemStackUtil.toNative(itemStack).getDamageValue();
this.manipulators = builder.build();
this.privateStack = itemStack.copy();
this.keys = keyBuilder.build();
this.values = valueBuilder.build();
this.keys = itemStack.getKeys();
this.values = itemStack.getValues();
this.components = ItemStackUtil.toNative(this.privateStack).getComponentsPatch();
}

Expand Down