Fix Cargo Crate being in wrong creative tabs

This commit is contained in:
DBotThePony 2022-08-26 23:27:24 +07:00
parent 7c14614555
commit 5deb14f62f
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -91,6 +91,9 @@ class WriteOnce<V> : ReadWriteProperty<Any, V> {
}
}
/**
* Colored only
*/
@Suppress("PropertyName", "unused")
open class ColoredDecorativeBlock(
val baseName: String,
@ -330,10 +333,14 @@ open class ColoredDecorativeBlock(
}
}
/**
* Base + Colored
*/
class DecorativeBlock(
baseName: String,
private val provider: (DyeColor?) -> Block,
itemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE
itemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE,
val baseItemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE,
) : ColoredDecorativeBlock(baseName, provider, itemGroup) {
private var _block: RegistryObject<Block> by WriteOnce()
private var _item: RegistryObject<Item> by WriteOnce()
@ -394,7 +401,7 @@ class DecorativeBlock(
}
override fun registerItems(registry: DeferredRegister<Item>) {
_item = registry.register(baseName) { BlockItem(_block.get(), Item.Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE).stacksTo(64)) }
_item = registry.register(baseName) { BlockItem(_block.get(), Item.Properties().tab(baseItemGroup).stacksTo(64)) }
super.registerItems(registry)
}
@ -426,7 +433,7 @@ object MRegistry {
research.build(event)
}
val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock, OverdriveThatMatters.INSTANCE.CREATIVE_TAB)
val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock, baseItemGroup = OverdriveThatMatters.INSTANCE.CREATIVE_TAB)
val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK, {
BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE)