Interface IClientItemExtensions


public interface IClientItemExtensions
Client-only extensions to Item.
See Also:
  • Field Details

  • Method Details

    • of

      static IClientItemExtensions of(ItemStack stack)
    • of

      static IClientItemExtensions of(Item item)
    • getFont

      @Nullable default @Nullable Font getFont(ItemStack stack, IClientItemExtensions.FontContext context)
      Returns the font used to render data related to this item as specified in the context. Return null to use the default font.
      Parameters:
      stack - The item stack
      context - The context in which the font will be used
      Returns:
      A Font or null to use the default
    • getArmPose

      @Nullable default HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack itemStack)
      This method returns an ArmPose that can be defined using the
      invalid reference
      net.minecraft.client.model.HumanoidModel.ArmPose#create(String, boolean, IArmPoseTransformer)
      method. This allows for creating custom item use animations.
      Parameters:
      entityLiving - The entity holding the item
      hand - The hand the ArmPose will be applied to
      itemStack - The stack being held
      Returns:
      A custom ArmPose that can be used to define movement of the arm
    • applyForgeHandTransform

      default boolean applyForgeHandTransform(PoseStack poseStack, LocalPlayer player, HumanoidArm arm, ItemStack itemInHand, float partialTick, float equipProcess, float swingProcess)
      Called right before when client applies transformations to item in hand and render it.
      Parameters:
      poseStack - The pose stack
      player - The player holding the item, it's always main client player
      arm - The arm holding the item
      itemInHand - The held item
      partialTick - Partial tick time, useful for interpolation
      equipProcess - Equip process time, Ranging from 0.0 to 1.0. 0.0 when it's done equipping
      swingProcess - Swing process time, Ranging from 0.0 to 1.0. 0.0 when it's done swinging
      Returns:
      true if it should skip applying other transforms and go straight to rendering
    • getHumanoidArmorModel

      default HumanoidModel<?> getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> original)
      Queries the humanoid armor model for this item when it's equipped.
      Parameters:
      livingEntity - The entity wearing the armor
      itemStack - The item stack
      equipmentSlot - The slot the item is in
      original - The original armor model. Will have attributes set.
      Returns:
      A HumanoidModel to be rendered. Relevant properties are to be copied over by the caller.
      See Also:
    • getGenericArmorModel

      default Model getGenericArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> original)
      Queries the armor model for this item when it's equipped. Useful in place of getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel) for wrapping the original model or returning anything non-standard.

      If you override this method you are responsible for copying any properties you care about from the original model.

      Parameters:
      livingEntity - The entity wearing the armor
      itemStack - The item stack
      equipmentSlot - The slot the item is in
      original - The original armor model. Will have attributes set.
      Returns:
      A Model to be rendered. Relevant properties must be copied over manually.
      See Also:
    • setupModelAnimations

      default void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, Model model, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch)
      Called when an armor piece is about to be rendered, allowing parts of the model to be animated or changed.
      Parameters:
      livingEntity - The entity wearing the armor
      itemStack - The item stack being worn
      equipmentSlot - The slot the armor stack is being worn in
      model - The armor model being rendered
      limbSwing - The swing position of the entity's walk animation
      limbSwingAmount - The swing speed of the entity's walk animation
      partialTick - The partial tick time
      ageInTicks - The total age of the entity, with partialTick already applied
      netHeadYaw - The yaw (Y rotation) of the entity's head
      headPitch - The pitch (X rotation) of the entity's head
    • renderHelmetOverlay

      @Deprecated(forRemoval=true) default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTick)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • renderHelmetOverlay

      default void renderHelmetOverlay(ItemStack stack, Player player, GuiGraphics guiGraphics, DeltaTracker deltaTracker)
      Called when the client starts rendering the HUD, and is wearing this item in the helmet slot.

      This is where pumpkins would render their overlay.

      Parameters:
      stack - The item stack
      player - The player entity
      guiGraphics - The gui graphics
      deltaTracker - The delta tracker
    • getCustomRenderer

      default BlockEntityWithoutLevelRenderer getCustomRenderer()
      Queries this item's renderer.

      Only used if BakedModel.isCustomRenderer() returns true or BlockBehaviour.BlockStateBase.getRenderShape() returns RenderShape.ENTITYBLOCK_ANIMATED.

      By default, returns vanilla's block entity renderer.

    • shouldBobAsEntity

      default boolean shouldBobAsEntity(ItemStack stack)
      Returns Whether the item should bob when rendered in the world as an entity.
      Parameters:
      stack - The stack being rendered
      Returns:
      Whether the item should bob when rendered in the world as an entity
    • shouldSpreadAsEntity

      default boolean shouldSpreadAsEntity(ItemStack stack)
      Returns Whether the item should be spread out when rendered in the world as an entity.
      Parameters:
      stack - The stack being rendered
      Returns:
      Whether the item should be spread out when rendered in the world as an entity
    • getArmorLayerTintColor

      default int getArmorLayerTintColor(ItemStack stack, LivingEntity entity, ArmorMaterial.Layer layer, int layerIdx, int fallbackColor)
      Called when armor layers are rendered by HumanoidArmorLayer.

      Allows custom dye colors to be specified per-layer; default vanilla behavior allows for only a single dye color (specified by the DataComponents.DYED_COLOR data component) for all layers.

      Returning 0 here will cause rendering of this layer to be skipped entirely; this is recommended if the layer doesn't need to be rendered for a particular armor slot.

      Parameters:
      stack - the armor item stack being rendered
      entity - the entity wearing the armor
      layer - the armor layer being rendered
      layerIdx - an index into the list of layers for the ArmorMaterial used by this item
      fallbackColor - the return value of getDefaultDyeColor(ItemStack), passed as a parameter for performance
      Returns:
      a custom color for the layer, in ARGB format, or 0 to skip rendering
    • getDefaultDyeColor

      default int getDefaultDyeColor(ItemStack stack)
      Called once per render pass of equipped armor items, regardless of the number of layers; the return value of this method is passed to getArmorLayerTintColor(ItemStack, LivingEntity, ArmorMaterial.Layer, int, int) as the fallbackColor parameter.

      You can override this method for your custom armor item to provide an alternative default color for the item when no explicit color is specified.

      Parameters:
      stack - the armor item stack
      Returns:
      a default color for the layer, in ARGB format