Matter capacitor bank datagen
This commit is contained in:
parent
8cb915aad8
commit
a5b0091522
@ -1,23 +1,11 @@
|
|||||||
package ru.dbotthepony.mc.otm.datagen
|
package ru.dbotthepony.mc.otm.datagen
|
||||||
|
|
||||||
import net.minecraft.core.Direction
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
import net.minecraftforge.client.model.generators.BlockStateProvider
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent
|
import net.minecraftforge.eventbus.api.SubscribeEvent
|
||||||
import net.minecraftforge.fml.common.Mod
|
import net.minecraftforge.fml.common.Mod
|
||||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent
|
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.Registry
|
import ru.dbotthepony.mc.otm.datagen.blocks.BatteryBankProvider
|
||||||
import ru.dbotthepony.mc.otm.block.BlockBatteryBank
|
import ru.dbotthepony.mc.otm.datagen.blocks.MatterBankProvider
|
||||||
import ru.dbotthepony.mc.otm.block.BlockMatteryRotatable
|
|
||||||
import ru.dbotthepony.mc.otm.toYRotBlockstate
|
|
||||||
|
|
||||||
fun nothingOrNumber(input: Int): String {
|
|
||||||
if (input == 0)
|
|
||||||
return ""
|
|
||||||
|
|
||||||
return (input - 1).toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = DataGen.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(modid = DataGen.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
object DataGen {
|
object DataGen {
|
||||||
@ -25,33 +13,9 @@ object DataGen {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@Suppress("unused")
|
||||||
fun onGatherData(event: GatherDataEvent) {
|
fun onGatherData(event: GatherDataEvent) {
|
||||||
event.generator.addProvider(object : BlockStateProvider(event.generator, MOD_ID, event.existingFileHelper) {
|
event.generator.addProvider(MatterBankProvider(event))
|
||||||
override fun registerStatesAndModels() {
|
event.generator.addProvider(BatteryBankProvider(event))
|
||||||
with(getMultipartBuilder(Registry.Blocks.BATTERY_BANK)) {
|
|
||||||
val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/battery_bank"))
|
|
||||||
|
|
||||||
BlockMatteryRotatable.FACING.possibleValues.forEach {
|
|
||||||
part().modelFile(battery_bank).rotationY(it.toYRotBlockstate()).addModel().condition(BlockMatteryRotatable.FACING, it)
|
|
||||||
|
|
||||||
for (i in 0 .. 5) {
|
|
||||||
part().modelFile(
|
|
||||||
models().getExistingFile(ResourceLocation("overdrive_that_matters:block/battery/battery_front${nothingOrNumber(i)}"))
|
|
||||||
).rotationY(it.toYRotBlockstate()).addModel()
|
|
||||||
.condition(BlockMatteryRotatable.FACING, it)
|
|
||||||
.condition(BlockBatteryBank.BATTERY_SLOTS_PROPS[i], true)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i in 6 .. 11) {
|
|
||||||
part().modelFile(
|
|
||||||
models().getExistingFile(ResourceLocation("overdrive_that_matters:block/battery/battery_back${nothingOrNumber(i - 6)}"))
|
|
||||||
).rotationY(it.toYRotBlockstate()).addModel()
|
|
||||||
.condition(BlockMatteryRotatable.FACING, it)
|
|
||||||
.condition(BlockBatteryBank.BATTERY_SLOTS_PROPS[i], true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm
|
package ru.dbotthepony.mc.otm.datagen
|
||||||
|
|
||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.datagen.blocks
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.world.level.block.Block
|
||||||
|
import net.minecraftforge.client.model.generators.BlockStateProvider
|
||||||
|
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent
|
||||||
|
import ru.dbotthepony.mc.otm.Registry
|
||||||
|
import ru.dbotthepony.mc.otm.block.BlockBatteryBank
|
||||||
|
import ru.dbotthepony.mc.otm.block.BlockMatteryRotatable
|
||||||
|
import ru.dbotthepony.mc.otm.datagen.DataGen
|
||||||
|
import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate
|
||||||
|
|
||||||
|
private fun nothingOrNumber(input: Int): String {
|
||||||
|
if (input == 0)
|
||||||
|
return ""
|
||||||
|
|
||||||
|
return (input - 1).toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) {
|
||||||
|
protected var block = "battery_bank"
|
||||||
|
protected var batteryPath = "block/battery/battery_front"
|
||||||
|
protected var mainline = true
|
||||||
|
protected var registry: Block = Registry.Blocks.BATTERY_BANK
|
||||||
|
|
||||||
|
override fun registerStatesAndModels() {
|
||||||
|
with(getMultipartBuilder(registry)) {
|
||||||
|
val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block"))
|
||||||
|
|
||||||
|
BlockMatteryRotatable.FACING.possibleValues.forEach {
|
||||||
|
part().modelFile(battery_bank).rotationY(it.toYRotBlockstate()).addModel().condition(
|
||||||
|
BlockMatteryRotatable.FACING, it)
|
||||||
|
|
||||||
|
if (mainline) {
|
||||||
|
for (i in 0 .. 5) {
|
||||||
|
part().modelFile(
|
||||||
|
models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath${nothingOrNumber(i)}"))
|
||||||
|
).rotationY(it.toYRotBlockstate()).addModel()
|
||||||
|
.condition(BlockMatteryRotatable.FACING, it)
|
||||||
|
.condition(BlockBatteryBank.BATTERY_SLOTS_PROPS[i], true)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i in 6 .. 11) {
|
||||||
|
part().modelFile(
|
||||||
|
models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath${nothingOrNumber(i - 6)}"))
|
||||||
|
).rotationY(it.toYRotBlockstate()).addModel()
|
||||||
|
.condition(BlockMatteryRotatable.FACING, it)
|
||||||
|
.condition(BlockBatteryBank.BATTERY_SLOTS_PROPS[i], true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i in 0 .. 11) {
|
||||||
|
part().modelFile(
|
||||||
|
models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath$i"))
|
||||||
|
).rotationY(it.toYRotBlockstate()).addModel()
|
||||||
|
.condition(BlockMatteryRotatable.FACING, it)
|
||||||
|
.condition(BlockBatteryBank.BATTERY_SLOTS_PROPS[i], true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MatterBankProvider(event: GatherDataEvent) : BatteryBankProvider(event) {
|
||||||
|
init {
|
||||||
|
block = "matter_capacitor_bank"
|
||||||
|
batteryPath = "block/battery/matter_capacitor"
|
||||||
|
mainline = false
|
||||||
|
registry = Registry.Blocks.MATTER_CAPACITOR_BANK
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user