Class ItemUtils

java.lang.Object
codechicken.lib.util.ItemUtils

public class ItemUtils extends Object
Created by covers1624 on 6/30/2016.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areStacksSameType(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2)
     
    static int
    compareItemStack(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2)
    Compares an ItemStack, Useful for comparators.
    static net.minecraft.world.item.ItemStack
    copyStack(net.minecraft.world.item.ItemStack stack, int quantity)
    Copy's an ItemStack.
    static void
    dropInventory(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.Container inventory)
    Drops all the items in an IInventory on the ground.
    static void
    dropItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, Vector3 dropLocation)
    Drops an item with basic default random velocity.
    static void
    dropItem(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack)
    Drops an item in the world at the given BlockPos
    static void
    dropItem(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack, double velocity)
    Drops an item in the world at the given BlockPos
    static void
    ejectItem(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction dir)
    Ejects an item with .3 velocity in the given direction.
    static void
    ejectItems(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> stacks, net.minecraft.core.Direction dir)
    Ejects an list of items with .3 velocity in the given direction.
    static net.minecraft.world.item.ItemStack
    getHeldStack(net.minecraft.world.entity.player.Player player)
     
    static boolean
    isPlayerHolding(net.minecraft.world.entity.LivingEntity entity, Predicate<net.minecraft.world.item.Item> predicate)
     
    static boolean
    isPlayerHoldingSomething(net.minecraft.world.entity.player.Player player)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ItemUtils

      public ItemUtils()
  • Method Details

    • isPlayerHolding

      public static boolean isPlayerHolding(net.minecraft.world.entity.LivingEntity entity, Predicate<net.minecraft.world.item.Item> predicate)
    • isPlayerHoldingSomething

      public static boolean isPlayerHoldingSomething(net.minecraft.world.entity.player.Player player)
    • getHeldStack

      @Nonnull public static net.minecraft.world.item.ItemStack getHeldStack(net.minecraft.world.entity.player.Player player)
    • dropItem

      public static void dropItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, Vector3 dropLocation)
      Drops an item with basic default random velocity.
    • dropItem

      public static void dropItem(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, @Nonnull net.minecraft.world.item.ItemStack stack, double velocity)
      Drops an item in the world at the given BlockPos
      Parameters:
      world - World to drop the item.
      pos - Location to drop item.
      stack - ItemStack to drop.
      velocity - The velocity to add.
    • dropItem

      public static void dropItem(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, @Nonnull net.minecraft.world.item.ItemStack stack)
      Drops an item in the world at the given BlockPos
      Parameters:
      world - World to drop the item.
      pos - Location to drop item.
      stack - ItemStack to drop.
    • dropInventory

      public static void dropInventory(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.Container inventory)
      Drops all the items in an IInventory on the ground.
      Parameters:
      world - World to drop the item.
      pos - Position to drop item.
      inventory - IInventory to drop.
    • copyStack

      public static net.minecraft.world.item.ItemStack copyStack(@Nonnull net.minecraft.world.item.ItemStack stack, int quantity)
      Copy's an ItemStack.
      Parameters:
      stack - Stack to copy.
      quantity - Size of the new stack.
      Returns:
      The new stack.
    • ejectItem

      public static void ejectItem(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, @Nonnull net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction dir)
      Ejects an item with .3 velocity in the given direction.
      Parameters:
      world - World to spawn the item.
      pos - Location for item to spawn.
      stack - Stack to spawn.
      dir - Direction to shoot.
    • ejectItems

      public static void ejectItems(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> stacks, net.minecraft.core.Direction dir)
      Ejects an list of items with .3 velocity in the given direction.
      Parameters:
      world - World to spawn the item.
      pos - Location for item to spawn.
      stacks - Stack to spawn.
      dir - Direction to shoot.
    • compareItemStack

      public static int compareItemStack(@Nonnull net.minecraft.world.item.ItemStack stack1, @Nonnull net.minecraft.world.item.ItemStack stack2)
      Compares an ItemStack, Useful for comparators.
      Parameters:
      stack1 - First Stack.
      stack2 - Second Stack.
      Returns:
      Returns the difference.
    • areStacksSameType

      public static boolean areStacksSameType(@Nonnull net.minecraft.world.item.ItemStack stack1, @Nonnull net.minecraft.world.item.ItemStack stack2)
      Parameters:
      stack1 - The ItemStack being compared.
      stack2 - The ItemStack to compare to.
      Returns:
      whether the two items are the same in terms of damage and itemID.