Add missing methods to StripedColoredDecorativeBlock

This commit is contained in:
DBotThePony 2022-08-28 16:36:46 +07:00
parent d3166894f3
commit a34930a310
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -25,9 +25,37 @@ class StripedColoredDecorativeBlock(
private val mapItems = EnumMap<DyeColor, EnumMap<DyeColor, RegistryObject<Item>>>(DyeColor::class.java) private val mapItems = EnumMap<DyeColor, EnumMap<DyeColor, RegistryObject<Item>>>(DyeColor::class.java)
fun getBlockNullable(base: DyeColor, stripe: DyeColor): Block? { fun getBlockNullable(base: DyeColor, stripe: DyeColor): Block? {
if (!registeredBlocks) {
throw IllegalStateException("Not yet registered blocks")
}
return mapBlocks.get(base)?.get(stripe)?.get() return mapBlocks.get(base)?.get(stripe)?.get()
} }
fun getItemNullable(base: DyeColor, stripe: DyeColor): Item? {
if (!registeredItems) {
throw IllegalStateException("Not yet registered items")
}
return mapItems.get(base)?.get(stripe)?.get()
}
fun getBlock(base: DyeColor, stripe: DyeColor): Block {
if (!registeredBlocks) {
throw IllegalStateException("Not yet registered blocks")
}
return mapBlocks.get(base)?.get(stripe)?.get() ?: throw NoSuchElementException("$base colored $stripe striped block does not exist")
}
fun getItem(base: DyeColor, stripe: DyeColor): Item {
if (!registeredItems) {
throw IllegalStateException("Not yet registered items")
}
return mapItems.get(base)?.get(stripe)?.get() ?: throw NoSuchElementException("$base colored $stripe striped item does not exist")
}
var registeredItems = false var registeredItems = false
private set private set
@ -88,7 +116,7 @@ class StripedColoredDecorativeBlock(
val mappedItems: Map<DyeColor, Map<DyeColor, Item>> by lazy { val mappedItems: Map<DyeColor, Map<DyeColor, Item>> by lazy {
if (!registeredItems) { if (!registeredItems) {
throw IllegalStateException("Not yet registered blocks") throw IllegalStateException("Not yet registered items")
} }
val builder = ImmutableMap.Builder<DyeColor, Map<DyeColor, Item>>() val builder = ImmutableMap.Builder<DyeColor, Map<DyeColor, Item>>()