mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
remove test-util source set, AirBlock
This commit is contained in:
parent
5054ea139d
commit
3eedebde81
@ -224,13 +224,13 @@ testing {
|
||||
}
|
||||
sources {
|
||||
kotlin {
|
||||
setSrcDirs(listOf("src/integration-test/kotlin", "src/test-util/kotlin"))
|
||||
setSrcDirs(listOf("src/integration-test/kotlin"))
|
||||
}
|
||||
}
|
||||
}
|
||||
val benchmark by registering(JvmTestSuite::class) {
|
||||
testType.set(TestSuiteType.PERFORMANCE_TEST)
|
||||
useTestNG("7.7.0")
|
||||
useTestNG("7.7.1")
|
||||
|
||||
dependencies {
|
||||
implementation(project())
|
||||
@ -265,7 +265,7 @@ testing {
|
||||
}
|
||||
sources {
|
||||
kotlin {
|
||||
setSrcDirs(listOf("src/benchmark/kotlin", "src/test-util/kotlin"))
|
||||
setSrcDirs(listOf("src/benchmark/kotlin"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.world.chunk
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.concurrent.lock.thread.ThreadLock
|
||||
import de.bixilon.kutil.observer.DataObserver
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
|
||||
import de.bixilon.minosoft.data.world.World
|
||||
import de.bixilon.minosoft.data.world.chunk.light.ChunkLight
|
||||
import de.bixilon.minosoft.data.world.chunk.neighbours.ChunkNeighbours
|
||||
import de.bixilon.minosoft.data.world.positions.ChunkPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.master.EventMaster
|
||||
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import org.objenesis.ObjenesisStd
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
const val SECTIONS = 16
|
||||
|
||||
@Deprecated("Shit")
|
||||
object ChunkTestingUtil {
|
||||
private val world = createWorld()
|
||||
|
||||
fun createConnection(): PlayConnection {
|
||||
val connection = ObjenesisStd().newInstance(PlayConnection::class.java)
|
||||
|
||||
Connection::events.javaField!!.forceSet(connection, EventMaster())
|
||||
return connection
|
||||
}
|
||||
|
||||
fun createWorld(): World {
|
||||
val objenesis = ObjenesisStd()
|
||||
val world = objenesis.newInstance(World::class.java)
|
||||
world::dimension.javaField!!.forceSet(world, DataObserver(DimensionProperties(hasSkyLight = true)))
|
||||
world::connection.javaField!!.forceSet(world, createConnection())
|
||||
|
||||
return world
|
||||
}
|
||||
|
||||
fun createEmptyChunk(position: ChunkPosition): Chunk {
|
||||
val objenesis = ObjenesisStd()
|
||||
val chunk = objenesis.newInstance(Chunk::class.java)
|
||||
Chunk::lock.javaField!!.forceSet(chunk, ThreadLock())
|
||||
chunk::chunkPosition.forceSet(position)
|
||||
Chunk::world.javaField!!.forceSet(chunk, world)
|
||||
Chunk::maxSection.javaField!!.forceSet(chunk, chunk.world.dimension!!.maxSection)
|
||||
Chunk::connection.javaField!!.forceSet(chunk, chunk.world.connection)
|
||||
Chunk::light.javaField!!.forceSet(chunk, ChunkLight(chunk))
|
||||
Chunk::neighbours.javaField!!.forceSet(chunk, ChunkNeighbours(chunk))
|
||||
chunk.sections = arrayOfNulls(SECTIONS)
|
||||
|
||||
return chunk
|
||||
}
|
||||
|
||||
fun createChunkWithNeighbours(): Chunk {
|
||||
val chunk = createEmptyChunk(Vec2i.EMPTY)
|
||||
var index = 0
|
||||
for (x in -1..1) {
|
||||
for (z in -1..1) {
|
||||
if (x == 0 && z == 0) {
|
||||
continue
|
||||
}
|
||||
chunk.neighbours[index++] = createEmptyChunk(Vec2i(x, z))
|
||||
}
|
||||
}
|
||||
|
||||
return chunk
|
||||
}
|
||||
|
||||
fun ChunkSection.fill(state: BlockState) {
|
||||
for (index in 0 until 4096) {
|
||||
blocks.unsafeSet(index, state)
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.data.registries.blocks.factory
|
||||
|
||||
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.air.AirBlock
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.fluid.LavaFluidBlock
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.fluid.WaterFluidBlock
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.stone.RockBlock
|
||||
@ -22,7 +23,11 @@ import de.bixilon.minosoft.data.registries.factory.DefaultFactory
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
object BlockFactories : DefaultFactory<BlockFactory<*>>(
|
||||
AirBlock.Air, AirBlock.VoidAir, AirBlock.CaveAir,
|
||||
|
||||
RockBlock.Stone,
|
||||
RockBlock.Granite, RockBlock.PolishedGranite,
|
||||
RockBlock.Diorite, RockBlock.PolishedDiorite,
|
||||
|
@ -49,10 +49,8 @@ import de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.water.KelpPlant
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.water.SeagrassBlock
|
||||
import de.bixilon.minosoft.data.registries.factory.clazz.DefaultClassFactory
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@Deprecated("BlockFactories")
|
||||
object PixLyzerBlockFactories : DefaultClassFactory<PixLyzerBlockFactory<*>>(
|
||||
AirBlock,
|
||||
PixLyzerBlock,
|
||||
DoorBlock,
|
||||
LeverBlock,
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.registries.blocks.types.air
|
||||
|
||||
import de.bixilon.kutil.exception.Broken
|
||||
import de.bixilon.minosoft.data.registries.blocks.factory.BlockFactory
|
||||
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
|
||||
@Deprecated("air == null")
|
||||
@Suppress("DEPRECATION")
|
||||
abstract class AirBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings) {
|
||||
override val hardness: Float get() = Broken("Its air!")
|
||||
|
||||
|
||||
@Deprecated("air == null")
|
||||
open class Air(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : AirBlock(identifier, settings) {
|
||||
|
||||
companion object : BlockFactory<Air> {
|
||||
override val identifier = minecraft("air")
|
||||
|
||||
override fun build(registries: Registries, settings: BlockSettings) = Air(settings = settings)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("air == null")
|
||||
open class VoidAir(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : AirBlock(identifier, settings) {
|
||||
|
||||
companion object : BlockFactory<VoidAir> {
|
||||
override val identifier = minecraft("void_air")
|
||||
|
||||
override fun build(registries: Registries, settings: BlockSettings) = VoidAir(settings = settings)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("air == null")
|
||||
open class CaveAir(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : AirBlock(identifier, settings) {
|
||||
|
||||
companion object : BlockFactory<CaveAir> {
|
||||
override val identifier = minecraft("cave_air")
|
||||
|
||||
override fun build(registries: Registries, settings: BlockSettings) = CaveAir(settings = settings)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.registries.blocks.types.pixlyzer
|
||||
|
||||
import de.bixilon.minosoft.data.registries.blocks.factory.PixLyzerBlockFactory
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
|
||||
@Deprecated("Air == null!")
|
||||
open class AirBlock(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>) : PixLyzerBlock(resourceLocation, registries, data) {
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
companion object : PixLyzerBlockFactory<AirBlock> {
|
||||
|
||||
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): AirBlock {
|
||||
return AirBlock(resourceLocation, registries, data)
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.data.registries.registries.registry
|
||||
import de.bixilon.kutil.exception.Broken
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.AirBlock
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.air.AirBlock
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
@ -69,7 +69,7 @@ class BlockStateRegistry(var flattened: Boolean) : AbstractRegistry<BlockState?>
|
||||
return getOrNull(id)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@Suppress("DEPRECATION")
|
||||
override fun getOrNull(id: Int): BlockState? {
|
||||
if (id == ProtocolDefinition.AIR_BLOCK_ID) {
|
||||
return null
|
||||
|
Loading…
x
Reference in New Issue
Block a user