Give ItemStack context to IForgeItem.getCapabilityProvider (#10404)

This commit is contained in:
Jonathing 2025-02-05 12:15:37 -05:00 committed by GitHub
parent b25f6e3a7c
commit 02e82c672d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -18,7 +18,7 @@
this.count = p_332766_;
this.components = p_333722_;
this.getItem().verifyComponentsAfterLoad(this);
+ gatherCapabilities(() -> this.item.getCapabilityProvider());
+ gatherCapabilities(() -> this.item.getCapabilityProvider(this));
}
private ItemStack(@Nullable Void p_282703_) {

View file

@ -615,9 +615,18 @@ public interface IForgeItem {
/**
* @return The Default Capability Provider for this item, if any.
*
* @deprecated Use the itemstack-sensitive version instead: {@link #getCapabilityProvider(ItemStack)}
*/
@Nullable
@Deprecated(forRemoval = true, since = "1.21.4")
default ICapabilityProvider getCapabilityProvider() {
return null;
}
/** @return The Default Capability Provider for this item, if any, accounting for the given itemstack. */
@Nullable
default ICapabilityProvider getCapabilityProvider(ItemStack stack) {
return this.getCapabilityProvider();
}
}