-
Notifications
You must be signed in to change notification settings - Fork 428
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
The Council Of Bikeshed (Transfer API v1) #1278
Changes from 1 commit
c38d075
7a1ab86
e1f0ed2
a9ba2a4
3bd4cde
85e56eb
91980b6
8b48098
77d8821
10881ca
0aa755e
fa81038
fd63147
64c61d8
58a1cb0
4f149eb
8d20007
d3b050d
ed5f626
0cd4e36
da3072b
3c3b8bb
30d45b6
5477c43
dee0ad2
cb61f6d
047fe88
eaba1d7
8f91dfb
0f76220
12d2832
cc57649
0373108
f13dd79
90c3fdf
5533049
5de61bb
e940ac9
3516324
74fc1dc
904a804
e979f75
3193cfd
4bd5c77
5ab7ccd
74a1014
44d1379
91e3be8
e08708c
6648541
6b963c0
5216ed5
1412856
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
import java.util.Objects; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import net.minecraft.item.Item; | ||
|
@@ -31,7 +32,10 @@ | |
|
||
/** | ||
* The immutable combination of an item and additional NBT data. Compare using {@link ItemKey#equals}. | ||
* | ||
* <p>Do not implement. | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface ItemKey { | ||
Technici4n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ItemKey EMPTY = ItemKeyImpl.of(Items.AIR, null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason of keeping a separate ItemKeyImpl? Imo you can just have this as a pojo in api than writing a separate impl There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd agree here with a final class pojo for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be an interface, to allow people to make copy-on-write ItemKeys and whatnot There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Item keys are supposed to be immutable and thus thread safe, what the heck are you suggesting @Devan-Kerman There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What? the ItemKey itself can be immutable, the underlying nbt tag is copied when the ItemKey is initialized, which isn't always necessary, people should be allowed to make their own ItemKey implementations, because they can optimize, like that case. Another one would be if some tool's ItemKey only cares about the durability, instead of storing a CompoundTag, it can store an int (if it doesn't have additional data of course) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@Devan-Kerman you realize this just defeats your whole point of tool not having to keep a full stack for performance purposes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Being a pojo doesn't prevent it from being cached. You will just hide the constructor to be package private and users can only call a static method to obtain instances. Also since there is mutability concern, I suggest making ItemKey a public final class to ensure safety. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I understand the value of making this a pojo? I fail to see a direct benefit, and I would very much prefer the ugly implementation details to be kept outside of public API classes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
no? copying 2 tags != copying 1 tag, and u could also short cut in some cases too.
they also made TACS, item performance can actually be a pretty big problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think Mojang's decisions are made with modded item transfer in mind... Anyway, I don't think there is a viable alternative to the |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ | |
import net.minecraft.fluid.Fluid; | ||
import net.minecraft.fluid.Fluids; | ||
|
||
/** | ||
* Preconditions for fluid transfer. | ||
*/ | ||
public class FluidPreconditions { | ||
Technici4n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static void notEmpty(Fluid fluid) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably shouldn't. |
||
if (fluid == Fluids.EMPTY) { | ||
|
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.
Note in javadocs that it differs from an item stack in that it doesn't have count? Also possibly state that it's for filtering
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.
Definitely needs more javadoc, I agree. This is both for filtering and direct storage in the item transfer api.