Class CitizenItemUtils

java.lang.Object
com.minecolonies.core.util.citizenutils.CitizenItemUtils

public class CitizenItemUtils extends Object
Handles the citizens interaction with an item with the world.
  • Constructor Details

    • CitizenItemUtils

      public CitizenItemUtils()
  • Method Details

    • tryPickupItemEntity

      public static void tryPickupItemEntity(@NotNull @NotNull AbstractEntityCitizen citizen, @NotNull @NotNull net.minecraft.world.entity.item.ItemEntity itemEntity)
      Citizen will try to pick up a certain item.
      Parameters:
      itemEntity - the item he wants to pickup.
    • removeHeldItem

      public static void removeHeldItem(AbstractEntityCitizen citizen)
      Removes the currently held item.
    • setHeldItem

      public static void setHeldItem(@NotNull @NotNull AbstractEntityCitizen citizen, net.minecraft.world.InteractionHand hand, int slot)
      Sets the currently held item.
      Parameters:
      hand - what hand we're setting
      slot - from the inventory slot.
    • setMainHeldItem

      public static void setMainHeldItem(@NotNull @NotNull AbstractEntityCitizen citizen, int slot)
      Sets the currently held for mainHand item.
      Parameters:
      slot - from the inventory slot.
    • hitBlockWithToolInHand

      public static void hitBlockWithToolInHand(@NotNull @NotNull AbstractEntityCitizen citizen, @Nullable @Nullable net.minecraft.core.BlockPos blockPos)
      Swing entity arm, create sound and particle effects.

      Will not break the block.

      Parameters:
      blockPos - Block position.
    • hitBlockWithToolInHand

      public static void hitBlockWithToolInHand(@NotNull @NotNull AbstractEntityCitizen citizen, @Nullable @Nullable net.minecraft.core.BlockPos blockPos, boolean breakBlock)
      Swing entity arm, create sound and particle effects.

      If breakBlock is true then it will break the block (different sound and particles), and damage the tool in the citizens hand.

      Parameters:
      blockPos - Block position.
      breakBlock - if we want to break this block.
    • damageItemInHand

      public static void damageItemInHand(@NotNull @NotNull AbstractEntityCitizen citizen, net.minecraft.world.InteractionHand hand, int damage)
      Damage the current held item.
      Parameters:
      damage - amount of damage.
    • pickupItems

      public static void pickupItems(AbstractEntityCitizen citizen)
      Pick up all items in a range around the citizen.
    • breakBlockWithToolInHand

      public static void breakBlockWithToolInHand(@NotNull @NotNull AbstractEntityCitizen citizen, @Nullable @Nullable net.minecraft.core.BlockPos blockPos)
      Swing entity arm, create sound and particle effects.

      This will break the block (different sound and particles), and damage the tool in the citizens hand.

      Parameters:
      blockPos - Block position.
    • entityDropItem

      public static net.minecraft.world.entity.item.ItemEntity entityDropItem(@NotNull @NotNull AbstractEntityCitizen citizen, @NotNull @NotNull net.minecraft.world.item.ItemStack itemstack)
      Handles the dropping of items from the entity.
      Parameters:
      itemstack - to drop.
      Returns:
      the dropped item.
    • updateArmorDamage

      public static void updateArmorDamage(@NotNull @NotNull AbstractEntityCitizen citizen, double damage)
      Updates the armour damage after being hit.
      Parameters:
      damage - damage dealt.
    • applyMending

      public static double applyMending(@NotNull @NotNull AbstractEntityCitizen citizen, double xp)