Tritanium doors

This commit is contained in:
DBotThePony 2022-09-29 16:28:38 +07:00
parent ec50b7f6ef
commit fc74241f39
Signed by: DBot
GPG Key ID: DCC23B5715498507
10 changed files with 195 additions and 47 deletions

View File

@ -1,9 +1,13 @@
package ru.dbotthepony.mc.otm.datagen
import net.minecraft.core.Direction
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.state.properties.BlockStateProperties
import net.minecraft.world.level.block.state.properties.DoorHingeSide
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf
import net.minecraftforge.client.model.generators.ConfiguredModel
import net.minecraftforge.client.model.generators.ModelFile
import net.minecraftforge.eventbus.api.SubscribeEvent
@ -31,6 +35,7 @@ import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider
import ru.dbotthepony.mc.otm.datagen.loot.addLootModifiers
import ru.dbotthepony.mc.otm.datagen.loot.addLootTables
import ru.dbotthepony.mc.otm.datagen.models.MatteryModelBuilder
import ru.dbotthepony.mc.otm.datagen.models.addBlockModels
import ru.dbotthepony.mc.otm.datagen.recipes.addBlastingRecipes
import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes
import ru.dbotthepony.mc.otm.datagen.recipes.addDecorativesRecipes
@ -118,19 +123,106 @@ object DataGen {
}
}
@Suppress("name_shadowing")
blockStateProvider.exec {
check(mdl_post != null) { "DataGen execution order is screwed lmaooooooo" }
val mdl_post = checkNotNull(mdl_post) { "mdl_post is null" }
val mdl_side = checkNotNull(mdl_side) { "mdl_side is null" }
val mdl_side_alt = checkNotNull(mdl_side_alt) { "mdl_side_alt is null" }
val mdl_noside = checkNotNull(mdl_noside) { "mdl_noside is null" }
val mdl_noside_alt = checkNotNull(mdl_noside_alt) { "mdl_noside_alt is null" }
with(blockStateProvider.getMultipartBuilder(block)) {
part().modelFile(mdl_post!!).addModel()
part().modelFile(mdl_side!!).addModel().condition(IronBarsBlock.NORTH, true)
part().modelFile(mdl_side!!).rotationY(90).addModel().condition(IronBarsBlock.EAST, true)
part().modelFile(mdl_side_alt!!).addModel().condition(IronBarsBlock.SOUTH, true)
part().modelFile(mdl_side_alt!!).rotationY(90).addModel().condition(IronBarsBlock.WEST, true)
part().modelFile(mdl_noside!!).addModel().condition(IronBarsBlock.NORTH, false)
part().modelFile(mdl_noside!!).rotationY(270).addModel().condition(IronBarsBlock.WEST, false)
part().modelFile(mdl_noside_alt!!).addModel().condition(IronBarsBlock.EAST, false)
part().modelFile(mdl_noside_alt!!).rotationY(90).addModel().condition(IronBarsBlock.SOUTH, false)
part().modelFile(mdl_post).addModel()
part().modelFile(mdl_side).addModel().condition(IronBarsBlock.NORTH, true)
part().modelFile(mdl_side).rotationY(90).addModel().condition(IronBarsBlock.EAST, true)
part().modelFile(mdl_side_alt).addModel().condition(IronBarsBlock.SOUTH, true)
part().modelFile(mdl_side_alt).rotationY(90).addModel().condition(IronBarsBlock.WEST, true)
part().modelFile(mdl_noside).addModel().condition(IronBarsBlock.NORTH, false)
part().modelFile(mdl_noside).rotationY(270).addModel().condition(IronBarsBlock.WEST, false)
part().modelFile(mdl_noside_alt).addModel().condition(IronBarsBlock.EAST, false)
part().modelFile(mdl_noside_alt).rotationY(90).addModel().condition(IronBarsBlock.SOUTH, false)
}
}
}
fun door(block: Block, textureTop: ResourceLocation, textureBottom: ResourceLocation) {
var doorBottomLeft: ModelFile? = null
var doorBottomLeftOpen: ModelFile? = null
var doorBottomRight: ModelFile? = null
var doorBottomRightOpen: ModelFile? = null
var doorTopLeft: ModelFile? = null
var doorTopLeftOpen: ModelFile? = null
var doorTopRight: ModelFile? = null
var doorTopRightOpen: ModelFile? = null
val doorBottomLeftName = "${block.registryName!!.path}_bl"
val doorBottomLeftOpenName = "${block.registryName!!.path}_blo"
val doorBottomRightName = "${block.registryName!!.path}_br"
val doorBottomRightOpenName = "${block.registryName!!.path}_bro"
val doorTopLeftName = "${block.registryName!!.path}_tl"
val doorTopLeftOpenName = "${block.registryName!!.path}_tlo"
val doorTopRightName = "${block.registryName!!.path}_tr"
val doorTopRightOpenName = "${block.registryName!!.path}_tro"
blockModelProvider.exec {
doorBottomLeft = it.doorBottomLeft(doorBottomLeftName, textureBottom, textureTop).renderType("cutout")
doorBottomLeftOpen = it.doorBottomLeftOpen(doorBottomLeftOpenName, textureBottom, textureTop).renderType("cutout")
doorBottomRight = it.doorBottomRight(doorBottomRightName, textureBottom, textureTop).renderType("cutout")
doorBottomRightOpen = it.doorBottomRightOpen(doorBottomRightOpenName, textureBottom, textureTop).renderType("cutout")
doorTopLeft = it.doorTopLeft(doorTopLeftName, textureBottom, textureTop).renderType("cutout")
doorTopLeftOpen = it.doorTopLeftOpen(doorTopLeftOpenName, textureBottom, textureTop).renderType("cutout")
doorTopRight = it.doorTopRight(doorTopRightName, textureBottom, textureTop).renderType("cutout")
doorTopRightOpen = it.doorTopRightOpen(doorTopRightOpenName, textureBottom, textureTop).renderType("cutout")
}
@Suppress("name_shadowing")
blockStateProvider.exec {
val doorBottomLeft = checkNotNull(doorBottomLeft) { "doorBottomLeft is null" }
val doorBottomLeftOpen = checkNotNull(doorBottomLeftOpen) { "doorBottomLeftOpen is null" }
val doorBottomRight = checkNotNull(doorBottomRight) { "doorBottomRight is null" }
val doorBottomRightOpen = checkNotNull(doorBottomRightOpen) { "doorBottomRightOpen is null" }
val doorTopLeft = checkNotNull(doorTopLeft) { "doorTopLeft is null" }
val doorTopLeftOpen = checkNotNull(doorTopLeftOpen) { "doorTopLeftOpen is null" }
val doorTopRight = checkNotNull(doorTopRight) { "doorTopRight is null" }
val doorTopRightOpen = checkNotNull(doorTopRightOpen) { "doorTopRightOpen is null" }
with(blockStateProvider.getMultipartBuilder(block)) {
for (facing in DoorBlock.FACING.possibleValues) {
for (hinge in DoorBlock.HINGE.possibleValues) {
for (open in listOf(false, true)) {
for (half in DoorBlock.HALF.possibleValues) {
part().modelFile(
when (half!!) {
DoubleBlockHalf.UPPER -> {
when (hinge!!) {
DoorHingeSide.LEFT -> if (open) doorTopLeftOpen else doorTopLeft
DoorHingeSide.RIGHT -> if (open) doorTopRightOpen else doorTopRight
}
}
DoubleBlockHalf.LOWER -> {
when (hinge!!) {
DoorHingeSide.LEFT -> if (open) doorBottomLeftOpen else doorBottomLeft
DoorHingeSide.RIGHT -> if (open) doorBottomRightOpen else doorBottomRight
}
}
}
).rotationY(
facing.toYRotBlockstate() - 90 +
(if (open) when (hinge) {
DoorHingeSide.LEFT -> 90
DoorHingeSide.RIGHT -> -90
} else 0)
).addModel()
.condition(DoorBlock.FACING, facing)
.condition(DoorBlock.HINGE, hinge)
.condition(DoorBlock.OPEN, open)
.condition(DoorBlock.HALF, half)
.end()
}
}
}
}
}
}
}
@ -232,36 +324,8 @@ object DataGen {
AddEnglishLanguage(languageProvider)
blockModelProvider.resourceCubeAll(MBlocks.TRITANIUM_ORE)
blockModelProvider.resourceCubeAll(MBlocks.TRITANIUM_RAW_BLOCK)
blockModelProvider.resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE)
with(blockModelProvider) {
exec {
copy("block/battery/battery1", "block/battery/battery0").also { it.offset(-4f, 0f, 0f) }
copy("block/battery/battery2", "block/battery/battery0").also { it.offset(-8f, 0f, 0f) }
copy("block/battery/battery3", "block/battery/battery0").also { it.offset(0f, 6f, 0f) }
copy("block/battery/battery4", "block/battery/battery0").also { it.offset(-4f, 6f, 0f) }
copy("block/battery/battery5", "block/battery/battery0").also { it.offset(-8f, 6f, 0f) }
copy("block/battery/battery7", "block/battery/battery6").also { it.offset(4f, 0f, 0f) }
copy("block/battery/battery8", "block/battery/battery6").also { it.offset(8f, 0f, 0f) }
copy("block/battery/battery9", "block/battery/battery6").also { it.offset(0f, 6f, 0f) }
copy("block/battery/battery10", "block/battery/battery6").also { it.offset(4f, 6f, 0f) }
copy("block/battery/battery11", "block/battery/battery6").also { it.offset(8f, 6f, 0f) }
for (i in 0 .. 11) {
withExistingParent("block/battery/matter_capacitor$i", ResourceLocation(MOD_ID, "block/battery/battery$i"))
.texture("1", "block/matterybank_core")
}
for (i in 1 .. 7) {
copy("block/pattern/model$i", "block/pattern/model0").also { it.offset(-2f * i, 0f, 0f) }
}
}
}
door(MBlocks.TRITANIUM_DOOR, modLocation("block/decorative/tritanium_door_top"), modLocation("block/decorative/tritanium_door_bottom"))
addBlockModels(blockModelProvider)
addDecorativeData(blockStateProvider, itemModelProvider, blockModelProvider)

View File

@ -351,6 +351,10 @@ private fun blocks(provider: MatteryLanguageProvider) {
add(MBlocks.LABORATORY_LAMP_INVERTED, "Laboratory Lamp (Inverted Signal)")
add(MBlocks.DANGER_STRIPE_BLOCK, "Danger Stripes")
add(MBlocks.METAL_BEAM, "Metal Beam")
add(MBlocks.TRITANIUM_DOOR, "Tritanium Door")
add(MBlocks.TRITANIUM_DOOR, "description0", "High blast resistance door with redstone latch...")
add(MBlocks.TRITANIUM_DOOR, "description1", "...feeling safe now?")
}
}

View File

@ -17,14 +17,15 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity
import java.util.LinkedList
import java.util.function.BiConsumer
import java.util.function.Consumer
import java.util.function.Supplier
private typealias LootBuilderCallback = BiConsumer<ResourceLocation, LootTable.Builder>
private typealias LootBuilderWorker = Consumer<LootBuilderCallback>
private typealias LootBuilderWorkerSupplier = Supplier<LootBuilderWorker>
private typealias LootTuple = Pair<LootBuilderWorkerSupplier, LootContextParamSet>
private typealias LootTableSaver = BiConsumer<ResourceLocation, LootTable.Builder>
private typealias LootTableCallback = Consumer<LootTableSaver>
private typealias LootTableCallbackProvider = Supplier<LootTableCallback>
private typealias LootTuple = Pair<LootTableCallbackProvider, LootContextParamSet>
fun singleLootPool(f: (LootPool.Builder) -> Unit): LootTable.Builder {
return LootTable.lootTable().withPool(LootPool.lootPool().also(f))
@ -59,7 +60,7 @@ private val poweredMatterWorker = arrayOf(
)
class LootTables(generator: DataGenerator) : LootTableProvider(generator) {
private val providers = ArrayList<LootTuple>()
private val providers = LinkedList<LootTuple>()
override fun getTables(): List<LootTuple> {
return providers
@ -67,8 +68,12 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator) {
override fun validate(map: MutableMap<ResourceLocation, LootTable>, validationtracker: ValidationContext) {}
fun block(provider: LootBuilderWorker) {
providers.add(Pair(Supplier {provider}, LootContextParamSets.BLOCK))
fun block(provider: LootTableCallback) {
providers.add(Pair(Supplier { provider }, LootContextParamSets.BLOCK))
}
fun provider(provider: LootTableCallback, context: LootContextParamSet) {
providers.add(Pair(Supplier { provider }, context))
}
private val seenStuff = ObjectArraySet<Any>()

View File

@ -1,5 +1,6 @@
package ru.dbotthepony.mc.otm.datagen.loot
import net.minecraft.data.loot.BlockLoot
import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity
import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY
@ -75,4 +76,8 @@ fun addLootTables(lootTables: LootTables) {
lootTables.basicTile(MBlocks.MATTER_CAPACITOR_BANK)
lootTables.poweredTile(MBlocks.MATTER_BOTTLER,
TileNbtCopy(MATTER_STORAGE_KEY), TileNbtCopy(MatterBottlerBlockEntity.IS_BOTTLING_KEY))
lootTables.block {
it.accept(MBlocks.TRITANIUM_DOOR.lootTable, BlockLoot.createDoorTable(MBlocks.TRITANIUM_DOOR))
}
}

View File

@ -0,0 +1,37 @@
package ru.dbotthepony.mc.otm.datagen.models
import net.minecraft.resources.ResourceLocation
import ru.dbotthepony.mc.otm.registry.MBlocks
fun addBlockModels(provider: MatteryBlockModelProvider) {
with(provider) {
resourceCubeAll(MBlocks.TRITANIUM_ORE)
resourceCubeAll(MBlocks.TRITANIUM_RAW_BLOCK)
resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE)
exec {
copy("block/battery/battery1", "block/battery/battery0").also { it.offset(-4f, 0f, 0f) }
copy("block/battery/battery2", "block/battery/battery0").also { it.offset(-8f, 0f, 0f) }
copy("block/battery/battery3", "block/battery/battery0").also { it.offset(0f, 6f, 0f) }
copy("block/battery/battery4", "block/battery/battery0").also { it.offset(-4f, 6f, 0f) }
copy("block/battery/battery5", "block/battery/battery0").also { it.offset(-8f, 6f, 0f) }
copy("block/battery/battery7", "block/battery/battery6").also { it.offset(4f, 0f, 0f) }
copy("block/battery/battery8", "block/battery/battery6").also { it.offset(8f, 0f, 0f) }
copy("block/battery/battery9", "block/battery/battery6").also { it.offset(0f, 6f, 0f) }
copy("block/battery/battery10", "block/battery/battery6").also { it.offset(4f, 6f, 0f) }
copy("block/battery/battery11", "block/battery/battery6").also { it.offset(8f, 6f, 0f) }
for (i in 0 .. 11) {
withExistingParent("block/battery/matter_capacitor$i", ResourceLocation(ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID, "block/battery/battery$i"))
.texture("1", "block/matterybank_core")
}
for (i in 1 .. 7) {
copy("block/pattern/model$i", "block/pattern/model0").also { it.offset(-2f * i, 0f, 0f) }
}
}
}
}

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonParser
import net.minecraft.resources.ResourceLocation
import net.minecraft.server.packs.PackType
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.DoorBlock
import net.minecraftforge.client.model.generators.ModelProvider
import net.minecraftforge.data.event.GatherDataEvent
import ru.dbotthepony.mc.otm.datagen.DataGen

View File

@ -1,5 +1,7 @@
package ru.dbotthepony.mc.otm.datagen.tags
import net.minecraft.tags.BlockTags
import net.minecraft.tags.ItemTags
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.Items
@ -62,6 +64,9 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.blocks.appender(MBlockTags.INDUSTRIAL_GLASS).add(MRegistry.INDUSTRIAL_GLASS.allBlocks.values)
tagsProvider.blocks.appender(MBlockTags.CARGO_CRATES).add(MRegistry.CARGO_CRATES.allBlocks.values)
tagsProvider.items.appender(ItemTags.DOORS).add(MItems.TRITANIUM_DOOR)
tagsProvider.blocks.appender(BlockTags.DOORS).add(MBlocks.TRITANIUM_DOOR)
tagsProvider.requiresPickaxe(listOf(
MBlocks.ANDROID_STATION,
MBlocks.BATTERY_BANK,
@ -88,6 +93,8 @@ fun addTags(tagsProvider: TagsProvider) {
MBlocks.PHANTOM_ATTRACTOR,
MBlocks.ENERGY_SERVO,
MBlocks.TRITANIUM_DOOR,
), Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ORE, Tiers.IRON)

View File

@ -1,8 +1,14 @@
package ru.dbotthepony.mc.otm.registry
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import net.minecraft.util.valueproviders.UniformInt
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag
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.SoundType
import net.minecraft.world.level.block.state.BlockBehaviour
@ -15,6 +21,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.block.*
import ru.dbotthepony.mc.otm.block.matter.*
import ru.dbotthepony.mc.otm.block.storage.*
import ru.dbotthepony.mc.otm.core.TranslatableComponent
object MBlocks {
@ -85,6 +92,20 @@ object MBlocks {
val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) }
val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) }
val TRITANIUM_DOOR: Block by registry.register(MNames.TRITANIUM_DOOR) {
object : DoorBlock(Properties.of(Material.METAL, DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) {
override fun appendHoverText(
p_49816_: ItemStack,
p_49817_: BlockGetter?,
p_49818_: MutableList<Component>,
p_49819_: TooltipFlag
) {
super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_)
p_49818_.add(TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY))
p_49818_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY))
}
} }
init {
MRegistry.CARGO_CRATES.registerBlocks(registry)
MRegistry.TRITANIUM_BLOCK.registerBlocks(registry)

View File

@ -224,6 +224,8 @@ object MItems {
val DANGER_STRIPE_BLOCK: Item by registry.register(MNames.DANGER_STRIPE_BLOCK) { BlockItem(MBlocks.DANGER_STRIPE_BLOCK, DEFAULT_PROPERTIES_DECORATIVE) }
val METAL_BEAM: Item by registry.register(MNames.METAL_BEAM) { BlockItem(MBlocks.METAL_BEAM, DEFAULT_PROPERTIES_DECORATIVE) }
val TRITANIUM_DOOR: Item by registry.register(MNames.TRITANIUM_DOOR) { DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR, DEFAULT_PROPERTIES_DECORATIVE) }
// components
val MATTER_IO_PORT: Item by registry.register(MNames.MATTER_IO_PORT) { Item(DEFAULT_PROPERTIES) }
val MATTER_TRANSFORM_MATRIX: Item by registry.register(MNames.MATTER_TRANSFORM_MATRIX) { Item(DEFAULT_PROPERTIES) }

View File

@ -225,6 +225,8 @@ object MNames {
const val PHANTOM_ATTRACTOR = "phantom_attractor"
const val JUMP_BOOST = "jump_boost"
const val TRITANIUM_DOOR = "tritanium_door"
}
object StatNames {