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 fillingfluidTest- a predicate for fluids that can be used to fill the target blockcanFill- a predicate that must match the target BlockState to fill itfillFunction- 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
ConstructorsConstructorDescriptionStateChangingBehavior(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 aStateChangingBehaviorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintamount()Returns the value of theamountrecord component.Predicate<net.minecraft.world.level.block.state.BlockState> canFill()Returns the value of thecanFillrecord component.final booleanIndicates whether some other object is "equal to" this one.intfillBlock(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 thefillFunctionrecord component.Predicate<net.minecraft.world.level.material.Fluid> Returns the value of thefluidTestrecord component.final inthashCode()Returns a hash code value for this object.static BlockSpoutingBehaviourincrementingState(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.state.properties.IntegerProperty property) Create aBlockSpoutingBehaviourthat will increment the givenIntegerPropertyuntil it reaches its maximum value, consumingamounteach time fluid is filled.static BlockSpoutingBehavioursetTo(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.Block block) Shortcut forsetTo(int, Predicate, BlockState)that uses the Block's default state.static BlockSpoutingBehavioursetTo(int amount, Predicate<net.minecraft.world.level.material.Fluid> fluidTest, net.minecraft.world.level.block.state.BlockState newState) Create aBlockSpoutingBehaviourthat will simply convert the target block to the given state.final StringtoString()Returns a string representation of this record class.
-
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 aStateChangingBehaviorrecord class.- Parameters:
amount- the value for theamountrecord componentfluidTest- the value for thefluidTestrecord componentcanFill- the value for thecanFillrecord componentfillFunction- the value for thefillFunctionrecord 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:BlockSpoutingBehaviourWhile 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:
fillBlockin interfaceBlockSpoutingBehaviour- Parameters:
level- The current levelpos- The position of the affected blockspout- The spout block entity that is calling thisavailableFluid- A copy of the fluidStack that is available, modifying this will do nothing, return the amount to be subtracted insteadsimulate- 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 forsetTo(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 aBlockSpoutingBehaviourthat 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 aBlockSpoutingBehaviourthat will increment the givenIntegerPropertyuntil it reaches its maximum value, consumingamounteach time fluid is filled.- Parameters:
property- the property that will be incremented by one on each fill
-
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 '=='. -
amount
public int amount()Returns the value of theamountrecord component.- Returns:
- the value of the
amountrecord component
-
fluidTest
Returns the value of thefluidTestrecord component.- Returns:
- the value of the
fluidTestrecord component
-
canFill
Returns the value of thecanFillrecord component.- Returns:
- the value of the
canFillrecord component
-
fillFunction
Returns the value of thefillFunctionrecord component.- Returns:
- the value of the
fillFunctionrecord component
-