Rename block rotation freedom once again

This commit is contained in:
DBotThePony 2023-08-15 10:52:49 +07:00
parent 7f1971cd81
commit 615912de8b
Signed by: DBot
GPG Key ID: DCC23B5715498507
19 changed files with 73 additions and 74 deletions

View File

@ -230,16 +230,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.XZ_XY.property].front.xRotationBlockstateNorth()) .rotationX(it[BlockRotationFreedom.DIRECTIONAL.property].front.xRotationBlockstateNorth())
.rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth()) .rotationY(it[BlockRotationFreedom.DIRECTIONAL.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.XZ_XY.property].front.xRotationBlockstateNorth()) .rotationX(it[BlockRotationFreedom.DIRECTIONAL.property].front.xRotationBlockstateNorth())
.rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth()) .rotationY(it[BlockRotationFreedom.DIRECTIONAL.property].front.yRotationBlockstateNorth())
.build() .build()
} }
} }

View File

@ -28,7 +28,7 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even
forAllStates { forAllStates {
ConfiguredModel.builder() ConfiguredModel.builder()
.modelFile(models().getExistingFile(modLocation("block/$block"))) .modelFile(models().getExistingFile(modLocation("block/$block")))
.rotationY(it[BlockRotationFreedom.XZ.property].front.yRotationBlockstateNorth()) .rotationY(it[BlockRotationFreedom.HORIZONTAL.property].front.yRotationBlockstateNorth())
.build() .build()
} }
} }

View File

@ -36,54 +36,54 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
provider.exec { provider.exec {
with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) { with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) {
for (dir in BlockRotationFreedom.XZ.possibleValues) { for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) {
part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}"))) part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}")))
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER) .condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)
.condition(BlockRotationFreedom.XZ.property, dir) .condition(BlockRotationFreedom.HORIZONTAL.property, dir)
.end() .end()
} }
} }
with(provider.getMultipartBuilder(MBlocks.ANDROID_CHARGER)) { with(provider.getMultipartBuilder(MBlocks.ANDROID_CHARGER)) {
for (dir in BlockRotationFreedom.XZ.possibleValues) { for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) {
for (part in AndroidChargerBlock.PART.possibleValues) { for (part in AndroidChargerBlock.PART.possibleValues) {
part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.ANDROID_CHARGER}_${part.serializedName}"))) part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.ANDROID_CHARGER}_${part.serializedName}")))
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(AndroidChargerBlock.PART, part) .condition(AndroidChargerBlock.PART, part)
.condition(BlockRotationFreedom.XZ.property, dir) .condition(BlockRotationFreedom.HORIZONTAL.property, dir)
.end() .end()
} }
} }
} }
with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) {
for (dir in BlockRotationFreedom.XZ.possibleValues) { for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) {
for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) {
part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name.lowercase()}"))) part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name.lowercase()}")))
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ.property, dir) .condition(BlockRotationFreedom.HORIZONTAL.property, dir)
.condition(WorkerState.WORKER_STATE, enum) .condition(WorkerState.WORKER_STATE, enum)
.end() .end()
} }
} }
for (dir in BlockRotationFreedom.XZ.possibleValues) { for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) {
for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { for (enum in MatterBottlerBlock.SLOT_PROPERTIES) {
part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_open"))) part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_open")))
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ.property, dir) .condition(BlockRotationFreedom.HORIZONTAL.property, dir)
.condition(enum, false) .condition(enum, false)
.end() .end()
part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_closed"))) part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_closed")))
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ.property, dir) .condition(BlockRotationFreedom.HORIZONTAL.property, dir)
.condition(enum, true) .condition(enum, true)
.end() .end()
} }
@ -116,19 +116,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
modLocation("${crate.registryName!!.path}_${if (it.getValue( modLocation("${crate.registryName!!.path}_${if (it.getValue(
CargoCrateBlock.IS_OPEN)) "open" else "closed"}") CargoCrateBlock.IS_OPEN)) "open" else "closed"}")
)) ))
.rotationY(it.getValue(BlockRotationFreedom.XZ.property).front.yRotationBlockstateNorth()) .rotationY(it.getValue(BlockRotationFreedom.HORIZONTAL.property).front.yRotationBlockstateNorth())
.buildLast() .buildLast()
) )
} }
} }
with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) {
for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { for (dir in BlockRotationFreedom.DIRECTIONAL.possibleValues) {
part().modelFile(provider.models().getExistingFile(modLocation("storage_bus"))) part().modelFile(provider.models().getExistingFile(modLocation("storage_bus")))
.rotationX(dir.front.xRotationBlockstateNorth()) .rotationX(dir.front.xRotationBlockstateNorth())
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ_XY.property, dir) .condition(BlockRotationFreedom.DIRECTIONAL.property, dir)
.end() .end()
part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection")))
@ -144,12 +144,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
} }
with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) {
for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { for (dir in BlockRotationFreedom.DIRECTIONAL.possibleValues) {
part().modelFile(provider.models().getExistingFile(modLocation("storage_importer"))) part().modelFile(provider.models().getExistingFile(modLocation("storage_importer")))
.rotationX(dir.front.xRotationBlockstateNorth()) .rotationX(dir.front.xRotationBlockstateNorth())
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ_XY.property, dir) .condition(BlockRotationFreedom.DIRECTIONAL.property, dir)
.end() .end()
part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection")))
@ -165,12 +165,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
} }
with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) {
for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { for (dir in BlockRotationFreedom.DIRECTIONAL.possibleValues) {
part().modelFile(provider.models().getExistingFile(modLocation("storage_exporter"))) part().modelFile(provider.models().getExistingFile(modLocation("storage_exporter")))
.rotationX(dir.front.xRotationBlockstateNorth()) .rotationX(dir.front.xRotationBlockstateNorth())
.rotationY(dir.front.yRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ_XY.property, dir) .condition(BlockRotationFreedom.DIRECTIONAL.property, dir)
.end() .end()
part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection")))

View File

@ -12,12 +12,12 @@ import ru.dbotthepony.mc.otm.registry.MBlocks
fun addComplexBlockStates(provider: MatteryBlockStateProvider) { fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) { with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) {
for (facing in BlockRotationFreedom.XZ.possibleValues) { for (facing in BlockRotationFreedom.HORIZONTAL.possibleValues) {
part() part()
.modelFile(provider.models().getExistingFile(modLocation("block/drive_viewer_drive_part"))) .modelFile(provider.models().getExistingFile(modLocation("block/drive_viewer_drive_part")))
.rotationY(facing.front.yRotationBlockstateNorth()) .rotationY(facing.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ.property, facing) .condition(BlockRotationFreedom.HORIZONTAL.property, facing)
.condition(DriveViewerBlock.DRIVE_PRESENT, true) .condition(DriveViewerBlock.DRIVE_PRESENT, true)
for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) {
@ -26,25 +26,25 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
.rotationY(facing.front.yRotationBlockstateNorth()) .rotationY(facing.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(WorkerState.SEMI_WORKER_STATE, workState) .condition(WorkerState.SEMI_WORKER_STATE, workState)
.condition(BlockRotationFreedom.XZ.property, facing) .condition(BlockRotationFreedom.HORIZONTAL.property, facing)
} }
} }
} }
with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) { with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) {
for (facing in BlockRotationFreedom.XZ.possibleValues) { for (facing in BlockRotationFreedom.HORIZONTAL.possibleValues) {
part() part()
.modelFile(provider.models().getExistingFile(modLocation("block/pattern_storage"))) .modelFile(provider.models().getExistingFile(modLocation("block/pattern_storage")))
.rotationY(facing.front.yRotationBlockstateNorth()) .rotationY(facing.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ.property, facing) .condition(BlockRotationFreedom.HORIZONTAL.property, facing)
for (i in 0 .. 7) { for (i in 0 .. 7) {
part() part()
.modelFile(provider.models().getExistingFile(modLocation("block/pattern/model$i"))) .modelFile(provider.models().getExistingFile(modLocation("block/pattern/model$i")))
.rotationY(facing.front.yRotationBlockstateNorth()) .rotationY(facing.front.yRotationBlockstateNorth())
.addModel() .addModel()
.condition(BlockRotationFreedom.XZ.property, facing) .condition(BlockRotationFreedom.HORIZONTAL.property, facing)
.condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true)
} }
} }

View File

@ -21,16 +21,16 @@ private val EMPTY: BlockStateTransform = { _, _, _ -> null }
private fun initialTransform(it: BlockState, modelPath: String, builder: ConfiguredModel.Builder<*>): String { private fun initialTransform(it: BlockState, modelPath: String, builder: ConfiguredModel.Builder<*>): String {
@Suppress("NAME_SHADOWING") var modelPath = modelPath @Suppress("NAME_SHADOWING") var modelPath = modelPath
it.getValueNullable(BlockRotationFreedom.XZ.property)?.let { it.getValueNullable(BlockRotationFreedom.HORIZONTAL.property)?.let {
builder.rotationY(it.front.yRotationBlockstateNorth()) builder.rotationY(it.front.yRotationBlockstateNorth())
} }
it.getValueNullable(BlockRotationFreedom.XZ_XY.property)?.let { it.getValueNullable(BlockRotationFreedom.DIRECTIONAL.property)?.let {
builder.rotationY(it.front.yRotationBlockstateNorth()) builder.rotationY(it.front.yRotationBlockstateNorth())
builder.rotationX(it.front.xRotationBlockstateNorth()) builder.rotationX(it.front.xRotationBlockstateNorth())
} }
it.getValueNullable(BlockRotationFreedom.XZ_XY_ZY.property)?.let { it.getValueNullable(BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION.property)?.let {
builder.rotationY(it.front.yRotationBlockstateNorth() + it.top.yRotationBlockstateNorth()) builder.rotationY(it.front.yRotationBlockstateNorth() + it.top.yRotationBlockstateNorth())
builder.rotationX(it.front.xRotationBlockstateNorth()) builder.rotationX(it.front.xRotationBlockstateNorth())
} }

View File

@ -115,9 +115,9 @@ abstract class MatteryBlock @JvmOverloads constructor(
val state = blockState.getOptionalValue(WorkerState.WORKER_STATE).or { blockState.getOptionalValue(WorkerState.SEMI_WORKER_STATE) } val state = blockState.getOptionalValue(WorkerState.WORKER_STATE).or { blockState.getOptionalValue(WorkerState.SEMI_WORKER_STATE) }
if (state.isPresent && state.get() == WorkerState.WORKING) { if (state.isPresent && state.get() == WorkerState.WORKING) {
val state2 = blockState.getOptionalValue(BlockRotationFreedom.XZ.property) val state2 = blockState.getOptionalValue(BlockRotationFreedom.HORIZONTAL.property)
.or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY.property) } .or { blockState.getOptionalValue(BlockRotationFreedom.DIRECTIONAL.property) }
.or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY_ZY.property) } .or { blockState.getOptionalValue(BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION.property) }
if (state2.isPresent) { if (state2.isPresent) {
val direction = state2.get() val direction = state2.get()

View File

@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotation
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) { abstract class RotatableMatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) {
init { init {
@Suppress("LeakingThis") @Suppress("LeakingThis")
registerDefaultState(getStateDefinition().any().setValue(rotationProperty, BlockRotation.SOUTH)) registerDefaultState(getStateDefinition().any().setValue(rotationProperty, BlockRotation.SOUTH))
@ -22,17 +22,17 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
return when (val freedom = rotationFreedom()) { return when (val freedom = rotationFreedom()) {
BlockRotationFreedom.XZ -> defaultBlockState().setValue( BlockRotationFreedom.HORIZONTAL -> defaultBlockState().setValue(
freedom.property, freedom.property,
freedom.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection) freedom.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection)
) )
BlockRotationFreedom.XZ_XY -> defaultBlockState().setValue( BlockRotationFreedom.DIRECTIONAL -> defaultBlockState().setValue(
freedom.property, freedom.property,
freedom.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection) freedom.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection)
) )
BlockRotationFreedom.XZ_XY_ZY -> { BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION -> {
val primary = if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection val primary = if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection
var secondary = if (faceToPlayer(context)) context.horizontalDirection else context.horizontalDirection.opposite var secondary = if (faceToPlayer(context)) context.horizontalDirection else context.horizontalDirection.opposite
@ -46,7 +46,7 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope
) )
} }
BlockRotationFreedom.FOUR -> TODO("Can't rotate with four rotation freedom yet") BlockRotationFreedom.FULL -> TODO("Can't rotate with four rotation freedom yet")
} }
} }
@ -59,7 +59,7 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope
val rotationProperty get() = rotationFreedom().property val rotationProperty get() = rotationFreedom().property
open fun rotationFreedom(): BlockRotationFreedom { open fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ return BlockRotationFreedom.HORIZONTAL
} }
open fun faceToPlayer(context: BlockPlaceContext): Boolean { open fun faceToPlayer(context: BlockPlaceContext): Boolean {

View File

@ -29,7 +29,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLO
} }
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY return BlockRotationFreedom.DIRECTIONAL
} }
private val shapes = getShapeForEachState { BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() } private val shapes = getShapeForEachState { BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() }

View File

@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes
class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { class HoloSignBlock : RotatableMatteryBlock(), EntityBlock {
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY_ZY return BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION
} }
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {

View File

@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.core.math.plus
import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.once
import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MBlocks
private val FACING_FULL = BlockRotationFreedom.XZ_XY.property private val FACING_FULL = BlockRotationFreedom.DIRECTIONAL.property
class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) { class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) {
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {

View File

@ -26,7 +26,7 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat
fun tick(level: Level) { fun tick(level: Level) {
var findBlackHole: BlackHoleBlockEntity? = null var findBlackHole: BlackHoleBlockEntity? = null
val dir = blockState[BlockRotationFreedom.XZ_XY].normal val dir = blockState[BlockRotationFreedom.DIRECTIONAL].normal
for (i in 2 .. RANGE) { for (i in 2 .. RANGE) {
val pos = blockPos + dir * i val pos = blockPos + dir * i

View File

@ -25,10 +25,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
private val shapes: ImmutableMap<BlockState, VoxelShape> private val shapes: ImmutableMap<BlockState, VoxelShape>
init { init {
registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.SOUTH)) registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.SOUTH))
shapes = getShapeForEachState { shapes = getShapeForEachState {
when (it[BlockRotationFreedom.XZ_XY.property].front) { when (it[BlockRotationFreedom.DIRECTIONAL.property].front) {
Direction.NORTH -> Shapes.box( Direction.NORTH -> Shapes.box(
0.0, 0.0,
0.0, 0.0,
@ -91,10 +91,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
} }
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY return BlockRotationFreedom.DIRECTIONAL
} }
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
return defaultBlockState().setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(context.clickedFace)) return defaultBlockState().setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(context.clickedFace))
} }
} }

View File

@ -30,11 +30,10 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.math.unaryMinus
import ru.dbotthepony.mc.otm.oncePre
class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY return BlockRotationFreedom.DIRECTIONAL
} }
init { init {
@ -52,7 +51,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
} }
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace))
} }
override fun appendHoverText( override fun appendHoverText(

View File

@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.core.math.unaryMinus
class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY return BlockRotationFreedom.DIRECTIONAL
} }
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
@ -76,7 +76,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
} }
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace))
} }
override fun appendHoverText( override fun appendHoverText(
@ -116,7 +116,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY return BlockRotationFreedom.DIRECTIONAL
} }
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
@ -169,7 +169,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
} }
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace))
} }
private val shapes = getShapeForEachState { private val shapes = getShapeForEachState {

View File

@ -55,7 +55,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
} }
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY return BlockRotationFreedom.DIRECTIONAL
} }
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
@ -68,7 +68,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
val blockPos = context.clickedPos val blockPos = context.clickedPos
val level = context.level val level = context.level
for (face in BlockRotationFreedom.XZ_XY.possibleValues) { for (face in BlockRotationFreedom.DIRECTIONAL.possibleValues) {
val dir = face.normal val dir = face.normal
for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) { for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) {
@ -78,14 +78,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
if (!getState.isAir) { if (!getState.isAir) {
if (chunk.getBlockEntity(pos) is BlackHoleBlockEntity) { if (chunk.getBlockEntity(pos) is BlackHoleBlockEntity) {
state = state.setValue(BlockRotationFreedom.XZ_XY.property, face) state = state.setValue(BlockRotationFreedom.DIRECTIONAL.property, face)
break break
} }
} }
} }
} }
val bbPos = blockPos + state.getValue(BlockRotationFreedom.XZ_XY.property).normal val bbPos = blockPos + state.getValue(BlockRotationFreedom.DIRECTIONAL.property).normal
if (!context.level.isInWorldBounds(bbPos)) return null if (!context.level.isInWorldBounds(bbPos)) return null
if (!level.getBlockState(bbPos).canBeReplaced(context)) return null if (!level.getBlockState(bbPos).canBeReplaced(context)) return null
@ -103,9 +103,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
super.setPlacedBy(level, blockPos, blockState, entity, itemStack) super.setPlacedBy(level, blockPos, blockState, entity, itemStack)
if (!level.isClientSide) { if (!level.isClientSide) {
val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).normal val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property).normal
val newState = MBlocks.GRAVITATION_STABILIZER_LENS.defaultBlockState() val newState = MBlocks.GRAVITATION_STABILIZER_LENS.defaultBlockState()
.setValue(BlockRotationFreedom.XZ_XY.property, blockState.getValue(BlockRotationFreedom.XZ_XY.property)) .setValue(BlockRotationFreedom.DIRECTIONAL.property, blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property))
level.setBlock(bbPos, newState, UPDATE_ALL) level.setBlock(bbPos, newState, UPDATE_ALL)
} }
@ -137,7 +137,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
p_60557_: BlockPos, p_60557_: BlockPos,
p_60558_: CollisionContext p_60558_: CollisionContext
): VoxelShape { ): VoxelShape {
return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].ordinal] return SHAPES[p_60555_[BlockRotationFreedom.DIRECTIONAL].ordinal]
} }
companion object { companion object {
@ -155,14 +155,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
} }
fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos {
return blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).normal return blockPos + blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property).normal
} }
} }
} }
class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.XZ_XY return BlockRotationFreedom.DIRECTIONAL
} }
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
@ -196,7 +196,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
p_60557_: BlockPos, p_60557_: BlockPos,
p_60558_: CollisionContext p_60558_: CollisionContext
): VoxelShape { ): VoxelShape {
return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].front.ordinal] return SHAPES[p_60555_[BlockRotationFreedom.DIRECTIONAL].front.ordinal]
} }
companion object { companion object {
@ -205,7 +205,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
} }
fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos {
return blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).front.opposite.normal return blockPos + blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property).front.opposite.normal
} }
private val SHAPES = arrayOf( private val SHAPES = arrayOf(

View File

@ -49,7 +49,7 @@ abstract class BankRenderer<T : MatteryDeviceBlockEntity>(private val context: B
stack.pushPose() stack.pushPose()
stack.translate(0.5f, 0.5f, 0.5f) stack.translate(0.5f, 0.5f, 0.5f)
stack.rotate(blockEntity.blockState[BlockRotationFreedom.XZ.property].front) stack.rotate(blockEntity.blockState[BlockRotationFreedom.HORIZONTAL.property].front)
stack.translate(-0.5f, -0.5f, -0.5f) stack.translate(-0.5f, -0.5f, -0.5f)
for ((i, model) in models.withIndex()) { for ((i, model) in models.withIndex()) {
@ -73,7 +73,7 @@ abstract class BankRenderer<T : MatteryDeviceBlockEntity>(private val context: B
stack.pushPose() stack.pushPose()
val facing = blockEntity.blockState[BlockRotationFreedom.XZ].front val facing = blockEntity.blockState[BlockRotationFreedom.HORIZONTAL].front
val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH
if (rotateFacing) { if (rotateFacing) {

View File

@ -47,7 +47,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv
var len = 64.0 var len = 64.0
var lenI = 64 var lenI = 64
val normal = tile.blockState[BlockRotationFreedom.XZ_XY].normal val normal = tile.blockState[BlockRotationFreedom.DIRECTIONAL].normal
val level = tile.level val level = tile.level
var bhTile: BlackHoleBlockEntity? = null var bhTile: BlackHoleBlockEntity? = null
@ -68,7 +68,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv
poseStack.pushPose() poseStack.pushPose()
poseStack.translate(0.5, 0.5, 0.5) poseStack.translate(0.5, 0.5, 0.5)
val facing = tile.blockState[BlockRotationFreedom.XZ_XY].front val facing = tile.blockState[BlockRotationFreedom.DIRECTIONAL].front
val rotateZ: Double val rotateZ: Double
val rotateY: Double val rotateY: Double

View File

@ -27,7 +27,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context)
return return
poseStack.pushPose() poseStack.pushPose()
poseStack.rotateWithBlockFacing(tile.blockState[BlockRotationFreedom.XZ_XY_ZY]) poseStack.rotateWithBlockFacing(tile.blockState[BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION])
poseStack.translate(0.5f, 0.5f, 0.5f) poseStack.translate(0.5f, 0.5f, 0.5f)
poseStack.scale(0.01f, 0.01f, 0.01f) poseStack.scale(0.01f, 0.01f, 0.01f)

View File

@ -8,13 +8,13 @@ import java.util.EnumMap
* Controls the rotational freedom of block in space, employing [property] and [of] to get valid value from set of possible values * Controls the rotational freedom of block in space, employing [property] and [of] to get valid value from set of possible values
*/ */
enum class BlockRotationFreedom(vararg values: BlockRotation) { enum class BlockRotationFreedom(vararg values: BlockRotation) {
XZ( HORIZONTAL(
BlockRotation.NORTH, BlockRotation.NORTH,
BlockRotation.SOUTH, BlockRotation.SOUTH,
BlockRotation.WEST, BlockRotation.WEST,
BlockRotation.EAST, BlockRotation.EAST,
), ),
XZ_XY( DIRECTIONAL(
BlockRotation.DOWN, BlockRotation.DOWN,
BlockRotation.UP, BlockRotation.UP,
BlockRotation.NORTH, BlockRotation.NORTH,
@ -22,7 +22,7 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) {
BlockRotation.WEST, BlockRotation.WEST,
BlockRotation.EAST, BlockRotation.EAST,
), ),
XZ_XY_ZY( DIRECTIONAL_WITH_ROTATION(
BlockRotation.DOWN, BlockRotation.DOWN,
BlockRotation.UP, BlockRotation.UP,
BlockRotation.NORTH, BlockRotation.NORTH,
@ -40,7 +40,7 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) {
/** /**
* These rotations are impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis) * These rotations are impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis)
*/ */
FOUR( FULL(
BlockRotation.DOWN, BlockRotation.DOWN,
BlockRotation.UP, BlockRotation.UP,
BlockRotation.NORTH, BlockRotation.NORTH,