Tritanium slabs and walls

This commit is contained in:
DBotThePony 2022-10-05 14:53:21 +07:00
parent 987d6df934
commit 30b739f9ce
Signed by: DBot
GPG Key ID: DCC23B5715498507
17 changed files with 398 additions and 42 deletions

View File

@ -5,7 +5,9 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.DoorBlock
import net.minecraft.world.level.block.IronBarsBlock
import net.minecraft.world.level.block.SlabBlock
import net.minecraft.world.level.block.StairBlock
import net.minecraft.world.level.block.WallBlock
import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraft.world.level.block.state.properties.DoorHingeSide
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf
@ -111,14 +113,66 @@ object DataGen {
}
}
const val DECORATIVE_BLOCK_LOCATION = "block/decorative"
fun decorativeStairs(block: StairBlock, side: String, top: String) {
blockStateProvider.exec {
blockStateProvider.stairsBlock(block, modLocation("block/decorative/$side"), modLocation("block/decorative/$top"), modLocation("block/decorative/$top"))
blockStateProvider.stairsBlock(block, modLocation("$DECORATIVE_BLOCK_LOCATION/$side"), modLocation("$DECORATIVE_BLOCK_LOCATION/$top"), modLocation("$DECORATIVE_BLOCK_LOCATION/$top"))
}
}
fun decorativeSlab(block: SlabBlock, base: ResourceLocation, sideTexture: String, topTexture: String) {
blockStateProvider.exec {
blockStateProvider.slabBlock(
block,
base,
modLocation("$DECORATIVE_BLOCK_LOCATION/$sideTexture"),
modLocation("$DECORATIVE_BLOCK_LOCATION/$topTexture"),
modLocation("$DECORATIVE_BLOCK_LOCATION/$topTexture"),
)
}
}
fun stairs(block: StairBlock) {
stairs(block, "block/decorative/${block.registryName!!.path}", "block/decorative/${block.registryName!!.path}")
stairs(block, "$DECORATIVE_BLOCK_LOCATION/${block.registryName!!.path}", "$DECORATIVE_BLOCK_LOCATION/${block.registryName!!.path}")
}
fun decorativeWall(block: WallBlock, sideTexture: String, topTexture: String) {
wall(block, "$DECORATIVE_BLOCK_LOCATION/$sideTexture", "$DECORATIVE_BLOCK_LOCATION/$topTexture")
}
fun wall(block: WallBlock, sideTexture: String, topTexture: String) {
val name = block.registryName?.path ?: throw IllegalStateException("Invalid state of wall block $block")
var post: ModelFile? = null
var side: ModelFile? = null
var sideTall: ModelFile? = null
blockModelProvider.exec {
post = blockModelProvider
.withExistingParent(name + "_post", modLocation("block/template_wall_post"))
.texture("wall", modLocation(topTexture))
.texture("wall_side", modLocation(sideTexture))
side = blockModelProvider
.withExistingParent(name + "_side", modLocation("block/template_wall_side"))
.texture("wall", modLocation(topTexture))
.texture("wall_side", modLocation(sideTexture))
sideTall = blockModelProvider
.withExistingParent(name + "_side_tall", modLocation("block/template_wall_side_tall"))
.texture("wall", modLocation(topTexture))
.texture("wall_side", modLocation(sideTexture))
}
blockStateProvider.exec {
blockStateProvider.wallBlock(
block,
checkNotNull(post) { "post model is null" },
checkNotNull(side) { "side model is null" },
checkNotNull(sideTall) { "sideTall model is null" },
)
}
}
fun pane(block: Block, textureSide: ResourceLocation, textureRailing: ResourceLocation) {

View File

@ -1,7 +1,9 @@
package ru.dbotthepony.mc.otm.datagen
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.level.block.SlabBlock
import net.minecraft.world.level.block.StairBlock
import net.minecraft.world.level.block.WallBlock
import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraftforge.client.model.generators.ConfiguredModel
import ru.dbotthepony.mc.otm.OverdriveThatMatters
@ -36,10 +38,38 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
DataGen.decorativeStairs(block as StairBlock, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path)
}
for ((color, block) in MRegistry.TRITANIUM_SLAB.allBlocks) {
blockStateProvider.exec {
blockStateProvider.slabBlock(
block as SlabBlock,
MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!,
modLocation("${DataGen.DECORATIVE_BLOCK_LOCATION}/${MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path}")
)
}
}
for ((color, block) in MRegistry.TRITANIUM_WALL.allBlocks) {
DataGen.decorativeWall(
block as WallBlock,
sideTexture = MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path,
topTexture = MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path
)
}
for (item in MRegistry.TRITANIUM_STAIRS.allItems.values) {
itemModelProvider.block(item)
}
for (item in MRegistry.TRITANIUM_SLAB.allItems.values) {
itemModelProvider.block(item)
}
for ((color, item) in MRegistry.TRITANIUM_WALL.allItems) {
itemModelProvider.exec {
itemModelProvider.wallInventory(item.registryName!!.path, modLocation(DataGen.DECORATIVE_BLOCK_LOCATION + "/" + MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path))
}
}
DataGen.decoratives(MRegistry.FLOOR_TILES)
DataGen.decoratives(MRegistry.UNREFINED_FLOOR_TILES)
DataGen.decoratives(MRegistry.VENT)
@ -64,10 +94,39 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
)
}
for ((block, colors) in MRegistry.TRITANIUM_STRIPED_SLAB.blocksWithColor) {
DataGen.decorativeSlab(
block as SlabBlock,
MRegistry.TRITANIUM_STRIPED_BLOCK.getBlock(colors.first, colors.second).registryName!!,
"stripe/${MRegistry.TRITANIUM_STRIPED_BLOCK.getBlock(colors.first, colors.second).registryName!!.path}",
"tritanium_block_${colors.first.name.lowercase()}"
)
}
for ((block, colors) in MRegistry.TRITANIUM_STRIPED_WALL.blocksWithColor) {
DataGen.decorativeWall(
block as WallBlock,
sideTexture = "stripe/${MRegistry.TRITANIUM_STRIPED_BLOCK.getBlock(colors.first, colors.second).registryName!!.path}",
topTexture = "tritanium_block_${colors.first.name.lowercase()}"
)
}
for (item in MRegistry.TRITANIUM_STRIPED_STAIRS.flatItems) {
itemModelProvider.block(item)
}
for (item in MRegistry.TRITANIUM_STRIPED_SLAB.flatItems) {
itemModelProvider.block(item)
}
for ((item, colors) in MRegistry.TRITANIUM_STRIPED_WALL.itemsWithColor) {
itemModelProvider.exec {
itemModelProvider.withExistingParent(item.registryName!!.path, modLocation("block/wall_inventory"))
.texture("wall_side", modLocation("${DataGen.DECORATIVE_BLOCK_LOCATION}/stripe/${MRegistry.TRITANIUM_STRIPED_BLOCK.getBlock(colors.first, colors.second).registryName!!.path}"))
.texture("wall", modLocation("${DataGen.DECORATIVE_BLOCK_LOCATION}/tritanium_block_${colors.first.name.lowercase()}"))
}
}
DataGen.decorativeCubeAll(MBlocks.DANGER_STRIPE_BLOCK)
DataGen.decorativeColumn(MBlocks.METAL_BEAM, "metal_beam_side", "metal_beam_top")
@ -135,7 +194,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
DataGen.decorativeColumn(MBlocks.TRITANIUM_STRIPED_BLOCK, "tritanium_striped_block", "tritanium_block")
DataGen.decorativeStairs(MBlocks.TRITANIUM_STRIPED_STAIRS as StairBlock, "tritanium_striped_block", "tritanium_block")
DataGen.decorativeWall(MBlocks.TRITANIUM_STRIPED_WALL as WallBlock, "tritanium_striped_block", "tritanium_block")
DataGen.decorativeSlab(MBlocks.TRITANIUM_STRIPED_SLAB as SlabBlock, MBlocks.TRITANIUM_STRIPED_BLOCK.registryName!!, "tritanium_striped_block", "tritanium_block")
itemModelProvider.block(MItems.TRITANIUM_STRIPED_STAIRS)
itemModelProvider.block(MItems.TRITANIUM_STRIPED_SLAB)
itemModelProvider.exec {
itemModelProvider.withExistingParent(MItems.TRITANIUM_STRIPED_WALL.registryName!!.path, modLocation("block/wall_inventory"))
.texture("wall_side", modLocation("${DataGen.DECORATIVE_BLOCK_LOCATION}/tritanium_striped_block"))
.texture("wall", modLocation("${DataGen.DECORATIVE_BLOCK_LOCATION}/tritanium_block"))
}
for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allBlocks) {
val name = MRegistry.INDUSTRIAL_GLASS.allBlocks[color]!!.registryName!!.path

View File

@ -8,6 +8,8 @@ private fun decoratives(provider: MatteryLanguageProvider) {
provider.englishColors.add(MRegistry.TRITANIUM_BLOCK, "%s Tritanium Block")
provider.englishColors.add(MRegistry.TRITANIUM_STAIRS, "%s Tritanium Stairs")
provider.englishColors.add(MRegistry.TRITANIUM_SLAB, "%s Tritanium Slab")
provider.englishColors.add(MRegistry.TRITANIUM_WALL, "%s Tritanium Wall")
provider.englishColors.add(MRegistry.FLOOR_TILES, "%s Floor Tiles")
provider.englishColors.add(MRegistry.UNREFINED_FLOOR_TILES, "Unrefined %s Floor Tiles")
@ -29,6 +31,8 @@ private fun decoratives(provider: MatteryLanguageProvider) {
add(MRegistry.CARGO_CRATES.block, "Cargo Crate")
add(MRegistry.TRITANIUM_BLOCK.block, "Tritanium Block")
add(MRegistry.TRITANIUM_STAIRS.block, "Tritanium Stairs")
add(MRegistry.TRITANIUM_SLAB.block, "Tritanium Slab")
add(MRegistry.TRITANIUM_WALL.block, "Tritanium Wall")
add(MRegistry.INDUSTRIAL_GLASS.block, "Industrial Glass")
add(MRegistry.INDUSTRIAL_GLASS_PANE.block, "Industrial Glass Pane")
@ -55,6 +59,24 @@ private fun decoratives(provider: MatteryLanguageProvider) {
add(block, "$baseName Colored $stripeName Striped Tritanium Stairs")
}
for ((block, colors) in MRegistry.TRITANIUM_STRIPED_SLAB.blocksWithColor) {
val (base, stripe) = colors
val baseName = provider.englishColors.dyeClassMapped[base]!!
val stripeName = provider.englishColors.dyeClassMapped[stripe]!!
add(block, "$baseName Colored $stripeName Striped Tritanium Slab")
}
for ((block, colors) in MRegistry.TRITANIUM_STRIPED_WALL.blocksWithColor) {
val (base, stripe) = colors
val baseName = provider.englishColors.dyeClassMapped[base]!!
val stripeName = provider.englishColors.dyeClassMapped[stripe]!!
add(block, "$baseName Colored $stripeName Striped Tritanium Wall")
}
}
}
@ -339,6 +361,8 @@ private fun blocks(provider: MatteryLanguageProvider) {
add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Tritanium Striped Block")
add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Tritanium Striped Stairs")
add(MBlocks.TRITANIUM_STRIPED_SLAB, "Tritanium Striped Slab")
add(MBlocks.TRITANIUM_STRIPED_WALL, "Tritanium Striped Wall")
add(MBlocks.TRITANIUM_ORE, "Tritanium Ore")
add(MBlocks.DEEPSLATE_TRITANIUM_ORE, "Deepslate Tritanium Ore")
add(MBlocks.TRITANIUM_RAW_BLOCK, "Raw Tritanium Block")

View File

@ -2,22 +2,29 @@ package ru.dbotthepony.mc.otm.datagen.loot
import com.mojang.datafixers.util.Pair
import it.unimi.dsi.fastutil.objects.ObjectArraySet
import net.minecraft.advancements.critereon.StatePropertiesPredicate
import net.minecraft.data.DataGenerator
import net.minecraft.data.loot.BlockLoot
import net.minecraft.data.loot.LootTableProvider
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.level.ItemLike
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.SlabBlock
import net.minecraft.world.level.block.state.properties.SlabType
import net.minecraft.world.level.storage.loot.LootPool
import net.minecraft.world.level.storage.loot.LootTable
import net.minecraft.world.level.storage.loot.ValidationContext
import net.minecraft.world.level.storage.loot.entries.LootItem
import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity
import java.util.LinkedList
import java.util.*
import java.util.function.BiConsumer
import java.util.function.Consumer
import java.util.function.Supplier
@ -72,6 +79,29 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator) {
providers.add(Pair(Supplier { provider }, LootContextParamSets.BLOCK))
}
fun createSlabItemTable(block: Block) {
provider(LootContextParamSets.BLOCK) {
it.accept(block.lootTable, LootTable.lootTable().withPool(
LootPool.lootPool().setRolls(ConstantValue.exactly(1.0f)).add(
LootItem.lootTableItem(block).apply(
SetItemCountFunction.setCount(
ConstantValue.exactly(2.0f)
).`when`(
LootItemBlockStatePropertyCondition.hasBlockStateProperties(block).setProperties(
StatePropertiesPredicate.Builder.properties()
.hasProperty(SlabBlock.TYPE, SlabType.DOUBLE)
)
)
)
)
))
}
}
fun createSlabItemTable(block: Collection<Block>) {
block.forEach(this::createSlabItemTable)
}
fun blockSimple(block: Block, provider: (LootPool.Builder) -> Unit) {
block {
it.accept(block.lootTable, singleLootPool(provider::invoke))

View File

@ -33,17 +33,24 @@ fun addLootTables(lootTables: LootTables) {
lootTables.dropsSelf(MRegistry.INDUSTRIAL_GLASS.allBlocks.values)
lootTables.dropsSelf(MRegistry.INDUSTRIAL_GLASS_PANE.allBlocks.values)
lootTables.dropsSelf(MRegistry.TRITANIUM_BLOCK.allBlocks.values)
lootTables.dropsSelf(MRegistry.TRITANIUM_WALL.allBlocks.values)
lootTables.dropsSelf(MRegistry.TRITANIUM_STAIRS.allBlocks.values)
lootTables.createSlabItemTable(MRegistry.TRITANIUM_SLAB.allBlocks.values)
lootTables.dropsSelf(MRegistry.VENT.allBlocks.values)
lootTables.dropsSelf(MRegistry.VENT_ALTERNATIVE.allBlocks.values)
lootTables.dropsSelf(MRegistry.FLOOR_TILES.blocks.values)
lootTables.dropsSelf(MRegistry.UNREFINED_FLOOR_TILES.blocks.values)
lootTables.dropsSelf(MRegistry.TRITANIUM_STRIPED_BLOCK.flatBlocks)
lootTables.dropsSelf(MRegistry.TRITANIUM_STRIPED_STAIRS.flatBlocks)
lootTables.dropsSelf(MRegistry.TRITANIUM_STRIPED_WALL.flatBlocks)
lootTables.createSlabItemTable(MRegistry.TRITANIUM_STRIPED_SLAB.flatBlocks)
lootTables.dropsSelf(MBlocks.CARBON_FIBRE_BLOCK)
lootTables.dropsSelf(MBlocks.TRITANIUM_RAW_BLOCK)
lootTables.dropsSelf(MBlocks.TRITANIUM_STRIPED_BLOCK)
lootTables.dropsSelf(MBlocks.TRITANIUM_STRIPED_WALL)
lootTables.dropsSelf(MBlocks.TRITANIUM_STRIPED_STAIRS)
lootTables.createSlabItemTable(MBlocks.TRITANIUM_STRIPED_SLAB)
lootTables.dropsSelf(MBlocks.MATTER_CABLE)
lootTables.dropsSelf(MBlocks.GRAVITATION_STABILIZER)
lootTables.dropsOther(MBlocks.GRAVITATION_STABILIZER_LENS, MBlocks.GRAVITATION_STABILIZER)

View File

@ -27,6 +27,21 @@ private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer<Finished
.build(consumer)
}
private fun slab(base: ItemLike, result: ItemLike, consumer: Consumer<FinishedRecipe>) {
MatteryRecipe(result, 6)
.row(base, base, base)
.unlockedBy(base)
.build(consumer)
}
private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer<FinishedRecipe>) {
MatteryRecipe(result, 6)
.row(base, base, base)
.row(base, base, base)
.unlockedBy(base)
.build(consumer)
}
fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer<FinishedRecipe>) {
// Напольная плитка
for ((color, unrefinedItem) in MRegistry.UNREFINED_FLOOR_TILES.items) {
@ -49,14 +64,20 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer<Fi
for ((color, item) in MRegistry.TRITANIUM_BLOCK.allItems) {
stairs(item, MRegistry.TRITANIUM_STAIRS.allItems[color]!!, consumer)
slab(item, MRegistry.TRITANIUM_SLAB.allItems[color]!!, consumer)
wall(item, MRegistry.TRITANIUM_WALL.allItems[color]!!, consumer)
}
for ((item, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.itemsWithColor) {
val (a, b) = colors
stairs(item, MRegistry.TRITANIUM_STRIPED_STAIRS.getItem(a, b), consumer)
slab(item, MRegistry.TRITANIUM_STRIPED_SLAB.getItem(a, b), consumer)
wall(item, MRegistry.TRITANIUM_STRIPED_WALL.getItem(a, b), consumer)
}
stairs(MItems.TRITANIUM_STRIPED_BLOCK, MItems.TRITANIUM_STRIPED_STAIRS, consumer)
slab(MItems.TRITANIUM_STRIPED_BLOCK, MItems.TRITANIUM_STRIPED_SLAB, consumer)
wall(MItems.TRITANIUM_STRIPED_BLOCK, MItems.TRITANIUM_STRIPED_WALL, consumer)
for ((item, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.itemsWithColor) {
val (base, stripe) = colors

View File

@ -75,6 +75,26 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.items.appender(MItemTags.MACHINES).add(MItems.MACHINES)
tagsProvider.blocks.appender(MBlockTags.MACHINES).add(MItems.MACHINES.stream().map { it as? BlockItem }.filter { it != null }.map { it!!.block })
tagsProvider.blocks.appender(BlockTags.SLABS)
.add(MRegistry.TRITANIUM_SLAB.allBlocks.values)
.add(MRegistry.TRITANIUM_STRIPED_SLAB.flatBlocks)
.add(MBlocks.TRITANIUM_STRIPED_SLAB)
tagsProvider.blocks.appender(BlockTags.WALLS)
.add(MRegistry.TRITANIUM_WALL.allBlocks.values)
.add(MRegistry.TRITANIUM_STRIPED_WALL.flatBlocks)
.add(MBlocks.TRITANIUM_STRIPED_WALL)
tagsProvider.items.appender(ItemTags.SLABS)
.add(MRegistry.TRITANIUM_SLAB.allItems.values)
.add(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems)
.add(MItems.TRITANIUM_STRIPED_SLAB)
tagsProvider.items.appender(ItemTags.WALLS)
.add(MRegistry.TRITANIUM_WALL.allItems.values)
.add(MRegistry.TRITANIUM_STRIPED_WALL.flatItems)
.add(MItems.TRITANIUM_STRIPED_WALL)
tagsProvider.requiresPickaxe(listOf(
MBlocks.ANDROID_STATION,
MBlocks.BATTERY_BANK,
@ -114,6 +134,8 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_STRIPED_BLOCK, Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_STRIPED_STAIRS, Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_STRIPED_WALL, Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_STRIPED_SLAB, Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.CARBON_FIBRE_BLOCK, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.CARGO_CRATES.allBlocks.values, Tiers.IRON)
@ -121,9 +143,13 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.requiresPickaxe(MRegistry.VENT.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.VENT_ALTERNATIVE.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_BLOCK.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_SLAB.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_WALL.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STAIRS.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_BLOCK.flatBlocks, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_STAIRS.flatBlocks, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_WALL.flatBlocks, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_SLAB.flatBlocks, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.FLOOR_TILES.blocks.values)
tagsProvider.requiresShovel(MRegistry.UNREFINED_FLOOR_TILES.blocks.values)

View File

@ -17,17 +17,17 @@ import java.util.stream.Stream
import net.minecraft.data.tags.TagsProvider as MinecraftTagsProvider
interface MTagAppender<T> {
fun add(value: T): TagsProvider
fun add(value: T): MTagAppender<T>
fun addSafe(value: T): Boolean
fun add(vararg values: T): TagsProvider
fun add(vararg values: T): MTagAppender<T>
fun addSafe(vararg values: T): Boolean {
var any = false
for (value in values) any = addSafe(value)
return any
}
fun add(values: Collection<T>): TagsProvider
fun add(values: Stream<out T>): TagsProvider = add(values.toList())
fun add(values: Collection<T>): MTagAppender<T>
fun add(values: Stream<out T>): MTagAppender<T> = add(values.toList())
fun addSafe(values: Collection<T>): Boolean {
var any = false
@ -37,16 +37,16 @@ interface MTagAppender<T> {
}
interface ForgeTagAppender<T> : MTagAppender<T> {
fun add(key: String, value: T): TagsProvider
fun add(key: String, value: T): MTagAppender<T>
fun addSafe(key: String, value: T): Boolean
fun add(key: String, vararg values: T): TagsProvider
fun add(key: String, vararg values: T): MTagAppender<T>
fun addSafe(key: String, vararg values: T): Boolean {
var any = false
for (value in values) any = addSafe(key, value)
return any
}
fun add(key: String, values: Collection<T>): TagsProvider
fun add(key: String, values: Collection<T>): MTagAppender<T>
fun addSafe(key: String, values: Collection<T>): Boolean {
var any = false
@ -89,26 +89,26 @@ class TagsProvider(
val list = getSet(tag)
return object : MTagAppender<T> {
override fun add(value: T): TagsProvider {
override fun add(value: T): MTagAppender<T> {
if (!list.add(value)) {
throw IllegalStateException(message.invoke(value).toString())
}
return this@TagsProvider
return this
}
override fun add(values: Collection<T>): TagsProvider {
override fun add(values: Collection<T>): MTagAppender<T> {
for (value in values) add(value)
return this@TagsProvider
return this
}
override fun addSafe(value: T): Boolean {
return list.add(value)
}
override fun add(vararg values: T): TagsProvider {
override fun add(vararg values: T): MTagAppender<T> {
values.forEach(this::add)
return this@TagsProvider
return this
}
}
}
@ -117,14 +117,14 @@ class TagsProvider(
val parent by lazy { appender(ResourceLocation("forge", path)) }
return object : ForgeTagAppender<T> {
override fun add(key: String, value: T): TagsProvider {
override fun add(key: String, value: T): MTagAppender<T> {
val tag = TagKey.create(registry.key(), ResourceLocation("forge", "$path/$key"))
if (!getSet(tag).add(value)) {
throw IllegalStateException("$value is already in $tag")
}
return this@TagsProvider
return this
}
override fun addSafe(key: String, value: T): Boolean {
@ -132,17 +132,17 @@ class TagsProvider(
return getSet(tag).add(value)
}
override fun add(key: String, vararg values: T): TagsProvider {
override fun add(key: String, vararg values: T): MTagAppender<T> {
for (value in values) add(key, value)
return this@TagsProvider
return this
}
override fun add(key: String, values: Collection<T>): TagsProvider {
override fun add(key: String, values: Collection<T>): MTagAppender<T> {
for (value in values) add(key, value)
return this@TagsProvider
return this
}
override fun add(value: T): TagsProvider {
override fun add(value: T): MTagAppender<T> {
return parent.add(value)
}
@ -150,11 +150,11 @@ class TagsProvider(
return parent.addSafe(value)
}
override fun add(vararg values: T): TagsProvider {
override fun add(vararg values: T): MTagAppender<T> {
return parent.add(*values)
}
override fun add(values: Collection<T>): TagsProvider {
override fun add(values: Collection<T>): MTagAppender<T> {
return parent.add(values)
}
}

View File

@ -10,9 +10,11 @@ import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.DoorBlock
import net.minecraft.world.level.block.DropExperienceBlock
import net.minecraft.world.level.block.SlabBlock
import net.minecraft.world.level.block.SoundType
import net.minecraft.world.level.block.StairBlock
import net.minecraft.world.level.block.TrapDoorBlock
import net.minecraft.world.level.block.WallBlock
import net.minecraft.world.level.block.state.BlockBehaviour
import net.minecraft.world.level.material.Material
import net.minecraft.world.level.material.MaterialColor
@ -160,6 +162,8 @@ object MBlocks {
MRegistry.CARGO_CRATES.registerBlocks(registry)
MRegistry.TRITANIUM_BLOCK.registerBlocks(registry)
MRegistry.TRITANIUM_STAIRS.registerBlocks(registry)
MRegistry.TRITANIUM_SLAB.registerBlocks(registry)
MRegistry.TRITANIUM_WALL.registerBlocks(registry)
}
val TRITANIUM_STRIPED_BLOCK: Block by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { Block(
@ -172,13 +176,17 @@ object MBlocks {
val TRITANIUM_STRIPED_STAIRS: Block by registry.register(MNames.TRITANIUM_STRIPED_STAIRS) { StairBlock(
{ TRITANIUM_STRIPED_BLOCK.defaultBlockState() },
BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT)
.requiresCorrectToolForDrops()
.explosionResistance(80f)
.strength(4f)
BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK)
) }
val TRITANIUM_STRIPED_SLAB: Block by registry.register(MNames.TRITANIUM_STRIPED_SLAB) {
SlabBlock(BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK))
}
val TRITANIUM_STRIPED_WALL: Block by registry.register(MNames.TRITANIUM_STRIPED_WALL) {
WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK))
}
val CARBON_FIBRE_BLOCK: Block by registry.register(MNames.CARBON_FIBRE_BLOCK) { Block(
BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT)
@ -197,5 +205,7 @@ object MBlocks {
MRegistry.DECORATIVE_CRATE.registerBlocks(registry)
MRegistry.TRITANIUM_STRIPED_BLOCK.registerBlocks(registry)
MRegistry.TRITANIUM_STRIPED_STAIRS.registerBlocks(registry)
MRegistry.TRITANIUM_STRIPED_SLAB.registerBlocks(registry)
MRegistry.TRITANIUM_STRIPED_WALL.registerBlocks(registry)
}
}

View File

@ -333,10 +333,14 @@ object MItems {
MRegistry.CARGO_CRATES.registerItems(registry)
MRegistry.TRITANIUM_BLOCK.registerItems(registry)
MRegistry.TRITANIUM_STAIRS.registerItems(registry)
MRegistry.TRITANIUM_SLAB.registerItems(registry)
MRegistry.TRITANIUM_WALL.registerItems(registry)
}
val TRITANIUM_STRIPED_BLOCK: Item by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { BlockItem(MBlocks.TRITANIUM_STRIPED_BLOCK, DEFAULT_PROPERTIES_DECORATIVE) }
val TRITANIUM_STRIPED_STAIRS: Item by registry.register(MNames.TRITANIUM_STRIPED_STAIRS) { BlockItem(MBlocks.TRITANIUM_STRIPED_STAIRS, DEFAULT_PROPERTIES_DECORATIVE) }
val TRITANIUM_STRIPED_SLAB: Item by registry.register(MNames.TRITANIUM_STRIPED_SLAB) { BlockItem(MBlocks.TRITANIUM_STRIPED_SLAB, DEFAULT_PROPERTIES_DECORATIVE) }
val TRITANIUM_STRIPED_WALL: Item by registry.register(MNames.TRITANIUM_STRIPED_WALL) { BlockItem(MBlocks.TRITANIUM_STRIPED_WALL, DEFAULT_PROPERTIES_DECORATIVE) }
val CARBON_FIBRE_BLOCK: Item by registry.register(MNames.CARBON_FIBRE_BLOCK) { BlockItem(MBlocks.CARBON_FIBRE_BLOCK, DEFAULT_PROPERTIES_DECORATIVE) }
init {
@ -349,5 +353,7 @@ object MItems {
MRegistry.DECORATIVE_CRATE.registerItems(registry)
MRegistry.TRITANIUM_STRIPED_BLOCK.registerItems(registry)
MRegistry.TRITANIUM_STRIPED_STAIRS.registerItems(registry)
MRegistry.TRITANIUM_STRIPED_SLAB.registerItems(registry)
MRegistry.TRITANIUM_STRIPED_WALL.registerItems(registry)
}
}

View File

@ -52,8 +52,12 @@ object MNames {
// building blocks
const val TRITANIUM_BLOCK = "tritanium_block"
const val TRITANIUM_STAIRS = "tritanium_stairs"
const val TRITANIUM_SLAB = "tritanium_slab"
const val TRITANIUM_WALL = "tritanium_wall"
const val TRITANIUM_STRIPED_BLOCK = "tritanium_striped_block"
const val TRITANIUM_STRIPED_STAIRS = "tritanium_striped_stairs"
const val TRITANIUM_STRIPED_SLAB = "tritanium_striped_slab"
const val TRITANIUM_STRIPED_WALL = "tritanium_striped_wall"
const val INDUSTRIAL_GLASS = "industrial_glass"
const val INDUSTRIAL_GLASS_PANE = "industrial_glass_pane"

View File

@ -138,14 +138,18 @@ object MRegistry {
val TRITANIUM_STAIRS = DecorativeBlock(MNames.TRITANIUM_STAIRS, {
StairBlock(
{ TRITANIUM_BLOCK.allBlocks[it]!!.defaultBlockState() },
BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT)
.requiresCorrectToolForDrops()
.explosionResistance(80f)
.destroyTime(2.5f)
BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!)
)
})
val TRITANIUM_SLAB = DecorativeBlock(MNames.TRITANIUM_SLAB, {
SlabBlock(BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!))
})
val TRITANIUM_WALL = DecorativeBlock(MNames.TRITANIUM_WALL, {
WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!))
})
val VENT = DecorativeBlock.simple(MNames.VENT, {
BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT)
@ -251,11 +255,15 @@ object MRegistry {
})
val TRITANIUM_STRIPED_STAIRS = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_STAIRS, { colorA, colorB ->
StairBlock({ TRITANIUM_STRIPED_BLOCK.getBlock(colorA, colorB).defaultBlockState() }, BlockBehaviour.Properties.of(Material.METAL, colorA.materialColor)
.sound(SoundType.BASALT)
.requiresCorrectToolForDrops()
.explosionResistance(80f)
.strength(4f))
StairBlock({ TRITANIUM_STRIPED_BLOCK.getBlock(colorA, colorB).defaultBlockState() }, BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK.getBlock(colorA, colorB)))
})
val TRITANIUM_STRIPED_SLAB = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_SLAB, { colorA, colorB ->
SlabBlock(BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK.getBlock(colorA, colorB)))
})
val TRITANIUM_STRIPED_WALL = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_WALL, { colorA, colorB ->
WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK.getBlock(colorA, colorB)))
})
fun initialize(bus: IEventBus) {

View File

@ -90,7 +90,7 @@ class StripedColoredDecorativeBlock(
}
mapItems.computeIfAbsent(base) { EnumMap(DyeColor::class.java) }
.put(stripe, registry.register("${basename}_${base.name.lowercase()}_${stripe.name.lowercase()}") { itemFactory.invoke(base, stripe, mapBlocks.get(base)!!.get(stripe)!!.get()) })
.put(stripe, registry.register("${basename}_${base.name.lowercase()}_${stripe.name.lowercase()}".intern()) { itemFactory.invoke(base, stripe, mapBlocks.get(base)!!.get(stripe)!!.get()) })
}
}
@ -105,7 +105,7 @@ class StripedColoredDecorativeBlock(
}
mapBlocks.computeIfAbsent(base) { EnumMap(DyeColor::class.java) }
.put(stripe, registry.register("${basename}_${base.name.lowercase()}_${stripe.name.lowercase()}") { blockFactory.invoke(base, stripe) })
.put(stripe, registry.register("${basename}_${base.name.lowercase()}_${stripe.name.lowercase()}".intern()) { blockFactory.invoke(base, stripe) })
}
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"particle": "#wall"
},
"elements": [
{ "from": [ 4, 0, 4 ],
"to": [ 12, 16, 12 ],
"faces": {
"down": { "texture": "#wall", "cullface": "down" },
"up": { "texture": "#wall", "cullface": "up" },
"north": { "texture": "#wall_side" },
"south": { "texture": "#wall_side" },
"west": { "texture": "#wall_side" },
"east": { "texture": "#wall_side" }
},
"__comment": "Center post"
}
]
}

View File

@ -0,0 +1,18 @@
{
"textures": {
"particle": "#wall"
},
"elements": [
{ "from": [ 5, 0, 0 ],
"to": [ 11, 14, 8 ],
"faces": {
"down": { "texture": "#wall", "cullface": "down" },
"up": { "texture": "#wall" },
"north": { "texture": "#wall_side", "cullface": "north" },
"west": { "texture": "#wall_side" },
"east": { "texture": "#wall_side" }
},
"__comment": "wall"
}
]
}

View File

@ -0,0 +1,17 @@
{
"textures": {
"particle": "#wall"
},
"elements": [
{ "from": [ 5, 0, 0 ],
"to": [ 11, 16, 8 ],
"faces": {
"down": { "texture": "#wall", "cullface": "down" },
"up": { "texture": "#wall", "cullface": "up"},
"north": { "texture": "#wall_side", "cullface": "north" },
"west": { "texture": "#wall_side" },
"east": { "texture": "#wall_side" }
}
}
]
}

View File

@ -0,0 +1,44 @@
{ "parent": "block/block",
"display": {
"gui": {
"rotation": [ 30, 135, 0 ],
"translation": [ 0, 0, 0],
"scale":[ 0.625, 0.625, 0.625 ]
},
"fixed": {
"rotation": [ 0, 90, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.5, 0.5, 0.5 ]
}
},
"ambientocclusion": false,
"textures": {
"particle": "#wall"
},
"elements": [
{ "from": [ 4, 0, 4 ],
"to": [ 12, 16, 12 ],
"faces": {
"down": { "uv": [ 4, 4, 12, 12 ], "texture": "#wall", "cullface": "down" },
"up": { "uv": [ 4, 4, 12, 12 ], "texture": "#wall" },
"north": { "uv": [ 4, 0, 12, 16 ], "texture": "#wall_side" },
"south": { "uv": [ 4, 0, 12, 16 ], "texture": "#wall_side" },
"west": { "uv": [ 4, 0, 12, 16 ], "texture": "#wall_side" },
"east": { "uv": [ 4, 0, 12, 16 ], "texture": "#wall_side" }
},
"__comment": "Center post"
},
{ "from": [ 5, 0, 0 ],
"to": [ 11, 13, 16 ],
"faces": {
"down": { "uv": [ 5, 0, 11, 16 ], "texture": "#wall", "cullface": "down" },
"up": { "uv": [ 5, 0, 11, 16 ], "texture": "#wall" },
"north": { "uv": [ 5, 3, 11, 16 ], "texture": "#wall_side", "cullface": "north" },
"south": { "uv": [ 5, 3, 11, 16 ], "texture": "#wall_side", "cullface": "south" },
"west": { "uv": [ 0, 3, 16, 16 ], "texture": "#wall_side" },
"east": { "uv": [ 0, 3, 16, 16 ], "texture": "#wall_side" }
},
"__comment": "Full wall"
}
]
}