Datagen test
This commit is contained in:
parent
f23be0c213
commit
8cb915aad8
2
.gitignore
vendored
2
.gitignore
vendored
@ -25,6 +25,8 @@ design/
|
||||
libs/
|
||||
logs/
|
||||
|
||||
/src/data/resources
|
||||
|
||||
# Files from Forge MDK
|
||||
forge*changelog.txt
|
||||
/src/main/resources/assets/overdrive_that_matters/models/block/pattern/pattern_storage_pattern0.json
|
||||
|
27
build.gradle
27
build.gradle
@ -30,11 +30,6 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
exec {
|
||||
executable 'node'
|
||||
args 'shapenator.js'
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = ['-Xjvm-default=all']
|
||||
@ -49,6 +44,22 @@ test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
//exec {
|
||||
// executable 'node'
|
||||
// args 'shapenator.js'
|
||||
//}
|
||||
|
||||
sourceSets {
|
||||
data {
|
||||
compileClasspath += main.output
|
||||
runtimeClasspath += main.output
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
dataImplementation.extendsFrom implementation
|
||||
}
|
||||
|
||||
minecraft {
|
||||
// The mappings can be changed at any time and must be in the following format.
|
||||
// Channel: Version:
|
||||
@ -130,11 +141,11 @@ minecraft {
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
args '--mod', 'overdrive_that_matters', '--all', '--output', file('src/data/resources/'), '--existing', file('src/main/resources/')
|
||||
|
||||
mods {
|
||||
overdrive_that_matters {
|
||||
source sourceSets.main
|
||||
sources sourceSets.main, sourceSets.data
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,7 +153,7 @@ minecraft {
|
||||
}
|
||||
|
||||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
sourceSets.main.resources { srcDir 'src/data/resources' }
|
||||
|
||||
repositories {
|
||||
// Put repositories for dependencies here
|
||||
|
57
src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt
Normal file
57
src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt
Normal file
@ -0,0 +1,57 @@
|
||||
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.fml.common.Mod
|
||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
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.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)
|
||||
object DataGen {
|
||||
const val MOD_ID = OverdriveThatMatters.MOD_ID
|
||||
|
||||
@SubscribeEvent
|
||||
@JvmStatic
|
||||
fun onGatherData(event: GatherDataEvent) {
|
||||
event.generator.addProvider(object : BlockStateProvider(event.generator, MOD_ID, event.existingFileHelper) {
|
||||
override fun registerStatesAndModels() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
16
src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt
Normal file
16
src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt
Normal file
@ -0,0 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm
|
||||
|
||||
import net.minecraft.core.Direction
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
fun Direction.toYRotBlockstate(): Int {
|
||||
return when (this) {
|
||||
Direction.DOWN -> 0
|
||||
Direction.UP -> 0
|
||||
Direction.NORTH -> 0
|
||||
Direction.SOUTH -> 180
|
||||
Direction.WEST -> 270
|
||||
Direction.EAST -> 90
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user