Fix shapegen for storage bus

This commit is contained in:
DBotThePony 2023-12-28 19:59:15 +07:00
parent 93942161ad
commit 6784271ac7
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 9 additions and 36 deletions

View File

@ -49,9 +49,11 @@ abstract class CableBlock(properties: Properties) : Block(properties) {
}
protected fun generateShapes(halfCoreSize: Double): ImmutableMap<BlockState, VoxelShape> {
val core = Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize)
return getShapeForEachState { getShapeFor(it, halfCoreSize) }
}
return getShapeForEachState {
companion object {
fun getShapeFor(it: BlockState, halfCoreSize: Double): VoxelShape {
val shapes = ArrayList<VoxelShape>()
if (it.getValue(CONNECTION_SOUTH))
@ -72,16 +74,14 @@ abstract class CableBlock(properties: Properties) : Block(properties) {
if (it.getValue(CONNECTION_WEST))
shapes.add(Shapes.box(0.0, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize))
var finalShape = core
var finalShape = Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize)
for (shape in shapes)
finalShape = Shapes.join(finalShape, shape, BooleanOp.OR)
return@getShapeForEachState finalShape
}
return finalShape
}
companion object {
val CONNECTION_SOUTH: BooleanProperty = BooleanProperty.create("connect_south")
val CONNECTION_WEST: BooleanProperty = BooleanProperty.create("connect_west")
val CONNECTION_EAST: BooleanProperty = BooleanProperty.create("connect_east")

View File

@ -90,16 +90,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
}
private val shapes = getShapeForEachState {
val shapes = StorageCableBlock.getShapeFor(it)
var finalShape = shapes[0]
for (i in 1 until shapes.size) {
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
}
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR)
return@getShapeForEachState finalShape
Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_BUS.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR)
}
@Suppress("OVERRIDE_DEPRECATION")

View File

@ -91,16 +91,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
}
private val shapes = getShapeForEachState {
val shapes = StorageCableBlock.getShapeFor(it)
var finalShape = shapes[0]
for (i in 1 until shapes.size) {
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
}
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR)
return@getShapeForEachState finalShape
Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR)
}
@Suppress("OVERRIDE_DEPRECATION")
@ -173,16 +164,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
}
private val shapes = getShapeForEachState {
val shapes = StorageCableBlock.getShapeFor(it)
var finalShape = shapes[0]
for (i in 1 until shapes.size) {
finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR)
}
finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR)
return@getShapeForEachState finalShape
Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_EXPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR)
}
@Suppress("OVERRIDE_DEPRECATION")