Interface ImmersiveRenderHelpers

All Known Implementing Classes:
ImmersiveRenderHelpersImpl

public interface ImmersiveRenderHelpers
Contains several methods to help with rendering Immersives into the world.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    getTransitionMultiplier(long ticksExisted)
    Returns a float between 0 and 1 denoting the multiplier to the size of something being rendered that ImmersiveMC uses to create the initial "growing" animation.
    float
    Gets the multiplier to apply to the size of an item to attach when the item is being hovered over.
     
    void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox)
    Render a white, solid, hitbox in the world if showing hitboxes.
    void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender)
    Render a white, solid, hitbox in the world.
    void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue)
    Render a solid hitbox in the world.
    void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue, float alpha)
    Render a hitbox in the world.
    void
    renderImage(com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.resources.ResourceLocation imageLocation, net.minecraft.world.phys.Vec3 pos, float size, int light, @Nullable net.minecraft.core.Direction facing)
    Render an image in the world.
    void
    renderItem(@Nullable net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, float size, BoundingBox hitbox, boolean renderItemCounts, int light)
    Renders an item at the specified position facing the camera.
    void
    renderItem(@Nullable net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, float size, BoundingBox hitbox, boolean renderItemCounts, int light, @Nullable Float spinDegrees, @Nullable net.minecraft.core.Direction facing, @Nullable net.minecraft.core.Direction upDown)
    Renders an item at the specified position.
    void
    renderItemGuide(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean isSelected, int light)
    Renders an item guide.
    void
    renderItemWithInfo(@Nullable net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, float size, boolean renderItemCounts, int light, ImmersiveInfo info, boolean shouldRenderItemGuide, int hitboxIndex, @Nullable Float spinDegrees, @Nullable net.minecraft.core.Direction facing, @Nullable net.minecraft.core.Direction upDown)
    Renders an item based on an ImmersiveInfo, or an item guide if applicable.
    void
    renderText(net.minecraft.network.chat.Component text, com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.world.phys.Vec3 pos, int light, float textSize)
    Render some text in the world.
  • Method Details

    • instance

      static ImmersiveRenderHelpers instance()
      Returns:
      An ImmersiveRenderHelpers instance to access API functions. All details of this object not mentioned in this file are assumed to be an implementation detail, and may change at any time.
    • renderItemWithInfo

      void renderItemWithInfo(@Nullable @Nullable net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, float size, boolean renderItemCounts, int light, ImmersiveInfo info, boolean shouldRenderItemGuide, int hitboxIndex, @Nullable @Nullable Float spinDegrees, @Nullable @Nullable net.minecraft.core.Direction facing, @Nullable @Nullable net.minecraft.core.Direction upDown)
      Renders an item based on an ImmersiveInfo, or an item guide if applicable. As of writing, items will grow when hovered-over/selected, will shrink for the start of the info's existence, and an item guide will render if there is no item and
      Parameters:
      item - The item to render.
      stack - The pose stack being rendered with.
      size - The size of the item to render before automatic changes from ImmersiveMC
      renderItemCounts - Whether to render a number representing the item count with the item.
      light - The packed sky light and block light to render with.
      info - The ImmersiveInfo that is rendering this item.
      shouldRenderItemGuide - Whether this slot should render an item guide if other conditions are met to do so.
      hitboxIndex - The index into ImmersiveInfo.getAllHitboxes() that is being rendered.
      spinDegrees - The number of degrees to spin on x/z. Ignored if null.
      facing - The direction for the item to face. If null, the item will face the camera. This value should not be UP or DOWN. Ignored if spinDegrees is at least 0.
      upDown - Direction upwards or downwards for the item to face. Can be null if not facing up or down. If this is not null, facing instead controls the direction the item is rotated towards.
    • renderItem

      void renderItem(@Nullable @Nullable net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, float size, BoundingBox hitbox, boolean renderItemCounts, int light)
      Renders an item at the specified position facing the camera.
      Parameters:
      item - The item to render.
      stack - The pose stack being rendered with.
      size - The size to render at.
      hitbox - The hitbox for interacting with this item. Used for displaying a hitbox when hitboxes are enabled.
      renderItemCounts - Whether to render a number representing the item count with the item.
      light - The packed sky light and block light to render with.
    • renderItem

      void renderItem(@Nullable @Nullable net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, float size, BoundingBox hitbox, boolean renderItemCounts, int light, @Nullable @Nullable Float spinDegrees, @Nullable @Nullable net.minecraft.core.Direction facing, @Nullable @Nullable net.minecraft.core.Direction upDown)
      Renders an item at the specified position.
      Parameters:
      item - The item to render.
      stack - The pose stack being rendered with.
      size - The size to render at.
      hitbox - The hitbox for interacting with this item. Used for displaying a hitbox when hitboxes are enabled.
      renderItemCounts - Whether to render a number representing the item count with the item.
      light - The packed sky light and block light to render with.
      spinDegrees - The number of degrees to spin on x/z. Ignored if null.
      facing - The direction for the item to face. If null, the item will face the camera. This value should not be UP or DOWN. Ignored if spinDegrees is at least 0.
      upDown - Direction upwards or downwards for the item to face. Can be null if not facing up or down. If this is not null, facing instead controls the direction the item is rotated towards.
    • renderItemGuide

      void renderItemGuide(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean isSelected, int light)
      Renders an item guide. Any place where items can be input should call this method if there isn't an item there.
      Technically, this doesn't immediately render the item guide, but renders it after all Immersives have already rendered. This way, transparency happens properly.
      Parameters:
      stack - Pose stack to render with.
      hitbox - The hitbox defining the item guide.
      isSelected - Whether the item guide is currently selected/hovered over.
      light - The packed sky light and block light to render with.
    • renderHitbox

      void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox)
      Render a white, solid, hitbox in the world if showing hitboxes.
      Parameters:
      stack - The pose stack being rendered with.
      hitbox - The hitbox to render.
    • renderHitbox

      void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender)
      Render a white, solid, hitbox in the world.
      Parameters:
      stack - The pose stack being rendered with.
      hitbox - The hitbox to render.
      alwaysRender - If true, the hitbox will always render. If false, the hitbox will only render if hitbox rendering is enabled.
    • renderHitbox

      void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue)
      Render a solid hitbox in the world.
      Parameters:
      stack - The pose stack being rendered with.
      hitbox - The hitbox to render.
      alwaysRender - If true, the hitbox will always render. If false, the hitbox will only render if hitbox rendering is enabled.
      red - The amount of red to color this hitbox with. Should be between 0 and 1 inclusive.
      green - The amount of green to color this hitbox with. Should be between 0 and 1 inclusive.
      blue - The amount of blue to color this hitbox with. Should be between 0 and 1 inclusive.
    • renderHitbox

      void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue, float alpha)
      Render a hitbox in the world.
      Parameters:
      stack - The pose stack being rendered with.
      hitbox - The hitbox to render.
      alwaysRender - If true, the hitbox will always render. If false, the hitbox will only render if hitbox rendering is enabled.
      red - The amount of red to color this hitbox with. Should be between 0 and 1 inclusive.
      green - The amount of green to color this hitbox with. Should be between 0 and 1 inclusive.
      blue - The amount of blue to color this hitbox with. Should be between 0 and 1 inclusive.
      alpha - The alpha value for the hitbox. 0 makes the hitbox lines completely invisible, and 1 makes them not transparent at all. Should be between 0 and 1 inclusive.
    • renderText

      void renderText(net.minecraft.network.chat.Component text, com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.world.phys.Vec3 pos, int light, float textSize)
      Render some text in the world.
      Parameters:
      text - The text to render in the world.
      stack - The pose stack being rendered with.
      pos - The world position to render the text at.
      light - The packed sky light and block light to render with.
      textSize - The text size to render with. ImmersiveMC uses 0.02 for this value in most cases.
    • renderImage

      void renderImage(com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.resources.ResourceLocation imageLocation, net.minecraft.world.phys.Vec3 pos, float size, int light, @Nullable @Nullable net.minecraft.core.Direction facing)
      Render an image in the world.
      Parameters:
      stack - The pose stack being rendered with.
      imageLocation - The location to the image PNG file.
      pos - The position in the world to render at.
      size - The size to render this image at.
      light - The packed sky light and block light to render with.
      facing - The direction for the item to face. If null, the item will face the camera. This value should not be UP or DOWN.
    • getTransitionMultiplier

      float getTransitionMultiplier(long ticksExisted)
      Returns a float between 0 and 1 denoting the multiplier to the size of something being rendered that ImmersiveMC uses to create the initial "growing" animation. If you want to create such an animation, or are using a function that doesn't already handle it for you, use this in case the formula ImmersiveMC uses changes later.
      Parameters:
      ticksExisted - The amount of ticks your Immersive has existed.
      Returns:
      The aforementioned float.
    • hoverScaleSizeMultiplier

      float hoverScaleSizeMultiplier()
      Gets the multiplier to apply to the size of an item to attach when the item is being hovered over. For example, if you want to render an item at some size n, you should render it as size n * getTransitionMultiplier(long) * hoverScaleSizeMultiplier() if being hovered over, (or n * getTransitionMultiplier(long) if not being hovered over).
      Returns:
      A float denoting the multiplier to use to increase the render size of an item to denote it's being hovered over (pointed at or has a VR hand placed inside).