Get rid of blockstate explosion caused by battery banks
except now they have unbaked models
This commit is contained in:
parent
81c773b228
commit
52a2e845fa
@ -20,6 +20,7 @@ import net.minecraftforge.data.event.GatherDataEvent
|
|||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidResearchDataProvider
|
import ru.dbotthepony.mc.otm.android.AndroidResearchDataProvider
|
||||||
import ru.dbotthepony.mc.otm.block.*
|
import ru.dbotthepony.mc.otm.block.*
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
||||||
import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
||||||
import ru.dbotthepony.mc.otm.datagen.blocks.BatteryBankProvider
|
import ru.dbotthepony.mc.otm.datagen.blocks.BatteryBankProvider
|
||||||
import ru.dbotthepony.mc.otm.datagen.blocks.MatterBankProvider
|
import ru.dbotthepony.mc.otm.datagen.blocks.MatterBankProvider
|
||||||
@ -272,7 +273,7 @@ object DataGen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
).rotationY(
|
).rotationY(
|
||||||
facing.toYRotBlockstate() - 90 +
|
facing.yRotationBlockstateNorth() - 90 +
|
||||||
(if (open) when (hinge) {
|
(if (open) when (hinge) {
|
||||||
DoorHingeSide.LEFT -> 90
|
DoorHingeSide.LEFT -> 90
|
||||||
DoorHingeSide.RIGHT -> -90
|
DoorHingeSide.RIGHT -> -90
|
||||||
@ -322,7 +323,7 @@ object DataGen {
|
|||||||
Half.BOTTOM -> trapdoorBottom
|
Half.BOTTOM -> trapdoorBottom
|
||||||
}
|
}
|
||||||
).rotationY(
|
).rotationY(
|
||||||
facing.toYRotBlockstate()
|
facing.yRotationBlockstateNorth()
|
||||||
).addModel()
|
).addModel()
|
||||||
.condition(TrapDoorBlock.FACING, facing)
|
.condition(TrapDoorBlock.FACING, facing)
|
||||||
.condition(TrapDoorBlock.OPEN, open)
|
.condition(TrapDoorBlock.OPEN, open)
|
||||||
|
@ -11,6 +11,8 @@ import net.minecraftforge.client.model.generators.ModelFile
|
|||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
||||||
import ru.dbotthepony.mc.otm.core.registryName
|
import ru.dbotthepony.mc.otm.core.registryName
|
||||||
import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider
|
import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider
|
||||||
import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider
|
import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider
|
||||||
@ -216,16 +218,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
|
|||||||
blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates {
|
blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates {
|
||||||
return@forAllStates ConfiguredModel.builder()
|
return@forAllStates ConfiguredModel.builder()
|
||||||
.modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!)
|
.modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!)
|
||||||
.rotationX(it[BlockRotationFreedom.TWO.property].front.toXRotBlockstate())
|
.rotationX(it[BlockRotationFreedom.TWO.property].front.xRotationBlockstateNorth())
|
||||||
.rotationY(it[BlockRotationFreedom.TWO.property].front.toYRotBlockstate())
|
.rotationY(it[BlockRotationFreedom.TWO.property].front.yRotationBlockstateNorth())
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates {
|
blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates {
|
||||||
return@forAllStates ConfiguredModel.builder()
|
return@forAllStates ConfiguredModel.builder()
|
||||||
.modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!)
|
.modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!)
|
||||||
.rotationX(it[BlockRotationFreedom.TWO.property].front.toXRotBlockstate())
|
.rotationX(it[BlockRotationFreedom.TWO.property].front.xRotationBlockstateNorth())
|
||||||
.rotationY(it[BlockRotationFreedom.TWO.property].front.toYRotBlockstate())
|
.rotationY(it[BlockRotationFreedom.TWO.property].front.yRotationBlockstateNorth())
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.datagen
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction
|
|
||||||
import net.minecraft.world.level.block.state.BlockState
|
|
||||||
import net.minecraft.world.level.block.state.properties.Property
|
|
||||||
|
|
||||||
fun Direction.toYRotBlockstate(): Int {
|
|
||||||
return when (this) {
|
|
||||||
Direction.DOWN, Direction.UP, Direction.NORTH -> 0
|
|
||||||
Direction.SOUTH -> 180
|
|
||||||
Direction.WEST -> -90
|
|
||||||
Direction.EAST -> 90
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Direction.toYRotBlockstateInv(): Int {
|
|
||||||
return when (this) {
|
|
||||||
Direction.DOWN, Direction.UP -> 0
|
|
||||||
Direction.NORTH -> 180
|
|
||||||
Direction.SOUTH -> 0
|
|
||||||
Direction.WEST -> 90
|
|
||||||
Direction.EAST -> -90
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Direction.toXRotBlockstate(): Int {
|
|
||||||
return when (this) {
|
|
||||||
Direction.DOWN -> 90
|
|
||||||
Direction.UP -> -90
|
|
||||||
Direction.NORTH -> 0
|
|
||||||
Direction.SOUTH -> 0
|
|
||||||
Direction.WEST -> 0
|
|
||||||
Direction.EAST -> 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Direction.toXRotBlockstateInv(): Int {
|
|
||||||
return when (this) {
|
|
||||||
Direction.DOWN -> -90
|
|
||||||
Direction.UP -> 90
|
|
||||||
Direction.NORTH -> 0
|
|
||||||
Direction.SOUTH -> 0
|
|
||||||
Direction.WEST -> 0
|
|
||||||
Direction.EAST -> 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T : Comparable<T>> BlockState.getValueNullable(prop: Property<T>): T? {
|
|
||||||
if (hasProperty(prop)) {
|
|
||||||
return getValue(prop)
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
@ -3,11 +3,12 @@ package ru.dbotthepony.mc.otm.datagen.blocks
|
|||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.minecraftforge.client.model.generators.BlockStateProvider
|
import net.minecraftforge.client.model.generators.BlockStateProvider
|
||||||
|
import net.minecraftforge.client.model.generators.ConfiguredModel
|
||||||
import net.minecraftforge.data.event.GatherDataEvent
|
import net.minecraftforge.data.event.GatherDataEvent
|
||||||
import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
||||||
import ru.dbotthepony.mc.otm.datagen.DataGen
|
import ru.dbotthepony.mc.otm.datagen.DataGen
|
||||||
import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate
|
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||||
|
|
||||||
private fun nothingOrNumber(input: Int): String {
|
private fun nothingOrNumber(input: Int): String {
|
||||||
@ -23,20 +24,12 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even
|
|||||||
protected var registry: Block = MBlocks.BATTERY_BANK
|
protected var registry: Block = MBlocks.BATTERY_BANK
|
||||||
|
|
||||||
override fun registerStatesAndModels() {
|
override fun registerStatesAndModels() {
|
||||||
with(getMultipartBuilder(registry)) {
|
with(getVariantBuilder(registry)) {
|
||||||
val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block"))
|
forAllStates {
|
||||||
|
ConfiguredModel.builder()
|
||||||
BlockRotationFreedom.ONE.possibleValues.forEach {
|
.modelFile(models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block")))
|
||||||
part().modelFile(battery_bank).rotationY(it.front.toYRotBlockstate()).addModel().condition(
|
.rotationY(it[BlockRotationFreedom.ONE.property].front.yRotationBlockstateNorth())
|
||||||
BlockRotationFreedom.ONE.property, it)
|
.build()
|
||||||
|
|
||||||
for (i in 0 .. 11) {
|
|
||||||
part().modelFile(
|
|
||||||
models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath$i"))
|
|
||||||
).rotationY(it.front.toYRotBlockstate()).addModel()
|
|
||||||
.condition(BlockRotationFreedom.ONE.property, it)
|
|
||||||
.condition(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,12 @@ import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock
|
import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock
|
||||||
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateSouth
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateSouth
|
||||||
import ru.dbotthepony.mc.otm.core.registryName
|
import ru.dbotthepony.mc.otm.core.registryName
|
||||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||||
import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate
|
|
||||||
import ru.dbotthepony.mc.otm.datagen.toXRotBlockstateInv
|
|
||||||
import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate
|
|
||||||
import ru.dbotthepony.mc.otm.datagen.toYRotBlockstateInv
|
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||||
import ru.dbotthepony.mc.otm.registry.MNames
|
import ru.dbotthepony.mc.otm.registry.MNames
|
||||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||||
@ -38,7 +38,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) {
|
with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) {
|
||||||
for (dir in BlockRotationFreedom.ONE.possibleValues) {
|
for (dir in BlockRotationFreedom.ONE.possibleValues) {
|
||||||
part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}")))
|
part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}")))
|
||||||
.rotationY(dir.front.toYRotBlockstate())
|
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)
|
.condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)
|
||||||
.condition(BlockRotationFreedom.ONE.property, dir)
|
.condition(BlockRotationFreedom.ONE.property, dir)
|
||||||
@ -50,7 +50,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
for (dir in BlockRotationFreedom.ONE.possibleValues) {
|
for (dir in BlockRotationFreedom.ONE.possibleValues) {
|
||||||
for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) {
|
for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) {
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}")))
|
||||||
.rotationY(dir.front.toYRotBlockstate())
|
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.ONE.property, dir)
|
.condition(BlockRotationFreedom.ONE.property, dir)
|
||||||
.condition(WorkerState.WORKER_STATE, enum)
|
.condition(WorkerState.WORKER_STATE, enum)
|
||||||
@ -61,14 +61,14 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
for (dir in BlockRotationFreedom.ONE.possibleValues) {
|
for (dir in BlockRotationFreedom.ONE.possibleValues) {
|
||||||
for (enum in MatterBottlerBlock.SLOT_PROPERTIES) {
|
for (enum in MatterBottlerBlock.SLOT_PROPERTIES) {
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open")))
|
||||||
.rotationY(dir.front.toYRotBlockstate())
|
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.ONE.property, dir)
|
.condition(BlockRotationFreedom.ONE.property, dir)
|
||||||
.condition(enum, false)
|
.condition(enum, false)
|
||||||
.end()
|
.end()
|
||||||
|
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed")))
|
||||||
.rotationY(dir.front.toYRotBlockstate())
|
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.ONE.property, dir)
|
.condition(BlockRotationFreedom.ONE.property, dir)
|
||||||
.condition(enum, true)
|
.condition(enum, true)
|
||||||
@ -98,7 +98,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue(
|
OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue(
|
||||||
CargoCrateBlock.IS_OPEN)) "open" else "closed"}")
|
CargoCrateBlock.IS_OPEN)) "open" else "closed"}")
|
||||||
))
|
))
|
||||||
.rotationY(it.getValue(BlockRotationFreedom.ONE.property).front.toYRotBlockstate())
|
.rotationY(it.getValue(BlockRotationFreedom.ONE.property).front.yRotationBlockstateNorth())
|
||||||
.buildLast()
|
.buildLast()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -107,15 +107,15 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) {
|
with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) {
|
||||||
for (dir in BlockRotationFreedom.TWO.possibleValues) {
|
for (dir in BlockRotationFreedom.TWO.possibleValues) {
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus")))
|
||||||
.rotationX(dir.front.toXRotBlockstate())
|
.rotationX(dir.front.xRotationBlockstateNorth())
|
||||||
.rotationY(dir.front.toYRotBlockstate())
|
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.TWO.property, dir)
|
.condition(BlockRotationFreedom.TWO.property, dir)
|
||||||
.end()
|
.end()
|
||||||
|
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection")))
|
||||||
.rotationX(dir.front.toXRotBlockstateInv())
|
.rotationX(dir.front.xRotationBlockstateSouth())
|
||||||
.rotationY(dir.front.toYRotBlockstateInv())
|
.rotationY(dir.front.yRotationBlockstateSouth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
||||||
.end()
|
.end()
|
||||||
@ -128,15 +128,15 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) {
|
with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) {
|
||||||
for (dir in BlockRotationFreedom.TWO.possibleValues) {
|
for (dir in BlockRotationFreedom.TWO.possibleValues) {
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer")))
|
||||||
.rotationX(dir.front.toXRotBlockstate())
|
.rotationX(dir.front.xRotationBlockstateNorth())
|
||||||
.rotationY(dir.front.toYRotBlockstate())
|
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.TWO.property, dir)
|
.condition(BlockRotationFreedom.TWO.property, dir)
|
||||||
.end()
|
.end()
|
||||||
|
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection")))
|
||||||
.rotationX(dir.front.toXRotBlockstateInv())
|
.rotationX(dir.front.xRotationBlockstateSouth())
|
||||||
.rotationY(dir.front.toYRotBlockstateInv())
|
.rotationY(dir.front.yRotationBlockstateSouth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
||||||
.end()
|
.end()
|
||||||
@ -149,15 +149,15 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) {
|
with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) {
|
||||||
for (dir in BlockRotationFreedom.TWO.possibleValues) {
|
for (dir in BlockRotationFreedom.TWO.possibleValues) {
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter")))
|
||||||
.rotationX(dir.front.toXRotBlockstate())
|
.rotationX(dir.front.xRotationBlockstateNorth())
|
||||||
.rotationY(dir.front.toYRotBlockstate())
|
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.TWO.property, dir)
|
.condition(BlockRotationFreedom.TWO.property, dir)
|
||||||
.end()
|
.end()
|
||||||
|
|
||||||
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection")))
|
part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection")))
|
||||||
.rotationX(dir.front.toXRotBlockstateInv())
|
.rotationX(dir.front.xRotationBlockstateSouth())
|
||||||
.rotationY(dir.front.toYRotBlockstateInv())
|
.rotationY(dir.front.yRotationBlockstateSouth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
||||||
.end()
|
.end()
|
||||||
|
@ -7,8 +7,8 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
|||||||
import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock
|
import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock
|
||||||
import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock
|
import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock
|
||||||
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
||||||
import ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID
|
import ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID
|
||||||
import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate
|
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||||
|
|
||||||
fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
||||||
@ -16,7 +16,7 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
for (facing in BlockRotationFreedom.ONE.possibleValues) {
|
for (facing in BlockRotationFreedom.ONE.possibleValues) {
|
||||||
part()
|
part()
|
||||||
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part")))
|
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part")))
|
||||||
.rotationY(facing.front.toYRotBlockstate())
|
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.ONE.property, facing)
|
.condition(BlockRotationFreedom.ONE.property, facing)
|
||||||
.condition(DriveViewerBlock.DRIVE_PRESENT, true)
|
.condition(DriveViewerBlock.DRIVE_PRESENT, true)
|
||||||
@ -24,7 +24,7 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) {
|
for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) {
|
||||||
part()
|
part()
|
||||||
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}")))
|
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}")))
|
||||||
.rotationY(facing.front.toYRotBlockstate())
|
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(WorkerState.SEMI_WORKER_STATE, workState)
|
.condition(WorkerState.SEMI_WORKER_STATE, workState)
|
||||||
.condition(BlockRotationFreedom.ONE.property, facing)
|
.condition(BlockRotationFreedom.ONE.property, facing)
|
||||||
@ -36,14 +36,14 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
for (facing in BlockRotationFreedom.ONE.possibleValues) {
|
for (facing in BlockRotationFreedom.ONE.possibleValues) {
|
||||||
part()
|
part()
|
||||||
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage")))
|
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage")))
|
||||||
.rotationY(facing.front.toYRotBlockstate())
|
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.ONE.property, facing)
|
.condition(BlockRotationFreedom.ONE.property, facing)
|
||||||
|
|
||||||
for (i in 0 .. 7) {
|
for (i in 0 .. 7) {
|
||||||
part()
|
part()
|
||||||
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i")))
|
.modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i")))
|
||||||
.rotationY(facing.front.toYRotBlockstate())
|
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockRotationFreedom.ONE.property, facing)
|
.condition(BlockRotationFreedom.ONE.property, facing)
|
||||||
.condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true)
|
.condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true)
|
||||||
@ -69,8 +69,8 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
val southWest = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_west"))
|
val southWest = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_west"))
|
||||||
|
|
||||||
for (dir in arrayOf(Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.NORTH)) {
|
for (dir in arrayOf(Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.NORTH)) {
|
||||||
part().modelFile(down).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.UP).condition(EnergyCounterBlock.IF_DIRECTION, dir)
|
part().modelFile(down).rotationY(dir.yRotationBlockstateNorth()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.UP).condition(EnergyCounterBlock.IF_DIRECTION, dir)
|
||||||
part().modelFile(up).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.DOWN).condition(EnergyCounterBlock.IF_DIRECTION, dir)
|
part().modelFile(up).rotationY(dir.yRotationBlockstateNorth()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.DOWN).condition(EnergyCounterBlock.IF_DIRECTION, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// низкий поклон за полностью рабочий поворот вокруг оси Z
|
// низкий поклон за полностью рабочий поворот вокруг оси Z
|
||||||
|
@ -7,11 +7,11 @@ import net.minecraftforge.client.model.generators.BlockStateProvider
|
|||||||
import net.minecraftforge.client.model.generators.ConfiguredModel
|
import net.minecraftforge.client.model.generators.ConfiguredModel
|
||||||
import net.minecraftforge.data.event.GatherDataEvent
|
import net.minecraftforge.data.event.GatherDataEvent
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.getValueNullable
|
||||||
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
||||||
import ru.dbotthepony.mc.otm.datagen.DataGen
|
import ru.dbotthepony.mc.otm.datagen.DataGen
|
||||||
import ru.dbotthepony.mc.otm.datagen.getValueNullable
|
|
||||||
import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate
|
|
||||||
import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate
|
|
||||||
import ru.dbotthepony.mc.otm.core.registryName
|
import ru.dbotthepony.mc.otm.core.registryName
|
||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
|
|
||||||
@ -22,17 +22,17 @@ private fun initialTransform(it: BlockState, modelPath: String, builder: Configu
|
|||||||
@Suppress("NAME_SHADOWING") var modelPath = modelPath
|
@Suppress("NAME_SHADOWING") var modelPath = modelPath
|
||||||
|
|
||||||
it.getValueNullable(BlockRotationFreedom.ONE.property)?.let {
|
it.getValueNullable(BlockRotationFreedom.ONE.property)?.let {
|
||||||
builder.rotationY(it.front.toYRotBlockstate())
|
builder.rotationY(it.front.yRotationBlockstateNorth())
|
||||||
}
|
}
|
||||||
|
|
||||||
it.getValueNullable(BlockRotationFreedom.TWO.property)?.let {
|
it.getValueNullable(BlockRotationFreedom.TWO.property)?.let {
|
||||||
builder.rotationY(it.front.toYRotBlockstate())
|
builder.rotationY(it.front.yRotationBlockstateNorth())
|
||||||
builder.rotationX(it.front.toXRotBlockstate())
|
builder.rotationX(it.front.xRotationBlockstateNorth())
|
||||||
}
|
}
|
||||||
|
|
||||||
it.getValueNullable(BlockRotationFreedom.THREE.property)?.let {
|
it.getValueNullable(BlockRotationFreedom.THREE.property)?.let {
|
||||||
builder.rotationY(it.front.toYRotBlockstate() + it.top.toYRotBlockstate())
|
builder.rotationY(it.front.yRotationBlockstateNorth() + it.top.yRotationBlockstateNorth())
|
||||||
builder.rotationX(it.front.toXRotBlockstate())
|
builder.rotationX(it.front.xRotationBlockstateNorth())
|
||||||
}
|
}
|
||||||
|
|
||||||
it.getValueNullable(WorkerState.WORKER_STATE)?.let {
|
it.getValueNullable(WorkerState.WORKER_STATE)?.let {
|
||||||
|
@ -31,6 +31,8 @@ import ru.dbotthepony.mc.otm.client.model.ExosuitModel;
|
|||||||
import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel;
|
import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel;
|
||||||
import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel;
|
import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel;
|
||||||
import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer;
|
import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer;
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer;
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer;
|
||||||
import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt;
|
import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt;
|
||||||
import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt;
|
import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt;
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal;
|
import ru.dbotthepony.mc.otm.core.math.Decimal;
|
||||||
@ -113,7 +115,10 @@ public final class OverdriveThatMatters {
|
|||||||
modBus.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping.INSTANCE::register);
|
modBus.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping.INSTANCE::register);
|
||||||
modBus.addListener(EventPriority.NORMAL, TritaniumArmorModel::register);
|
modBus.addListener(EventPriority.NORMAL, TritaniumArmorModel::register);
|
||||||
modBus.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register);
|
modBus.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register);
|
||||||
modBus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::register$overdrive_that_matters);
|
modBus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::register);
|
||||||
|
|
||||||
|
modBus.addListener(EventPriority.NORMAL, BatteryBankRenderer.Companion::onRegisterAdditionalModels);
|
||||||
|
modBus.addListener(EventPriority.NORMAL, MatterBatteryBankRenderer.Companion::onRegisterAdditionalModels);
|
||||||
});
|
});
|
||||||
|
|
||||||
ClientConfig.INSTANCE.register();
|
ClientConfig.INSTANCE.register();
|
||||||
|
@ -19,10 +19,12 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
|||||||
import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock
|
import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock
|
||||||
import ru.dbotthepony.mc.otm.block.IDroppableContainer
|
import ru.dbotthepony.mc.otm.block.IDroppableContainer
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.capability.FlowDirection
|
import ru.dbotthepony.mc.otm.capability.FlowDirection
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||||
import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage
|
import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage
|
||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
|
import ru.dbotthepony.mc.otm.core.ImmutableList
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.ifPresentK
|
import ru.dbotthepony.mc.otm.core.ifPresentK
|
||||||
import ru.dbotthepony.mc.otm.graph.Graph6Node
|
import ru.dbotthepony.mc.otm.graph.Graph6Node
|
||||||
@ -135,30 +137,18 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
|
|||||||
|
|
||||||
private var resolver = LazyOptional.of { this }
|
private var resolver = LazyOptional.of { this }
|
||||||
|
|
||||||
val container = object : MatteryContainer(this::setChangedLight, 6 * 2) {
|
val container = object : MatteryContainer(this::setChangedLight, BatteryBankBlockEntity.CAPACITY) {
|
||||||
override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {
|
override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {
|
||||||
super.setChanged(slot, new, old)
|
super.setChanged(slot, new, old)
|
||||||
val level = level
|
capacitorStatus[slot].value = new.getCapability(MatteryCapability.MATTER).isPresent
|
||||||
|
|
||||||
if (level != null) {
|
|
||||||
var state = blockState
|
|
||||||
|
|
||||||
for (i in BatteryBankBlock.BATTERY_SLOTS_PROPS.indices) {
|
|
||||||
state = state.setValue(
|
|
||||||
BatteryBankBlock.BATTERY_SLOTS_PROPS[i],
|
|
||||||
getItem(i).getCapability(MatteryCapability.MATTER).isPresent
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state !== blockState) {
|
|
||||||
level.setBlock(blockPos, state, Block.UPDATE_CLIENTS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gaugeLevel = (storedMatter / maxStoredMatter).toFloat()
|
gaugeLevel = (storedMatter / maxStoredMatter).toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val capacitorStatus = ImmutableList(BatteryBankBlockEntity.CAPACITY) {
|
||||||
|
synchronizer.bool(false, name = "capacitor$it")
|
||||||
|
}
|
||||||
|
|
||||||
override val droppableContainer: Container
|
override val droppableContainer: Container
|
||||||
get() = container
|
get() = container
|
||||||
override val defaultDisplayName: Component
|
override val defaultDisplayName: Component
|
||||||
|
@ -44,24 +44,15 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
|||||||
val container: MatteryContainer = object : MatteryContainer(this::setChanged, CAPACITY) {
|
val container: MatteryContainer = object : MatteryContainer(this::setChanged, CAPACITY) {
|
||||||
override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {
|
override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {
|
||||||
super.setChanged(slot, new, old)
|
super.setChanged(slot, new, old)
|
||||||
|
batteryStatus[slot].value = new.getCapability(ForgeCapabilities.ENERGY).isPresent
|
||||||
val level = level
|
|
||||||
if (level != null) {
|
|
||||||
var state = blockState
|
|
||||||
|
|
||||||
for (i in BatteryBankBlock.BATTERY_SLOTS_PROPS.indices) {
|
|
||||||
state = state.setValue(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], getItem(i).getCapability(ForgeCapabilities.ENERGY).isPresent)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state !== blockState) {
|
|
||||||
level.setBlock(blockPos, state, Block.UPDATE_CLIENTS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gaugeLevel = (energy.batteryLevel / energy.maxBatteryLevel).toFloat()
|
gaugeLevel = (energy.batteryLevel / energy.maxBatteryLevel).toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val batteryStatus = ImmutableList(CAPACITY) {
|
||||||
|
synchronizer.bool(false, name = "battery$it")
|
||||||
|
}
|
||||||
|
|
||||||
override val droppableContainer: Container
|
override val droppableContainer: Container
|
||||||
get() = container
|
get() = container
|
||||||
private val itemHandler = container.handler(
|
private val itemHandler = container.handler(
|
||||||
|
@ -23,21 +23,7 @@ class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
return MatterCapacitorBankBlockEntity(blockPos, blockState)
|
return MatterCapacitorBankBlockEntity(blockPos, blockState)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_CAPACITOR_BANK.rotateFromNorth(it[rotationProperty]).computeShape() }
|
||||||
var state = super.getStateForPlacement(context) ?: return null
|
|
||||||
|
|
||||||
for (prop in BatteryBankBlock.BATTERY_SLOTS_PROPS)
|
|
||||||
state = state.setValue(prop, false)
|
|
||||||
|
|
||||||
return state
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
|
||||||
BatteryBankBlock.BATTERY_SLOTS_PROPS.forEach(builder::add)
|
|
||||||
super.createBlockStateDefinition(builder)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(it[rotationProperty]).computeShape() }
|
|
||||||
|
|
||||||
@Suppress("override_deprecation")
|
@Suppress("override_deprecation")
|
||||||
override fun getShape(
|
override fun getShape(
|
||||||
|
@ -28,15 +28,6 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
|||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock {
|
class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
|
|
||||||
var state = super.getStateForPlacement(context)!!
|
|
||||||
|
|
||||||
for (prop in BATTERY_SLOTS_PROPS)
|
|
||||||
state = state.setValue(prop, false)
|
|
||||||
|
|
||||||
return state
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : BlockEntity> getTicker(
|
override fun <T : BlockEntity> getTicker(
|
||||||
level: Level,
|
level: Level,
|
||||||
p_153213_: BlockState,
|
p_153213_: BlockState,
|
||||||
@ -48,16 +39,11 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
return BlockEntityTicker { _, _, _, tile -> if (tile is BatteryBankBlockEntity) tile.tick() }
|
return BlockEntityTicker { _, _, _, tile -> if (tile is BatteryBankBlockEntity) tile.tick() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||||
BATTERY_SLOTS_PROPS.forEach(builder::add)
|
|
||||||
super.createBlockStateDefinition(builder)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? {
|
|
||||||
return BatteryBankBlockEntity(blockPos, blockState)
|
return BatteryBankBlockEntity(blockPos, blockState)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.BATTERY_BANK.rotateFromSouth(it[rotationProperty]).computeShape() }
|
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.BATTERY_BANK.rotateFromNorth(it[rotationProperty]).computeShape() }
|
||||||
|
|
||||||
@Suppress("override_deprecation")
|
@Suppress("override_deprecation")
|
||||||
override fun getShape(
|
override fun getShape(
|
||||||
@ -85,21 +71,4 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
val blockEntity = level.getBlockEntity(pos) as? BatteryBankBlockEntity ?: return
|
val blockEntity = level.getBlockEntity(pos) as? BatteryBankBlockEntity ?: return
|
||||||
level.oncePre { blockEntity.checkSurroundings() }
|
level.oncePre { blockEntity.checkSurroundings() }
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
val BATTERY_SLOTS_PROPS: ImmutableList<BooleanProperty> = ImmutableList.of(
|
|
||||||
BooleanProperty.create("battery_0") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_1") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_2") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_3") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_4") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_5") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_6") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_7") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_8") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_9") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_10") as BooleanProperty,
|
|
||||||
BooleanProperty.create("battery_11") as BooleanProperty,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,25 +2,43 @@ package ru.dbotthepony.mc.otm.client.render.blockentity
|
|||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.renderer.MultiBufferSource
|
import net.minecraft.client.renderer.MultiBufferSource
|
||||||
|
import net.minecraft.client.renderer.RenderType
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||||
|
import net.minecraft.client.resources.model.BakedModel
|
||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import net.minecraft.resources.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity
|
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
|
||||||
|
import net.minecraftforge.client.event.ModelEvent
|
||||||
|
import org.joml.AxisAngle4f
|
||||||
|
import org.joml.Quaternionf
|
||||||
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||||
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
||||||
|
import ru.dbotthepony.mc.otm.core.ImmutableList
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.PIf
|
||||||
import ru.dbotthepony.mc.otm.core.math.facingOne
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.rotate
|
||||||
import ru.dbotthepony.mc.otm.core.math.rotateY
|
import ru.dbotthepony.mc.otm.core.math.rotateY
|
||||||
|
import ru.dbotthepony.mc.otm.nanoTime
|
||||||
|
import java.util.function.Supplier
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
|
|
||||||
abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<T> {
|
abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<T> {
|
||||||
protected abstract fun gaugeLevel(entity: T): Float
|
protected abstract fun gaugeLevel(entity: T): Float
|
||||||
protected abstract val texture: AbstractMatterySprite
|
protected abstract val texture: AbstractMatterySprite
|
||||||
|
protected abstract val models: List<BakedModel>
|
||||||
|
protected abstract fun status(entity: T): List<Supplier<Boolean>>
|
||||||
|
|
||||||
|
private val random = XoroshiroRandomSource(nanoTime)
|
||||||
|
|
||||||
override fun render(
|
override fun render(
|
||||||
blockEntity: T,
|
blockEntity: T,
|
||||||
@ -30,6 +48,26 @@ abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEn
|
|||||||
p_112311_: Int,
|
p_112311_: Int,
|
||||||
p_112312_: Int
|
p_112312_: Int
|
||||||
) {
|
) {
|
||||||
|
val status = status(blockEntity)
|
||||||
|
|
||||||
|
stack.pushPose()
|
||||||
|
stack.translate(0.5f, 0.5f, 0.5f)
|
||||||
|
stack.rotate(blockEntity.blockState[BlockRotationFreedom.ONE.property].front)
|
||||||
|
stack.translate(-0.5f, -0.5f, -0.5f)
|
||||||
|
|
||||||
|
for ((i, model) in models.withIndex()) {
|
||||||
|
if (!status[i].get()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
val buffer = DynamicBufferSource.WORLD.getBuffer(RenderType.solid())
|
||||||
|
|
||||||
|
for (quad in model.getQuads(null, null, random))
|
||||||
|
buffer.putBulkData(stack.last(), quad, 1f, 1f, 1f, p_112311_, p_112312_)
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.popPose()
|
||||||
|
|
||||||
val plainLevel = gaugeLevel(blockEntity)
|
val plainLevel = gaugeLevel(blockEntity)
|
||||||
|
|
||||||
if (plainLevel <= 0f) {
|
if (plainLevel <= 0f) {
|
||||||
@ -81,20 +119,56 @@ abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEn
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer<BatteryBankBlockEntity>(context) {
|
class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer<BatteryBankBlockEntity>(context) {
|
||||||
|
override val models: List<BakedModel> by lazy {
|
||||||
|
ImmutableList(12) {
|
||||||
|
minecraft.modelManager.modelBakery.bakedTopLevelModels[ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$it")]!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun status(entity: BatteryBankBlockEntity): List<Supplier<Boolean>> {
|
||||||
|
return entity.batteryStatus
|
||||||
|
}
|
||||||
|
|
||||||
override fun gaugeLevel(entity: BatteryBankBlockEntity): Float {
|
override fun gaugeLevel(entity: BatteryBankBlockEntity): Float {
|
||||||
return entity.gaugeLevel
|
return entity.gaugeLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
override val texture: AbstractMatterySprite
|
override val texture: AbstractMatterySprite
|
||||||
get() = PowerGaugePanel.GAUGE_FOREGROUND
|
get() = PowerGaugePanel.GAUGE_FOREGROUND
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) {
|
||||||
|
for (i in 0 .. 11) {
|
||||||
|
event.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$i"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer<MatterCapacitorBankBlockEntity>(context) {
|
class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer<MatterCapacitorBankBlockEntity>(context) {
|
||||||
|
override val models: List<BakedModel> by lazy {
|
||||||
|
ImmutableList(12) {
|
||||||
|
minecraft.modelManager.modelBakery.bakedTopLevelModels[ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$it")]!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun status(entity: MatterCapacitorBankBlockEntity): List<Supplier<Boolean>> {
|
||||||
|
return entity.capacitorStatus
|
||||||
|
}
|
||||||
|
|
||||||
override fun gaugeLevel(entity: MatterCapacitorBankBlockEntity): Float {
|
override fun gaugeLevel(entity: MatterCapacitorBankBlockEntity): Float {
|
||||||
return entity.gaugeLevel
|
return entity.gaugeLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
override val texture: AbstractMatterySprite
|
override val texture: AbstractMatterySprite
|
||||||
get() = MatterGaugePanel.GAUGE_FOREGROUND
|
get() = MatterGaugePanel.GAUGE_FOREGROUND
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) {
|
||||||
|
for (i in 0 .. 11) {
|
||||||
|
event.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$i"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ fun <T : Enum<T>> T.prev(values: Array<out T>): T {
|
|||||||
return values[next]
|
return values[next]
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <T> ImmutableList(size: Int, initializer: (index: Int) -> T): ImmutableList<T> {
|
inline fun <T : Any> ImmutableList(size: Int, initializer: (index: Int) -> T): ImmutableList<T> {
|
||||||
require(size >= 0) { "Invalid list size $size" }
|
require(size >= 0) { "Invalid list size $size" }
|
||||||
|
|
||||||
return when (size) {
|
return when (size) {
|
||||||
@ -253,3 +253,11 @@ inline fun <T> MutableList<out Reference<out T>>.forValidRefs(fn: (T) -> Unit) {
|
|||||||
|
|
||||||
val ComponentContents.key: String
|
val ComponentContents.key: String
|
||||||
get() = (this as? TranslatableContents ?: throw ClassCastException("$this is not a TranslatableContents"))?.key
|
get() = (this as? TranslatableContents ?: throw ClassCastException("$this is not a TranslatableContents"))?.key
|
||||||
|
|
||||||
|
fun <T : Comparable<T>> BlockState.getValueNullable(prop: Property<T>): T? {
|
||||||
|
if (hasProperty(prop)) {
|
||||||
|
return getValue(prop)
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
@ -561,6 +561,15 @@ fun PoseStack.rotateZ(rotation: Float): PoseStack {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun PoseStack.rotate(rotation: Direction): PoseStack {
|
||||||
|
return rotateY(rotation.yRotationNorth()).rotateX(rotation.xRotationNorth())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun PoseStack.rotateSouth(rotation: Direction): PoseStack {
|
||||||
|
return rotateY(rotation.yRotationSouth()).rotateX(rotation.xRotationSouth())
|
||||||
|
}
|
||||||
|
// /1.19.3 stuff
|
||||||
|
|
||||||
const val PIf = 3.1415927f
|
const val PIf = 3.1415927f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -666,3 +675,71 @@ fun PoseStack.rotateZDegrees(rotation: Float): PoseStack {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Direction.yRotationBlockstateNorth(): Int {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN, Direction.UP, Direction.NORTH -> 0
|
||||||
|
Direction.SOUTH -> 180
|
||||||
|
Direction.WEST -> -90
|
||||||
|
Direction.EAST -> 90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Direction.yRotationBlockstateSouth(): Int {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN, Direction.UP, Direction.SOUTH -> 0
|
||||||
|
Direction.NORTH -> 180
|
||||||
|
Direction.WEST -> 90
|
||||||
|
Direction.EAST -> -90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Direction.xRotationBlockstateNorth(): Int {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN -> 90
|
||||||
|
Direction.UP -> -90
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Direction.xRotationBlockstateSouth(): Int {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN -> -90
|
||||||
|
Direction.UP -> 90
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Direction.yRotationNorth(): Float {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN, Direction.UP, Direction.NORTH -> 0f
|
||||||
|
Direction.SOUTH -> PIf
|
||||||
|
Direction.WEST -> -PIf / 2f
|
||||||
|
Direction.EAST -> PIf / 2f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Direction.yRotationSouth(): Float {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN, Direction.UP, Direction.SOUTH -> 0f
|
||||||
|
Direction.NORTH -> PIf
|
||||||
|
Direction.WEST -> PIf / 2f
|
||||||
|
Direction.EAST -> -PIf / 2f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Direction.xRotationNorth(): Float {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN -> PIf / 2f
|
||||||
|
Direction.UP -> -PIf / 2f
|
||||||
|
else -> 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Direction.xRotationSouth(): Float {
|
||||||
|
return when (this) {
|
||||||
|
Direction.DOWN -> -PIf / 2f
|
||||||
|
Direction.UP -> PIf / 2f
|
||||||
|
else -> 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ object MCreativeTabs {
|
|||||||
var DECORATIVE by WriteOnce<CreativeModeTab>()
|
var DECORATIVE by WriteOnce<CreativeModeTab>()
|
||||||
private set
|
private set
|
||||||
|
|
||||||
internal fun register(event: CreativeModeTabEvent.Register) {
|
fun register(event: CreativeModeTabEvent.Register) {
|
||||||
MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) {
|
MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) {
|
||||||
it.icon { ItemStack(BATTERY_CREATIVE, 1) }
|
it.icon { ItemStack(BATTERY_CREATIVE, 1) }
|
||||||
it.title(TranslatableComponent("itemGroup.otm"))
|
it.title(TranslatableComponent("itemGroup.otm"))
|
||||||
|
Loading…
Reference in New Issue
Block a user