Package codechicken.microblock.item
Record Class SawComponent
java.lang.Object
java.lang.Record
codechicken.microblock.item.SawComponent
Component to be added to saw items that can cut microblocks. Provides the logic that
determines which blocks can be cut by the saw item this is attached to.
For standard Tier-based saws, use forTier(Tier)
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<SawComponent> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, SawComponent> -
Constructor Summary
ConstructorsConstructorDescriptionSawComponent(List<SawComponent.Rule> rules, boolean defaultAllowCut) Creates an instance of aSawComponentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCut(net.minecraft.world.level.block.state.BlockState state) booleanReturns the value of thedefaultAllowCutrecord component.final booleanIndicates whether some other object is "equal to" this one.static SawComponentforTier(net.minecraft.world.item.Tier tier) Creates a SawComponent that cuts any block at the given tier or lower.static @Nullable SawComponentgetComponent(net.minecraft.world.item.ItemStack stack) final inthashCode()Returns a hash code value for this object.rules()Returns the value of therulesrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,SawComponent> STREAM_CODEC
-
-
Constructor Details
-
SawComponent
Creates an instance of aSawComponentrecord class.- Parameters:
rules- the value for therulesrecord componentdefaultAllowCut- the value for thedefaultAllowCutrecord component
-
-
Method Details
-
canCut
public boolean canCut(net.minecraft.world.level.block.state.BlockState state) -
forTier
Creates a SawComponent that cuts any block at the given tier or lower. If a tool of the given tier can harvest a block, then the saw can cut it.- Parameters:
tier- The tier of the saw.- Returns:
- The saw component.
-
getComponent
@Nullable public static @Nullable SawComponent getComponent(net.minecraft.world.item.ItemStack stack) -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
rules
Returns the value of therulesrecord component.- Returns:
- the value of the
rulesrecord component
-
defaultAllowCut
public boolean defaultAllowCut()Returns the value of thedefaultAllowCutrecord component.- Returns:
- the value of the
defaultAllowCutrecord component
-