Record Class BlockSpec
java.lang.Object
java.lang.Record
nl.pim16aap2.lightkeeper.framework.BlockSpec
- Record Components:
materialKey- Canonical namespaced material key, e.g.minecraft:lever.properties- The state properties this spec names, in insertion order.
A block specification: a material plus the state properties a test cares about.
Specs are partial by design: only the named properties participate in matching (see
BlockStateSnapshot.matches(BlockSpec)), so a lever test can assert powered=true without
enumerating face and facing defaults.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()Renders this spec in block-data string form.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thematerialKeyrecord component.static BlockSpecCreates a spec for a material key with no state properties.static BlockSpecof(org.bukkit.Material material) Creates a spec for a material with no state properties.static BlockSpecParses a block-data style string into a spec.Returns the value of thepropertiesrecord component.final StringtoString()Returns a string representation of this record class.Returns a copy of this spec with one property set.
-
Constructor Details
-
BlockSpec
Validates and normalizes the fields.
-
-
Method Details
-
of
Creates a spec for a material with no state properties.- Parameters:
material- The material.- Returns:
- The spec.
-
of
Creates a spec for a material key with no state properties.- Parameters:
materialKey- Material key, e.g.STONEorminecraft:stone.- Returns:
- The spec.
-
parse
Parses a block-data style string into a spec.- Parameters:
blockData- A string likeminecraft:lever[powered=true,facing=north]; the bracket section is optional.- Returns:
- The parsed spec.
- Throws:
IllegalArgumentException- If the string is malformed.
-
with
Returns a copy of this spec with one property set.- Parameters:
property- The property name.value- The property value.- Returns:
- A new spec with the property applied.
-
asString
Renders this spec in block-data string form.- Returns:
- E.g.
minecraft:lever[powered=true]; just the material key when no properties are named.
-
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). -
materialKey
Returns the value of thematerialKeyrecord component.- Returns:
- the value of the
materialKeyrecord component
-
properties
Returns the value of thepropertiesrecord component.- Returns:
- the value of the
propertiesrecord component
-