RebarFluidTank

A common pattern is a 'fluid tank' which can only store one fluid at a time, but can store many types of fluids. RebarFluidTank implements this pattern.

You must call setCapacity for this block to work.

As with RebarFluidBufferBlock, 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

The amount of fluid stored in the tank

Link copied to clipboard

The capacity of the tank

Link copied to clipboard

The amount of space remaining in the tank

Link copied to clipboard

The type of fluid stored in the tank

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(amount: Double): Boolean

Adds to the tank only if the new amount of fluid is greater than zero and fits in the tank.

Link copied to clipboard
@ApiStatus.NonExtendable
open fun areAllHeldEntitiesLoaded(): <Error class: unknown class>

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

Link copied to clipboard
open fun canAddFluid(amount: Double): Boolean

Checks if adding a certain amount of fluid would result in a valid fluid amount.

open fun canAddFluid(fluid: RebarFluid?, amount: Double): Boolean

Checks if adding a certain amount of fluid of a certain type would result in a valid fluid amount.

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

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

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 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 getFluidPointDisplay(type: FluidPointType): <Error class: unknown class>
Link copied to clipboard
open fun getFluidPointDisplayOrThrow(type: FluidPointType): <Error class: unknown class>
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 <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(): Map<RebarFluid, Double>

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

Link copied to clipboard
abstract fun isAllowedFluid(fluid: RebarFluid): Boolean
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)

In the case of a vanilla BlockBreakEvent this is called during the monitor priority

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)

In the case of a vanilla BlockBreakEvent this is called during the monitor priority

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(amount: Double): Boolean

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

Link copied to clipboard
open fun setCapacity(capacity: Double)

Sets the capacity of the fluid tank

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

Sets the fluid amount only if the new amount of fluid is greater than zero and fits in the tank.

Link copied to clipboard
open fun setFluidType(fluid: RebarFluid?)

Sets the type of fluid in the fluid tank

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>)