mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-10-02 16:41:40 -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(
|
object BlockGenerator : Generator(
|
||||||
"blocks"
|
"blocks"
|
||||||
) {
|
) {
|
||||||
val VOXEL_SHAPES: MutableList<VoxelShape> = mutableListOf()
|
val VOXEL_SHAPES: MutableMap<String, Pair<Int, VoxelShape>> = mutableMapOf()
|
||||||
|
|
||||||
override fun generate() {
|
override fun generate() {
|
||||||
val stateMap: MutableMap<Block, MutableSet<BlockState>> = mutableMapOf()
|
val stateMap: MutableMap<Block, MutableSet<BlockState>> = mutableMapOf()
|
||||||
@ -282,10 +282,22 @@ object BlockGenerator : Generator(
|
|||||||
for (voxelShape in it) {
|
for (voxelShape in it) {
|
||||||
occlusionJson.add(getOrAddVoxelShape(voxelShape))
|
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 {
|
(CACHE_COLLISION_SHAPES_FIELD.get(cache) as VoxelShape?)?.let {
|
||||||
if (it.isEmpty) {
|
if (it.isEmpty) {
|
||||||
return@let
|
return@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 {
|
private fun getOrAddVoxelShape(voxelShape: VoxelShape): Int {
|
||||||
if (VOXEL_SHAPES.contains(voxelShape)) {
|
val string = voxelShape.toString()
|
||||||
return VOXEL_SHAPES.indexOf(voxelShape)
|
VOXEL_SHAPES[string]?.let {
|
||||||
|
return it.first
|
||||||
}
|
}
|
||||||
val index = VOXEL_SHAPES.size
|
|
||||||
VOXEL_SHAPES.add(voxelShape)
|
val pair = Pair(VOXEL_SHAPES.size, voxelShape)
|
||||||
return index
|
|
||||||
|
VOXEL_SHAPES[string] = pair
|
||||||
|
println(voxelShape)
|
||||||
|
return pair.first
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun allTheSame(array: BooleanArray): Boolean {
|
private fun allTheSame(array: BooleanArray): Boolean {
|
||||||
|
@ -9,12 +9,13 @@ import net.minecraft.world.phys.shapes.VoxelShape
|
|||||||
object VoxelShapeGenerator : Generator(
|
object VoxelShapeGenerator : Generator(
|
||||||
"shapes"
|
"shapes"
|
||||||
) {
|
) {
|
||||||
val AABBS: MutableList<AABB> = mutableListOf()
|
private val AABBS: MutableList<AABB> = mutableListOf()
|
||||||
|
|
||||||
override fun generate() {
|
override fun generate() {
|
||||||
val shapes = JsonArray()
|
val shapes = JsonArray()
|
||||||
for (shape in BlockGenerator.VOXEL_SHAPES) {
|
for ((_, shape) in BlockGenerator.VOXEL_SHAPES) {
|
||||||
shapes.add(shape.serialize())
|
println("Shape ${shape.first}")
|
||||||
|
shapes.add(shape.second.serialize())
|
||||||
}
|
}
|
||||||
data.add("shapes", shapes)
|
data.add("shapes", shapes)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user