Record Class StateChangingBehavior

java.lang.Object
java.lang.Record
com.simibubi.create.api.behaviour.spouting.StateChangingBehavior
Record Components:
amount - the amount of fluid consumed when filling
fluidTest - a predicate for fluids that can be used to fill the target block
canFill - a predicate that must match the target BlockState to fill it
fillFunction - a function that converts the current state into the filled one
All Implemented Interfaces:
BlockSpoutingBehaviour

public record StateChangingBehavior(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, Predicate<net.minecraft.world.level.block.state.BlockState> canFill, UnaryOperator<net.minecraft.world.level.block.state.BlockState> fillFunction) extends Record implements BlockSpoutingBehaviour
An implementation of BlockSpoutingBehaviour that allows for easily modifying a BlockState through spouting.
  • Field Summary

    Fields inherited from interface com.simibubi.create.api.behaviour.spouting.BlockSpoutingBehaviour

    BY_BLOCK, BY_BLOCK_ENTITY
  • Constructor Summary

    Constructors
    Constructor
    Description
    StateChangingBehavior(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, Predicate<net.minecraft.world.level.block.state.BlockState> canFill, UnaryOperator<net.minecraft.world.level.block.state.BlockState> fillFunction)
    Creates an instance of a StateChangingBehavior record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the amount record component.
    Predicate<net.minecraft.world.level.block.state.BlockState>
    Returns the value of the canFill record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    fillBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, SpoutBlockEntity spout, net.neoforged.neoforge.fluids.FluidStack availableFluid, boolean simulate)
    While idle, spouts will query the behavior provided by the block below it.
    UnaryOperator<net.minecraft.world.level.block.state.BlockState>
    Returns the value of the fillFunction record component.
    Predicate<net.minecraft.world.level.material.Fluid>
    Returns the value of the fluidTest record component.
    final int
    Returns a hash code value for this object.
    incrementingState(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.state.properties.IntegerProperty property)
    Create a BlockSpoutingBehaviour that will increment the given IntegerProperty until it reaches its maximum value, consuming amount each time fluid is filled.
    setTo(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.Block block)
    Shortcut for setTo(int, Predicate, BlockState) that uses the Block's default state.
    setTo(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.state.BlockState newState)
    Create a BlockSpoutingBehaviour that will simply convert the target block to the given state.
    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
  • Constructor Details

    • StateChangingBehavior

      public StateChangingBehavior(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, Predicate<net.minecraft.world.level.block.state.BlockState> canFill, UnaryOperator<net.minecraft.world.level.block.state.BlockState> fillFunction)
      Creates an instance of a StateChangingBehavior record class.
      Parameters:
      amount - the value for the amount record component
      fluidTest - the value for the fluidTest record component
      canFill - the value for the canFill record component
      fillFunction - the value for the fillFunction record component
  • Method Details

    • fillBlock

      public int fillBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, SpoutBlockEntity spout, net.neoforged.neoforge.fluids.FluidStack availableFluid, boolean simulate)
      Description copied from interface: BlockSpoutingBehaviour
      While idle, spouts will query the behavior provided by the block below it. If one is present, this method will be called every tick with simulate == true.

      When a value greater than 0 is returned, the spout will begin processing. It will call this method again with simulate == false, which is when any filling behavior should actually occur.

      This method is only called on the server side, except for in Ponder.

      Specified by:
      fillBlock in interface BlockSpoutingBehaviour
      Parameters:
      level - The current level
      pos - The position of the affected block
      spout - The spout block entity that is calling this
      availableFluid - A copy of the fluidStack that is available, modifying this will do nothing, return the amount to be subtracted instead
      simulate - Whether the spout is testing or actually performing this behaviour
      Returns:
      The amount filled into the block, 0 to idle/cancel
    • setTo

      public static BlockSpoutingBehaviour setTo(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.Block block)
      Shortcut for setTo(int, Predicate, BlockState) that uses the Block's default state.
    • setTo

      public static BlockSpoutingBehaviour setTo(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.state.BlockState newState)
      Create a BlockSpoutingBehaviour that will simply convert the target block to the given state.
      Parameters:
      newState - the state that will be set after filling
    • incrementingState

      public static BlockSpoutingBehaviour incrementingState(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.state.properties.IntegerProperty property)
      Create a BlockSpoutingBehaviour that will increment the given IntegerProperty until it reaches its maximum value, consuming amount each time fluid is filled.
      Parameters:
      property - the property that will be incremented by one on each fill
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • amount

      public int amount()
      Returns the value of the amount record component.
      Returns:
      the value of the amount record component
    • fluidTest

      public Predicate<net.minecraft.world.level.material.Fluid> fluidTest()
      Returns the value of the fluidTest record component.
      Returns:
      the value of the fluidTest record component
    • canFill

      public Predicate<net.minecraft.world.level.block.state.BlockState> canFill()
      Returns the value of the canFill record component.
      Returns:
      the value of the canFill record component
    • fillFunction

      public UnaryOperator<net.minecraft.world.level.block.state.BlockState> fillFunction()
      Returns the value of the fillFunction record component.
      Returns:
      the value of the fillFunction record component