NetworkedTileEntity

abstract class NetworkedTileEntity(val pos: BlockPos, blockState: NovaBlockState, data: Compound) : TileEntity, NetworkEndPoint

Constructors

Link copied to clipboard
constructor(pos: BlockPos, blockState: NovaBlockState, data: Compound)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
lateinit var coroutineSupervisor: Job

The supervisor Job for coroutines of this TileEntity.

Link copied to clipboard

The FakeItemDisplay(s) used to display the model of this TileEntity, if it is entity-backed.

Link copied to clipboard

The EndPointDataHolders that contain the data of this NetworkEndPoint.

Link copied to clipboard

Whether this TileEntity is enabled.

Link copied to clipboard
override var isValid: Boolean

Whether this NetworkNode is valid and Network including it should be ticked.

Link copied to clipboard
open override val linkedNodes: Set<NetworkNode>

A set of NetworkNodes that are not connected via networks, but still share data and need to be clustered together, such as the left and right part of a double chest.

Link copied to clipboard

The MenuContainer for this TileEntity's gui. May stay uninitialized if the TileEntity has no gui.

Link copied to clipboard
var owner: OfflinePlayer?

The OfflinePlayer that placed this TileEntity, may be null if it wasn't placed by a player.

Link copied to clipboard

The UUID of the Player that placed this TileEntity, may be null if it wasn't placed by a player.

Link copied to clipboard
Link copied to clipboard
val uuid: UUID

The UUID of this TileEntity.

Functions

Link copied to clipboard
fun dropProvider(provider: () -> Collection<ItemStack>)

Registers a new drop provider that will be called during TileEntity.getDrops when this TileEntity is destroyed.

Link copied to clipboard
open fun getDrops(includeSelf: Boolean): List<ItemStack>

Gets a list of ItemStacks to be dropped when this TileEntity is destroyed.

Link copied to clipboard
open fun getExp(): Int

Gets the amount of exp to be dropped when this TileEntity is destroyed.

Link copied to clipboard
fun getViewers(): List<Player>

Gets a List of all players that this TileEntity is visible for.

Link copied to clipboard

Called when this TileEntity is destroyed.

Link copied to clipboard
open override fun handleDisable()

Called when this TileEntity is disabled.

Link copied to clipboard

Called when this TileEntity stops ticking.

Link copied to clipboard
open override fun handleEnable()

Called when this TileEntity is enabled.

Link copied to clipboard

Called when this TileEntity starts ticking.

Link copied to clipboard
open suspend fun handleNetworkLoaded(state: NetworkState)

Called when a NetworkNode is loaded into the state.

Link copied to clipboard
open suspend fun handleNetworkUpdate(state: NetworkState)

Called when a NetworkNode in one of the six cartesian directions is added, removed, or updated in a way that affects this node.

Link copied to clipboard

Called when this TileEntity is placed.

Link copied to clipboard
Link copied to clipboard
open fun handleTick()

Called every tick for every TileEntity that is in a loaded chunk.

Link copied to clipboard

Checks whether there is data stored under the given key, regardless of whether it is persistent or not.

Link copied to clipboard
fun removeData(key: String)

Removes the data stored under the given key, regardless of whether it is persistent or not.

Link copied to clipboard
inline fun <T> retrieveData(key: String, defaultValue: () -> T): T

Retrieves data from the data Compound of this TileEntity. If it can't find anything under the given key, the result of the defaultValue lambda is returned.

inline fun <T> retrieveData(type: KType, key: String, defaultValue: () -> T): T

Retrieves data of the specified type or invokes the defaultValue lambda if there is no data stored under the given key.

Link copied to clipboard
inline fun <T> retrieveDataOrNull(key: String): T?

Retrieves data of type T or returns null if there is no data stored under the given key.

fun <T> retrieveDataOrNull(type: KType, key: String): T?

Retrieves data of the specified type or returns null if there is no data stored under the given key.

Link copied to clipboard
open fun saveData()

Called to save all data using the storeData method.

Link copied to clipboard
inline fun <T> storeData(key: String, value: T?, persistent: Boolean = false)

Stores value as the reified type T under the given key.

fun <T> storeData(type: KType, key: String, value: T?, persistent: Boolean = false)

Stores value as the given type under the given key.

Link copied to clipboard
@JvmName(name = "storedEnergyHolderBlockFace")
fun storedEnergyHolder(maxEnergy: Provider<Long>, allowedConnectionType: NetworkConnectionType, blockedFaces: Set<BlockFace> = emptySet(), defaultConnectionConfig: () -> Map<BlockFace, NetworkConnectionType> = { CUBE_FACES.associateWithTo(enumMap()) { allowedConnectionType } }): DefaultEnergyHolder
@JvmName(name = "storedEnergyHolderBlockSide")
fun storedEnergyHolder(maxEnergy: Provider<Long>, allowedConnectionType: NetworkConnectionType, blockedSides: Set<BlockSide>, defaultConnectionConfig: () -> Map<BlockFace, NetworkConnectionType> = { CUBE_FACES.associateWithTo(enumMap()) { allowedConnectionType } }): DefaultEnergyHolder

Retrieves the EnergyHolder previously stored or creates a new one and registers it in the holders map.

Link copied to clipboard
fun storedFluidContainer(name: String, allowedTypes: Set<FluidType>, capacity: Provider<Long>, persistent: Boolean = false, updateHandler: () -> Unit? = null): FluidContainer

Retrieves a FluidContainer stored under name or creates an empty new one. The values allowedTypes and capacity are not serialized and will be applied every time. Then registers the specified updateHandler.

Link copied to clipboard
@JvmName(name = "storedFluidHolderBlockFace")
fun storedFluidHolder(container: Pair<NetworkedFluidContainer, NetworkConnectionType>, vararg containers: Pair<NetworkedFluidContainer, NetworkConnectionType>, blockedFaces: Set<BlockFace> = emptySet(), defaultContainerConfig: () -> MutableMap<BlockFace, NetworkedFluidContainer> = { CUBE_FACES.associateWithTo(enumMap()) { container.first } }, defaultConnectionConfig: () -> EnumMap<BlockFace, NetworkConnectionType>? = null): DefaultFluidHolder
@JvmName(name = "storedFluidHolderBlockSide")
fun storedFluidHolder(container: Pair<NetworkedFluidContainer, NetworkConnectionType>, vararg containers: Pair<NetworkedFluidContainer, NetworkConnectionType>, blockedSides: Set<BlockSide>, defaultContainerConfig: () -> MutableMap<BlockFace, NetworkedFluidContainer> = { CUBE_FACES.associateWithTo(enumMap()) { container.first } }, defaultConnectionConfig: () -> EnumMap<BlockFace, NetworkConnectionType>? = null): DefaultFluidHolder

Retrieves the FluidHolder previously stored or creates a new one and registers it in the holders map.

Link copied to clipboard
fun storedInventory(name: String, size: Int, preUpdateHandler: (ItemPreUpdateEvent) -> Unit? = null, postUpdateHandler: (ItemPostUpdateEvent) -> Unit? = null): VirtualInventory

Retrieves a VirtualInventory stored under name or creates a new one using the specified size. Then registers the specified postUpdateHandler and preUpdateHandler.

fun storedInventory(name: String, size: Int, persistent: Boolean = false, maxStackSizes: IntArray = IntArray(size) { 64 }, preUpdateHandler: (ItemPreUpdateEvent) -> Unit? = null, postUpdateHandler: (ItemPostUpdateEvent) -> Unit? = null): VirtualInventory

Retrieves a VirtualInventory stored under name or creates a new one using the specified size, maxStackSizes and persistent properties. Then registers the specified postUpdateHandler and preUpdateHandler.

Link copied to clipboard
@JvmName(name = "storedItemHolderBlockFace")
fun storedItemHolder(inventory: Pair<VirtualInventory, NetworkConnectionType>, vararg inventories: Pair<VirtualInventory, NetworkConnectionType>, blockedFaces: Set<BlockFace> = emptySet(), defaultInventoryConfig: () -> Map<BlockFace, VirtualInventory>? = null, defaultConnectionConfig: () -> Map<BlockFace, NetworkConnectionType>? = null): DefaultItemHolder
@JvmName(name = "storedItemHolderBlockSide")
fun storedItemHolder(inventory: Pair<VirtualInventory, NetworkConnectionType>, vararg inventories: Pair<VirtualInventory, NetworkConnectionType>, blockedSides: Set<BlockSide>, defaultInventoryConfig: () -> Map<BlockFace, VirtualInventory>? = null, defaultConnectionConfig: () -> Map<BlockFace, NetworkConnectionType>? = null): DefaultItemHolder
@JvmName(name = "storedItemHolderBlockFace")
fun storedItemHolder(inventory: Pair<NetworkedInventory, NetworkConnectionType>, vararg inventories: Pair<NetworkedInventory, NetworkConnectionType>, mergedInventory: NetworkedInventory? = null, blockedFaces: Set<BlockFace> = emptySet(), defaultInventoryConfig: () -> Map<BlockFace, NetworkedInventory> = { CUBE_FACES.associateWithTo(enumMap()) { inventory.first } }, defaultConnectionConfig: () -> Map<BlockFace, NetworkConnectionType>? = null): DefaultItemHolder
@JvmName(name = "storedItemHolderBlockSide")
fun storedItemHolder(inventory: Pair<NetworkedInventory, NetworkConnectionType>, vararg inventories: Pair<NetworkedInventory, NetworkConnectionType>, mergedInventory: NetworkedInventory? = null, blockedSides: Set<BlockSide>, defaultInventoryConfig: () -> Map<BlockFace, NetworkedInventory> = { CUBE_FACES.associateWithTo(enumMap()) { inventory.first } }, defaultConnectionConfig: () -> Map<BlockFace, NetworkConnectionType>? = null): DefaultItemHolder

Retrieves the ItemHolder previously stored or creates a new one, registers it in the holders map, and adds drop providers for ItemHolder.insertFilters and ItemHolder.extractFilters.

Link copied to clipboard
fun storedRegion(name: String, minSize: Provider<Int>, maxSize: Provider<Int>, defaultSize: Int, createRegion: (Int) -> Region): DynamicRegion

Creates a DynamicRegion with the size stored under name or defaultSize if it doesn't exist, using createRegion. The minSize and maxSize properties are not serialized and will be applied every time.

Link copied to clipboard
inline fun <T : Any> storedValue(key: String, persistent: Boolean = false): MutableProvider<T?>
inline fun <T : Any> storedValue(key: String, noinline defaultValue: () -> T): MutableProvider<T>
inline fun <T : Any> storedValue(key: String, persistent: Boolean, noinline defaultValue: () -> T): MutableProvider<T>

Creates a MutableProvider to which properties can delegate.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Changes the block state of this TileEntity to blockState.