-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
Abstract ItemStack & ItemStackSnapshot to ItemStackLike #2563
Abstract ItemStack & ItemStackSnapshot to ItemStackLike #2563
Conversation
I wouldn't mind keeping the "old" methods but marking them deprecated. If we keep the old methods, I'm also happy to start adding overload methods that accept |
Added old methods back as defaulted with deprecation. I'm not sure what do you mean with deprecating methods that accept About generic methods based on Also this PR seems to fail on build stage due to reasons I don't know and don't think that's because of me. |
This is a binary breaking change. When plugins are compiled they target specific method signature, which the JVM uses to distinguish different methods at runtime. By changing the method parameters you change the signature which invalidates the old signature. |
Ah, got it. Didn't know it works this way |
9bbd6dd
to
68d2ef7
Compare
Migrated whole There were some generic based methods in recipes that I changed directly:
I guess that's not breaking change since it has the same signature and is casting compatible with the old method. So, assuming changes above are fine, I think this PR is ready. |
SpongeAPI | Sponge
Completely QOL PR.
I was doing some item stuff and realized I need a lot of copy-pasted methods for
ItemStack
andItemStackSnapshot
.Then I realized they are in fact the same object with the only difference is mutability, so why not abstract it?
Also made
ItemStack#maxStackQuantity()
defaulted inItemStackLike
(this PR allowed it).Breaking changes:
ItemStack#createSnapshot()
andItemStackSnapshot#createStack()
ItemStackLike#asMutable()
,#asMutableCopy()
and#asImmutable()
These breaking changes are not vital for this PR so if they are not okay, I can revert them. But they feel natural to work with
ItemStackLike
(and imo new methods just look better).Possible usage in API (I guess this makes sense only if breaking changes are accepted):
There are a lot of places where methods accept only
ItemStack
or onlyItemStackSnapshot
while there is no real difference for dev in what to pass (becauseItemStack
s are copied anyway). So they can be easily changed to acceptItemStackLike