-
-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose a way to iterate internal stacks of a QIO Frequency to the API…
… to allow for slightly better performance in some use cases
- Loading branch information
1 parent
c2ea3e4
commit 25459b3
Showing
22 changed files
with
225 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package mekanism.api.inventory; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Represents an "item type" for comparing {@link ItemStack ItemStack's} without size. | ||
* | ||
* @since 10.3.6 | ||
*/ | ||
@MethodsReturnNonnullByDefault | ||
public interface IHashedItem { | ||
|
||
/** | ||
* Gets the internal {@link ItemStack} that backs this item type. It is <strong>IMPORTANT</strong> to not modify the returned value. | ||
* | ||
* @return The internal {@link ItemStack} that backs this item type. | ||
* | ||
* @apiNote Do not modify the returned value. This is only exposed for cases where the stack is needed for performance reasons and mutation is not needed. | ||
*/ | ||
ItemStack getInternalStack(); | ||
|
||
/** | ||
* Creates a mutable {@link ItemStack} of this type with the given size. | ||
* | ||
* @param size Size of the stack to create. | ||
* | ||
* @return A new {@link ItemStack} of this type. | ||
*/ | ||
ItemStack createStack(int size); | ||
|
||
/** | ||
* Helper to get the {@link Item} that this item type represents. | ||
* | ||
* @return The {@link Item} that this item type represents. | ||
*/ | ||
default Item getItem() { | ||
return getInternalStack().getItem(); | ||
} | ||
|
||
/** | ||
* Helper to get the max stack size of the {@link Item} that this item type represents. | ||
* | ||
* @return Max stack size of the {@link Item} that this item type represents. | ||
*/ | ||
default int getMaxStackSize() { | ||
return getInternalStack().getMaxStackSize(); | ||
} | ||
|
||
/** | ||
* Helper to get the tag of the internal {@link ItemStack} that backs this item type. It is <strong>IMPORTANT</strong> to not modify the returned tag. | ||
* | ||
* @return Tag of the internal {@link ItemStack} that backs this item type. | ||
* | ||
* @apiNote Do not modify the returned tag. | ||
*/ | ||
@Nullable | ||
default CompoundTag getInternalTag() { | ||
return getInternalStack().getTag(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.