Package codechicken.lib.util
Class ItemUtils
java.lang.Object
codechicken.lib.util.ItemUtils
Created by covers1624 on 6/30/2016.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareStacksSameType(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2) static intcompareItemStack(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2) Compares an ItemStack, Useful for comparators.static net.minecraft.world.item.ItemStackcopyStack(net.minecraft.world.item.ItemStack stack, int quantity) Copy's an ItemStack.static voiddropInventory(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 voiddropItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, Vector3 dropLocation) Drops an item with basic default random velocity.static voiddropItem(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 BlockPosstatic voiddropItem(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 BlockPosstatic voidejectItem(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 voidejectItems(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.ItemStackgetHeldStack(net.minecraft.world.entity.player.Player player) static booleanisPlayerHolding(net.minecraft.world.entity.LivingEntity entity, Predicate<net.minecraft.world.item.Item> predicate) static booleanisPlayerHoldingSomething(net.minecraft.world.entity.player.Player player)
-
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- TheItemStackbeing compared.stack2- TheItemStackto compare to.- Returns:
- whether the two items are the same in terms of damage and itemID.
-