Skip to content

net.kernelpanicsoft.archie.util

Types

ClickEventBuilder

ComponentBuilder

ComponentBuilderDsl

@DslMarker
annotation class ComponentBuilderDsl

HoverEventBuilder

MutableEntry

data class MutableEntry<K, V>(var key: K, var value: V) : Map.Entry<K, V> 

A Map.Entry whose key and value can be reassigned, unlike the standard read-only entry.

StyleBuilder

class StyleBuilder

Properties

clothConfigModId

Cloth Config's own mod id, which differs by loader: Fabric allows hyphens ("cloth-config"), while NeoForge's mod id charset doesn't, so its variant registers as "cloth_config" instead.

hasMinecraftClient

Whether there is a real Minecraft behind this physical client yet - see withMinecraftClient, which is how you should almost always spend this.

hasMinecraftServer

Whether a MinecraftServer is running - integrated or dedicated alike, since a single-player client has one just as truly as a server jar does. See withMinecraftServer, which is how you should almost always spend this.

isClient

isClothConfigLoaded

Whether Cloth Config is actually present among the currently loaded mods - not merely whether this is the physical client. onClient alone only rules out a dedicated server; it still lets client-only code run on a client that simply doesn't have Cloth Config installed, which is exactly the case any code touching Cloth Config's own types (ModifierKeyCode and friends) needs to additionally guard against to avoid a hard dependency on it.

isServer

minecraftClient

val minecraftClient: Minecraft?

The running Minecraft, or null where there is none.

minecraftServer

val minecraftServer: MinecraftServer?

requireMinecraftClient

val requireMinecraftClient: Minecraft

The running Minecraft, for code that cannot execute without one - drawing a widget, handling a click, reading the options behind a tooltip.

requireMinecraftServer

val requireMinecraftServer: MinecraftServer

The running MinecraftServer, for code that cannot execute without one - a block entity tick, a command, anything reached from a ServerLevel.

Functions

blockEntityType

fun <T : BlockEntity> blockEntityType(factory: BlockEntityType.BlockEntitySupplier<T>, builder: MutableList<Block>.() -> Unit): BlockEntityType<T>

Builds a BlockEntityType for factory, valid for the set of Blocks declared via builder (e.g. { add(MyBlocks.MY_BLOCK.get()) }).

blockProperties

fun blockProperties(parent: BlockBehaviour? = null, block: BlockBehaviour.Properties.() -> Unit): BlockBehaviour.Properties

Builds a BlockBehaviour.Properties via block, optionally starting from a full copy of parent's properties instead of the defaults.

buildArray

inline fun <T> buildArray(builderAction: MutableList<T>.() -> Unit): Array<T>

Builds a reference Array of T using the buildList DSL via builderAction.

inline fun <T> buildArray(capacity: Int, builderAction: MutableList<T>.() -> Unit): Array<T>

Like buildArray, but pre-sizes the backing list to capacity.

buildComponent

inline fun buildComponent(builderAction: ComponentBuilder.() -> Unit): Component

buildStyle

inline fun buildStyle(builderAction: StyleBuilder.() -> Unit): Style

div

operator fun String.div(other: ResourceLocation): ResourceLocation

Prepends this/ to other's path, keeping other's namespace.

operator fun ResourceLocation.div(other: String): ResourceLocation

Appends /[other] to this location's path.

operator fun ResourceLocation.div(other: ResourceLocation): ResourceLocation

Appends / plus other's path (namespace of other is ignored) to this location's path.

foldEnv

inline fun <T> foldEnv(crossinline client: () -> T, crossinline server: () -> T): T

Runs client on the physical client and server on a dedicated server, returning whichever ran. Only the branch matching the current Env is ever class-loaded, so client can safely reference client-only classes even when this is called from common code.

getReflection

inline fun <T, R> getReflection(instance: T, field: String): R

Reads a private/inaccessible declared field named field off instance via reflection, searching T and its superclasses.

getReflection

@JvmName
(name = "getReflectionExtension")inline fun <T, R> T.getReflection(field: String): R

Extension form of getReflection; reads field (searching up the class hierarchy) from this instance.

invoke

inline operator fun Component.invoke(builderAction: ComponentBuilder.() -> Unit): Component

itemProperties

fun itemProperties(block: Item.Properties.() -> Unit): Item.Properties

Builds an Item.Properties via block.

onClient

inline fun <T> onClient(crossinline client: () -> T): Optional<T>

Runs client and returns its result, only on the physical client; returns Optional.empty on a dedicated server without ever class-loading client.

onServer

inline fun <T> onServer(crossinline server: () -> T): Optional<T>

Runs server and returns its result, only on a dedicated server; returns Optional.empty on the physical client without ever class-loading server.

plus

operator fun String.plus(other: ResourceLocation): ResourceLocation

Prepends this directly to other's path with no separator, keeping other's namespace.

operator fun ResourceLocation.plus(other: String): ResourceLocation

Appends other directly to this location's path with no separator, e.g. loc + "_dark".

operator fun ResourceLocation.plus(other: ResourceLocation): ResourceLocation

Appends other's path directly to this location's path with no separator (namespace of other is ignored).

rem

operator fun Mod.rem(other: String): ResourceLocation

Builds a ResourceLocation namespaced under this Mod's id, with other as the path, e.g. MyMod.MOD % "my_item".

operator fun String.rem(other: String): ResourceLocation

Builds a ResourceLocation with this as the namespace and other as the path, e.g. "mymod" % "my_item".

operator fun Archie.rem(other: String): ResourceLocation

Builds a ResourceLocation namespaced under Archie.MOD_ID, with other as the path, e.g. Archie % "main".

sendSystemMessage

inline fun Player.sendSystemMessage(builderAction: ComponentBuilder.() -> Unit)

setReflection

inline fun <T, R> setReflection(
    instance: T, 
    field: String, 
    value: R
)

Writes value to a private/inaccessible declared field named field on instance via reflection, searching T and its superclasses.

setReflection

@JvmName
(name = "setReflectionExtension")inline fun <T, R> T.setReflection(field: String, value: R)

Extension form of setReflection; writes field (searching up the class hierarchy) on this instance.

tab

fun Item.Properties.tab(tab: DeferredSupplier<CreativeModeTab>): Item.Properties

Assigns tab as this item's creative tab, via Architectury's injected item-properties extension.

fun Item.Properties.tab(tab: ResourceKey<CreativeModeTab>): Item.Properties

Assigns tab as this item's creative tab, via Architectury's injected item-properties extension.

fun Item.Properties.tab(tab: CreativeModeTab): Item.Properties

Assigns tab as this item's creative tab, via Architectury's injected item-properties extension.

withMinecraftClient

inline fun withMinecraftClient(crossinline block: Minecraft.() -> Unit)

Runs block against the running Minecraft, on the physical client and only once there is a game to run it against - see withMinecraftServer for the server-side counterpart.

withMinecraftServer

inline fun withMinecraftServer(crossinline block: MinecraftServer.() -> Unit)

Runs block against the running MinecraftServer, if there is one.