Record Class BlockIngredient

java.lang.Object
java.lang.Record
top.girlkisser.lazuli.api.crafting.BlockIngredient
Record Components:
block - The ingredient block, if any.
tag - The ingredient tag, if any.

public record BlockIngredient(Optional<net.minecraft.world.level.block.Block> block, Optional<net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>> tag) extends Record
An ingredient record for blocks or block tags.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A block ingredient where the block and tag are represented by their respective ResourceLocations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<BlockIngredient.BIRL>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BlockIngredient.BIRL>
     
    static final com.mojang.serialization.Codec<BlockIngredient>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BlockIngredient>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockIngredient(Optional<net.minecraft.world.level.block.Block> block, Optional<net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>> tag)
    Creates an instance of a BlockIngredient record class.
    BlockIngredient(net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> blockTag)
    An ingredient record for blocks or block tags.
    BlockIngredient(net.minecraft.world.level.block.Block block)
    An ingredient record for blocks or block tags.
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<net.minecraft.world.level.block.Block>
    Returns the value of the block record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Optional<net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>>
    tag()
    Returns the value of the tag record component.
    boolean
    test(net.minecraft.world.level.block.state.BlockState state)
    Match the block state to the ingredient.
    Converts the block ingredient to a BlockIngredient.BIRL ("Block Ingredient from Resource Location").
    net.minecraft.world.item.crafting.Ingredient
    Converts the block ingredient to an item ingredient (using Block.asItem())
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • BIRL_CODEC

      public static final com.mojang.serialization.Codec<BlockIngredient.BIRL> BIRL_CODEC
    • BIRL_STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BlockIngredient.BIRL> BIRL_STREAM_CODEC
    • CODEC

      public static final com.mojang.serialization.Codec<BlockIngredient> CODEC
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BlockIngredient> STREAM_CODEC
  • Constructor Details

    • BlockIngredient

      public BlockIngredient(net.minecraft.world.level.block.Block block)
      An ingredient record for blocks or block tags.
      Parameters:
      block - The ingredient block.
    • BlockIngredient

      public BlockIngredient(net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> blockTag)
      An ingredient record for blocks or block tags.
      Parameters:
      blockTag - The ingredient block tag.
    • BlockIngredient

      public BlockIngredient(Optional<net.minecraft.world.level.block.Block> block, Optional<net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>> tag)
      Creates an instance of a BlockIngredient record class.
      Parameters:
      block - the value for the block record component
      tag - the value for the tag record component
  • Method Details

    • test

      public boolean test(net.minecraft.world.level.block.state.BlockState state)
      Match the block state to the ingredient.
      Parameters:
      state - The block state to test.
      Returns:
      Whether the block state matches the ingredient.
    • toItemIngredient

      public net.minecraft.world.item.crafting.Ingredient toItemIngredient()
      Converts the block ingredient to an item ingredient (using Block.asItem())
      Returns:
      The ingredient.
    • toBIRL

      public BlockIngredient.BIRL toBIRL()
      Converts the block ingredient to a BlockIngredient.BIRL ("Block Ingredient from Resource Location").
      Returns:
      The BIRL.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • block

      public Optional<net.minecraft.world.level.block.Block> block()
      Returns the value of the block record component.
      Returns:
      the value of the block record component
    • tag

      public Optional<net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>> tag()
      Returns the value of the tag record component.
      Returns:
      the value of the tag record component