Class ItemStackHelpers

java.lang.Object
org.cyclops.cyclopscore.helper.ItemStackHelpers

public final class ItemStackHelpers extends Object
Contains helper methods for various itemstack specific things.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    getItemStackHashCode(net.minecraft.world.item.ItemStack stack)
    Get a hash code would satisfy the requirements of Object.hashCode() if ItemStack.isSameItem(ItemStack, ItemStack) stood in for Object.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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 world
      pos - The position
      itemStack - 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 world
      x - X
      y - Y
      z - Z
      itemStack - 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 world
      pos - The position to spawn an
      stack - The stack to spawn
      player - 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

      public static net.minecraft.world.item.ItemStack parseItemStack(String itemStackString)
      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 of Object.hashCode() if ItemStack.isSameItem(ItemStack, ItemStack) stood in for Object.equals(java.lang.Object).
      Parameters:
      stack - The itemstack.
      Returns:
      The hash code.