java.lang.Object
net.neoforged.neoforge.client.model.generators.template.ElementBuilder

public final class ElementBuilder extends Object
  • Field Details

    • from

      private org.joml.Vector3f from
    • to

      private org.joml.Vector3f to
    • faces

      private final Map<net.minecraft.core.Direction,FaceBuilder> faces
    • rotation

      @Nullable private @Nullable RotationBuilder rotation
    • shade

      private boolean shade
    • lightEmission

      private int lightEmission
    • color

      private int color
    • blockLight

      private int blockLight
    • skyLight

      private int skyLight
    • hasAmbientOcclusion

      private boolean hasAmbientOcclusion
  • Constructor Details

    • ElementBuilder

      public ElementBuilder()
  • Method Details

    • from

      public ElementBuilder from(float x, float y, float z)
      Set the "from" position for this element.
      Parameters:
      x - x-position for this vector
      y - y-position for this vector
      z - z-position for this vector
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the vector is out of bounds (any coordinate not between -16 and 32, inclusive)
    • to

      public ElementBuilder to(float x, float y, float z)
      Set the "to" position for this element.
      Parameters:
      x - x-position for this vector
      y - y-position for this vector
      z - z-position for this vector
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the vector is out of bounds (any coordinate not between -16 and 32, inclusive)
    • face

      public ElementBuilder face(net.minecraft.core.Direction dir, Consumer<FaceBuilder> action)
      Return or create the face builder for the given direction.
      Parameters:
      dir - the direction
      Returns:
      the face builder for the given direction
      Throws:
      NullPointerException - if dir is null
    • rotation

      public ElementBuilder rotation(Consumer<RotationBuilder> action)
      Allows modifying the rotation for this element.
    • shade

      public ElementBuilder shade(boolean shade)
      Sets whether or not this element should be shaded.
    • allFaces

      public ElementBuilder allFaces(BiConsumer<net.minecraft.core.Direction,FaceBuilder> action)
      Modify all possible faces dynamically using a function, creating new faces as necessary.
      Parameters:
      action - the function to apply to each direction
      Returns:
      this builder
      Throws:
      NullPointerException - if action is null
    • allFacesExcept

      public ElementBuilder allFacesExcept(BiConsumer<net.minecraft.core.Direction,FaceBuilder> action, Set<net.minecraft.core.Direction> exc)
      Creates possible faces for the model as needed, excluding those specified in the second argument, and then applies a function to modify added faces.
      Parameters:
      action - the function to apply to each direction
      exc - directions which will be excluded from adding to model file
      Returns:
      this builder
      Throws:
      NullPointerException - if action is null
    • faces

      public ElementBuilder faces(BiConsumer<net.minecraft.core.Direction,FaceBuilder> action)
      Modify all existing faces dynamically using a function.
      Parameters:
      action - the function to apply to each direction
      Returns:
      this builder
      Throws:
      NullPointerException - if action is null
    • textureAll

      public ElementBuilder textureAll(net.minecraft.client.data.models.model.TextureSlot texture)
      Texture all possible faces in the current element with the given texture, creating new faces where necessary.
      Parameters:
      texture - the texture
      Returns:
      this builder
      Throws:
      NullPointerException - if texture is null
    • texture

      public ElementBuilder texture(net.minecraft.client.data.models.model.TextureSlot texture)
      Texture all existing faces in the current element with the given texture.
      Parameters:
      texture - the texture
      Returns:
      this builder
      Throws:
      NullPointerException - if texture is null
    • cube

      public ElementBuilder cube(net.minecraft.client.data.models.model.TextureSlot texture)
      Create a typical cube element, creating new faces as needed, applying the given texture, and setting the cullface.
      Parameters:
      texture - the texture
      Returns:
      this builder
      Throws:
      NullPointerException - if texture is null
    • emissivity

      public ElementBuilder emissivity(int blockLight, int skyLight)
      Set the block and sky light of the element (0-15). Traditional "emissivity" values were set both of these to the same value.
      Parameters:
      blockLight - the block light
      skyLight - the sky light
      Returns:
      this builder
    • lightEmission

      public ElementBuilder lightEmission(int lightEmission)
      Set the light emission of the element (0-15)

      If block and sky light values should be different, use emissivity(int, int) instead

      Parameters:
      lightEmission - the light value
      Returns:
      this builder
    • color

      public ElementBuilder color(int color)
      Sets the color of the element.
      Parameters:
      color - the color in ARGB format.
      Returns:
      this builder
    • ambientOcclusion

      public ElementBuilder ambientOcclusion(boolean ambientOcclusion)
      Set the ambient occlusion of the element.
      Parameters:
      ambientOcclusion - the ambient occlusion
      Returns:
      this builder
    • addTexture

      private static BiConsumer<net.minecraft.core.Direction,FaceBuilder> addTexture(net.minecraft.client.data.models.model.TextureSlot texture)
    • validateCoordinate

      private static void validateCoordinate(float coord, char name)
    • validatePosition

      private static void validatePosition(org.joml.Vector3f pos)
    • build

      net.minecraft.client.renderer.block.model.BlockElement build()
    • copy