Rename block rotation freedom once again
This commit is contained in:
parent
7f1971cd81
commit
615912de8b
@ -230,16 +230,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
|
||||
blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates {
|
||||
return@forAllStates ConfiguredModel.builder()
|
||||
.modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!)
|
||||
.rotationX(it[BlockRotationFreedom.XZ_XY.property].front.xRotationBlockstateNorth())
|
||||
.rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth())
|
||||
.rotationX(it[BlockRotationFreedom.DIRECTIONAL.property].front.xRotationBlockstateNorth())
|
||||
.rotationY(it[BlockRotationFreedom.DIRECTIONAL.property].front.yRotationBlockstateNorth())
|
||||
.build()
|
||||
}
|
||||
|
||||
blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates {
|
||||
return@forAllStates ConfiguredModel.builder()
|
||||
.modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!)
|
||||
.rotationX(it[BlockRotationFreedom.XZ_XY.property].front.xRotationBlockstateNorth())
|
||||
.rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth())
|
||||
.rotationX(it[BlockRotationFreedom.DIRECTIONAL.property].front.xRotationBlockstateNorth())
|
||||
.rotationY(it[BlockRotationFreedom.DIRECTIONAL.property].front.yRotationBlockstateNorth())
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even
|
||||
forAllStates {
|
||||
ConfiguredModel.builder()
|
||||
.modelFile(models().getExistingFile(modLocation("block/$block")))
|
||||
.rotationY(it[BlockRotationFreedom.XZ.property].front.yRotationBlockstateNorth())
|
||||
.rotationY(it[BlockRotationFreedom.HORIZONTAL.property].front.yRotationBlockstateNorth())
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
@ -36,54 +36,54 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
||||
|
||||
provider.exec {
|
||||
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}")))
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)
|
||||
.condition(BlockRotationFreedom.XZ.property, dir)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, dir)
|
||||
.end()
|
||||
}
|
||||
}
|
||||
|
||||
with(provider.getMultipartBuilder(MBlocks.ANDROID_CHARGER)) {
|
||||
for (dir in BlockRotationFreedom.XZ.possibleValues) {
|
||||
for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) {
|
||||
for (part in AndroidChargerBlock.PART.possibleValues) {
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.ANDROID_CHARGER}_${part.serializedName}")))
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(AndroidChargerBlock.PART, part)
|
||||
.condition(BlockRotationFreedom.XZ.property, dir)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, dir)
|
||||
.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name.lowercase()}")))
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ.property, dir)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, dir)
|
||||
.condition(WorkerState.WORKER_STATE, enum)
|
||||
.end()
|
||||
}
|
||||
}
|
||||
|
||||
for (dir in BlockRotationFreedom.XZ.possibleValues) {
|
||||
for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) {
|
||||
for (enum in MatterBottlerBlock.SLOT_PROPERTIES) {
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_open")))
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ.property, dir)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, dir)
|
||||
.condition(enum, false)
|
||||
.end()
|
||||
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_closed")))
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ.property, dir)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, dir)
|
||||
.condition(enum, true)
|
||||
.end()
|
||||
}
|
||||
@ -116,19 +116,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
||||
modLocation("${crate.registryName!!.path}_${if (it.getValue(
|
||||
CargoCrateBlock.IS_OPEN)) "open" else "closed"}")
|
||||
))
|
||||
.rotationY(it.getValue(BlockRotationFreedom.XZ.property).front.yRotationBlockstateNorth())
|
||||
.rotationY(it.getValue(BlockRotationFreedom.HORIZONTAL.property).front.yRotationBlockstateNorth())
|
||||
.buildLast()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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")))
|
||||
.rotationX(dir.front.xRotationBlockstateNorth())
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ_XY.property, dir)
|
||||
.condition(BlockRotationFreedom.DIRECTIONAL.property, dir)
|
||||
.end()
|
||||
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection")))
|
||||
@ -144,12 +144,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
||||
}
|
||||
|
||||
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")))
|
||||
.rotationX(dir.front.xRotationBlockstateNorth())
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ_XY.property, dir)
|
||||
.condition(BlockRotationFreedom.DIRECTIONAL.property, dir)
|
||||
.end()
|
||||
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection")))
|
||||
@ -165,12 +165,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
||||
}
|
||||
|
||||
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")))
|
||||
.rotationX(dir.front.xRotationBlockstateNorth())
|
||||
.rotationY(dir.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ_XY.property, dir)
|
||||
.condition(BlockRotationFreedom.DIRECTIONAL.property, dir)
|
||||
.end()
|
||||
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection")))
|
||||
|
@ -12,12 +12,12 @@ import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||
|
||||
fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
||||
with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) {
|
||||
for (facing in BlockRotationFreedom.XZ.possibleValues) {
|
||||
for (facing in BlockRotationFreedom.HORIZONTAL.possibleValues) {
|
||||
part()
|
||||
.modelFile(provider.models().getExistingFile(modLocation("block/drive_viewer_drive_part")))
|
||||
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ.property, facing)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, facing)
|
||||
.condition(DriveViewerBlock.DRIVE_PRESENT, true)
|
||||
|
||||
for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) {
|
||||
@ -26,25 +26,25 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) {
|
||||
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(WorkerState.SEMI_WORKER_STATE, workState)
|
||||
.condition(BlockRotationFreedom.XZ.property, facing)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, facing)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) {
|
||||
for (facing in BlockRotationFreedom.XZ.possibleValues) {
|
||||
for (facing in BlockRotationFreedom.HORIZONTAL.possibleValues) {
|
||||
part()
|
||||
.modelFile(provider.models().getExistingFile(modLocation("block/pattern_storage")))
|
||||
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ.property, facing)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, facing)
|
||||
|
||||
for (i in 0 .. 7) {
|
||||
part()
|
||||
.modelFile(provider.models().getExistingFile(modLocation("block/pattern/model$i")))
|
||||
.rotationY(facing.front.yRotationBlockstateNorth())
|
||||
.addModel()
|
||||
.condition(BlockRotationFreedom.XZ.property, facing)
|
||||
.condition(BlockRotationFreedom.HORIZONTAL.property, facing)
|
||||
.condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true)
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ private val EMPTY: BlockStateTransform = { _, _, _ -> null }
|
||||
private fun initialTransform(it: BlockState, modelPath: String, builder: ConfiguredModel.Builder<*>): String {
|
||||
@Suppress("NAME_SHADOWING") var modelPath = modelPath
|
||||
|
||||
it.getValueNullable(BlockRotationFreedom.XZ.property)?.let {
|
||||
it.getValueNullable(BlockRotationFreedom.HORIZONTAL.property)?.let {
|
||||
builder.rotationY(it.front.yRotationBlockstateNorth())
|
||||
}
|
||||
|
||||
it.getValueNullable(BlockRotationFreedom.XZ_XY.property)?.let {
|
||||
it.getValueNullable(BlockRotationFreedom.DIRECTIONAL.property)?.let {
|
||||
builder.rotationY(it.front.yRotationBlockstateNorth())
|
||||
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.rotationX(it.front.xRotationBlockstateNorth())
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ abstract class MatteryBlock @JvmOverloads constructor(
|
||||
val state = blockState.getOptionalValue(WorkerState.WORKER_STATE).or { blockState.getOptionalValue(WorkerState.SEMI_WORKER_STATE) }
|
||||
|
||||
if (state.isPresent && state.get() == WorkerState.WORKING) {
|
||||
val state2 = blockState.getOptionalValue(BlockRotationFreedom.XZ.property)
|
||||
.or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY.property) }
|
||||
.or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY_ZY.property) }
|
||||
val state2 = blockState.getOptionalValue(BlockRotationFreedom.HORIZONTAL.property)
|
||||
.or { blockState.getOptionalValue(BlockRotationFreedom.DIRECTIONAL.property) }
|
||||
.or { blockState.getOptionalValue(BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION.property) }
|
||||
|
||||
if (state2.isPresent) {
|
||||
val direction = state2.get()
|
||||
|
@ -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.BlockRotationFreedom
|
||||
|
||||
abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) {
|
||||
abstract class RotatableMatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) {
|
||||
init {
|
||||
@Suppress("LeakingThis")
|
||||
registerDefaultState(getStateDefinition().any().setValue(rotationProperty, BlockRotation.SOUTH))
|
||||
@ -22,17 +22,17 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
return when (val freedom = rotationFreedom()) {
|
||||
BlockRotationFreedom.XZ -> defaultBlockState().setValue(
|
||||
BlockRotationFreedom.HORIZONTAL -> defaultBlockState().setValue(
|
||||
freedom.property,
|
||||
freedom.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection)
|
||||
)
|
||||
|
||||
BlockRotationFreedom.XZ_XY -> defaultBlockState().setValue(
|
||||
BlockRotationFreedom.DIRECTIONAL -> defaultBlockState().setValue(
|
||||
freedom.property,
|
||||
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
|
||||
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
|
||||
|
||||
open fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ
|
||||
return BlockRotationFreedom.HORIZONTAL
|
||||
}
|
||||
|
||||
open fun faceToPlayer(context: BlockPlaceContext): Boolean {
|
||||
|
@ -29,7 +29,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLO
|
||||
}
|
||||
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
||||
private val shapes = getShapeForEachState { BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() }
|
||||
|
@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class HoloSignBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY_ZY
|
||||
return BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION
|
||||
}
|
||||
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
|
@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.core.math.plus
|
||||
import ru.dbotthepony.mc.otm.once
|
||||
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 }) {
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
|
@ -26,7 +26,7 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat
|
||||
|
||||
fun tick(level: Level) {
|
||||
var findBlackHole: BlackHoleBlockEntity? = null
|
||||
val dir = blockState[BlockRotationFreedom.XZ_XY].normal
|
||||
val dir = blockState[BlockRotationFreedom.DIRECTIONAL].normal
|
||||
|
||||
for (i in 2 .. RANGE) {
|
||||
val pos = blockPos + dir * i
|
||||
|
@ -25,10 +25,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
private val shapes: ImmutableMap<BlockState, VoxelShape>
|
||||
|
||||
init {
|
||||
registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.SOUTH))
|
||||
registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.SOUTH))
|
||||
|
||||
shapes = getShapeForEachState {
|
||||
when (it[BlockRotationFreedom.XZ_XY.property].front) {
|
||||
when (it[BlockRotationFreedom.DIRECTIONAL.property].front) {
|
||||
Direction.NORTH -> Shapes.box(
|
||||
0.0,
|
||||
0.0,
|
||||
@ -91,10 +91,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
}
|
||||
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,10 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
import ru.dbotthepony.mc.otm.core.math.unaryMinus
|
||||
import ru.dbotthepony.mc.otm.oncePre
|
||||
|
||||
class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
||||
init {
|
||||
@ -52,7 +51,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.core.math.unaryMinus
|
||||
|
||||
class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
@ -76,7 +76,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
}
|
||||
|
||||
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(
|
||||
@ -116,7 +116,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
|
||||
class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
@ -169,7 +169,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -55,7 +55,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
}
|
||||
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
@ -68,7 +68,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
val blockPos = context.clickedPos
|
||||
val level = context.level
|
||||
|
||||
for (face in BlockRotationFreedom.XZ_XY.possibleValues) {
|
||||
for (face in BlockRotationFreedom.DIRECTIONAL.possibleValues) {
|
||||
val dir = face.normal
|
||||
|
||||
for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) {
|
||||
@ -78,14 +78,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
|
||||
if (!getState.isAir) {
|
||||
if (chunk.getBlockEntity(pos) is BlackHoleBlockEntity) {
|
||||
state = state.setValue(BlockRotationFreedom.XZ_XY.property, face)
|
||||
state = state.setValue(BlockRotationFreedom.DIRECTIONAL.property, face)
|
||||
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 (!level.getBlockState(bbPos).canBeReplaced(context)) return null
|
||||
@ -103,9 +103,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
super.setPlacedBy(level, blockPos, blockState, entity, itemStack)
|
||||
|
||||
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()
|
||||
.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)
|
||||
}
|
||||
@ -137,7 +137,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
p_60557_: BlockPos,
|
||||
p_60558_: CollisionContext
|
||||
): VoxelShape {
|
||||
return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].ordinal]
|
||||
return SHAPES[p_60555_[BlockRotationFreedom.DIRECTIONAL].ordinal]
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -155,14 +155,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
}
|
||||
|
||||
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) {
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.XZ_XY
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
@ -196,7 +196,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
|
||||
p_60557_: BlockPos,
|
||||
p_60558_: CollisionContext
|
||||
): VoxelShape {
|
||||
return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].front.ordinal]
|
||||
return SHAPES[p_60555_[BlockRotationFreedom.DIRECTIONAL].front.ordinal]
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -205,7 +205,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -49,7 +49,7 @@ abstract class BankRenderer<T : MatteryDeviceBlockEntity>(private val context: B
|
||||
|
||||
stack.pushPose()
|
||||
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)
|
||||
|
||||
for ((i, model) in models.withIndex()) {
|
||||
@ -73,7 +73,7 @@ abstract class BankRenderer<T : MatteryDeviceBlockEntity>(private val context: B
|
||||
|
||||
stack.pushPose()
|
||||
|
||||
val facing = blockEntity.blockState[BlockRotationFreedom.XZ].front
|
||||
val facing = blockEntity.blockState[BlockRotationFreedom.HORIZONTAL].front
|
||||
val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH
|
||||
|
||||
if (rotateFacing) {
|
||||
|
@ -47,7 +47,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv
|
||||
|
||||
var len = 64.0
|
||||
var lenI = 64
|
||||
val normal = tile.blockState[BlockRotationFreedom.XZ_XY].normal
|
||||
val normal = tile.blockState[BlockRotationFreedom.DIRECTIONAL].normal
|
||||
val level = tile.level
|
||||
var bhTile: BlackHoleBlockEntity? = null
|
||||
|
||||
@ -68,7 +68,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv
|
||||
poseStack.pushPose()
|
||||
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 rotateY: Double
|
||||
|
@ -27,7 +27,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context)
|
||||
return
|
||||
|
||||
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.scale(0.01f, 0.01f, 0.01f)
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
enum class BlockRotationFreedom(vararg values: BlockRotation) {
|
||||
XZ(
|
||||
HORIZONTAL(
|
||||
BlockRotation.NORTH,
|
||||
BlockRotation.SOUTH,
|
||||
BlockRotation.WEST,
|
||||
BlockRotation.EAST,
|
||||
),
|
||||
XZ_XY(
|
||||
DIRECTIONAL(
|
||||
BlockRotation.DOWN,
|
||||
BlockRotation.UP,
|
||||
BlockRotation.NORTH,
|
||||
@ -22,7 +22,7 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) {
|
||||
BlockRotation.WEST,
|
||||
BlockRotation.EAST,
|
||||
),
|
||||
XZ_XY_ZY(
|
||||
DIRECTIONAL_WITH_ROTATION(
|
||||
BlockRotation.DOWN,
|
||||
BlockRotation.UP,
|
||||
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)
|
||||
*/
|
||||
FOUR(
|
||||
FULL(
|
||||
BlockRotation.DOWN,
|
||||
BlockRotation.UP,
|
||||
BlockRotation.NORTH,
|
||||
|
Loading…
Reference in New Issue
Block a user