mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-30 15:42:01 -04:00
shapes: remove some duplicates
This commit is contained in:
parent
3de4a859d6
commit
f1bde0a49e
@ -19,7 +19,7 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
||||
object BlockGenerator : Generator(
|
||||
"blocks"
|
||||
) {
|
||||
val VOXEL_SHAPES: MutableList<VoxelShape> = mutableListOf()
|
||||
val VOXEL_SHAPES: MutableMap<String, Pair<Int, VoxelShape>> = mutableMapOf()
|
||||
|
||||
override fun generate() {
|
||||
val stateMap: MutableMap<Block, MutableSet<BlockState>> = mutableMapOf()
|
||||
@ -282,8 +282,20 @@ object BlockGenerator : Generator(
|
||||
for (voxelShape in it) {
|
||||
occlusionJson.add(getOrAddVoxelShape(voxelShape))
|
||||
}
|
||||
val firstFace = occlusionJson[0].asInt
|
||||
var allTheSame = true
|
||||
for (face in occlusionJson) {
|
||||
if (face.asInt != firstFace) {
|
||||
allTheSame = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (allTheSame) {
|
||||
stateData.addProperty("occlusion_shapes", firstFace)
|
||||
} else {
|
||||
stateData.add("occlusion_shapes", occlusionJson)
|
||||
}
|
||||
|
||||
stateData.add("occlusion_shapes", occlusionJson)
|
||||
}
|
||||
|
||||
(CACHE_COLLISION_SHAPES_FIELD.get(cache) as VoxelShape?)?.let {
|
||||
@ -318,17 +330,21 @@ object BlockGenerator : Generator(
|
||||
}
|
||||
}
|
||||
|
||||
val PROPERTY_METHOD = getClass("net.minecraft.world.level.block.state.properties.Property")!!
|
||||
private val PROPERTY_METHOD = getClass("net.minecraft.world.level.block.state.properties.Property")!!
|
||||
|
||||
val PROPERTY_NAME_METHOD = PROPERTY_METHOD.getDeclaredMethod("getName")
|
||||
private val PROPERTY_NAME_METHOD = PROPERTY_METHOD.getDeclaredMethod("getName")
|
||||
|
||||
private fun getOrAddVoxelShape(voxelShape: VoxelShape): Int {
|
||||
if (VOXEL_SHAPES.contains(voxelShape)) {
|
||||
return VOXEL_SHAPES.indexOf(voxelShape)
|
||||
val string = voxelShape.toString()
|
||||
VOXEL_SHAPES[string]?.let {
|
||||
return it.first
|
||||
}
|
||||
val index = VOXEL_SHAPES.size
|
||||
VOXEL_SHAPES.add(voxelShape)
|
||||
return index
|
||||
|
||||
val pair = Pair(VOXEL_SHAPES.size, voxelShape)
|
||||
|
||||
VOXEL_SHAPES[string] = pair
|
||||
println(voxelShape)
|
||||
return pair.first
|
||||
}
|
||||
|
||||
private fun allTheSame(array: BooleanArray): Boolean {
|
||||
|
@ -9,12 +9,13 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
||||
object VoxelShapeGenerator : Generator(
|
||||
"shapes"
|
||||
) {
|
||||
val AABBS: MutableList<AABB> = mutableListOf()
|
||||
private val AABBS: MutableList<AABB> = mutableListOf()
|
||||
|
||||
override fun generate() {
|
||||
val shapes = JsonArray()
|
||||
for (shape in BlockGenerator.VOXEL_SHAPES) {
|
||||
shapes.add(shape.serialize())
|
||||
for ((_, shape) in BlockGenerator.VOXEL_SHAPES) {
|
||||
println("Shape ${shape.first}")
|
||||
shapes.add(shape.second.serialize())
|
||||
}
|
||||
data.add("shapes", shapes)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user