Interface InputType<T>

All Known Implementing Classes:
BooleanInputType, DataProviderInputType, ExpandableListInputType, ItemStackInputType, NumberInputType, RegistryInputType, TextInputType

public interface InputType<T>
Represents data that can be inputted by the user
Note: This class is required on the client and the server
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<InputType<?>>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    bool(boolean currentValue, net.minecraft.network.chat.Component label)
    Creates a new boolean input type with the given value
    com.mojang.serialization.Codec<? extends InputType<?>>
    The codec used for encoding and decoding the data when transferring between the client and server
    default net.minecraft.resources.ResourceLocation
    Gets the registry key for this input type
    List<net.minecraft.client.gui.layouts.Layout>
    getWidget(Runnable init, Runnable rearrangeTabs)
     
    static InputType<net.minecraft.world.item.ItemStack>
    itemStack(net.minecraft.world.item.ItemStack currentValue, net.minecraft.network.chat.Component label)
    Creates a new ItemStack input type with the given value
    number(Number currentValue, net.minecraft.network.chat.Component label)
    Creates a new number input type with the given value
    static InputType<net.minecraft.resources.ResourceLocation>
    registry(net.minecraft.resources.ResourceLocation currentValue, net.minecraft.resources.ResourceLocation registry, net.minecraft.network.chat.Component label)
    Creates a new registry input type with the given value
    static InputType<net.minecraft.resources.ResourceLocation>
    registry(net.minecraft.resources.ResourceLocation currentValue, net.minecraftforge.registries.IForgeRegistry<?> registry, net.minecraft.network.chat.Component label)
    Creates a new registry input type with the given value
    void
    setValue(T value)
    Sets the value of the input
    text(String currentValue, net.minecraft.network.chat.Component label)
    Creates a new text input type with the given value
    The current value of the input
  • Field Details

    • CODEC

      static final com.mojang.serialization.Codec<InputType<?>> CODEC
  • Method Details

    • codec

      com.mojang.serialization.Codec<? extends InputType<?>> codec()
      The codec used for encoding and decoding the data when transferring between the client and server
      Returns:
      The codec
    • getKey

      default net.minecraft.resources.ResourceLocation getKey()
      Gets the registry key for this input type
      Returns:
      The registry key
    • value

      T value()
      The current value of the input
      Returns:
      The current value
    • setValue

      void setValue(T value)
      Sets the value of the input
      Parameters:
      value - The new value
    • getWidget

      List<net.minecraft.client.gui.layouts.Layout> getWidget(Runnable init, Runnable rearrangeTabs)
      Parameters:
      init -
      rearrangeTabs -
      Returns:
    • text

      static InputType<String> text(String currentValue, net.minecraft.network.chat.Component label)
      Creates a new text input type with the given value
      Parameters:
      currentValue - The current value
      Returns:
      The new text input type
    • number

      static InputType<Number> number(Number currentValue, net.minecraft.network.chat.Component label)
      Creates a new number input type with the given value
      Parameters:
      currentValue - The current value
      Returns:
      The new text input type
    • bool

      static InputType<Boolean> bool(boolean currentValue, net.minecraft.network.chat.Component label)
      Creates a new boolean input type with the given value
      Parameters:
      currentValue - The current value
      Returns:
      The new text input type
    • itemStack

      static InputType<net.minecraft.world.item.ItemStack> itemStack(net.minecraft.world.item.ItemStack currentValue, net.minecraft.network.chat.Component label)
      Creates a new ItemStack input type with the given value
      Parameters:
      currentValue - The current value
      Returns:
      The new text input type
    • registry

      static InputType<net.minecraft.resources.ResourceLocation> registry(net.minecraft.resources.ResourceLocation currentValue, net.minecraftforge.registries.IForgeRegistry<?> registry, net.minecraft.network.chat.Component label)
      Creates a new registry input type with the given value
      Parameters:
      currentValue - The current value
      registry - The registry to use
      label - The label to display
      Returns:
      The new text input type
    • registry

      static InputType<net.minecraft.resources.ResourceLocation> registry(net.minecraft.resources.ResourceLocation currentValue, net.minecraft.resources.ResourceLocation registry, net.minecraft.network.chat.Component label)
      Creates a new registry input type with the given value
      Parameters:
      currentValue - The current value
      registry - The registry to use
      label - The label to display
      Returns:
      The new text input type