Add BlockRotationFreedom and BlockRotation without changing any logic
This commit is contained in:
parent
a99dab51b4
commit
e2791add3b
@ -11,6 +11,7 @@ import net.minecraftforge.client.model.generators.ModelFile
|
|||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
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.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 +217,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[RotatableMatteryBlock.FACING_FULL].toXRotBlockstate())
|
.rotationX(it[BlockRotationFreedom.TWO.property].primary.toXRotBlockstate())
|
||||||
.rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate())
|
.rotationY(it[BlockRotationFreedom.TWO.property].primary.toYRotBlockstate())
|
||||||
.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[RotatableMatteryBlock.FACING_FULL].toXRotBlockstate())
|
.rotationX(it[BlockRotationFreedom.TWO.property].primary.toXRotBlockstate())
|
||||||
.rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate())
|
.rotationY(it[BlockRotationFreedom.TWO.property].primary.toYRotBlockstate())
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import net.minecraftforge.client.model.generators.BlockStateProvider
|
|||||||
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.block.tech.BatteryBankBlock
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
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.datagen.toYRotBlockstate
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||||
@ -26,15 +27,15 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even
|
|||||||
with(getMultipartBuilder(registry)) {
|
with(getMultipartBuilder(registry)) {
|
||||||
val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block"))
|
val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block"))
|
||||||
|
|
||||||
RotatableMatteryBlock.FACING.possibleValues.forEach {
|
BlockRotationFreedom.ONE.possibleValues.forEach {
|
||||||
part().modelFile(battery_bank).rotationY(it.toYRotBlockstate()).addModel().condition(
|
part().modelFile(battery_bank).rotationY(it.primary.toYRotBlockstate()).addModel().condition(
|
||||||
RotatableMatteryBlock.FACING, it)
|
BlockRotationFreedom.ONE.property, it)
|
||||||
|
|
||||||
for (i in 0 .. 11) {
|
for (i in 0 .. 11) {
|
||||||
part().modelFile(
|
part().modelFile(
|
||||||
models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath$i"))
|
models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath$i"))
|
||||||
).rotationY(it.toYRotBlockstate()).addModel()
|
).rotationY(it.primary.toYRotBlockstate()).addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING, it)
|
.condition(BlockRotationFreedom.ONE.property, it)
|
||||||
.condition(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], true)
|
.condition(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
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.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.toXRotBlockstate
|
||||||
@ -36,41 +37,41 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
|
|
||||||
provider.exec {
|
provider.exec {
|
||||||
with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) {
|
with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) {
|
||||||
for (dir in RotatableMatteryBlock.FACING.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.toYRotBlockstate())
|
.rotationY(dir.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)
|
.condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)
|
||||||
.condition(RotatableMatteryBlock.FACING, dir)
|
.condition(BlockRotationFreedom.ONE.property, dir)
|
||||||
.end()
|
.end()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) {
|
with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) {
|
||||||
for (dir in RotatableMatteryBlock.FACING.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.toYRotBlockstate())
|
.rotationY(dir.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING, dir)
|
.condition(BlockRotationFreedom.ONE.property, dir)
|
||||||
.condition(WorkerState.WORKER_STATE, enum)
|
.condition(WorkerState.WORKER_STATE, enum)
|
||||||
.end()
|
.end()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dir in RotatableMatteryBlock.FACING.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.toYRotBlockstate())
|
.rotationY(dir.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING, 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.toYRotBlockstate())
|
.rotationY(dir.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING, dir)
|
.condition(BlockRotationFreedom.ONE.property, dir)
|
||||||
.condition(enum, true)
|
.condition(enum, true)
|
||||||
.end()
|
.end()
|
||||||
}
|
}
|
||||||
@ -98,26 +99,26 @@ 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(RotatableMatteryBlock.FACING).toYRotBlockstate())
|
.rotationY(it.getValue(BlockRotationFreedom.ONE.property).primary.toYRotBlockstate())
|
||||||
.buildLast()
|
.buildLast()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) {
|
with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) {
|
||||||
for (dir in net.minecraft.core.Direction.values()) {
|
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.toXRotBlockstate())
|
.rotationX(dir.primary.toXRotBlockstate())
|
||||||
.rotationY(dir.toYRotBlockstate())
|
.rotationY(dir.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING_FULL, 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.toXRotBlockstateInv())
|
.rotationX(dir.primary.toXRotBlockstateInv())
|
||||||
.rotationY(dir.toYRotBlockstateInv())
|
.rotationY(dir.primary.toYRotBlockstateInv())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true)
|
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true)
|
||||||
.end()
|
.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,19 +127,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) {
|
with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) {
|
||||||
for (dir in net.minecraft.core.Direction.values()) {
|
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.toXRotBlockstate())
|
.rotationX(dir.primary.toXRotBlockstate())
|
||||||
.rotationY(dir.toYRotBlockstate())
|
.rotationY(dir.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING_FULL, 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.toXRotBlockstateInv())
|
.rotationX(dir.primary.toXRotBlockstateInv())
|
||||||
.rotationY(dir.toYRotBlockstateInv())
|
.rotationY(dir.primary.toYRotBlockstateInv())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true)
|
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true)
|
||||||
.end()
|
.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,19 +148,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) {
|
with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) {
|
||||||
for (dir in net.minecraft.core.Direction.values()) {
|
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.toXRotBlockstate())
|
.rotationX(dir.primary.toXRotBlockstate())
|
||||||
.rotationY(dir.toYRotBlockstate())
|
.rotationY(dir.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING_FULL, 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.toXRotBlockstateInv())
|
.rotationX(dir.primary.toXRotBlockstateInv())
|
||||||
.rotationY(dir.toYRotBlockstateInv())
|
.rotationY(dir.primary.toYRotBlockstateInv())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true)
|
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true)
|
||||||
.end()
|
.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,45 +7,46 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
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.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.datagen.toYRotBlockstate
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
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 RotatableMatteryBlock.FACING.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.toYRotBlockstate())
|
.rotationY(facing.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING, facing)
|
.condition(BlockRotationFreedom.ONE.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) {
|
||||||
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.toYRotBlockstate())
|
.rotationY(facing.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(WorkerState.SEMI_WORKER_STATE, workState)
|
.condition(WorkerState.SEMI_WORKER_STATE, workState)
|
||||||
.condition(RotatableMatteryBlock.FACING, facing)
|
.condition(BlockRotationFreedom.ONE.property, facing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) {
|
with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) {
|
||||||
for (facing in RotatableMatteryBlock.FACING.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.toYRotBlockstate())
|
.rotationY(facing.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING, 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.toYRotBlockstate())
|
.rotationY(facing.primary.toYRotBlockstate())
|
||||||
.addModel()
|
.addModel()
|
||||||
.condition(RotatableMatteryBlock.FACING, facing)
|
.condition(BlockRotationFreedom.ONE.property, facing)
|
||||||
.condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true)
|
.condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ 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.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
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.getValueNullable
|
||||||
import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate
|
import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate
|
||||||
@ -21,13 +22,13 @@ 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(RotatableMatteryBlock.FACING)?.let {
|
it.getValueNullable(BlockRotationFreedom.ONE.property)?.let {
|
||||||
builder.rotationY(it.toYRotBlockstate())
|
builder.rotationY(it.primary.toYRotBlockstate())
|
||||||
}
|
}
|
||||||
|
|
||||||
it.getValueNullable(RotatableMatteryBlock.FACING_FULL)?.let {
|
it.getValueNullable(BlockRotationFreedom.TWO.property)?.let {
|
||||||
builder.rotationY(it.toYRotBlockstate())
|
builder.rotationY(it.primary.toYRotBlockstate())
|
||||||
builder.rotationX(it.toXRotBlockstate())
|
builder.rotationX(it.primary.toXRotBlockstate())
|
||||||
}
|
}
|
||||||
|
|
||||||
it.getValueNullable(WorkerState.WORKER_STATE)?.let {
|
it.getValueNullable(WorkerState.WORKER_STATE)?.let {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package ru.dbotthepony.mc.otm.block
|
package ru.dbotthepony.mc.otm.block
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
|
import net.minecraft.core.Direction
|
||||||
import net.minecraft.world.level.BlockGetter
|
import net.minecraft.world.level.BlockGetter
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.minecraft.world.level.block.EntityBlock
|
import net.minecraft.world.level.block.EntityBlock
|
||||||
@ -19,6 +20,9 @@ import net.minecraft.world.phys.shapes.Shapes
|
|||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotation
|
||||||
|
import java.util.Collections
|
||||||
|
import java.util.EnumMap
|
||||||
|
|
||||||
abstract class CableBlock(properties: Properties) : Block(properties) {
|
abstract class CableBlock(properties: Properties) : Block(properties) {
|
||||||
init {
|
init {
|
||||||
@ -52,14 +56,16 @@ abstract class CableBlock(properties: Properties) : Block(properties) {
|
|||||||
val CONNECTION_UP: BooleanProperty = BooleanProperty.create("connect_up")
|
val CONNECTION_UP: BooleanProperty = BooleanProperty.create("connect_up")
|
||||||
val CONNECTION_DOWN: BooleanProperty = BooleanProperty.create("connect_down")
|
val CONNECTION_DOWN: BooleanProperty = BooleanProperty.create("connect_down")
|
||||||
|
|
||||||
val MAPPING_CONNECTION_PROP = listOf(
|
val MAPPING_CONNECTION_PROP: Map<Direction, BooleanProperty> = EnumMap<Direction, BooleanProperty>(Direction::class.java)
|
||||||
CONNECTION_DOWN,
|
.let {
|
||||||
CONNECTION_UP,
|
it[Direction.DOWN] = CONNECTION_DOWN
|
||||||
CONNECTION_NORTH,
|
it[Direction.UP] = CONNECTION_UP
|
||||||
CONNECTION_SOUTH,
|
it[Direction.NORTH] = CONNECTION_NORTH
|
||||||
CONNECTION_WEST,
|
it[Direction.SOUTH] = CONNECTION_SOUTH
|
||||||
CONNECTION_EAST
|
it[Direction.WEST] = CONNECTION_WEST
|
||||||
)
|
it[Direction.EAST] = CONNECTION_EAST
|
||||||
|
Collections.unmodifiableMap(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.block
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos
|
||||||
|
import net.minecraft.world.Container
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
|
import net.minecraft.world.level.Level
|
||||||
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
|
|
||||||
|
interface IDroppableContainer {
|
||||||
|
val droppableContainer: Container
|
||||||
|
|
||||||
|
fun beforeDroppingItems(
|
||||||
|
oldBlockState: BlockState,
|
||||||
|
level: Level,
|
||||||
|
blockPos: BlockPos,
|
||||||
|
newBlockState: BlockState,
|
||||||
|
movedByPiston: Boolean
|
||||||
|
) {}
|
||||||
|
|
||||||
|
fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {}
|
||||||
|
}
|
@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos
|
|||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import net.minecraft.core.particles.DustParticleOptions
|
import net.minecraft.core.particles.DustParticleOptions
|
||||||
import net.minecraft.util.RandomSource
|
import net.minecraft.util.RandomSource
|
||||||
import net.minecraft.world.Container
|
|
||||||
import net.minecraft.world.Containers
|
import net.minecraft.world.Containers
|
||||||
import net.minecraft.world.InteractionHand
|
import net.minecraft.world.InteractionHand
|
||||||
import net.minecraft.world.InteractionResult
|
import net.minecraft.world.InteractionResult
|
||||||
@ -12,38 +11,20 @@ import net.minecraft.world.MenuProvider
|
|||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.world.entity.LivingEntity
|
||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext
|
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.minecraft.world.level.block.EntityBlock
|
import net.minecraft.world.level.block.EntityBlock
|
||||||
import net.minecraft.world.level.block.Rotation
|
|
||||||
import net.minecraft.world.level.block.state.BlockState
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
import net.minecraft.world.level.block.state.StateDefinition
|
|
||||||
import net.minecraft.world.level.block.state.properties.EnumProperty
|
|
||||||
import net.minecraft.world.level.material.Material
|
import net.minecraft.world.level.material.Material
|
||||||
import net.minecraft.world.level.material.MaterialColor
|
import net.minecraft.world.level.material.MaterialColor
|
||||||
import net.minecraft.world.phys.BlockHitResult
|
import net.minecraft.world.phys.BlockHitResult
|
||||||
import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider
|
import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
import ru.dbotthepony.mc.otm.core.math.component1
|
import ru.dbotthepony.mc.otm.core.math.component1
|
||||||
import ru.dbotthepony.mc.otm.core.math.component2
|
import ru.dbotthepony.mc.otm.core.math.component2
|
||||||
import ru.dbotthepony.mc.otm.core.math.component3
|
import ru.dbotthepony.mc.otm.core.math.component3
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
|
||||||
|
|
||||||
interface IDroppableContainer {
|
|
||||||
val droppableContainer: Container
|
|
||||||
|
|
||||||
fun beforeDroppingItems(
|
|
||||||
oldBlockState: BlockState,
|
|
||||||
level: Level,
|
|
||||||
blockPos: BlockPos,
|
|
||||||
newBlockState: BlockState,
|
|
||||||
movedByPiston: Boolean
|
|
||||||
) {}
|
|
||||||
|
|
||||||
fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class MatteryBlock @JvmOverloads constructor(
|
abstract class MatteryBlock @JvmOverloads constructor(
|
||||||
properties: Properties = DEFAULT_PROPERTIES
|
properties: Properties = DEFAULT_PROPERTIES
|
||||||
@ -94,7 +75,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(RotatableMatteryBlock.FACING).or { blockState.getOptionalValue(RotatableMatteryBlock.FACING_FULL) }
|
val state2 = blockState.getOptionalValue(BlockRotationFreedom.ONE.property)
|
||||||
|
.or { blockState.getOptionalValue(BlockRotationFreedom.TWO.property) }
|
||||||
|
.or { blockState.getOptionalValue(BlockRotationFreedom.THREE.property) }
|
||||||
|
|
||||||
if (state2.isPresent) {
|
if (state2.isPresent) {
|
||||||
val direction = state2.get()
|
val direction = state2.get()
|
||||||
@ -109,7 +92,7 @@ abstract class MatteryBlock @JvmOverloads constructor(
|
|||||||
yd += ny * 0.5
|
yd += ny * 0.5
|
||||||
zd += nz * 0.5
|
zd += nz * 0.5
|
||||||
|
|
||||||
when (direction) {
|
when (direction.primary) {
|
||||||
Direction.DOWN, Direction.UP -> {
|
Direction.DOWN, Direction.UP -> {
|
||||||
xd += random.nextDouble() - 0.5
|
xd += random.nextDouble() - 0.5
|
||||||
zd += random.nextDouble() - 0.5
|
zd += random.nextDouble() - 0.5
|
||||||
@ -201,76 +184,3 @@ abstract class MatteryBlock @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) {
|
|
||||||
init {
|
|
||||||
@Suppress("LeakingThis")
|
|
||||||
registerDefaultState(getStateDefinition().any().setValue(facingProperty, Direction.SOUTH))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
|
||||||
builder.add(facingProperty)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
|
||||||
if (hasFreeRotation) {
|
|
||||||
return defaultBlockState().setValue(
|
|
||||||
FACING_FULL,
|
|
||||||
if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return defaultBlockState().setValue(
|
|
||||||
FACING,
|
|
||||||
if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("OVERRIDE_DEPRECATION")
|
|
||||||
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
return super.rotate(blockState, rotation).setValue(facingProperty, rotation.rotate(blockState[facingProperty]))
|
|
||||||
}
|
|
||||||
|
|
||||||
val facingProperty get() = if (hasFreeRotation) FACING_FULL else FACING
|
|
||||||
open val hasFreeRotation get() = false
|
|
||||||
|
|
||||||
open fun faceToPlayer(context: BlockPlaceContext): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
/**
|
|
||||||
* Allows to instance [RotatableMatteryBlock] directly
|
|
||||||
*/
|
|
||||||
fun make(properties: Properties, hasFreeRotation: Boolean = false, faceToPlayer: Boolean = true): RotatableMatteryBlock {
|
|
||||||
if (hasFreeRotation) { // can't have one class for two cases - superclass (both in OTM and in Minecraft) are leaking "this"
|
|
||||||
return object : RotatableMatteryBlock(properties) {
|
|
||||||
override val hasFreeRotation get() = true // this is accessed from superclass constructor
|
|
||||||
|
|
||||||
override fun faceToPlayer(context: BlockPlaceContext): Boolean {
|
|
||||||
return faceToPlayer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return object : RotatableMatteryBlock(properties) {
|
|
||||||
override val hasFreeRotation get() = false // this is accessed from superclass constructor
|
|
||||||
|
|
||||||
override fun faceToPlayer(context: BlockPlaceContext): Boolean {
|
|
||||||
return faceToPlayer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val FACING: EnumProperty<Direction> = EnumProperty.create(
|
|
||||||
"facing",
|
|
||||||
Direction::class.java,
|
|
||||||
Direction.SOUTH,
|
|
||||||
Direction.WEST,
|
|
||||||
Direction.NORTH,
|
|
||||||
Direction.EAST
|
|
||||||
)
|
|
||||||
|
|
||||||
val FACING_FULL: EnumProperty<Direction> = EnumProperty.create("facing", Direction::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.block
|
||||||
|
|
||||||
|
import net.minecraft.world.item.context.BlockPlaceContext
|
||||||
|
import net.minecraft.world.level.block.Block
|
||||||
|
import net.minecraft.world.level.block.Rotation
|
||||||
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition
|
||||||
|
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) {
|
||||||
|
init {
|
||||||
|
@Suppress("LeakingThis")
|
||||||
|
registerDefaultState(getStateDefinition().any().setValue(rotationProperty, BlockRotation.SOUTH))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||||
|
builder.add(rotationProperty)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||||
|
if (rotationFreedom() == BlockRotationFreedom.ONE) {
|
||||||
|
return defaultBlockState().setValue(
|
||||||
|
rotationProperty,
|
||||||
|
BlockRotation.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return defaultBlockState().setValue(
|
||||||
|
rotationProperty,
|
||||||
|
BlockRotation.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
|
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
return super.rotate(blockState, rotation).setValue(rotationProperty, blockState[rotationProperty].rotate(rotation))
|
||||||
|
}
|
||||||
|
|
||||||
|
val rotationProperty get() = rotationFreedom().property
|
||||||
|
|
||||||
|
open fun rotationFreedom(): BlockRotationFreedom {
|
||||||
|
return BlockRotationFreedom.ONE
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun faceToPlayer(context: BlockPlaceContext): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
@ -9,14 +9,16 @@ import net.minecraft.world.phys.shapes.CollisionContext
|
|||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
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.shapes.BlockShapes
|
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||||
|
|
||||||
class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) {
|
class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) {
|
||||||
override val hasFreeRotation: Boolean
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
get() = true
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
private val shapes = getShapeForEachState {
|
private val shapes = getShapeForEachState {
|
||||||
BlockShapes.ENGINE.rotateInv(it[FACING_FULL]).computeShape()
|
BlockShapes.ENGINE.rotateInv(it[rotationProperty].primary).computeShape()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getShape(
|
override fun getShape(
|
||||||
|
@ -2,8 +2,6 @@ package ru.dbotthepony.mc.otm.block.decorative
|
|||||||
|
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.world.level.BlockGetter
|
import net.minecraft.world.level.BlockGetter
|
||||||
import net.minecraft.world.level.Level
|
|
||||||
import net.minecraft.world.level.block.Block
|
|
||||||
import net.minecraft.world.level.block.EntityBlock
|
import net.minecraft.world.level.block.EntityBlock
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity
|
import net.minecraft.world.level.block.entity.BlockEntity
|
||||||
import net.minecraft.world.level.block.state.BlockState
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
@ -12,18 +10,20 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity
|
||||||
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.shapes.BlockShapes
|
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||||
|
|
||||||
class HoloSignBlock : RotatableMatteryBlock(), EntityBlock {
|
class HoloSignBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
override val hasFreeRotation: Boolean
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
get() = true
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||||
return HoloSignBlockEntity(p_153215_, p_153216_)
|
return HoloSignBlockEntity(p_153215_, p_153216_)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val shapes = getShapeForEachState {
|
private val shapes = getShapeForEachState {
|
||||||
BlockShapes.HOLO_SIGN.rotateInv(it[FACING_FULL]).computeShape()
|
BlockShapes.HOLO_SIGN.rotateInv(it[rotationProperty].primary).computeShape()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getShape(
|
override fun getShape(
|
||||||
|
@ -21,19 +21,20 @@ import net.minecraft.world.phys.shapes.CollisionContext
|
|||||||
import net.minecraft.world.phys.shapes.Shapes
|
import net.minecraft.world.phys.shapes.Shapes
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
import ru.dbotthepony.mc.otm.ServerConfig
|
import ru.dbotthepony.mc.otm.ServerConfig
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
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.blockRotation
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
import ru.dbotthepony.mc.otm.core.math.plus
|
||||||
import ru.dbotthepony.mc.otm.core.math.times
|
|
||||||
import ru.dbotthepony.mc.otm.core.math.unaryMinus
|
|
||||||
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.TWO.property
|
||||||
|
|
||||||
class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noLootTable().noOcclusion().lightLevel { 15 }) {
|
class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noLootTable().noOcclusion().lightLevel { 15 }) {
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||||
super.createBlockStateDefinition(builder)
|
super.createBlockStateDefinition(builder)
|
||||||
builder.add(RotatableMatteryBlock.FACING_FULL)
|
builder.add(FACING_FULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hasDynamicShape(): Boolean {
|
override fun hasDynamicShape(): Boolean {
|
||||||
@ -53,7 +54,7 @@ class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 36
|
|||||||
@Suppress("OVERRIDE_DEPRECATION")
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
return super.rotate(blockState, rotation).setValue(RotatableMatteryBlock.FACING_FULL, rotation.rotate(blockState[RotatableMatteryBlock.FACING_FULL]))
|
return super.rotate(blockState, rotation).setValue(FACING_FULL, blockState[FACING_FULL].rotate(rotation))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("OVERRIDE_DEPRECATION")
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
@ -80,7 +81,7 @@ class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 36
|
|||||||
if (level.getBlockState(pos) != state)
|
if (level.getBlockState(pos) != state)
|
||||||
return@once
|
return@once
|
||||||
|
|
||||||
val facing = state[RotatableMatteryBlock.FACING_FULL]
|
val facing = state[FACING_FULL]
|
||||||
|
|
||||||
var hit = false
|
var hit = false
|
||||||
|
|
||||||
@ -111,14 +112,14 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material
|
|||||||
|
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||||
super.createBlockStateDefinition(builder)
|
super.createBlockStateDefinition(builder)
|
||||||
builder.add(RotatableMatteryBlock.FACING_FULL)
|
builder.add(FACING_FULL)
|
||||||
builder.add(BlockStateProperties.LIT)
|
builder.add(BlockStateProperties.LIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
|
override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
|
||||||
return super.getStateForPlacement(context)!!
|
return super.getStateForPlacement(context)!!
|
||||||
.setValue(BlockStateProperties.LIT, !invertRedstone)
|
.setValue(BlockStateProperties.LIT, !invertRedstone)
|
||||||
.setValue(RotatableMatteryBlock.FACING_FULL, -context.nearestLookingDirection)
|
.setValue(FACING_FULL, -context.nearestLookingDirection.blockRotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun appendHoverText(
|
override fun appendHoverText(
|
||||||
@ -147,7 +148,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material
|
|||||||
@Suppress("OVERRIDE_DEPRECATION")
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
return super.rotate(blockState, rotation).setValue(RotatableMatteryBlock.FACING_FULL, rotation.rotate(blockState[RotatableMatteryBlock.FACING_FULL]))
|
return super.rotate(blockState, rotation).setValue(FACING_FULL, blockState[FACING_FULL].rotate(rotation))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doTick(
|
fun doTick(
|
||||||
@ -172,7 +173,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material
|
|||||||
level.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.LIT, shouldBeLit))
|
level.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.LIT, shouldBeLit))
|
||||||
}
|
}
|
||||||
|
|
||||||
val facing = state[RotatableMatteryBlock.FACING_FULL]
|
val facing = state[FACING_FULL]
|
||||||
|
|
||||||
for (i in 1 .. ServerConfig.LABORATORY_LAMP_LIGHT_LENGTH) {
|
for (i in 1 .. ServerConfig.LABORATORY_LAMP_LIGHT_LENGTH) {
|
||||||
val target = pos + facing * i
|
val target = pos + facing * i
|
||||||
@ -185,7 +186,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material
|
|||||||
if (shouldBeLit) {
|
if (shouldBeLit) {
|
||||||
if (targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) {
|
if (targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) {
|
||||||
level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState().setValue(
|
level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState().setValue(
|
||||||
RotatableMatteryBlock.FACING_FULL, -facing))
|
FACING_FULL, -facing))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (targetState.block == MBlocks.LABORATORY_LAMP_LIGHT) {
|
if (targetState.block == MBlocks.LABORATORY_LAMP_LIGHT) {
|
||||||
|
@ -54,14 +54,14 @@ class MatterCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true)
|
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true)
|
||||||
|
|
||||||
if (newState !== blockState && SERVER_IS_LIVE)
|
if (newState !== blockState && SERVER_IS_LIVE)
|
||||||
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false)
|
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false)
|
||||||
|
|
||||||
if (newState !== blockState && SERVER_IS_LIVE)
|
if (newState !== blockState && SERVER_IS_LIVE)
|
||||||
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
@ -110,14 +110,14 @@ class StorageCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true)
|
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true)
|
||||||
|
|
||||||
if (newState !== blockState && SERVER_IS_LIVE)
|
if (newState !== blockState && SERVER_IS_LIVE)
|
||||||
level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false)
|
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false)
|
||||||
|
|
||||||
if (newState !== blockState && SERVER_IS_LIVE)
|
if (newState !== blockState && SERVER_IS_LIVE)
|
||||||
level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
|
@ -27,6 +27,8 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
|||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.container.ItemFilter
|
import ru.dbotthepony.mc.otm.container.ItemFilter
|
||||||
import ru.dbotthepony.mc.otm.core.*
|
import ru.dbotthepony.mc.otm.core.*
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.getCapability
|
||||||
import ru.dbotthepony.mc.otm.core.math.isPositive
|
import ru.dbotthepony.mc.otm.core.math.isPositive
|
||||||
import ru.dbotthepony.mc.otm.core.math.isZero
|
import ru.dbotthepony.mc.otm.core.math.isZero
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
import ru.dbotthepony.mc.otm.core.math.plus
|
||||||
@ -79,14 +81,14 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
|
|||||||
|
|
||||||
val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener {
|
val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener {
|
||||||
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true)
|
val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true)
|
||||||
|
|
||||||
if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE)
|
if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE)
|
||||||
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false)
|
val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false)
|
||||||
|
|
||||||
if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE)
|
if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE)
|
||||||
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
@ -111,7 +113,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
|
|||||||
private var valid = true
|
private var valid = true
|
||||||
|
|
||||||
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
||||||
return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(RotatableMatteryBlock.FACING_FULL)) {
|
return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).primary) {
|
||||||
cell.get().cast()
|
cell.get().cast()
|
||||||
} else super.getCapability(cap, side)
|
} else super.getCapability(cap, side)
|
||||||
}
|
}
|
||||||
@ -157,8 +159,8 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
|
|||||||
if (isRemoved)
|
if (isRemoved)
|
||||||
return
|
return
|
||||||
|
|
||||||
val front = blockPos + blockState.getValue(RotatableMatteryBlock.FACING_FULL)
|
val front = blockPos + blockState.getValue(BlockRotationFreedom.TWO.property)
|
||||||
val storage = level?.getBlockEntity(front)?.getCapability(ForgeCapabilities.ITEM_HANDLER, -blockState.getValue(RotatableMatteryBlock.FACING_FULL))?.let { if (it.isPresent) it else null }
|
val storage = level?.getBlockEntity(front)?.getCapability(ForgeCapabilities.ITEM_HANDLER, -blockState.getValue(BlockRotationFreedom.TWO.property))?.let { if (it.isPresent) it else null }
|
||||||
|
|
||||||
if (neighbour != storage) {
|
if (neighbour != storage) {
|
||||||
neighbour = storage
|
neighbour = storage
|
||||||
|
@ -26,7 +26,9 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
|||||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.container.ItemFilter
|
import ru.dbotthepony.mc.otm.container.ItemFilter
|
||||||
import ru.dbotthepony.mc.otm.core.*
|
import ru.dbotthepony.mc.otm.core.*
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.rotationTwo
|
||||||
import ru.dbotthepony.mc.otm.core.math.toIntSafe
|
import ru.dbotthepony.mc.otm.core.math.toIntSafe
|
||||||
import ru.dbotthepony.mc.otm.core.math.unaryMinus
|
import ru.dbotthepony.mc.otm.core.math.unaryMinus
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.map
|
import ru.dbotthepony.mc.otm.core.nbt.map
|
||||||
@ -56,14 +58,14 @@ abstract class AbstractStorageImportExport<T>(
|
|||||||
|
|
||||||
val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener {
|
val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener {
|
||||||
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true)
|
val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true)
|
||||||
|
|
||||||
if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE)
|
if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE)
|
||||||
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) {
|
||||||
val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false)
|
val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false)
|
||||||
|
|
||||||
if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE)
|
if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE)
|
||||||
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||||
@ -73,7 +75,7 @@ abstract class AbstractStorageImportExport<T>(
|
|||||||
private var valid = true
|
private var valid = true
|
||||||
|
|
||||||
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
||||||
return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(RotatableMatteryBlock.FACING_FULL)) {
|
return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).primary) {
|
||||||
cell.get().cast()
|
cell.get().cast()
|
||||||
} else super.getCapability(cap, side)
|
} else super.getCapability(cap, side)
|
||||||
}
|
}
|
||||||
@ -112,7 +114,7 @@ abstract class AbstractStorageImportExport<T>(
|
|||||||
protected val target by lazy {
|
protected val target by lazy {
|
||||||
object : BESubscribeList<T>(this@AbstractStorageImportExport, targetCapability) {
|
object : BESubscribeList<T>(this@AbstractStorageImportExport, targetCapability) {
|
||||||
override fun test(t: Direction): Boolean {
|
override fun test(t: Direction): Boolean {
|
||||||
return t == -this@AbstractStorageImportExport.blockState.getValue(RotatableMatteryBlock.FACING_FULL)
|
return t == -this@AbstractStorageImportExport.blockState.getValue(BlockRotationFreedom.TWO.property).primary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,7 +179,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
||||||
if (valid && cap == ForgeCapabilities.ITEM_HANDLER && side == blockState.getValue(RotatableMatteryBlock.FACING_FULL)) {
|
if (valid && cap == ForgeCapabilities.ITEM_HANDLER && side == blockState.rotationTwo.primary) {
|
||||||
return resolverItemHandler.cast()
|
return resolverItemHandler.cast()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer
|
|||||||
import ru.dbotthepony.mc.otm.container.MatteryContainerHooks
|
import ru.dbotthepony.mc.otm.container.MatteryContainerHooks
|
||||||
import ru.dbotthepony.mc.otm.core.*
|
import ru.dbotthepony.mc.otm.core.*
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.rotationOne
|
||||||
import ru.dbotthepony.mc.otm.core.math.unaryMinus
|
import ru.dbotthepony.mc.otm.core.math.unaryMinus
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
import ru.dbotthepony.mc.otm.core.util.BESubscribeList
|
import ru.dbotthepony.mc.otm.core.util.BESubscribeList
|
||||||
@ -271,7 +273,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
|||||||
if (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) {
|
if (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) {
|
||||||
if (side == null) return resolverEnergy.cast()
|
if (side == null) return resolverEnergy.cast()
|
||||||
|
|
||||||
if (side == blockState.getValue(RotatableMatteryBlock.FACING))
|
if (side == blockState.facingOne)
|
||||||
return resolverEnergyExtractor.cast()
|
return resolverEnergyExtractor.cast()
|
||||||
else
|
else
|
||||||
return resolverEnergyReceiver.cast()
|
return resolverEnergyReceiver.cast()
|
||||||
@ -280,7 +282,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
|||||||
if (cap == MatteryCapability.MEKANISM_ENERGY) {
|
if (cap == MatteryCapability.MEKANISM_ENERGY) {
|
||||||
if (side == null) return mekanismResolverEnergy.cast()
|
if (side == null) return mekanismResolverEnergy.cast()
|
||||||
|
|
||||||
if (side == blockState.getValue(RotatableMatteryBlock.FACING))
|
if (side == blockState.facingOne)
|
||||||
return mekanismResolverEnergyExtractor.cast()
|
return mekanismResolverEnergyExtractor.cast()
|
||||||
else
|
else
|
||||||
return mekanismResolverEnergyReceiver.cast()
|
return mekanismResolverEnergyReceiver.cast()
|
||||||
@ -296,11 +298,11 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
|||||||
|
|
||||||
private val consumers = object : BESubscribeList<IEnergyStorage>(this@BatteryBankBlockEntity, ForgeCapabilities.ENERGY) {
|
private val consumers = object : BESubscribeList<IEnergyStorage>(this@BatteryBankBlockEntity, ForgeCapabilities.ENERGY) {
|
||||||
override fun test(t: Direction): Boolean {
|
override fun test(t: Direction): Boolean {
|
||||||
return -blockState.getValue(RotatableMatteryBlock.FACING) == t
|
return -blockState.facingOne == t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkSurroundings() = consumers.update((-blockState.getValue(RotatableMatteryBlock.FACING))::equals)
|
fun checkSurroundings() = consumers.update((-blockState.facingOne)::equals)
|
||||||
|
|
||||||
fun tick() {
|
fun tick() {
|
||||||
if (redstoneControl.isBlockedByRedstone)
|
if (redstoneControl.isBlockedByRedstone)
|
||||||
|
@ -34,6 +34,7 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
|||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue
|
import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue
|
||||||
import ru.dbotthepony.mc.otm.core.math.defineDecimal
|
import ru.dbotthepony.mc.otm.core.math.defineDecimal
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.map
|
import ru.dbotthepony.mc.otm.core.nbt.map
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
import ru.dbotthepony.mc.otm.core.util.BESubscribeList
|
import ru.dbotthepony.mc.otm.core.util.BESubscribeList
|
||||||
@ -62,7 +63,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
override fun <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
||||||
if (valid && (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) && side !== blockState.getValue(RotatableMatteryBlock.FACING))
|
if (valid && (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) && side !== blockState.facingOne)
|
||||||
return energy.resolver.cast()
|
return energy.resolver.cast()
|
||||||
|
|
||||||
if (valid && cap == ForgeCapabilities.ITEM_HANDLER)
|
if (valid && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||||
|
@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer
|
import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingTwo
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
import ru.dbotthepony.mc.otm.core.math.plus
|
||||||
import ru.dbotthepony.mc.otm.core.math.times
|
import ru.dbotthepony.mc.otm.core.math.times
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||||
@ -32,7 +33,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.getValue(RotatableMatteryBlock.FACING_FULL).normal
|
val dir = blockState.facingTwo.normal
|
||||||
|
|
||||||
for (i in 2 .. RANGE) {
|
for (i in 2 .. RANGE) {
|
||||||
val pos = blockPos + dir * i
|
val pos = blockPos + dir * i
|
||||||
|
@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ class MatterBottlerBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -14,6 +14,7 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock
|
import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||||
|
|
||||||
class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock {
|
class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
@ -41,7 +42,7 @@ class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.CollisionContext
|
|||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -17,6 +17,9 @@ import net.minecraft.world.level.block.Block
|
|||||||
import net.minecraft.world.level.block.state.properties.EnumProperty
|
import net.minecraft.world.level.block.state.properties.EnumProperty
|
||||||
import ru.dbotthepony.mc.otm.block.MatteryBlock
|
import ru.dbotthepony.mc.otm.block.MatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotation
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.rotationTwo
|
||||||
|
|
||||||
class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
|
class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||||
@ -26,10 +29,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
private val shapes: ImmutableMap<BlockState, VoxelShape>
|
private val shapes: ImmutableMap<BlockState, VoxelShape>
|
||||||
|
|
||||||
init {
|
init {
|
||||||
registerDefaultState(getStateDefinition().any().setValue(FACING_FULL, Direction.SOUTH))
|
registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.TWO.property, BlockRotation.SOUTH))
|
||||||
|
|
||||||
shapes = getShapeForEachState {
|
shapes = getShapeForEachState {
|
||||||
when (it.getValue(FACING_FULL)) {
|
when (it.rotationTwo.primary) {
|
||||||
Direction.NORTH -> Shapes.box(
|
Direction.NORTH -> Shapes.box(
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
@ -91,10 +94,11 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
return shapes[p_60555_]!!
|
return shapes[p_60555_]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override val hasFreeRotation: Boolean
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
get() = true
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||||
return defaultBlockState().setValue(FACING_FULL, context.clickedFace)
|
return defaultBlockState().setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(context.clickedFace))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ class MatterRecyclerBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.CollisionContext
|
|||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||||
|
|
||||||
class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock {
|
class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
@ -62,7 +63,7 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class DriveRackBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.storage.DriveViewerBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.DriveViewerBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class ItemMonitorBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -24,13 +24,18 @@ import ru.dbotthepony.mc.otm.block.StorageCableBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotation
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingTwo
|
||||||
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
|
import ru.dbotthepony.mc.otm.oncePre
|
||||||
|
|
||||||
class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
|
class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
override val hasFreeRotation: Boolean get() = true
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
registerDefaultState(defaultBlockState()
|
registerDefaultState(defaultBlockState()
|
||||||
@ -47,7 +52,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||||
return super.getStateForPlacement(context)?.setValue(FACING_FULL, -context.clickedFace)
|
return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun appendHoverText(
|
override fun appendHoverText(
|
||||||
@ -93,7 +98,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
|
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
|
||||||
}
|
}
|
||||||
|
|
||||||
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateInv(it.getValue(FACING_FULL)).computeShape(), BooleanOp.OR)
|
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR)
|
||||||
|
|
||||||
return@getShapeForEachState finalShape
|
return@getShapeForEachState finalShape
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,18 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotation
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingTwo
|
||||||
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
|
import ru.dbotthepony.mc.otm.oncePre
|
||||||
|
|
||||||
class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
override val hasFreeRotation: Boolean get() = true
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||||
return StorageImporterBlockEntity(p_153215_, p_153216_)
|
return StorageImporterBlockEntity(p_153215_, p_153216_)
|
||||||
@ -72,7 +77,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||||
return super.getStateForPlacement(context)?.setValue(FACING_FULL, -context.clickedFace)
|
return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun appendHoverText(
|
override fun appendHoverText(
|
||||||
@ -94,7 +99,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
|
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
|
||||||
}
|
}
|
||||||
|
|
||||||
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateInv(it.getValue(FACING_FULL)).computeShape(), BooleanOp.OR)
|
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR)
|
||||||
|
|
||||||
return@getShapeForEachState finalShape
|
return@getShapeForEachState finalShape
|
||||||
}
|
}
|
||||||
@ -133,7 +138,9 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
|
class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
|
||||||
override val hasFreeRotation: Boolean get() = true
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||||
return StorageExporterBlockEntity(p_153215_, p_153216_)
|
return StorageExporterBlockEntity(p_153215_, p_153216_)
|
||||||
@ -185,7 +192,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||||
return super.getStateForPlacement(context)?.setValue(FACING_FULL, -context.clickedFace)
|
return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace))
|
||||||
}
|
}
|
||||||
|
|
||||||
private val shapes = getShapeForEachState {
|
private val shapes = getShapeForEachState {
|
||||||
@ -196,7 +203,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
|
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
|
||||||
}
|
}
|
||||||
|
|
||||||
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateInv(it.getValue(FACING_FULL)).computeShape(), BooleanOp.OR)
|
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR)
|
||||||
|
|
||||||
return@getShapeForEachState finalShape
|
return@getShapeForEachState finalShape
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -19,6 +19,7 @@ import net.minecraft.world.level.block.Block
|
|||||||
import net.minecraft.world.phys.shapes.CollisionContext
|
import net.minecraft.world.phys.shapes.CollisionContext
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
import ru.dbotthepony.mc.otm.oncePre
|
import ru.dbotthepony.mc.otm.oncePre
|
||||||
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
|
||||||
@ -61,7 +62,7 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun faceToPlayer(context: BlockPlaceContext): Boolean {
|
override fun faceToPlayer(context: BlockPlaceContext): Boolean {
|
||||||
|
@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage
|
|||||||
import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl
|
import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl
|
||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.map
|
import ru.dbotthepony.mc.otm.core.nbt.map
|
||||||
import ru.dbotthepony.mc.otm.oncePre
|
import ru.dbotthepony.mc.otm.oncePre
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||||
@ -100,7 +101,7 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -15,6 +15,7 @@ import net.minecraft.world.phys.shapes.CollisionContext
|
|||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, Mat
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -26,6 +26,8 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingTwo
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
import ru.dbotthepony.mc.otm.core.math.plus
|
||||||
import ru.dbotthepony.mc.otm.core.math.times
|
import ru.dbotthepony.mc.otm.core.math.times
|
||||||
import ru.dbotthepony.mc.otm.oncePre
|
import ru.dbotthepony.mc.otm.oncePre
|
||||||
@ -52,7 +54,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
|||||||
return BlockEntityTicker { level, _, _, tile -> if (tile is GravitationStabilizerBlockEntity) tile.tick(level) }
|
return BlockEntityTicker { level, _, _, tile -> if (tile is GravitationStabilizerBlockEntity) tile.tick(level) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override val hasFreeRotation: Boolean get() = true
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||||
super.createBlockStateDefinition(builder)
|
super.createBlockStateDefinition(builder)
|
||||||
@ -64,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 FACING_FULL.possibleValues) {
|
for (face in BlockRotationFreedom.TWO.possibleValues) {
|
||||||
val dir = face.normal
|
val dir = face.normal
|
||||||
|
|
||||||
for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) {
|
for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) {
|
||||||
@ -74,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(FACING_FULL, face)
|
state = state.setValue(BlockRotationFreedom.TWO.property, face)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val bbPos = blockPos + state.getValue(FACING_FULL).normal
|
val bbPos = blockPos + state.getValue(BlockRotationFreedom.TWO.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
|
||||||
@ -99,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(FACING_FULL).normal
|
val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).normal
|
||||||
val newState = MBlocks.GRAVITATION_STABILIZER_LENS.defaultBlockState()
|
val newState = MBlocks.GRAVITATION_STABILIZER_LENS.defaultBlockState()
|
||||||
.setValue(FACING_FULL, blockState.getValue(FACING_FULL))
|
.setValue(BlockRotationFreedom.TWO.property, blockState.getValue(BlockRotationFreedom.TWO.property))
|
||||||
|
|
||||||
level.setBlock(bbPos, newState, UPDATE_ALL)
|
level.setBlock(bbPos, newState, UPDATE_ALL)
|
||||||
}
|
}
|
||||||
@ -137,7 +141,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING_FULL).ordinal]
|
return SHAPES[p_60555_.facingTwo.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -155,13 +159,15 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos {
|
fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos {
|
||||||
return blockPos + blockState.getValue(FACING_FULL).normal
|
return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
|
class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
|
||||||
override val hasFreeRotation: Boolean get() = true
|
override fun rotationFreedom(): BlockRotationFreedom {
|
||||||
|
return BlockRotationFreedom.TWO
|
||||||
|
}
|
||||||
|
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||||
super.createBlockStateDefinition(builder)
|
super.createBlockStateDefinition(builder)
|
||||||
@ -198,7 +204,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING_FULL).ordinal]
|
return SHAPES[p_60555_.facingTwo.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -207,7 +213,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos {
|
fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos {
|
||||||
return blockPos + blockState.getValue(FACING_FULL).opposite.normal
|
return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).opposite.normal
|
||||||
}
|
}
|
||||||
|
|
||||||
private val SHAPES = arrayOf(
|
private val SHAPES = arrayOf(
|
||||||
|
@ -27,6 +27,7 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
import net.minecraftforge.common.ForgeHooks
|
import net.minecraftforge.common.ForgeHooks
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
import ru.dbotthepony.mc.otm.core.math.minus
|
import ru.dbotthepony.mc.otm.core.math.minus
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
import ru.dbotthepony.mc.otm.core.math.plus
|
||||||
import ru.dbotthepony.mc.otm.once
|
import ru.dbotthepony.mc.otm.once
|
||||||
@ -92,7 +93,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL
|
|||||||
DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM
|
DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM
|
||||||
}
|
}
|
||||||
|
|
||||||
shape.rotate(it[FACING]!!).computeShape()
|
shape.rotate(it.facingOne).computeShape()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
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
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa
|
|||||||
p_60557_: BlockPos,
|
p_60557_: BlockPos,
|
||||||
p_60558_: CollisionContext
|
p_60558_: CollisionContext
|
||||||
): VoxelShape {
|
): VoxelShape {
|
||||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
return SHAPES[p_60555_.facingOne.ordinal]
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -14,6 +14,7 @@ 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.get
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingOne
|
||||||
import ru.dbotthepony.mc.otm.core.math.rotateY
|
import ru.dbotthepony.mc.otm.core.math.rotateY
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEn
|
|||||||
|
|
||||||
stack.pushPose()
|
stack.pushPose()
|
||||||
|
|
||||||
val facing = blockEntity.blockState[RotatableMatteryBlock.FACING]
|
val facing = blockEntity.blockState.facingOne
|
||||||
val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH
|
val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH
|
||||||
|
|
||||||
if (rotateFacing) {
|
if (rotateFacing) {
|
||||||
|
@ -26,6 +26,7 @@ import ru.dbotthepony.mc.otm.core.math.VECTOR_RIGHT
|
|||||||
import ru.dbotthepony.mc.otm.core.math.VECTOR_UP
|
import ru.dbotthepony.mc.otm.core.math.VECTOR_UP
|
||||||
import ru.dbotthepony.mc.otm.core.math.Vector
|
import ru.dbotthepony.mc.otm.core.math.Vector
|
||||||
import ru.dbotthepony.mc.otm.core.math.asAngle
|
import ru.dbotthepony.mc.otm.core.math.asAngle
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingTwo
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
import ru.dbotthepony.mc.otm.core.math.plus
|
||||||
import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis
|
import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis
|
||||||
import ru.dbotthepony.mc.otm.core.math.times
|
import ru.dbotthepony.mc.otm.core.math.times
|
||||||
@ -47,7 +48,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.getValue(RotatableMatteryBlock.FACING_FULL).normal
|
val normal = tile.blockState.facingTwo.normal
|
||||||
val level = tile.level
|
val level = tile.level
|
||||||
var bhTile: BlackHoleBlockEntity? = null
|
var bhTile: BlackHoleBlockEntity? = null
|
||||||
|
|
||||||
@ -68,7 +69,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: Direction = tile.blockState.getValue(RotatableMatteryBlock.FACING_FULL)
|
val facing = tile.blockState.facingTwo
|
||||||
|
|
||||||
val rotateZ: Double
|
val rotateZ: Double
|
||||||
val rotateY: Double
|
val rotateY: Double
|
||||||
|
@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign
|
|||||||
import ru.dbotthepony.mc.otm.client.render.drawAligned
|
import ru.dbotthepony.mc.otm.client.render.drawAligned
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.facingTwo
|
||||||
import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing
|
import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing
|
||||||
|
|
||||||
class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<HoloSignBlockEntity> {
|
class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<HoloSignBlockEntity> {
|
||||||
@ -28,7 +29,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context)
|
|||||||
return
|
return
|
||||||
|
|
||||||
poseStack.pushPose()
|
poseStack.pushPose()
|
||||||
poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL])
|
poseStack.rotateWithBlockFacing(tile.blockState.facingTwo)
|
||||||
poseStack.translate(0.5f, 0.5f, 0.6f)
|
poseStack.translate(0.5f, 0.5f, 0.6f)
|
||||||
poseStack.scale(0.01f, 0.01f, 0.01f)
|
poseStack.scale(0.01f, 0.01f, 0.01f)
|
||||||
|
|
||||||
|
137
src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt
Normal file
137
src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.core.math
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos
|
||||||
|
import net.minecraft.core.Direction
|
||||||
|
import net.minecraft.core.Vec3i
|
||||||
|
import net.minecraft.util.StringRepresentable
|
||||||
|
import net.minecraft.world.level.block.Rotation
|
||||||
|
import net.minecraftforge.common.capabilities.Capability
|
||||||
|
import net.minecraftforge.common.capabilities.ICapabilityProvider
|
||||||
|
import net.minecraftforge.common.util.LazyOptional
|
||||||
|
|
||||||
|
internal inline val Direction.blockRotation
|
||||||
|
get() = BlockRotation.of(this)
|
||||||
|
|
||||||
|
fun <T> ICapabilityProvider.getCapability(capability: Capability<T>, side: BlockRotation?): LazyOptional<T> {
|
||||||
|
return getCapability(capability, side?.primary)
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun Vec3i.plus(other: BlockRotation): Vec3i {
|
||||||
|
return this + other.normal
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun BlockPos.plus(other: BlockRotation): BlockPos {
|
||||||
|
return this + other.normal
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class BlockRotation(val primary: Direction, val secondary: Direction?) : StringRepresentable {
|
||||||
|
DOWN(Direction.DOWN, null),
|
||||||
|
UP(Direction.UP, null),
|
||||||
|
NORTH(Direction.NORTH, null),
|
||||||
|
SOUTH(Direction.SOUTH, null),
|
||||||
|
WEST(Direction.WEST, null),
|
||||||
|
EAST(Direction.EAST, null),
|
||||||
|
|
||||||
|
DOWN_NORTH(Direction.DOWN, Direction.NORTH),
|
||||||
|
DOWN_SOUTH(Direction.DOWN, Direction.SOUTH),
|
||||||
|
DOWN_WEST(Direction.DOWN, Direction.WEST),
|
||||||
|
DOWN_EAST(Direction.DOWN, Direction.EAST),
|
||||||
|
|
||||||
|
UP_NORTH(Direction.UP, Direction.NORTH),
|
||||||
|
UP_SOUTH(Direction.UP, Direction.SOUTH),
|
||||||
|
UP_WEST(Direction.UP, Direction.WEST),
|
||||||
|
UP_EAST(Direction.UP, Direction.EAST);
|
||||||
|
|
||||||
|
val lowercaseName = name.lowercase()
|
||||||
|
|
||||||
|
override fun getSerializedName(): String {
|
||||||
|
return lowercaseName
|
||||||
|
}
|
||||||
|
|
||||||
|
fun rotate(by: Rotation): BlockRotation {
|
||||||
|
return of(by.rotate(primary), secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun times(other: Int): Vec3i {
|
||||||
|
return normal * other
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun plus(other: Vec3i): Vec3i {
|
||||||
|
return normal + other
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun plus(other: Direction): Vec3i {
|
||||||
|
return normal + other
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun plus(other: BlockRotation): Vec3i {
|
||||||
|
return normal + other.normal
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun unaryMinus() = opposite
|
||||||
|
|
||||||
|
// more performant
|
||||||
|
val opposite by lazy { of(primary.opposite, secondary?.opposite) }
|
||||||
|
val normal: Vec3i get() = primary.normal
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun of(direction: Direction): BlockRotation {
|
||||||
|
return when (direction) {
|
||||||
|
Direction.DOWN -> DOWN
|
||||||
|
Direction.UP -> UP
|
||||||
|
Direction.NORTH -> NORTH
|
||||||
|
Direction.SOUTH -> SOUTH
|
||||||
|
Direction.WEST -> WEST
|
||||||
|
Direction.EAST -> EAST
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun of(primary: Direction, secondary: Direction?): BlockRotation {
|
||||||
|
return when (primary) {
|
||||||
|
Direction.NORTH -> {
|
||||||
|
require(secondary == null) { "Impossible direction: $primary - $secondary" }
|
||||||
|
NORTH
|
||||||
|
}
|
||||||
|
|
||||||
|
Direction.SOUTH -> {
|
||||||
|
require(secondary == null) { "Impossible direction: $primary - $secondary" }
|
||||||
|
SOUTH
|
||||||
|
}
|
||||||
|
|
||||||
|
Direction.WEST -> {
|
||||||
|
require(secondary == null) { "Impossible direction: $primary - $secondary" }
|
||||||
|
WEST
|
||||||
|
}
|
||||||
|
|
||||||
|
Direction.EAST -> {
|
||||||
|
require(secondary == null) { "Impossible direction: $primary - $secondary" }
|
||||||
|
EAST
|
||||||
|
}
|
||||||
|
|
||||||
|
Direction.UP -> {
|
||||||
|
when (secondary) {
|
||||||
|
null -> UP
|
||||||
|
Direction.NORTH -> UP_NORTH
|
||||||
|
Direction.SOUTH -> UP_SOUTH
|
||||||
|
Direction.WEST -> UP_WEST
|
||||||
|
Direction.EAST -> UP_EAST
|
||||||
|
else -> throw IllegalArgumentException("Impossible direction: $primary - $secondary")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Direction.DOWN -> {
|
||||||
|
when (secondary) {
|
||||||
|
null -> DOWN
|
||||||
|
Direction.NORTH -> DOWN_NORTH
|
||||||
|
Direction.SOUTH -> DOWN_SOUTH
|
||||||
|
Direction.WEST -> DOWN_WEST
|
||||||
|
Direction.EAST -> DOWN_EAST
|
||||||
|
else -> throw IllegalArgumentException("Impossible direction: $primary - $secondary")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.core.math
|
||||||
|
|
||||||
|
import net.minecraft.core.Direction
|
||||||
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
|
import net.minecraft.world.level.block.state.properties.EnumProperty
|
||||||
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
|
|
||||||
|
internal inline val BlockState.rotationOne: BlockRotation get() = this[BlockRotationFreedom.ONE.property]
|
||||||
|
internal inline val BlockState.rotationTwo: BlockRotation get() = this[BlockRotationFreedom.TWO.property]
|
||||||
|
internal inline val BlockState.rotationThree: BlockRotation get() = this[BlockRotationFreedom.THREE.property]
|
||||||
|
|
||||||
|
internal inline val BlockState.facingOne: Direction get() = this[BlockRotationFreedom.ONE.property].primary
|
||||||
|
internal inline val BlockState.facingTwo: Direction get() = this[BlockRotationFreedom.TWO.property].primary
|
||||||
|
internal inline val BlockState.facingThree: Direction get() = this[BlockRotationFreedom.THREE.property].primary
|
||||||
|
|
||||||
|
enum class BlockRotationFreedom(vararg values: BlockRotation) {
|
||||||
|
ONE(
|
||||||
|
BlockRotation.NORTH,
|
||||||
|
BlockRotation.SOUTH,
|
||||||
|
BlockRotation.WEST,
|
||||||
|
BlockRotation.EAST,
|
||||||
|
),
|
||||||
|
TWO(
|
||||||
|
BlockRotation.DOWN,
|
||||||
|
BlockRotation.UP,
|
||||||
|
BlockRotation.NORTH,
|
||||||
|
BlockRotation.SOUTH,
|
||||||
|
BlockRotation.WEST,
|
||||||
|
BlockRotation.EAST,
|
||||||
|
),
|
||||||
|
THREE(
|
||||||
|
BlockRotation.DOWN,
|
||||||
|
BlockRotation.UP,
|
||||||
|
BlockRotation.NORTH,
|
||||||
|
BlockRotation.SOUTH,
|
||||||
|
BlockRotation.WEST,
|
||||||
|
BlockRotation.EAST,
|
||||||
|
BlockRotation.DOWN_NORTH,
|
||||||
|
BlockRotation.DOWN_SOUTH,
|
||||||
|
BlockRotation.DOWN_WEST,
|
||||||
|
BlockRotation.DOWN_EAST,
|
||||||
|
BlockRotation.UP_NORTH,
|
||||||
|
BlockRotation.UP_SOUTH,
|
||||||
|
BlockRotation.UP_WEST,
|
||||||
|
BlockRotation.UP_EAST,
|
||||||
|
);
|
||||||
|
|
||||||
|
val possibleValues: Collection<BlockRotation> get() = property.possibleValues
|
||||||
|
val property: EnumProperty<BlockRotation> = EnumProperty.create("facing", BlockRotation::class.java, *values)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user