RebarFluidBufferBlock

Allows for creating 'fluid buffers' in a block, which have a capacity and can be filled and emptied by fluid connections.

In more detail: Usually, fluid machines store fluids in internal 'buffers.' For example, the press has an internal buffer used to store plant oil, of size 1000mB by default. This is a common enough thing that we created a new interface to handle it: RebarFluidBufferBlock. This interface allows your block to easily manage fluid buffers.

You will need to call createFluidBuffer when your block is placed and specify the buffer's fluid type, capacity, whether it can take in fluids from input points, and whether it can supply fluids to output points.

You do not need to handle saving buffers or implement any of the RebarFluidBlock methods for this; this is all done automatically.

Properties

Link copied to clipboard
abstract val block: Block
Link copied to clipboard
@get:ApiStatus.NonExtendable
open val heldEntities: MutableMap<String, UUID>

Functions

Link copied to clipboard
open fun addEntity(name: String, entity: RebarEntity<*>)
open fun addEntity(name: String, entity: Entity)
Link copied to clipboard
open fun addFluid(fluid: RebarFluid, amount: Double): Boolean

Adds to a fluid buffer only if the new amount of fluid is greater than or equal to zero and fits in the buffer.

Link copied to clipboard
@ApiStatus.NonExtendable
open fun areAllHeldEntitiesLoaded(): Boolean

Returns false if any entity is unloaded or does not exist.

Link copied to clipboard
open fun canSetFluid(fluid: RebarFluid, amount: Double): Boolean

Checks if a new amount of fluid is greater than zero and fits inside the corresponding buffer.

Link copied to clipboard
open fun createFluidBuffer(fluid: RebarFluid, capacity: Double, input: Boolean, output: Boolean)

Creates a fluid buffer with the specified fluid type and capacity

Link copied to clipboard
open fun createFluidPoint(type: FluidPointType, face: BlockFace, radius: Float)
open fun createFluidPoint(type: FluidPointType, face: BlockFace, context: BlockCreateContext, allowVerticalFaces: Boolean)
open fun createFluidPoint(type: FluidPointType, face: BlockFace, context: BlockCreateContext, allowVerticalFaces: Boolean, radius: Float)

Creates a fluid input point. Call in your place constructor. Should be called at most once per block.

Link copied to clipboard
open fun deleteFluidBuffer(fluid: RebarFluid)

Deletes a fluid buffer

Link copied to clipboard
open fun fluidAmount(fluid: RebarFluid): Double

Returns the amount of fluid stored in a buffer

Link copied to clipboard
open override fun fluidAmountRequested(fluid: RebarFluid): Double

Returns the amount of the given fluid that the machine wants to receive next tick.

Link copied to clipboard
open fun fluidCapacity(fluid: RebarFluid): Double

Returns the capacity of a buffer

Link copied to clipboard

Returns the amount of space remaining in a fluid buffer

Link copied to clipboard
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntity(name: String): Entity?
@ApiStatus.NonExtendable
open fun <T : Entity> getHeldEntity(clazz: Class<T>, name: String): T?
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntityOrThrow(name: String): Entity
@ApiStatus.NonExtendable
open fun <T : Entity> getHeldEntityOrThrow(clazz: Class<T>, name: String): T
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntityUuid(name: String): UUID?
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntityUuidOrThrow(name: String): UUID
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldRebarEntity(name: String): RebarEntity<*>?
@ApiStatus.NonExtendable
open fun <T : RebarEntity<*>> getHeldRebarEntity(clazz: Class<T>, name: String): T?
Link copied to clipboard
@ApiStatus.NonExtendable
open fun <T : RebarEntity<*>> getHeldRebarEntityOrThrow(clazz: Class<T>, name: String): T
Link copied to clipboard
open override fun getSuppliedFluids(): List<Pair<RebarFluid, Double>>

Returns a list of fluid types - and their corresponding amounts - that can be supplied by the block for this fluid tick.

Link copied to clipboard
open fun hasFluid(fluid: RebarFluid): Boolean

Returns whether a buffer exists for this fluid

Link copied to clipboard
@ApiStatus.NonExtendable
open fun isHeldEntityPresent(name: String): Boolean

Returns false if the block holds no entity with the provided name, the entity is unloaded or does not physically exist.

Link copied to clipboard
@MustBeInvokedByOverriders
open override fun onBreak(drops: MutableList<ItemStack>, context: BlockBreakContext)

Called as the block is being broken. At this point, the block break cannot be cancelled, but the physical block has not yet been broken or removed from io.github.pylonmc.rebar.block.BlockStorage.

Link copied to clipboard
open override fun onFluidAdded(fluid: RebarFluid, amount: Double)

amount is always at most getRequestedFluids().get(fluid) and will never be zero or less.

Link copied to clipboard
open override fun onFluidRemoved(fluid: RebarFluid, amount: Double)

amount is always at least getSuppliedFluids().get(fluid) and will never be zero or less.

Link copied to clipboard
open fun postBreak(context: BlockBreakContext)

Called after the block has been broken. At this point, the block has been physically removed, block drops have been dropped, and the block has been removed from io.github.pylonmc.rebar.block.BlockStorage.

Link copied to clipboard
open fun preBreak(context: BlockBreakContext): Boolean

Called before the block is broken. Note this is not called for Deletions as those are not cancellable.

Link copied to clipboard
open fun removeFluid(fluid: RebarFluid, amount: Double): Boolean

Removes from a fluid buffer only if the new amount of fluid is greater than zero and fits in the buffer.

Link copied to clipboard
open fun setFluid(fluid: RebarFluid, amount: Double): Boolean

Sets a fluid buffer only if the new amount of fluid is greater than or equal to zero and fits in the buffer.

Link copied to clipboard
open fun setFluidCapacity(fluid: RebarFluid, capacity: Double)

Sets the new capacity of a buffer. Any existing fluid will not be removed, so you may end up with a buffer containing more fluid than it technically has capacity for.

Link copied to clipboard
Link copied to clipboard
open fun tryRemoveEntity(name: String)
Link copied to clipboard
@ApiStatus.NonExtendable
open fun whenHeldRebarEntityLoads(name: String, consumer: Consumer<RebarEntity<*>>)
@ApiStatus.NonExtendable
open fun <T : RebarEntity<*>> whenHeldRebarEntityLoads(clazz: Class<T>, name: String, consumer: Consumer<T>)