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 ClassesModifier and TypeClassDescriptionstatic final recordA block ingredient where the block and tag are represented by their respectiveResourceLocations. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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
ConstructorsConstructorDescriptionBlockIngredient(Optional<net.minecraft.world.level.block.Block> block, Optional<net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>> tag) Creates an instance of aBlockIngredientrecord 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 TypeMethodDescriptionOptional<net.minecraft.world.level.block.Block> block()Returns the value of theblockrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Optional<net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>> tag()Returns the value of thetagrecord component.booleantest(net.minecraft.world.level.block.state.BlockState state) Match the block state to the ingredient.toBIRL()Converts the block ingredient to aBlockIngredient.BIRL("Block Ingredient from Resource Location").net.minecraft.world.item.crafting.IngredientConverts the block ingredient to an item ingredient (usingBlock.asItem())final StringtoString()Returns a string representation of this record class.
-
Field Details
-
BIRL_CODEC
-
BIRL_STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BlockIngredient.BIRL> BIRL_STREAM_CODEC -
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 aBlockIngredientrecord class.
-
-
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 (usingBlock.asItem())- Returns:
- The ingredient.
-
toBIRL
Converts the block ingredient to aBlockIngredient.BIRL("Block Ingredient from Resource Location").- Returns:
- The BIRL.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
block
Returns the value of theblockrecord component.- Returns:
- the value of the
blockrecord component
-
tag
Returns the value of thetagrecord component.- Returns:
- the value of the
tagrecord component
-