-
Notifications
You must be signed in to change notification settings - Fork 549
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
SlimefunItemStack reimplementation #4251
base: walshy/mc-1.21
Are you sure you want to change the base?
Conversation
Pro Tip!
If your changes do not fall into any of these categories, don't worry. You can just ignore this message in that case! 👀 |
@@ -306,13 +307,13 @@ public void lock() { | |||
} | |||
|
|||
@Override | |||
public ItemStack clone() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return ItemStack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't be good logic wise though
src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java
Outdated
Show resolved
Hide resolved
...io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java
Outdated
Show resolved
Hide resolved
Really not a fan of getDelegate tbh, not sure a great other solution tho |
/** | ||
* @return underlying ItemStack used | ||
*/ | ||
public @Nonnull ItemStack getDelegate() { | ||
return delegate; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also pretty sure we don't want to do this because then they can just modify delegate which we previously prevent, it'll probably be the case regardless of what we do but gonna point it out anyways
src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java
Outdated
Show resolved
Hide resolved
public static @Nullable SlimefunItem getByItem(@Nullable SlimefunItemStack slimefunItemStack) { | ||
if (slimefunItemStack == null) { | ||
return null; | ||
} | ||
|
||
var delegate = slimefunItemStack.getDelegate(); | ||
if (delegate.getType() == Material.AIR) { | ||
return null; | ||
} | ||
|
||
return getById(slimefunItemStack.getItemId()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the material check is here, can use isEmpty but regardless it's unnecessary, also if we add this method we should probably add the others as well, though its a lot more fluff so ehh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i am adding these methods where i can for the time being, it is not like i can refactor everything with a simple replace either so this saves from time compared to just replacing stuff normally by hand
NOTE TO FUTURE SELF: Use ForwardingObject over lombok's @DeleGate
Once this works i will try replacing it with google's ForwardingObject rather than adding a new dependency, similar to how many paper classes are implemented so to not get surprises later on (Edit) this breaks a lot of compatibility compared to using lombok as you need to first get the delegate and then run the methods on the delegate, instead lombok generates code to access said delegate methods directly |
7e5f09a
to
d12ae85
Compare
Slimefun preview buildA Slimefun preview build is available for testing! https://preview-builds.walshy.dev/download/Slimefun/4251/99d2b293
|
d12ae85
to
b646376
Compare
# Conflicts: # pom.xml # src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java # src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java # src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java # src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java # src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java # src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java # src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java
No idea why it still says Merge Conflicts when i already solved those, it looks like there are some problems, rewriting them here for consistency
|
tested this and everything seems to be working fine. no errors in console and all items working as intended. |
Description
We can't extend itemstack anymore we need to fix EVERYTHING
Proposed changes
Use a delegate instead of extending itemstack
Related Issues (if applicable)
Checklist
I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.This is the frontrow for watching all addons burn.