Package commoble.exmachina.engine.api.content

# Record Class ConstantProperty

java.lang.Object
java.lang.Record
commoble.exmachina.engine.api.content.ConstantProperty

All Implemented Interfaces:
  `StaticProperty`

public record ConstantProperty(double value) extends Record implements StaticProperty
StaticProperty representing a constant value for all blockstates.

    {
            "type": "exmachina:constant",
            "value": 5.0
    }

## Nested Class Summary

## Nested classes/interfaces inherited from interface commoble.exmachina.engine.api.StaticProperty

`StaticProperty.BakedStaticProperty`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final com.mojang.serialization.Codec<ConstantProperty>`
`CODEC`
`static final net.minecraft.resources.ResourceKey<com.mojang.serialization.Codec<? extends StaticProperty>>`
`KEY`

## Constructor Summary

Constructors
Constructor
Description
`ConstantProperty(double value)`
Creates an instance of a `ConstantProperty` record class.

## Method Summary

Modifier and Type
Method
Description
`com.mojang.serialization.DataResult<StaticProperty.BakedStaticProperty>`
`bake(net.minecraft.world.level.block.Block block)`
`com.mojang.serialization.Codec<? extends StaticProperty>`
`codec()`
Returns Codec registered to `ExMachinaRegistries.STATIC_PROPERTY_TYPE`..
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`double`
`getValue(net.minecraft.world.level.block.state.BlockState state)`
`final int`
`hashCode()`
Returns a hash code value for this object.
`boolean`
`isPresent()`
Returns whether blocks with this property have this property.
`static ConstantProperty`
`of(double value)`
`final String`
`toString()`
Returns a string representation of this record class.
`double`
`value()`
Returns the value of the `value` record component.
`static ConstantProperty`
`zero()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### KEY

public static final net.minecraft.resources.ResourceKey<com.mojang.serialization.Codec<? extends StaticProperty>> KEY

### CODEC

public static final com.mojang.serialization.Codec<ConstantProperty> CODEC

## Constructor Details

### ConstantProperty

public ConstantProperty(double value)
Creates an instance of a `ConstantProperty` record class.

Parameters:
  `value` - the value for the `value` record component

## Method Details

### zero

public static ConstantProperty zero()

### of

public static ConstantProperty of(double value)

### bake

public com.mojang.serialization.DataResult<StaticProperty.BakedStaticProperty> bake(net.minecraft.world.level.block.Block block)

Specified by:
  `bake` in interface `StaticProperty`
Parameters:
  `block` - Block this StaticProperty is associated with.
Returns:
  DataResult success holding a state-to-double function if block is valid, error result otherwise

### getValue

public double getValue(net.minecraft.world.level.block.state.BlockState state)

### isPresent

public boolean isPresent()
Description copied from interface: `StaticProperty`
Returns whether blocks with this property have this property. If false, blocks with this property will be ignored when calculating the total value (saves us from having to add 100 zeros together). Consider using `zero()` instead of overriding.

Specified by:
  `isPresent` in interface `StaticProperty`
Returns:
  Whether blocks with this property can provide a value to the circuit

### codec

public com.mojang.serialization.Codec<? extends StaticProperty> codec()
Description copied from interface: `StaticProperty`
Returns Codec registered to `ExMachinaRegistries.STATIC_PROPERTY_TYPE`..

Specified by:
  `codec` in interface `StaticProperty`
Returns:
  Codec registered to `ExMachinaRegistries.STATIC_PROPERTY_TYPE`.

### 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 '=='.

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.

### value

public double value()
Returns the value of the `value` record component.

Returns:
  the value of the `value` record component