Package org.cyclops.cyclopscore.helper
Class ItemStackHelpers
java.lang.Object
org.cyclops.cyclopscore.helper.ItemStackHelpers
Contains helper methods for various itemstack specific things.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getItemStackHashCode
(net.minecraft.world.item.ItemStack stack) Get a hash code would satisfy the requirements ofObject.hashCode()
ifItemStack.isSameItem(ItemStack, ItemStack)
stood in forObject.equals(java.lang.Object)
.static boolean
hasPlayerItem
(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item) Check if the given player has at least one of the given item.static net.minecraft.world.item.ItemStack
parseItemStack
(String itemStackString) Parse a string to an itemstack.static void
spawnItemStack
(net.minecraft.world.level.Level world, double x, double y, double z, net.minecraft.world.item.ItemStack itemStack) Spawn an itemstack into the world.static void
spawnItemStack
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack itemStack) Spawn an itemstack into the world.static void
spawnItemStackToPlayer
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player) Spawn an entity in the direction of a player without setting a pickup delay.
-
Constructor Details
-
ItemStackHelpers
public ItemStackHelpers()
-
-
Method Details
-
spawnItemStack
public static void spawnItemStack(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack itemStack) Spawn an itemstack into the world.- Parameters:
world
- The worldpos
- The positionitemStack
- the item stack
-
spawnItemStack
public static void spawnItemStack(net.minecraft.world.level.Level world, double x, double y, double z, net.minecraft.world.item.ItemStack itemStack) Spawn an itemstack into the world.- Parameters:
world
- The worldx
- Xy
- Yz
- ZitemStack
- the item stack
-
spawnItemStackToPlayer
public static void spawnItemStackToPlayer(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player) Spawn an entity in the direction of a player without setting a pickup delay.- Parameters:
world
- The worldpos
- The position to spawn anstack
- The stack to spawnplayer
- The player to direct the motion to
-
hasPlayerItem
public static boolean hasPlayerItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item) Check if the given player has at least one of the given item.- Parameters:
player
- The player.item
- The item to search in the inventory.- Returns:
- If the player has the item.
-
parseItemStack
Parse a string to an itemstack. Expects the format "domain:itemname:amount" The domain and itemname are mandatory, the rest is optional.- Parameters:
itemStackString
- The string to parse.- Returns:
- The itemstack.
- Throws:
IllegalArgumentException
- If the string was incorrectly formatted.
-
getItemStackHashCode
public static int getItemStackHashCode(net.minecraft.world.item.ItemStack stack) Get a hash code would satisfy the requirements ofObject.hashCode()
ifItemStack.isSameItem(ItemStack, ItemStack)
stood in forObject.equals(java.lang.Object)
.- Parameters:
stack
- The itemstack.- Returns:
- The hash code.
-