NBT

object NBT: Any

A wrapper for public NBT functions.

Methods

writeNBT

fun DataOutputStream.writeNBT(byte: Byte)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
byte: Byte

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(short: Short)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
short: Short

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(int: Int)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
int: Int

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(long: Long)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
long: Long

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(float: Float)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
float: Float

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(double: Double)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
double: Double

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(byteArray: ByteArray)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
byteArray: ByteArray

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(string: String)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
string: String

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(intArray: IntArray)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
intArray: IntArray

ReturnValue

Name Description
Unit

writeNBT

fun DataOutputStream.writeNBT(longArray: LongArray)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
longArray: LongArray

ReturnValue

Name Description
Unit

writeNBT

fun <E> DataOutputStream.writeNBT(list: List<E>)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
list: List<E>

ReturnValue

Name Description
Unit

writeNBT

fun <V> DataOutputStream.writeNBT(map: Map<String, V>)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
map: Map<String, V>

ReturnValue

Name Description
Unit

writeNamedNBTCompound

fun <V> DataOutputStream.writeNamedNBTCompound(name: String, map: Map<String, V>)

Receiver

Name Description
DataOutputStream

Parameters

Name Description
name: String
map: Map<String, V>

ReturnValue

Name Description
Unit

readNBTByte

fun DataInputStream.readNBTByte(): Byte

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Byte

readNBTShort

fun DataInputStream.readNBTShort(): Short

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Short

readNBTInt

fun DataInputStream.readNBTInt(): Int

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Int

readNBTLong

fun DataInputStream.readNBTLong(): Long

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Long

readNBTFloat

fun DataInputStream.readNBTFloat(): Float

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Float

readNBTDouble

fun DataInputStream.readNBTDouble(): Double

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Double

readNBTByteArray

fun DataInputStream.readNBTByteArray(): ByteArray

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
ByteArray

readNBTString

fun DataInputStream.readNBTString(): String

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
String

readNBTIntArray

fun DataInputStream.readNBTIntArray(): IntArray

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
IntArray

readNBTLongArray

fun DataInputStream.readNBTLongArray(): LongArray

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
LongArray

readNBTList

fun DataInputStream.readNBTList(): List<Any>

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
List<Any>

readNBTCompound

fun DataInputStream.readNBTCompound(): Map<String, Any>

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Map<String, Any>

readNamedNBTCompound

fun DataInputStream.readNamedNBTCompound(): Pair><String, Map<String, Any>>

Receiver

Name Description
DataInputStream

ReturnValue

Name Description
Pair><String, Map<String, Any>>

toSNBT

fun Byte.toSNBT(): String

Receiver

Name Description
Byte

ReturnValue

Name Description
String

toSNBT

fun Short.toSNBT(): String

Receiver

Name Description
Short

ReturnValue

Name Description
String

toSNBT

fun Int.toSNBT(): String

Receiver

Name Description
Int

ReturnValue

Name Description
String

toSNBT

fun Long.toSNBT(): String

Receiver

Name Description
Long

ReturnValue

Name Description
String

toSNBT

fun Float.toSNBT(): String

Receiver

Name Description
Float

ReturnValue

Name Description
String

toSNBT

fun Double.toSNBT(): String

Receiver

Name Description
Double

ReturnValue

Name Description
String

toSNBT

fun ByteArray.toSNBT(): String

Receiver

Name Description
ByteArray

ReturnValue

Name Description
String

toSNBT

fun String.toSNBT(): String

Receiver

Name Description
String

ReturnValue

Name Description
String

toSNBT

fun IntArray.toSNBT(): String

Receiver

Name Description
IntArray

ReturnValue

Name Description
String

toSNBT

fun LongArray.toSNBT(): String

Receiver

Name Description
LongArray

ReturnValue

Name Description
String

toSNBT

fun <E> List<E>.toSNBT(): String

Receiver

Name Description
List<E>

ReturnValue

Name Description
String

toSNBT

fun <V> Map<String, V>.toSNBT(): String

Receiver

Name Description
Map<String, V>

ReturnValue

Name Description
String

mergeMaps

fun mergeMaps(a: Map<String, Any>, b: Map<String, Any>): Map<String, Any>

Merges a and b deeply with the following algorithm:


val c = a
for (key in b) {
    if (key in a && a[key] is Map && b[key] is Map) {
        c[key] = mergeMaps(a[key], b[key])
    } else {
        c[key] = b[key]
    }
}

Parameters

Name Description
a: Map<String, Any>
b: Map<String, Any>

ReturnValue

Name Description
Map<String, Any>

c, the merged map

mergeLists

fun mergeLists(a: List<Any>, b: List<Any>): List<Any>

Merges a and b deeply with the following algorithm:


val c = a
for (index in b) {
    if (index in a && a[index] is List && b[index] is List) {
        c[index] = mergeLists(a[index], b[index])
    } else {
        c[index] = b[index]
    }
}

Parameters

Name Description
a: List<Any>
b: List<Any>

ReturnValue

Name Description
List<Any>

c, the merged list

merge

fun merge(a: Map<String, Any>, b: Map<String, Any>): Map<String, Any>

Merges a and b deeply with the following algorithm:


val c = a
for (key in b) {
    if (key in a) {
        if (a[key] is Map && b[key] is Map) {
            c[key] = merge(a[key], b[key])
        }
        else if (a[key] is List && b[key] is List) {
            c[key] = merge(a[key], b[key])
        }
        else {
            c[key] = b[key]
        }
    } else {
        c[key] = b[key]
    }
}

Parameters

Name Description
a: Map<String, Any>
b: Map<String, Any>

ReturnValue

Name Description
Map<String, Any>

c, the merged map

merge

fun merge(a: List<Any>, b: List<Any>): List<Any>

Merges a and b deeply with the following algorithm:


val c = a
for (index in b) {
    if (index in a) {
        if (a[index] is Map && b[index] is Map) {
            c[index] = merge(a[index], b[index])
        }
        else if (a[index] is List && b[index] is List) {
            c[index] = merge(a[index], b[index])
        }
        else {
            c[index] = b[index]
        }
    } else {
        c[index] = b[index]
    }
}

Parameters

Name Description
a: List<Any>
b: List<Any>

ReturnValue

Name Description
List<Any>

c, the merged list

mergeAdding

fun mergeAdding(a: Map<String, Any>, b: Map<String, Any>): Map<String, Any>

Merges a and b deeply with the following algorithm:


val c = a
for (key in b) {
    if (key in a) {
        if (a[key] is Map && b[key] is Map) {
            c[key] = mergeAdding(a[key], b[key])
        }
        else if (a[key] is List && b[key] is List) {
            c[key] = a[key] + b[key]
        }
        else {
            c[key] = b[key]
        }
    } else {
        c[key] = b[key]
    }
}

Parameters

Name Description
a: Map<String, Any>
b: Map<String, Any>

ReturnValue

Name Description
Map<String, Any>

c, the merged map