Un codegen StripedColoredDecorativeBlock

This commit is contained in:
DBotThePony 2022-08-28 16:34:29 +07:00
parent 6d407d4c59
commit d3166894f3
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 144 additions and 2932 deletions

View File

@ -1,10 +1,13 @@
package ru.dbotthepony.mc.otm.registry
import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableSet
import net.minecraft.world.item.DyeColor
import net.minecraftforge.registries.RegistryObject
class LazyList<T>(private vararg val getters: () -> T) : AbstractList<T>() {
class LazyList<T>(private val getters: ImmutableList<() -> T>) : AbstractList<T>() {
constructor(vararg getters: () -> T) : this(ImmutableList.copyOf(getters))
override val size: Int
get() = getters.size
@ -13,7 +16,21 @@ class LazyList<T>(private vararg val getters: () -> T) : AbstractList<T>() {
}
}
class LazyMap<K, T>(vararg mValues: Pair<K, () -> T>) : AbstractMap<K, T>() {
class LazyMap<K, T> : AbstractMap<K, T> {
override val entries: Set<Map.Entry<K, T>>
constructor(vararg mValues: Pair<K, () -> T>) : super() {
entries = ImmutableSet.copyOf(mValues.map { Entry(it.first, it.second) })
}
constructor(mValues: List<Pair<K, () -> T>>) : super() {
entries = ImmutableSet.copyOf(mValues.map { Entry(it.first, it.second) })
}
constructor(mValues: Map<K, () -> T>) : super() {
entries = ImmutableSet.copyOf(mValues.map { Entry(it.key, it.value) })
}
private inner class Entry(
override val key: K,
private val getter: () -> T
@ -21,8 +38,6 @@ class LazyMap<K, T>(vararg mValues: Pair<K, () -> T>) : AbstractMap<K, T>() {
override val value: T
get() = getter.invoke()
}
override val entries: Set<Map.Entry<K, T>> = ImmutableSet.copyOf(mValues.map { Entry(it.first, it.second) })
}
class RegistryObjectList<T>(private vararg val getters: RegistryObject<T>) : AbstractList<T>() {