Migrate to kommons
This commit is contained in:
parent
c65d3f1a88
commit
c5d1e0f4c7
@ -11,8 +11,8 @@ plugins {
|
|||||||
group = "ru.dbotthepony"
|
group = "ru.dbotthepony"
|
||||||
version = "0.1-SNAPSHOT"
|
version = "0.1-SNAPSHOT"
|
||||||
|
|
||||||
val lwjglVersion = "3.3.0"
|
val lwjglVersion: String by project
|
||||||
val lwjglNatives = "natives-windows"
|
val lwjglNatives: String by project
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -37,6 +37,8 @@ tasks.compileKotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
val kommonsVersion: String by project
|
||||||
|
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.10")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.10")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.10")
|
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.10")
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation("it.unimi.dsi:fastutil:8.5.6")
|
implementation("it.unimi.dsi:fastutil:8.5.6")
|
||||||
|
|
||||||
implementation("com.google.guava:guava:31.0.1-jre")
|
implementation("com.google.guava:guava:33.0.0-jre")
|
||||||
|
|
||||||
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
|
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
|
||||||
|
|
||||||
@ -79,10 +81,16 @@ dependencies {
|
|||||||
runtimeOnly("org.lwjgl", "lwjgl-par", classifier = lwjglNatives)
|
runtimeOnly("org.lwjgl", "lwjgl-par", classifier = lwjglNatives)
|
||||||
runtimeOnly("org.lwjgl", "lwjgl-stb", classifier = lwjglNatives)
|
runtimeOnly("org.lwjgl", "lwjgl-stb", classifier = lwjglNatives)
|
||||||
|
|
||||||
implementation("net.java.dev.jna:jna:5.13.0")
|
val ffiVersion: String by project
|
||||||
implementation("com.github.jnr:jnr-ffi:2.2.13")
|
|
||||||
|
|
||||||
implementation("ru.dbotthepony:kvector:2.12.0")
|
implementation("net.java.dev.jna:jna:5.13.0")
|
||||||
|
implementation("com.github.jnr:jnr-ffi:$ffiVersion")
|
||||||
|
|
||||||
|
implementation("ru.dbotthepony.kommons:kommons:[$kommonsVersion,)")
|
||||||
|
implementation("ru.dbotthepony.kommons:gson:[$kommonsVersion,)")
|
||||||
|
implementation("ru.dbotthepony.kommons:guava:[$kommonsVersion,)")
|
||||||
|
implementation("ru.dbotthepony.kommons:linear-algebra:[$kommonsVersion,)")
|
||||||
|
implementation("ru.dbotthepony.kommons:gson-linear-algebra:[$kommonsVersion,)")
|
||||||
|
|
||||||
implementation("com.github.ben-manes.caffeine:caffeine:3.1.5")
|
implementation("com.github.ben-manes.caffeine:caffeine:3.1.5")
|
||||||
implementation("org.classdump.luna:luna-all-shaded:0.4.1")
|
implementation("org.classdump.luna:luna-all-shaded:0.4.1")
|
||||||
@ -103,16 +111,3 @@ jmh {
|
|||||||
tasks.getByName<Test>("test") {
|
tasks.getByName<Test>("test") {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
|
||||||
create("buildlua", type = Exec::class.java) {
|
|
||||||
commandLine(
|
|
||||||
"clang", "lua_glue.c",
|
|
||||||
"-I", "${Jvm.current().javaHome}/include",
|
|
||||||
"-I", "${Jvm.current().javaHome}/include/win32",
|
|
||||||
"-I", "${Jvm.current().javaHome}/include/win32/bridge",
|
|
||||||
"-o", "lua_glue.dll", "-shared", "lua54.lib"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,2 +1,9 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m
|
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m
|
||||||
|
|
||||||
|
kotlinVersion=1.9.0
|
||||||
|
kommonsVersion=1.7.1
|
||||||
|
|
||||||
|
ffiVersion=2.2.13
|
||||||
|
lwjglVersion=3.3.0
|
||||||
|
lwjglNatives=natives-windows
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.freetype.struct;
|
package ru.dbotthepony.kstarbound.client.freetype.struct;
|
||||||
|
|
||||||
import com.sun.jna.Structure;
|
import com.sun.jna.Structure;
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i;
|
import ru.dbotthepony.kommons.vector.Vector2i;
|
||||||
|
|
||||||
@Structure.FieldOrder({"x", "y"})
|
@Structure.FieldOrder({"x", "y"})
|
||||||
public class FT_Vector extends Structure {
|
public class FT_Vector extends Structure {
|
||||||
|
@ -7,7 +7,7 @@ import com.google.gson.TypeAdapter
|
|||||||
import com.google.gson.TypeAdapterFactory
|
import com.google.gson.TypeAdapterFactory
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
import java.util.Arrays
|
import java.util.Arrays
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
import java.util.concurrent.ForkJoinPool
|
import java.util.concurrent.ForkJoinPool
|
||||||
|
@ -3,24 +3,15 @@ package ru.dbotthepony.kstarbound
|
|||||||
|
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import org.lwjgl.Version
|
import org.lwjgl.Version
|
||||||
import org.lwjgl.glfw.GLFW.glfwSetWindowShouldClose
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.client.network.ClientConnection
|
|
||||||
import ru.dbotthepony.kstarbound.io.BTreeDB
|
import ru.dbotthepony.kstarbound.io.BTreeDB
|
||||||
import ru.dbotthepony.kstarbound.io.readVarInt
|
|
||||||
import ru.dbotthepony.kstarbound.json.VersionedJson
|
|
||||||
import ru.dbotthepony.kstarbound.server.IntegratedStarboundServer
|
import ru.dbotthepony.kstarbound.server.IntegratedStarboundServer
|
||||||
import ru.dbotthepony.kstarbound.server.world.LegacyChunkSource
|
import ru.dbotthepony.kstarbound.server.world.LegacyChunkSource
|
||||||
import ru.dbotthepony.kstarbound.server.world.ServerWorld
|
import ru.dbotthepony.kstarbound.server.world.ServerWorld
|
||||||
import ru.dbotthepony.kstarbound.util.AssetPathStack
|
|
||||||
import ru.dbotthepony.kstarbound.world.Direction
|
|
||||||
import ru.dbotthepony.kstarbound.world.WorldGeometry
|
import ru.dbotthepony.kstarbound.world.WorldGeometry
|
||||||
import ru.dbotthepony.kstarbound.world.api.MutableCell
|
|
||||||
import ru.dbotthepony.kstarbound.world.entities.ItemEntity
|
import ru.dbotthepony.kstarbound.world.entities.ItemEntity
|
||||||
import ru.dbotthepony.kstarbound.world.entities.PlayerEntity
|
|
||||||
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
@ -20,8 +20,8 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectMap
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.json.consumeNull
|
import ru.dbotthepony.kstarbound.json.consumeNull
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import java.lang.reflect.ParameterizedType
|
import java.lang.reflect.ParameterizedType
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
@ -5,6 +5,18 @@ import com.google.gson.*
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.kommons.gson.AABBTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.AABBiTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.ColorTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.EitherTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.KOptionalTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.NothingAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.Vector2dTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.Vector2fTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.Vector2iTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.Vector4dTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.gson.Vector4iTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.util.MailboxExecutorService
|
||||||
import ru.dbotthepony.kstarbound.defs.*
|
import ru.dbotthepony.kstarbound.defs.*
|
||||||
import ru.dbotthepony.kstarbound.defs.image.Image
|
import ru.dbotthepony.kstarbound.defs.image.Image
|
||||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||||
@ -15,20 +27,10 @@ import ru.dbotthepony.kstarbound.defs.`object`.ObjectDefinition
|
|||||||
import ru.dbotthepony.kstarbound.defs.`object`.ObjectOrientation
|
import ru.dbotthepony.kstarbound.defs.`object`.ObjectOrientation
|
||||||
import ru.dbotthepony.kstarbound.defs.player.BlueprintLearnList
|
import ru.dbotthepony.kstarbound.defs.player.BlueprintLearnList
|
||||||
import ru.dbotthepony.kstarbound.io.*
|
import ru.dbotthepony.kstarbound.io.*
|
||||||
import ru.dbotthepony.kstarbound.json.ColorTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.EitherTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.FastutilTypeAdapterFactory
|
import ru.dbotthepony.kstarbound.json.FastutilTypeAdapterFactory
|
||||||
import ru.dbotthepony.kstarbound.json.InternedJsonElementAdapter
|
import ru.dbotthepony.kstarbound.json.InternedJsonElementAdapter
|
||||||
import ru.dbotthepony.kstarbound.json.InternedStringAdapter
|
import ru.dbotthepony.kstarbound.json.InternedStringAdapter
|
||||||
import ru.dbotthepony.kstarbound.json.KOptionalTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.LongRangeAdapter
|
import ru.dbotthepony.kstarbound.json.LongRangeAdapter
|
||||||
import ru.dbotthepony.kstarbound.json.NothingAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.OneOfTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.Vector2dTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.Vector2fTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.Vector2iTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.Vector4dTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.Vector4iTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.json.builder.EnumAdapter
|
import ru.dbotthepony.kstarbound.json.builder.EnumAdapter
|
||||||
import ru.dbotthepony.kstarbound.json.builder.BuilderAdapter
|
import ru.dbotthepony.kstarbound.json.builder.BuilderAdapter
|
||||||
import ru.dbotthepony.kstarbound.json.builder.FactoryAdapter
|
import ru.dbotthepony.kstarbound.json.builder.FactoryAdapter
|
||||||
@ -40,7 +42,6 @@ import ru.dbotthepony.kstarbound.math.*
|
|||||||
import ru.dbotthepony.kstarbound.util.ItemStack
|
import ru.dbotthepony.kstarbound.util.ItemStack
|
||||||
import ru.dbotthepony.kstarbound.util.SBPattern
|
import ru.dbotthepony.kstarbound.util.SBPattern
|
||||||
import ru.dbotthepony.kstarbound.util.HashTableInterner
|
import ru.dbotthepony.kstarbound.util.HashTableInterner
|
||||||
import ru.dbotthepony.kstarbound.util.MailboxExecutorService
|
|
||||||
import ru.dbotthepony.kstarbound.util.traverseJsonPath
|
import ru.dbotthepony.kstarbound.util.traverseJsonPath
|
||||||
import ru.dbotthepony.kstarbound.world.physics.Poly
|
import ru.dbotthepony.kstarbound.world.physics.Poly
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@ -141,8 +142,6 @@ object Starbound : ISBFileLocator {
|
|||||||
|
|
||||||
// Either<>
|
// Either<>
|
||||||
registerTypeAdapterFactory(EitherTypeAdapter)
|
registerTypeAdapterFactory(EitherTypeAdapter)
|
||||||
// OneOf<>
|
|
||||||
registerTypeAdapterFactory(OneOfTypeAdapter)
|
|
||||||
// KOptional<>
|
// KOptional<>
|
||||||
registerTypeAdapterFactory(KOptionalTypeAdapter)
|
registerTypeAdapterFactory(KOptionalTypeAdapter)
|
||||||
|
|
||||||
@ -163,8 +162,8 @@ object Starbound : ISBFileLocator {
|
|||||||
registerTypeAdapter(StatModifier::Adapter)
|
registerTypeAdapter(StatModifier::Adapter)
|
||||||
|
|
||||||
// математические классы
|
// математические классы
|
||||||
registerTypeAdapter(ru.dbotthepony.kstarbound.json.AABBTypeAdapter)
|
registerTypeAdapter(AABBTypeAdapter)
|
||||||
registerTypeAdapter(ru.dbotthepony.kstarbound.json.AABBiTypeAdapter)
|
registerTypeAdapter(AABBiTypeAdapter)
|
||||||
registerTypeAdapter(Vector2dTypeAdapter)
|
registerTypeAdapter(Vector2dTypeAdapter)
|
||||||
registerTypeAdapter(Vector2fTypeAdapter)
|
registerTypeAdapter(Vector2fTypeAdapter)
|
||||||
registerTypeAdapter(Vector2iTypeAdapter)
|
registerTypeAdapter(Vector2iTypeAdapter)
|
||||||
|
@ -18,7 +18,15 @@ import org.lwjgl.stb.STBImage
|
|||||||
import org.lwjgl.system.MemoryStack
|
import org.lwjgl.system.MemoryStack
|
||||||
import org.lwjgl.system.MemoryUtil
|
import org.lwjgl.system.MemoryUtil
|
||||||
import org.lwjgl.system.MemoryUtil.memAddressSafe
|
import org.lwjgl.system.MemoryUtil.memAddressSafe
|
||||||
import ru.dbotthepony.kstarbound.util.MailboxExecutorService
|
import ru.dbotthepony.kommons.core.IStruct4f
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix3f
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix3fStack
|
||||||
|
import ru.dbotthepony.kommons.util.AABB
|
||||||
|
import ru.dbotthepony.kommons.util.MailboxExecutorService
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4f
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNIT
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNIT
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
@ -61,14 +69,6 @@ import ru.dbotthepony.kstarbound.world.Direction
|
|||||||
import ru.dbotthepony.kstarbound.world.LightCalculator
|
import ru.dbotthepony.kstarbound.world.LightCalculator
|
||||||
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
||||||
import ru.dbotthepony.kvector.api.IStruct4f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3fStack
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4f
|
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.ref.PhantomReference
|
import java.lang.ref.PhantomReference
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.gl
|
package ru.dbotthepony.kstarbound.client.gl
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import org.lwjgl.opengl.GL11
|
|
||||||
import org.lwjgl.opengl.GL45.*
|
import org.lwjgl.opengl.GL45.*
|
||||||
import org.lwjgl.stb.STBImage
|
import ru.dbotthepony.kommons.core.IStruct2i
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.defs.image.Image
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileNotFoundException
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
@ -96,7 +91,7 @@ class GLTexture2D(val width: Int, val height: Int, val format: Int, val levels:
|
|||||||
return UVCoord(x.toFloat() / width, y.toFloat() / height)
|
return UVCoord(x.toFloat() / width, y.toFloat() / height)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pixelToUV(pos: Vector2i) = pixelToUV(pos.x, pos.y)
|
fun pixelToUV(pos: IStruct2i) = pixelToUV(pos.component1(), pos.component2())
|
||||||
|
|
||||||
fun upload(level: Int, bufferFormat: Int, dataFormat: Int, data: ByteBuffer): GLTexture2D {
|
fun upload(level: Int, bufferFormat: Int, dataFormat: Int, data: ByteBuffer): GLTexture2D {
|
||||||
return upload(level, 0, 0, width, height, bufferFormat, dataFormat, data)
|
return upload(level, 0, 0, width, height, bufferFormat, dataFormat, data)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.gl
|
package ru.dbotthepony.kstarbound.client.gl
|
||||||
|
|
||||||
import ru.dbotthepony.kvector.util2d.intersectRectangles
|
import ru.dbotthepony.kommons.math.intersectRectangles
|
||||||
|
|
||||||
data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) {
|
data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) {
|
||||||
fun withinBounds(x: Int, y: Int): Boolean {
|
fun withinBounds(x: Int, y: Int): Boolean {
|
||||||
|
@ -5,18 +5,18 @@ import it.unimi.dsi.fastutil.objects.Object2BooleanFunction
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
||||||
import org.lwjgl.opengl.GL45.*
|
import org.lwjgl.opengl.GL45.*
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2f
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct3f
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct4f
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix3f
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix4f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector3f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4f
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.client.gl.GLObject
|
import ru.dbotthepony.kstarbound.client.gl.GLObject
|
||||||
import ru.dbotthepony.kstarbound.client.gl.checkForGLError
|
import ru.dbotthepony.kstarbound.client.gl.checkForGLError
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributes
|
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributes
|
||||||
import ru.dbotthepony.kvector.api.IStruct2f
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct3f
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct4f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix4f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector3f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4f
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.nio.ByteOrder
|
import java.nio.ByteOrder
|
||||||
import java.nio.FloatBuffer
|
import java.nio.FloatBuffer
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.gl.shader
|
package ru.dbotthepony.kstarbound.client.gl.shader
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import ru.dbotthepony.kommons.core.IStruct4f
|
||||||
import org.lwjgl.opengl.GL20.GL_FRAGMENT_SHADER
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import org.lwjgl.opengl.GL20.GL_VERTEX_SHADER
|
import ru.dbotthepony.kommons.matrix.Matrix3f
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.GeometryType
|
import ru.dbotthepony.kstarbound.client.gl.vertex.GeometryType
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.StreamVertexBuilder
|
import ru.dbotthepony.kstarbound.client.gl.vertex.StreamVertexBuilder
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributes
|
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributes
|
||||||
import ru.dbotthepony.kstarbound.client.render.FONT_VERTEX_FORMAT
|
import ru.dbotthepony.kstarbound.client.render.FONT_VERTEX_FORMAT
|
||||||
import ru.dbotthepony.kvector.api.IStruct4f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3f
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
|
|
||||||
private fun shaders(name: String): List<GLShader> {
|
private fun shaders(name: String): List<GLShader> {
|
||||||
val client = StarboundClient.current()
|
val client = StarboundClient.current()
|
||||||
|
@ -8,15 +8,15 @@ import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
|||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction
|
||||||
import org.lwjgl.opengl.GL20.GL_FRAGMENT_SHADER
|
import org.lwjgl.opengl.GL20.GL_FRAGMENT_SHADER
|
||||||
import org.lwjgl.opengl.GL20.GL_VERTEX_SHADER
|
import org.lwjgl.opengl.GL20.GL_VERTEX_SHADER
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct4f
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix3f
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.client.gl.GLTexture2D
|
import ru.dbotthepony.kstarbound.client.gl.GLTexture2D
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.StreamVertexBuilder
|
import ru.dbotthepony.kstarbound.client.gl.vertex.StreamVertexBuilder
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributeType
|
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributeType
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributes
|
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexAttributes
|
||||||
import ru.dbotthepony.kstarbound.client.render.RenderConfig
|
import ru.dbotthepony.kstarbound.client.render.RenderConfig
|
||||||
import ru.dbotthepony.kvector.api.IStruct4f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3f
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.EnumSet
|
import java.util.EnumSet
|
||||||
|
@ -4,11 +4,11 @@ import org.lwjgl.opengl.GL45
|
|||||||
import org.lwjgl.opengl.GL45.GL_UNSIGNED_INT
|
import org.lwjgl.opengl.GL45.GL_UNSIGNED_INT
|
||||||
import org.lwjgl.opengl.GL45.GL_UNSIGNED_SHORT
|
import org.lwjgl.opengl.GL45.GL_UNSIGNED_SHORT
|
||||||
import org.lwjgl.opengl.GL45.GL_UNSIGNED_BYTE
|
import org.lwjgl.opengl.GL45.GL_UNSIGNED_BYTE
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2d
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2f
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct4f
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix3f
|
||||||
import ru.dbotthepony.kstarbound.client.gl.BufferObject
|
import ru.dbotthepony.kstarbound.client.gl.BufferObject
|
||||||
import ru.dbotthepony.kvector.api.IStruct2d
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct2f
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct4f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3f
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.nio.ByteOrder
|
import java.nio.ByteOrder
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.network.packets
|
package ru.dbotthepony.kstarbound.client.network.packets
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.io.readCollection
|
||||||
|
import ru.dbotthepony.kommons.io.writeCollection
|
||||||
import ru.dbotthepony.kstarbound.client.network.ClientConnection
|
import ru.dbotthepony.kstarbound.client.network.ClientConnection
|
||||||
import ru.dbotthepony.kstarbound.network.IClientPacket
|
import ru.dbotthepony.kstarbound.network.IClientPacket
|
||||||
import ru.dbotthepony.kstarbound.io.readChunkPos
|
import ru.dbotthepony.kstarbound.io.readChunkPos
|
||||||
import ru.dbotthepony.kstarbound.io.readCollection
|
|
||||||
import ru.dbotthepony.kstarbound.io.writeCollection
|
|
||||||
import ru.dbotthepony.kstarbound.io.writeVec2i
|
import ru.dbotthepony.kstarbound.io.writeVec2i
|
||||||
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
||||||
import ru.dbotthepony.kstarbound.world.Chunk
|
import ru.dbotthepony.kstarbound.world.Chunk
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.network.packets
|
package ru.dbotthepony.kstarbound.client.network.packets
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf
|
|
||||||
import ru.dbotthepony.kstarbound.client.network.ClientConnection
|
import ru.dbotthepony.kstarbound.client.network.ClientConnection
|
||||||
import ru.dbotthepony.kstarbound.client.world.ClientWorld
|
import ru.dbotthepony.kstarbound.client.world.ClientWorld
|
||||||
import ru.dbotthepony.kstarbound.network.IClientPacket
|
|
||||||
import ru.dbotthepony.kstarbound.io.readUUID
|
import ru.dbotthepony.kstarbound.io.readUUID
|
||||||
import ru.dbotthepony.kstarbound.io.readVec2i
|
|
||||||
import ru.dbotthepony.kstarbound.io.writeUUID
|
import ru.dbotthepony.kstarbound.io.writeUUID
|
||||||
import ru.dbotthepony.kstarbound.io.writeVec2i
|
import ru.dbotthepony.kstarbound.network.IClientPacket
|
||||||
import ru.dbotthepony.kstarbound.world.World
|
import ru.dbotthepony.kstarbound.world.World
|
||||||
import ru.dbotthepony.kstarbound.world.WorldGeometry
|
import ru.dbotthepony.kstarbound.world.WorldGeometry
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
import java.io.DataOutputStream
|
import java.io.DataOutputStream
|
||||||
import java.util.UUID
|
import java.util.*
|
||||||
|
|
||||||
data class JoinWorldPacket(val uuid: UUID, val seed: Long, val geometry: WorldGeometry) : IClientPacket {
|
data class JoinWorldPacket(val uuid: UUID, val seed: Long, val geometry: WorldGeometry) : IClientPacket {
|
||||||
constructor(buff: DataInputStream) : this(buff.readUUID(), buff.readLong(), WorldGeometry(buff))
|
constructor(buff: DataInputStream) : this(buff.readUUID(), buff.readLong(), WorldGeometry(buff))
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.render
|
package ru.dbotthepony.kstarbound.client.render
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW.*
|
import org.lwjgl.glfw.GLFW.*
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
|
|
||||||
class Camera(val client: StarboundClient) {
|
class Camera(val client: StarboundClient) {
|
||||||
/**
|
/**
|
||||||
|
@ -7,6 +7,11 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
|||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||||
import org.lwjgl.opengl.GL45.*
|
import org.lwjgl.opengl.GL45.*
|
||||||
import org.lwjgl.system.MemoryUtil
|
import org.lwjgl.system.MemoryUtil
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix3f
|
||||||
|
import ru.dbotthepony.kommons.util.AABBi
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4f
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.client.freetype.LoadFlag
|
import ru.dbotthepony.kstarbound.client.freetype.LoadFlag
|
||||||
import ru.dbotthepony.kstarbound.client.gl.*
|
import ru.dbotthepony.kstarbound.client.gl.*
|
||||||
@ -18,13 +23,6 @@ import ru.dbotthepony.kstarbound.client.gl.vertex.VertexBuilder
|
|||||||
import ru.dbotthepony.kstarbound.defs.image.IUVCoordinates
|
import ru.dbotthepony.kstarbound.defs.image.IUVCoordinates
|
||||||
import ru.dbotthepony.kstarbound.math.roundTowardsNegativeInfinity
|
import ru.dbotthepony.kstarbound.math.roundTowardsNegativeInfinity
|
||||||
import ru.dbotthepony.kstarbound.math.roundTowardsPositiveInfinity
|
import ru.dbotthepony.kstarbound.math.roundTowardsPositiveInfinity
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3f
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABBi
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4f
|
|
||||||
|
|
||||||
private fun breakLines(text: String): List<String> {
|
private fun breakLines(text: String): List<String> {
|
||||||
var nextLineBreak = text.indexOf('\n', 0)
|
var nextLineBreak = text.indexOf('\n', 0)
|
||||||
|
@ -5,7 +5,6 @@ import ru.dbotthepony.kstarbound.client.StarboundClient
|
|||||||
import ru.dbotthepony.kstarbound.client.gl.checkForGLError
|
import ru.dbotthepony.kstarbound.client.gl.checkForGLError
|
||||||
import ru.dbotthepony.kstarbound.client.gl.shader.GLShaderProgram
|
import ru.dbotthepony.kstarbound.client.gl.shader.GLShaderProgram
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexBuilder
|
import ru.dbotthepony.kstarbound.client.gl.vertex.VertexBuilder
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix4f
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mesh is container for paired VAO, VBO and EBO, and metadata for them
|
* mesh is container for paired VAO, VBO and EBO, and metadata for them
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.client.render
|
package ru.dbotthepony.kstarbound.client.render
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.client.gl.shader.GLShaderProgram
|
import ru.dbotthepony.kstarbound.client.gl.shader.GLShaderProgram
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix4f
|
|
||||||
|
|
||||||
abstract class RenderConfig<out T : GLShaderProgram>(val program: T) {
|
abstract class RenderConfig<out T : GLShaderProgram>(val program: T) {
|
||||||
val client get() = program.client
|
val client get() = program.client
|
||||||
|
@ -5,6 +5,8 @@ import com.github.benmanes.caffeine.cache.Caffeine
|
|||||||
import com.github.benmanes.caffeine.cache.Scheduler
|
import com.github.benmanes.caffeine.cache.Scheduler
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import org.lwjgl.opengl.GL45.*
|
import org.lwjgl.opengl.GL45.*
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
||||||
import ru.dbotthepony.kstarbound.Registries
|
import ru.dbotthepony.kstarbound.Registries
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
@ -15,8 +17,6 @@ import ru.dbotthepony.kstarbound.defs.tile.*
|
|||||||
import ru.dbotthepony.kstarbound.world.api.ITileAccess
|
import ru.dbotthepony.kstarbound.world.api.ITileAccess
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractTileState
|
import ru.dbotthepony.kstarbound.world.api.AbstractTileState
|
||||||
import ru.dbotthepony.kstarbound.world.api.TileColor
|
import ru.dbotthepony.kstarbound.world.api.TileColor
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
|
@ -5,6 +5,11 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectFunction
|
|||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
|
||||||
import it.unimi.dsi.fastutil.longs.LongArraySet
|
import it.unimi.dsi.fastutil.longs.LongArraySet
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2i
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.util.AABB
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.Registry
|
import ru.dbotthepony.kstarbound.Registry
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
@ -23,11 +28,6 @@ import ru.dbotthepony.kstarbound.world.api.ITileAccess
|
|||||||
import ru.dbotthepony.kstarbound.world.api.OffsetCellAccess
|
import ru.dbotthepony.kstarbound.world.api.OffsetCellAccess
|
||||||
import ru.dbotthepony.kstarbound.world.api.TileView
|
import ru.dbotthepony.kstarbound.world.api.TileView
|
||||||
import ru.dbotthepony.kstarbound.world.positiveModulo
|
import ru.dbotthepony.kstarbound.world.positiveModulo
|
||||||
import ru.dbotthepony.kvector.api.IStruct2i
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
@ -8,6 +8,11 @@ import com.google.gson.reflect.TypeToken
|
|||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.matrix.Matrix3f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector3f
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.client.gl.vertex.GeometryType
|
import ru.dbotthepony.kstarbound.client.gl.vertex.GeometryType
|
||||||
@ -16,12 +21,7 @@ import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
|||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.consumeNull
|
import ru.dbotthepony.kstarbound.json.consumeNull
|
||||||
import ru.dbotthepony.kstarbound.math.LineF
|
import ru.dbotthepony.kstarbound.math.LineF
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import ru.dbotthepony.kstarbound.json.contains
|
import ru.dbotthepony.kstarbound.json.contains
|
||||||
import ru.dbotthepony.kvector.arrays.Matrix3f
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector3f
|
|
||||||
|
|
||||||
sealed class Drawable(val position: Vector2f, val color: RGBAColor, val fullbright: Boolean) {
|
sealed class Drawable(val position: Vector2f, val color: RGBAColor, val fullbright: Boolean) {
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
|
@ -5,9 +5,9 @@ import com.google.gson.JsonObject
|
|||||||
import com.google.gson.TypeAdapter
|
import com.google.gson.TypeAdapter
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.util.AssetPathStack
|
import ru.dbotthepony.kstarbound.util.AssetPathStack
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import ru.dbotthepony.kstarbound.json.set
|
import ru.dbotthepony.kstarbound.json.set
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
import java.util.function.Function
|
import java.util.function.Function
|
||||||
|
@ -10,10 +10,10 @@ import com.google.gson.reflect.TypeToken
|
|||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonToken
|
import com.google.gson.stream.JsonToken
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
|
import ru.dbotthepony.kommons.gson.Vector2dTypeAdapter
|
||||||
|
import ru.dbotthepony.kommons.math.linearInterpolation
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.json.builder.EnumAdapter
|
import ru.dbotthepony.kstarbound.json.builder.EnumAdapter
|
||||||
import ru.dbotthepony.kstarbound.json.Vector2dTypeAdapter
|
|
||||||
import ru.dbotthepony.kvector.util.linearInterpolation
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
enum class JsonFunctionInterpolation {
|
enum class JsonFunctionInterpolation {
|
||||||
LINEAR {
|
LINEAR {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs
|
package ru.dbotthepony.kstarbound.defs
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class JumpProfile(
|
data class JumpProfile(
|
||||||
|
@ -2,10 +2,9 @@ package ru.dbotthepony.kstarbound.defs
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.common.collect.ImmutableSet
|
import com.google.common.collect.ImmutableSet
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonAlias
|
import ru.dbotthepony.kstarbound.json.builder.JsonAlias
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonImplementation
|
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import ru.dbotthepony.kstarbound.world.physics.Poly
|
import ru.dbotthepony.kstarbound.world.physics.Poly
|
||||||
|
|
||||||
sealed class BaseMovementParameters {
|
sealed class BaseMovementParameters {
|
||||||
|
@ -2,8 +2,8 @@ package ru.dbotthepony.kstarbound.defs
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.common.collect.ImmutableSet
|
import com.google.common.collect.ImmutableSet
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class TouchDamage(
|
data class TouchDamage(
|
||||||
|
@ -2,11 +2,11 @@ package ru.dbotthepony.kstarbound.defs.animation
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.common.collect.ImmutableMap
|
import com.google.common.collect.ImmutableMap
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||||
import ru.dbotthepony.kstarbound.defs.particle.ParticleEmitter
|
import ru.dbotthepony.kstarbound.defs.particle.ParticleEmitter
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class AnimationDefinition(
|
data class AnimationDefinition(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.image
|
package ru.dbotthepony.kstarbound.defs.image
|
||||||
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct4f
|
import ru.dbotthepony.kommons.core.IStruct4f
|
||||||
|
|
||||||
interface IUVCoordinates : IStruct4f {
|
interface IUVCoordinates : IStruct4f {
|
||||||
val u0: Float
|
val u0: Float
|
||||||
|
@ -23,6 +23,8 @@ import org.lwjgl.stb.STBIReadCallbackI
|
|||||||
import org.lwjgl.stb.STBISkipCallback
|
import org.lwjgl.stb.STBISkipCallback
|
||||||
import org.lwjgl.stb.STBImage
|
import org.lwjgl.stb.STBImage
|
||||||
import org.lwjgl.system.MemoryUtil
|
import org.lwjgl.system.MemoryUtil
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4i
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNIT
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNIT
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITi
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITi
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
@ -33,8 +35,6 @@ import ru.dbotthepony.kstarbound.json.consumeNull
|
|||||||
import ru.dbotthepony.kstarbound.json.contains
|
import ru.dbotthepony.kstarbound.json.contains
|
||||||
import ru.dbotthepony.kstarbound.json.get
|
import ru.dbotthepony.kstarbound.json.get
|
||||||
import ru.dbotthepony.kstarbound.json.getObject
|
import ru.dbotthepony.kstarbound.json.getObject
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4i
|
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
@ -10,10 +10,10 @@ import org.classdump.luna.ByteString
|
|||||||
import org.classdump.luna.LuaRuntimeException
|
import org.classdump.luna.LuaRuntimeException
|
||||||
import org.classdump.luna.Table
|
import org.classdump.luna.Table
|
||||||
import org.classdump.luna.TableFactory
|
import org.classdump.luna.TableFactory
|
||||||
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
import ru.dbotthepony.kstarbound.lua.StateMachine
|
import ru.dbotthepony.kstarbound.lua.StateMachine
|
||||||
import ru.dbotthepony.kstarbound.lua.from
|
import ru.dbotthepony.kstarbound.lua.from
|
||||||
import ru.dbotthepony.kstarbound.lua.toJsonObject
|
import ru.dbotthepony.kstarbound.lua.toJsonObject
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
|
||||||
import ru.dbotthepony.kstarbound.json.get
|
import ru.dbotthepony.kstarbound.json.get
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ import com.google.gson.internal.bind.JsonTreeReader
|
|||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.Registry
|
import ru.dbotthepony.kstarbound.Registry
|
||||||
import ru.dbotthepony.kstarbound.defs.ItemReference
|
import ru.dbotthepony.kstarbound.defs.ItemReference
|
||||||
import ru.dbotthepony.kstarbound.json.consumeNull
|
import ru.dbotthepony.kstarbound.json.consumeNull
|
||||||
import ru.dbotthepony.kstarbound.json.stream
|
import ru.dbotthepony.kstarbound.json.stream
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import ru.dbotthepony.kstarbound.util.ItemStack
|
import ru.dbotthepony.kstarbound.util.ItemStack
|
||||||
import ru.dbotthepony.kstarbound.util.WriteOnce
|
import ru.dbotthepony.kstarbound.util.WriteOnce
|
||||||
import java.util.Random
|
import java.util.Random
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.api
|
package ru.dbotthepony.kstarbound.defs.item.api
|
||||||
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
|
||||||
interface IFlashlightDefinition : IItemDefinition, IItemInHandDefinition {
|
interface IFlashlightDefinition : IItemDefinition, IItemInHandDefinition {
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.api
|
package ru.dbotthepony.kstarbound.defs.item.api
|
||||||
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
|
||||||
interface IItemInHandDefinition : IItemDefinition {
|
interface IItemInHandDefinition : IItemDefinition {
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.api
|
package ru.dbotthepony.kstarbound.defs.item.api
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
import ru.dbotthepony.kommons.core.Either
|
||||||
|
|
||||||
interface ILiquidItem : IItemDefinition {
|
interface ILiquidItem : IItemDefinition {
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.api
|
package ru.dbotthepony.kstarbound.defs.item.api
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
|
|
||||||
interface IMaterialItem : IItemDefinition {
|
interface IMaterialItem : IItemDefinition {
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.impl
|
package ru.dbotthepony.kstarbound.defs.item.impl
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IFlashlightDefinition
|
import ru.dbotthepony.kstarbound.defs.item.api.IFlashlightDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory(logMisses = false)
|
@JsonFactory(logMisses = false)
|
||||||
class FlashlightDefinition(
|
class FlashlightDefinition(
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.impl
|
package ru.dbotthepony.kstarbound.defs.item.impl
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IHarvestingToolDefinition
|
import ru.dbotthepony.kstarbound.defs.item.api.IHarvestingToolDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory(logMisses = false)
|
@JsonFactory(logMisses = false)
|
||||||
class HarvestingToolPrototype(
|
class HarvestingToolPrototype(
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.impl
|
package ru.dbotthepony.kstarbound.defs.item.impl
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.ILiquidItem
|
import ru.dbotthepony.kstarbound.defs.item.api.ILiquidItem
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonAlias
|
import ru.dbotthepony.kstarbound.json.builder.JsonAlias
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonBuilder
|
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class LiquidItemDefinition(
|
data class LiquidItemDefinition(
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item.impl
|
package ru.dbotthepony.kstarbound.defs.item.impl
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.ILiquidItem
|
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IMaterialItem
|
import ru.dbotthepony.kstarbound.defs.item.api.IMaterialItem
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonAlias
|
import ru.dbotthepony.kstarbound.json.builder.JsonAlias
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonBuilder
|
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class MaterialItemDefinition(
|
data class MaterialItemDefinition(
|
||||||
|
@ -3,6 +3,7 @@ package ru.dbotthepony.kstarbound.defs.monster
|
|||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.common.collect.ImmutableMap
|
import com.google.common.collect.ImmutableMap
|
||||||
import com.google.common.collect.ImmutableSet
|
import com.google.common.collect.ImmutableSet
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.Registry
|
import ru.dbotthepony.kstarbound.Registry
|
||||||
import ru.dbotthepony.kstarbound.defs.ActorMovementParameters
|
import ru.dbotthepony.kstarbound.defs.ActorMovementParameters
|
||||||
import ru.dbotthepony.kstarbound.defs.AssetReference
|
import ru.dbotthepony.kstarbound.defs.AssetReference
|
||||||
@ -12,7 +13,6 @@ import ru.dbotthepony.kstarbound.defs.animation.AnimationDefinition
|
|||||||
import ru.dbotthepony.kstarbound.defs.item.TreasurePoolDefinition
|
import ru.dbotthepony.kstarbound.defs.item.TreasurePoolDefinition
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class MonsterTypeDefinition(
|
data class MonsterTypeDefinition(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.`object`
|
package ru.dbotthepony.kstarbound.defs.`object`
|
||||||
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
|
|
||||||
data class Anchor(val isForeground: Boolean, val pos: Vector2i, val isTilled: Boolean, val isSoil: Boolean, val anchorMaterial: String?)
|
data class Anchor(val isForeground: Boolean, val pos: Vector2i, val isTilled: Boolean, val isSoil: Boolean, val anchorMaterial: String?)
|
||||||
|
@ -11,6 +11,8 @@ import com.google.gson.JsonSyntaxException
|
|||||||
import com.google.gson.TypeAdapter
|
import com.google.gson.TypeAdapter
|
||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.kstarbound.Registry
|
import ru.dbotthepony.kstarbound.Registry
|
||||||
import ru.dbotthepony.kstarbound.defs.AssetPath
|
import ru.dbotthepony.kstarbound.defs.AssetPath
|
||||||
import ru.dbotthepony.kstarbound.defs.ItemReference
|
import ru.dbotthepony.kstarbound.defs.ItemReference
|
||||||
@ -23,12 +25,10 @@ import ru.dbotthepony.kstarbound.json.consumeNull
|
|||||||
import ru.dbotthepony.kstarbound.json.listAdapter
|
import ru.dbotthepony.kstarbound.json.listAdapter
|
||||||
import ru.dbotthepony.kstarbound.json.stream
|
import ru.dbotthepony.kstarbound.json.stream
|
||||||
import ru.dbotthepony.kstarbound.math.PeriodicFunction
|
import ru.dbotthepony.kstarbound.math.PeriodicFunction
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import ru.dbotthepony.kstarbound.json.contains
|
import ru.dbotthepony.kstarbound.json.contains
|
||||||
import ru.dbotthepony.kstarbound.json.get
|
import ru.dbotthepony.kstarbound.json.get
|
||||||
import ru.dbotthepony.kstarbound.json.getArray
|
import ru.dbotthepony.kstarbound.json.getArray
|
||||||
import ru.dbotthepony.kstarbound.json.set
|
import ru.dbotthepony.kstarbound.json.set
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
|
|
||||||
data class ObjectDefinition(
|
data class ObjectDefinition(
|
||||||
val objectName: String,
|
val objectName: String,
|
||||||
|
@ -10,6 +10,11 @@ import com.google.gson.TypeAdapter
|
|||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
|
import ru.dbotthepony.kommons.util.AABB
|
||||||
|
import ru.dbotthepony.kommons.util.AABBi
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2f
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
||||||
import ru.dbotthepony.kstarbound.client.render.RenderLayer
|
import ru.dbotthepony.kstarbound.client.render.RenderLayer
|
||||||
import ru.dbotthepony.kstarbound.defs.Drawable
|
import ru.dbotthepony.kstarbound.defs.Drawable
|
||||||
@ -23,11 +28,6 @@ import ru.dbotthepony.kstarbound.json.contains
|
|||||||
import ru.dbotthepony.kstarbound.json.get
|
import ru.dbotthepony.kstarbound.json.get
|
||||||
import ru.dbotthepony.kstarbound.json.set
|
import ru.dbotthepony.kstarbound.json.set
|
||||||
import ru.dbotthepony.kstarbound.world.Side
|
import ru.dbotthepony.kstarbound.world.Side
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABBi
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
|
|
||||||
data class ObjectOrientation(
|
data class ObjectOrientation(
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.particle
|
package ru.dbotthepony.kstarbound.defs.particle
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.defs.animation.DestructionAction
|
import ru.dbotthepony.kstarbound.defs.animation.DestructionAction
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonImplementation
|
import ru.dbotthepony.kstarbound.json.builder.JsonImplementation
|
||||||
import ru.dbotthepony.kstarbound.util.VirtualProperty
|
import ru.dbotthepony.kstarbound.util.VirtualProperty
|
||||||
import ru.dbotthepony.kstarbound.util.SBPattern
|
import ru.dbotthepony.kstarbound.util.SBPattern
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonImplementation(ParticleConfig::class)
|
@JsonImplementation(ParticleConfig::class)
|
||||||
interface IParticleConfig : IParticleVariance {
|
interface IParticleConfig : IParticleVariance {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.particle
|
package ru.dbotthepony.kstarbound.defs.particle
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4d
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonImplementation
|
import ru.dbotthepony.kstarbound.json.builder.JsonImplementation
|
||||||
import ru.dbotthepony.kstarbound.util.VirtualProperty
|
import ru.dbotthepony.kstarbound.util.VirtualProperty
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4d
|
|
||||||
|
|
||||||
@JsonImplementation(ParticleVariance::class)
|
@JsonImplementation(ParticleVariance::class)
|
||||||
interface IParticleVariance {
|
interface IParticleVariance {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.particle
|
package ru.dbotthepony.kstarbound.defs.particle
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4d
|
||||||
import ru.dbotthepony.kstarbound.defs.AssetReference
|
import ru.dbotthepony.kstarbound.defs.AssetReference
|
||||||
import ru.dbotthepony.kstarbound.defs.animation.AnimationDefinition
|
import ru.dbotthepony.kstarbound.defs.animation.AnimationDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.animation.DestructionAction
|
import ru.dbotthepony.kstarbound.defs.animation.DestructionAction
|
||||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.util.SBPattern
|
import ru.dbotthepony.kstarbound.util.SBPattern
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class ParticleConfig(
|
data class ParticleConfig(
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.particle
|
package ru.dbotthepony.kstarbound.defs.particle
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.Registry
|
import ru.dbotthepony.kstarbound.Registry
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class ParticleCreator(
|
data class ParticleCreator(
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.particle
|
package ru.dbotthepony.kstarbound.defs.particle
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4d
|
||||||
import ru.dbotthepony.kstarbound.defs.animation.DestructionAction
|
import ru.dbotthepony.kstarbound.defs.animation.DestructionAction
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.util.SBPattern
|
import ru.dbotthepony.kstarbound.util.SBPattern
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class ParticleEmitter(
|
data class ParticleEmitter(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.particle
|
package ru.dbotthepony.kstarbound.defs.particle
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector4d
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class ParticleVariance(
|
data class ParticleVariance(
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.player
|
package ru.dbotthepony.kstarbound.defs.player
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class MatterManipulatorConfig(
|
data class MatterManipulatorConfig(
|
||||||
|
@ -4,6 +4,9 @@ import com.google.common.collect.ImmutableList
|
|||||||
import com.google.common.collect.ImmutableMap
|
import com.google.common.collect.ImmutableMap
|
||||||
import com.google.common.collect.ImmutableSet
|
import com.google.common.collect.ImmutableSet
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.util.AABB
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.Registry
|
import ru.dbotthepony.kstarbound.Registry
|
||||||
import ru.dbotthepony.kstarbound.defs.ActorMovementParameters
|
import ru.dbotthepony.kstarbound.defs.ActorMovementParameters
|
||||||
import ru.dbotthepony.kstarbound.defs.AssetReference
|
import ru.dbotthepony.kstarbound.defs.AssetReference
|
||||||
@ -12,9 +15,6 @@ import ru.dbotthepony.kstarbound.util.SBPattern
|
|||||||
import ru.dbotthepony.kstarbound.defs.animation.AnimationDefinition
|
import ru.dbotthepony.kstarbound.defs.animation.AnimationDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.api.IItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class PlayerDefinition(
|
data class PlayerDefinition(
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.player
|
package ru.dbotthepony.kstarbound.defs.player
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class SplashConfig(
|
data class SplashConfig(
|
||||||
|
@ -2,8 +2,8 @@ package ru.dbotthepony.kstarbound.defs.player
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.common.collect.ImmutableMap
|
import com.google.common.collect.ImmutableMap
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class StatusControllerSettings(
|
data class StatusControllerSettings(
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.tile
|
package ru.dbotthepony.kstarbound.defs.tile
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.kstarbound.Registry
|
import ru.dbotthepony.kstarbound.Registry
|
||||||
import ru.dbotthepony.kstarbound.defs.StatusEffectDefinition
|
import ru.dbotthepony.kstarbound.defs.StatusEffectDefinition
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class LiquidDefinition(
|
data class LiquidDefinition(
|
||||||
|
@ -4,12 +4,12 @@ import com.google.common.collect.ImmutableList
|
|||||||
import com.google.common.collect.ImmutableMap
|
import com.google.common.collect.ImmutableMap
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.defs.image.Image
|
import ru.dbotthepony.kstarbound.defs.image.Image
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.util.WriteOnce
|
import ru.dbotthepony.kstarbound.util.WriteOnce
|
||||||
import ru.dbotthepony.kstarbound.world.api.ITileAccess
|
import ru.dbotthepony.kstarbound.world.api.ITileAccess
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractTileState
|
import ru.dbotthepony.kstarbound.world.api.AbstractTileState
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class RenderPiece(
|
data class RenderPiece(
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.tile
|
package ru.dbotthepony.kstarbound.defs.tile
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.kstarbound.defs.AssetReference
|
import ru.dbotthepony.kstarbound.defs.AssetReference
|
||||||
import ru.dbotthepony.kstarbound.world.physics.CollisionType
|
import ru.dbotthepony.kstarbound.world.physics.CollisionType
|
||||||
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
||||||
@ -8,7 +9,6 @@ import ru.dbotthepony.kstarbound.defs.ThingDescription
|
|||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||||
import ru.dbotthepony.kstarbound.json.builder.JsonIgnore
|
import ru.dbotthepony.kstarbound.json.builder.JsonIgnore
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
|
|
||||||
@JsonFactory
|
@JsonFactory
|
||||||
data class TileDefinition(
|
data class TileDefinition(
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package ru.dbotthepony.kstarbound.io
|
package ru.dbotthepony.kstarbound.io
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntArraySet
|
import it.unimi.dsi.fastutil.ints.IntArraySet
|
||||||
|
import ru.dbotthepony.kommons.io.readVarInt
|
||||||
|
import ru.dbotthepony.kommons.io.readVarIntInfo
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
@ -2,6 +2,9 @@ package ru.dbotthepony.kstarbound.io
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap
|
||||||
|
import ru.dbotthepony.kommons.io.readBinaryString
|
||||||
|
import ru.dbotthepony.kommons.io.readVarInt
|
||||||
|
import ru.dbotthepony.kommons.io.readVarLong
|
||||||
import ru.dbotthepony.kstarbound.IStarboundFile
|
import ru.dbotthepony.kstarbound.IStarboundFile
|
||||||
import ru.dbotthepony.kstarbound.getValue
|
import ru.dbotthepony.kstarbound.getValue
|
||||||
import ru.dbotthepony.kstarbound.json.readJsonObject
|
import ru.dbotthepony.kstarbound.json.readJsonObject
|
||||||
@ -212,8 +215,7 @@ class StarboundPak(val path: File, callback: (finished: Boolean, status: String)
|
|||||||
try {
|
try {
|
||||||
callback(false, "Reading index node $i")
|
callback(false, "Reading index node $i")
|
||||||
|
|
||||||
val readLength = stream.readVarInt()
|
name = stream.readBinaryString()
|
||||||
name = stream.readString(readLength)
|
|
||||||
require(name[0] == '/') { "index node at $i with '$name' appears to be not an absolute filename" }
|
require(name[0] == '/') { "index node at $i with '$name' appears to be not an absolute filename" }
|
||||||
val offset = stream.readLong()
|
val offset = stream.readLong()
|
||||||
val length = stream.readLong()
|
val length = stream.readLong()
|
||||||
|
@ -1,158 +1,28 @@
|
|||||||
package ru.dbotthepony.kstarbound.io
|
package ru.dbotthepony.kstarbound.io
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.bytes.ByteArrayList
|
import it.unimi.dsi.fastutil.bytes.ByteArrayList
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2d
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2i
|
||||||
|
import ru.dbotthepony.kommons.io.readDouble
|
||||||
|
import ru.dbotthepony.kommons.io.readLong
|
||||||
|
import ru.dbotthepony.kommons.io.readSignedVarInt
|
||||||
|
import ru.dbotthepony.kommons.io.writeDouble
|
||||||
|
import ru.dbotthepony.kommons.io.writeLong
|
||||||
|
import ru.dbotthepony.kommons.io.writeSignedVarInt
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kvector.api.IStruct2d
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct2i
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import java.io.DataInput
|
import java.io.DataInput
|
||||||
import java.io.DataOutput
|
import java.io.DataOutput
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.io.RandomAccessFile
|
import java.io.RandomAccessFile
|
||||||
import java.math.BigDecimal
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.function.IntConsumer
|
import java.util.function.IntConsumer
|
||||||
import java.util.function.IntSupplier
|
import java.util.function.IntSupplier
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
data class VarIntReadResult(val value: Int, val cells: Int)
|
|
||||||
data class VarLongReadResult(val value: Long, val cells: Int)
|
|
||||||
|
|
||||||
private fun readVarLongInfo(supplier: IntSupplier): VarLongReadResult {
|
|
||||||
var result = 0L
|
|
||||||
var read = supplier.asInt
|
|
||||||
var i = 1
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
result = (result shl 7) or (read.toLong() and 0x7F)
|
|
||||||
|
|
||||||
if (read and 0x80 == 0)
|
|
||||||
break
|
|
||||||
|
|
||||||
read = supplier.asInt
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
return VarLongReadResult(result, i)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun readVarIntInfo(supplier: IntSupplier): VarIntReadResult {
|
|
||||||
val read = readVarLongInfo(supplier)
|
|
||||||
return VarIntReadResult(read.value.toInt(), read.cells)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun readVarInt(supplier: IntSupplier): Int {
|
|
||||||
return readVarIntInfo(supplier).value
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun readVarLong(supplier: IntSupplier): Long {
|
|
||||||
return readVarLongInfo(supplier).value
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Int.fromSignedVar(): Int {
|
|
||||||
val sign = this and 1
|
|
||||||
|
|
||||||
if (sign == 0)
|
|
||||||
return this ushr 1
|
|
||||||
else
|
|
||||||
return -(this ushr 1) - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun VarIntReadResult.fromSignedVar(): VarIntReadResult {
|
|
||||||
val sign = this.value and 1
|
|
||||||
|
|
||||||
if (sign == 0)
|
|
||||||
return VarIntReadResult(this.value ushr 1, this.cells)
|
|
||||||
else
|
|
||||||
return VarIntReadResult(-(this.value ushr 1) - 1, this.cells)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Long.fromSignedVar(): Long {
|
|
||||||
val sign = this and 1
|
|
||||||
|
|
||||||
if (sign == 0L)
|
|
||||||
return this ushr 1
|
|
||||||
else
|
|
||||||
return -(this ushr 1) - 1L
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun VarLongReadResult.fromSignedVar(): VarLongReadResult {
|
|
||||||
val sign = this.value and 1
|
|
||||||
|
|
||||||
if (sign == 0L)
|
|
||||||
return VarLongReadResult(this.value ushr 1, this.cells)
|
|
||||||
else
|
|
||||||
return VarLongReadResult(-(this.value ushr 1) - 1, this.cells)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun RandomAccessFile.readVarLong() = readVarLong(::read)
|
|
||||||
fun RandomAccessFile.readVarInt() = readVarInt(::read)
|
|
||||||
fun RandomAccessFile.readVarLongInfo() = readVarLongInfo(::read)
|
|
||||||
fun RandomAccessFile.readVarIntInfo() = readVarIntInfo(::read)
|
|
||||||
fun InputStream.readVarLong() = readVarLong(::read)
|
|
||||||
fun InputStream.readVarInt() = readVarInt(::read)
|
|
||||||
fun InputStream.readVarLongInfo() = readVarLongInfo(::read)
|
|
||||||
fun InputStream.readVarIntInfo() = readVarIntInfo(::read)
|
|
||||||
|
|
||||||
fun RandomAccessFile.readSignedVarLong() = readVarLong(::read).fromSignedVar()
|
|
||||||
fun RandomAccessFile.readSignedVarInt() = readVarInt(::read).fromSignedVar()
|
|
||||||
fun RandomAccessFile.readSignedVarLongInfo() = readVarLongInfo(::read).fromSignedVar()
|
|
||||||
fun RandomAccessFile.readSignedVarIntInfo() = readVarIntInfo(::read).fromSignedVar()
|
|
||||||
fun InputStream.readSignedVarLong() = readVarLong(::read).fromSignedVar()
|
|
||||||
fun InputStream.readSignedVarInt() = readVarInt(::read).fromSignedVar()
|
|
||||||
fun InputStream.readSignedVarLongInfo() = readVarLongInfo(::read).fromSignedVar()
|
|
||||||
fun InputStream.readSignedVarIntInfo() = readVarIntInfo(::read).fromSignedVar()
|
|
||||||
|
|
||||||
private fun writeVarLong(write: IntConsumer, value: Long): Int {
|
|
||||||
var value = value
|
|
||||||
var i = 0
|
|
||||||
|
|
||||||
do {
|
|
||||||
val toWrite = (value and 0x7F).toInt()
|
|
||||||
value = value ushr 7
|
|
||||||
|
|
||||||
if (value == 0L)
|
|
||||||
write.accept(toWrite)
|
|
||||||
else
|
|
||||||
write.accept(toWrite or 0x80)
|
|
||||||
|
|
||||||
i++
|
|
||||||
} while (value != 0L)
|
|
||||||
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun writeVarInt(write: IntConsumer, value: Int): Int {
|
|
||||||
return writeVarLong(write, value.toLong())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Int.toSignedVar(): Int {
|
|
||||||
if (this >= 0)
|
|
||||||
return this shl 1
|
|
||||||
else
|
|
||||||
return (this shl 1) or 1
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Long.toSignedVar(): Long {
|
|
||||||
if (this >= 0)
|
|
||||||
return this shl 1
|
|
||||||
else
|
|
||||||
return ((-this - 1) shl 1) or 1L
|
|
||||||
}
|
|
||||||
|
|
||||||
fun RandomAccessFile.writeVarLong(value: Long) = writeVarLong(::write, value)
|
|
||||||
fun RandomAccessFile.writeVarInt(value: Int) = writeVarInt(::write, value)
|
|
||||||
fun OutputStream.writeVarLong(value: Long) = writeVarLong(::write, value)
|
|
||||||
fun OutputStream.writeVarInt(value: Int) = writeVarInt(::write, value)
|
|
||||||
|
|
||||||
fun RandomAccessFile.writeSignedVarLong(value: Long) = writeVarLong(::write, value.toSignedVar())
|
|
||||||
fun RandomAccessFile.writeSignedVarInt(value: Int) = writeVarInt(::write, value.toSignedVar())
|
|
||||||
fun OutputStream.writeSignedVarLong(value: Long) = writeVarLong(::write, value.toSignedVar())
|
|
||||||
fun OutputStream.writeSignedVarInt(value: Int) = writeVarInt(::write, value.toSignedVar())
|
|
||||||
|
|
||||||
fun RandomAccessFile.readString(length: Int): String {
|
fun RandomAccessFile.readString(length: Int): String {
|
||||||
require(length >= 0) { "Invalid length $length" }
|
require(length >= 0) { "Invalid length $length" }
|
||||||
|
|
||||||
@ -244,92 +114,3 @@ fun InputStream.readVec2d(): Vector2d {
|
|||||||
fun InputStream.readChunkPos(): ChunkPos {
|
fun InputStream.readChunkPos(): ChunkPos {
|
||||||
return ChunkPos(readSignedVarInt(), readSignedVarInt())
|
return ChunkPos(readSignedVarInt(), readSignedVarInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <S : OutputStream, V> S.writeCollection(collection: Collection<V>, writer: S.(V) -> Unit) {
|
|
||||||
writeVarInt(collection.size)
|
|
||||||
|
|
||||||
for (value in collection) {
|
|
||||||
writer(this, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <S : InputStream, V, C : MutableCollection<V>> S.readCollection(reader: S.() -> V, factory: (Int) -> C): C {
|
|
||||||
val size = readVarInt()
|
|
||||||
val collection = factory.invoke(size)
|
|
||||||
|
|
||||||
for (i in 0 until size) {
|
|
||||||
collection.add(reader(this))
|
|
||||||
}
|
|
||||||
|
|
||||||
return collection
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <S : InputStream, V> S.readCollection(reader: S.() -> V) = readCollection(reader, ::ArrayList)
|
|
||||||
|
|
||||||
fun OutputStream.writeInt(value: Int) {
|
|
||||||
if (this is DataOutput) {
|
|
||||||
writeInt(value)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
write(value ushr 24)
|
|
||||||
write(value ushr 16)
|
|
||||||
write(value ushr 8)
|
|
||||||
write(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun InputStream.readInt(): Int {
|
|
||||||
if (this is DataInput) {
|
|
||||||
return readInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
return (read() shl 24) or (read() shl 16) or (read() shl 8) or read()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun OutputStream.writeLong(value: Long) {
|
|
||||||
if (this is DataOutput) {
|
|
||||||
writeLong(value)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
write((value ushr 48).toInt())
|
|
||||||
write((value ushr 40).toInt())
|
|
||||||
write((value ushr 32).toInt())
|
|
||||||
write((value ushr 24).toInt())
|
|
||||||
write((value ushr 16).toInt())
|
|
||||||
write((value ushr 8).toInt())
|
|
||||||
write(value.toInt())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun InputStream.readLong(): Long {
|
|
||||||
if (this is DataInput) {
|
|
||||||
return readLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
return (read().toLong() shl 48) or
|
|
||||||
(read().toLong() shl 40) or
|
|
||||||
(read().toLong() shl 32) or
|
|
||||||
(read().toLong() shl 24) or
|
|
||||||
(read().toLong() shl 16) or
|
|
||||||
(read().toLong() shl 8) or
|
|
||||||
read().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun OutputStream.writeFloat(value: Float) = writeInt(value.toBits())
|
|
||||||
fun InputStream.readFloat() = Float.fromBits(readInt())
|
|
||||||
fun OutputStream.writeDouble(value: Double) = writeLong(value.toBits())
|
|
||||||
fun InputStream.readDouble() = Double.fromBits(readLong())
|
|
||||||
|
|
||||||
fun InputStream.readBinaryString(): String {
|
|
||||||
val size = readVarInt()
|
|
||||||
require(size >= 0) { "Negative payload size: $size" }
|
|
||||||
val bytes = ByteArray(size)
|
|
||||||
read(bytes)
|
|
||||||
return bytes.decodeToString()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun OutputStream.writeBinaryString(input: String) {
|
|
||||||
val bytes = input.encodeToByteArray()
|
|
||||||
writeVarInt(bytes.size)
|
|
||||||
write(bytes)
|
|
||||||
}
|
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
|
||||||
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABBi
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
|
|
||||||
object AABBTypeAdapter : TypeAdapter<AABB>() {
|
|
||||||
override fun write(out: JsonWriter, value: AABB) {
|
|
||||||
`out`.beginArray()
|
|
||||||
`out`.value(value.mins.x)
|
|
||||||
`out`.value(value.mins.y)
|
|
||||||
`out`.value(value.maxs.x)
|
|
||||||
`out`.value(value.maxs.y)
|
|
||||||
`out`.endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): AABB {
|
|
||||||
`in`.beginArray()
|
|
||||||
val (x1, x2) = Vector2d(`in`.nextDouble(), `in`.nextDouble())
|
|
||||||
val (y1, y2) = Vector2d(`in`.nextDouble(), `in`.nextDouble())
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
val xMins = x1.coerceAtMost(x2)
|
|
||||||
val xMaxs = x1.coerceAtLeast(x2)
|
|
||||||
|
|
||||||
val yMins = y1.coerceAtMost(y2)
|
|
||||||
val yMaxs = y1.coerceAtLeast(y2)
|
|
||||||
|
|
||||||
return AABB(
|
|
||||||
Vector2d(xMins, yMins),
|
|
||||||
Vector2d(xMaxs, yMaxs),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object AABBiTypeAdapter : TypeAdapter<AABBi>() {
|
|
||||||
override fun write(out: JsonWriter, value: AABBi) {
|
|
||||||
`out`.beginArray()
|
|
||||||
`out`.value(value.mins.x)
|
|
||||||
`out`.value(value.mins.y)
|
|
||||||
`out`.value(value.maxs.x)
|
|
||||||
`out`.value(value.maxs.y)
|
|
||||||
`out`.endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): AABBi {
|
|
||||||
`in`.beginArray()
|
|
||||||
val (x1, x2) = Vector2i(`in`.nextInt(), `in`.nextInt())
|
|
||||||
val (y1, y2) = Vector2i(`in`.nextInt(), `in`.nextInt())
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
val xMins = x1.coerceAtMost(x2)
|
|
||||||
val xMaxs = x1.coerceAtLeast(x2)
|
|
||||||
|
|
||||||
val yMins = y1.coerceAtMost(y2)
|
|
||||||
val yMaxs = y1.coerceAtLeast(y2)
|
|
||||||
|
|
||||||
return AABBi(
|
|
||||||
Vector2i(xMins, yMins),
|
|
||||||
Vector2i(xMaxs, yMaxs),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,10 +9,10 @@ import com.google.gson.JsonPrimitive
|
|||||||
import com.google.gson.JsonSyntaxException
|
import com.google.gson.JsonSyntaxException
|
||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonToken
|
import com.google.gson.stream.JsonToken
|
||||||
import ru.dbotthepony.kstarbound.io.readBinaryString
|
import ru.dbotthepony.kommons.io.readBinaryString
|
||||||
import ru.dbotthepony.kstarbound.io.readSignedVarLong
|
import ru.dbotthepony.kommons.io.readSignedVarLong
|
||||||
|
import ru.dbotthepony.kommons.io.readVarInt
|
||||||
import ru.dbotthepony.kstarbound.io.readString
|
import ru.dbotthepony.kstarbound.io.readString
|
||||||
import ru.dbotthepony.kstarbound.io.readVarInt
|
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
import java.io.EOFException
|
import java.io.EOFException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
@ -117,7 +117,7 @@ class BinaryJsonReader(private val stream: DataInputStream) : JsonReader(unreada
|
|||||||
|
|
||||||
if (last.readingName) {
|
if (last.readingName) {
|
||||||
last.readingName = false
|
last.readingName = false
|
||||||
stack.addLast(NameReader(stream.readString(stream.readVarInt())))
|
stack.addLast(NameReader(stream.readBinaryString()))
|
||||||
} else {
|
} else {
|
||||||
last.readingName = true
|
last.readingName = true
|
||||||
last.readPairs++
|
last.readPairs++
|
||||||
|
@ -5,9 +5,9 @@ import com.google.gson.JsonElement
|
|||||||
import com.google.gson.JsonNull
|
import com.google.gson.JsonNull
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import com.google.gson.JsonPrimitive
|
import com.google.gson.JsonPrimitive
|
||||||
import ru.dbotthepony.kstarbound.io.writeBinaryString
|
import ru.dbotthepony.kommons.io.writeBinaryString
|
||||||
import ru.dbotthepony.kstarbound.io.writeSignedVarLong
|
import ru.dbotthepony.kommons.io.writeSignedVarLong
|
||||||
import ru.dbotthepony.kstarbound.io.writeVarInt
|
import ru.dbotthepony.kommons.io.writeVarInt
|
||||||
import java.io.DataOutputStream
|
import java.io.DataOutputStream
|
||||||
|
|
||||||
fun DataOutputStream.writeJsonElement(value: JsonElement) {
|
fun DataOutputStream.writeJsonElement(value: JsonElement) {
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
|
||||||
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonToken
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
|
|
||||||
object ColorTypeAdapter : TypeAdapter<RGBAColor>() {
|
|
||||||
override fun write(out: JsonWriter, value: RGBAColor) {
|
|
||||||
TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): RGBAColor {
|
|
||||||
when (val type = `in`.peek()) {
|
|
||||||
JsonToken.BEGIN_ARRAY -> {
|
|
||||||
`in`.beginArray()
|
|
||||||
val red = `in`.nextDouble()
|
|
||||||
val green = `in`.nextDouble()
|
|
||||||
val blue = `in`.nextDouble()
|
|
||||||
|
|
||||||
if (red % 1.0 == 0.0 && green % 1.0 == 0.0 && blue % 1.0 == 0.0) {
|
|
||||||
val alpha = `in`.peek().let { if (it == JsonToken.END_ARRAY) 255.0 else `in`.nextDouble() }
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
return RGBAColor(
|
|
||||||
red.toFloat() / 255f,
|
|
||||||
green.toFloat() / 255f,
|
|
||||||
blue.toFloat() / 255f,
|
|
||||||
alpha.toFloat() / 255f,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
val alpha = `in`.peek().let { if (it == JsonToken.END_ARRAY) 1.0 else `in`.nextDouble() }
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
return RGBAColor(
|
|
||||||
red.toFloat(),
|
|
||||||
green.toFloat(),
|
|
||||||
blue.toFloat(),
|
|
||||||
alpha.toFloat(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonToken.BEGIN_OBJECT -> {
|
|
||||||
`in`.beginObject()
|
|
||||||
|
|
||||||
val keyed = mutableMapOf<String, Double>()
|
|
||||||
|
|
||||||
while (`in`.peek() != JsonToken.END_OBJECT) {
|
|
||||||
keyed[`in`.nextName()] = `in`.nextDouble()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyed.isEmpty())
|
|
||||||
throw IllegalArgumentException("Object is empty")
|
|
||||||
|
|
||||||
var values = 0
|
|
||||||
|
|
||||||
val red = keyed["red"]?.also { values++ } ?: keyed["r"]?.also { values++ } ?: 255.0
|
|
||||||
val green = keyed["green"]?.also { values++ } ?: keyed["g"]?.also { values++ } ?: 255.0
|
|
||||||
val blue = keyed["blue"]?.also { values++ } ?: keyed["b"]?.also { values++ } ?: 255.0
|
|
||||||
val alpha = keyed["alpha"]?.also { values++ } ?: keyed["a"]?.also { values++ } ?: 255.0
|
|
||||||
`in`.endObject()
|
|
||||||
|
|
||||||
if (values == 0) {
|
|
||||||
throw IllegalArgumentException("Object is not a RGBAColor")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (red % 1.0 == 0.0 && green % 1.0 == 0.0 && blue % 1.0 == 0.0 && alpha % 1.0 == 0.0) {
|
|
||||||
return RGBAColor(
|
|
||||||
red.toFloat() / 255f,
|
|
||||||
green.toFloat() / 255f,
|
|
||||||
blue.toFloat() / 255f,
|
|
||||||
alpha.toFloat() / 255f,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return RGBAColor(
|
|
||||||
red.toFloat(),
|
|
||||||
green.toFloat(),
|
|
||||||
blue.toFloat(),
|
|
||||||
alpha.toFloat(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonToken.NUMBER -> return RGBAColor.rgb(`in`.nextInt())
|
|
||||||
JsonToken.STRING -> {
|
|
||||||
val name = `in`.nextString()
|
|
||||||
//return RGBAColor.PRE_DEFINED_MAP[name] ?: throw IllegalArgumentException("Unknown pre defined RGBAColor name $name")
|
|
||||||
TODO("Can't determine color from name yet")
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("Expected array, object or number; got $type")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.JsonElement
|
|
||||||
import com.google.gson.JsonSyntaxException
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.TypeAdapterFactory
|
|
||||||
import com.google.gson.internal.bind.JsonTreeReader
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonToken
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import java.lang.reflect.ParameterizedType
|
|
||||||
|
|
||||||
object EitherTypeAdapter : TypeAdapterFactory {
|
|
||||||
override fun <T : Any?> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
|
|
||||||
if (type.rawType == Either::class.java) {
|
|
||||||
val params = type.type as? ParameterizedType ?: return null
|
|
||||||
val (left, right) = params.actualTypeArguments
|
|
||||||
|
|
||||||
return object : TypeAdapter<Either<Any, Any>>() {
|
|
||||||
private val leftAdapter = gson.getAdapter(TypeToken.get(left)) as TypeAdapter<Any?>
|
|
||||||
private val rightAdapter = gson.getAdapter(TypeToken.get(right)) as TypeAdapter<Any?>
|
|
||||||
private val elemAdapter = gson.getAdapter(JsonElement::class.java)
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter, value: Either<Any, Any>?) {
|
|
||||||
if (value == null)
|
|
||||||
out.nullValue()
|
|
||||||
else
|
|
||||||
value.map({ leftAdapter.write(out, it) }, { rightAdapter.write(out, it) })
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): Either<Any, Any>? {
|
|
||||||
if (`in`.peek() == JsonToken.NULL)
|
|
||||||
return null
|
|
||||||
|
|
||||||
val elem = elemAdapter.read(`in`)
|
|
||||||
|
|
||||||
return try {
|
|
||||||
Either.left(leftAdapter.read(JsonTreeReader(elem)) ?: throw NullPointerException("left was empty"))
|
|
||||||
} catch(leftError: Throwable) {
|
|
||||||
try {
|
|
||||||
Either.right(rightAdapter.read(JsonTreeReader(elem)) ?: throw NullPointerException("right was empty"))
|
|
||||||
} catch(rightError: Throwable) {
|
|
||||||
val error = JsonSyntaxException("Can't read Either of values (left is $left, right is $right)")
|
|
||||||
error.addSuppressed(leftError)
|
|
||||||
error.addSuppressed(rightError)
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} as TypeAdapter<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.JsonSyntaxException
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.TypeAdapterFactory
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
|
||||||
import java.lang.reflect.ParameterizedType
|
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
object KOptionalTypeAdapter : TypeAdapterFactory {
|
|
||||||
override fun <T : Any> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
|
|
||||||
if (type.rawType === KOptional.Nullable::class.java || type.rawType === KOptional::class.java || type.rawType === KOptional.NotNull::class.java) {
|
|
||||||
val notnull = type.rawType === KOptional.NotNull::class.java
|
|
||||||
val param = (type.type as? ParameterizedType ?: return null).actualTypeArguments[0]
|
|
||||||
val token = TypeToken.get(param)
|
|
||||||
val isBool = token.rawType === Boolean::class.java
|
|
||||||
|
|
||||||
return object : TypeAdapter<KOptional<Any?>>() {
|
|
||||||
private val adapter0 = gson.getAdapter(token) as TypeAdapter<Any?>
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter, value: KOptional<Any?>?) {
|
|
||||||
if (value === null) {
|
|
||||||
out.nullValue()
|
|
||||||
} else if (value.isPresent) {
|
|
||||||
adapter0.write(out, value.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): KOptional<Any?> {
|
|
||||||
if (isBool) {
|
|
||||||
if (notnull) {
|
|
||||||
return KOptional((adapter0.read(`in`) ?: throw JsonSyntaxException("This KOptional does not accept nulls")) as Boolean) as KOptional<Any?>
|
|
||||||
} else {
|
|
||||||
return KOptional(adapter0.read(`in`) as Boolean?) as KOptional<Any?>
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (notnull) {
|
|
||||||
return KOptional(adapter0.read(`in`) ?: throw JsonSyntaxException("This KOptional does not accept nulls"))
|
|
||||||
} else {
|
|
||||||
return KOptional(adapter0.read(`in`))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} as TypeAdapter<T>
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
|
||||||
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
|
|
||||||
object NothingAdapter : TypeAdapter<Nothing>() {
|
|
||||||
override fun write(out: JsonWriter, value: Nothing?) {
|
|
||||||
out.nullValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): Nothing? {
|
|
||||||
`in`.skipValue()
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.JsonElement
|
|
||||||
import com.google.gson.JsonSyntaxException
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.TypeAdapterFactory
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.util.OneOf
|
|
||||||
import java.lang.reflect.ParameterizedType
|
|
||||||
|
|
||||||
object OneOfTypeAdapter : TypeAdapterFactory {
|
|
||||||
private class Adapter<A, B, C>(gson: Gson, a: TypeToken<A>, b: TypeToken<B>, c: TypeToken<C>) : TypeAdapter<OneOf<A, B, C>>() {
|
|
||||||
private val adapter0 = gson.getAdapter(a)
|
|
||||||
private val adapter1 = gson.getAdapter(b)
|
|
||||||
private val adapter2 = gson.getAdapter(c)
|
|
||||||
private val elements = gson.getAdapter(JsonElement::class.java)
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter, value: OneOf<A, B, C>?) {
|
|
||||||
if (value == null) {
|
|
||||||
out.nullValue()
|
|
||||||
} else {
|
|
||||||
value.v0.ifPresent { adapter0.write(out, it) }
|
|
||||||
value.v1.ifPresent { adapter1.write(out, it) }
|
|
||||||
value.v2.ifPresent { adapter2.write(out, it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): OneOf<A, B, C>? {
|
|
||||||
if (`in`.consumeNull()) {
|
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
val read = elements.read(`in`)
|
|
||||||
val errors = ArrayList<Throwable>(3)
|
|
||||||
|
|
||||||
try {
|
|
||||||
return OneOf.first(adapter0.fromJsonTree(read))
|
|
||||||
} catch (err: Exception) {
|
|
||||||
errors.add(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return OneOf.second(adapter1.fromJsonTree(read))
|
|
||||||
} catch (err: Exception) {
|
|
||||||
errors.add(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return OneOf.third(adapter2.fromJsonTree(read))
|
|
||||||
} catch (err: Exception) {
|
|
||||||
errors.add(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
throw JsonSyntaxException("None of type adapters consumed the input: $read").also { errors.forEach(it::addSuppressed) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : Any?> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
|
|
||||||
if (type.rawType === OneOf::class.java) {
|
|
||||||
val p = type.type as? ParameterizedType ?: return null
|
|
||||||
val (a, b, c) = p.actualTypeArguments
|
|
||||||
|
|
||||||
return Adapter(gson, TypeToken.get(a), TypeToken.get(b), TypeToken.get(c)) as TypeAdapter<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,118 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
|
||||||
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector4i
|
|
||||||
|
|
||||||
object Vector4iTypeAdapter : TypeAdapter<Vector4i>() {
|
|
||||||
override fun write(out: JsonWriter, value: Vector4i) {
|
|
||||||
`out`.beginArray()
|
|
||||||
`out`.value(value.x)
|
|
||||||
`out`.value(value.y)
|
|
||||||
`out`.value(value.z)
|
|
||||||
`out`.value(value.w)
|
|
||||||
`out`.endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): Vector4i {
|
|
||||||
`in`.beginArray()
|
|
||||||
|
|
||||||
val x = `in`.nextInt()
|
|
||||||
val y = `in`.nextInt()
|
|
||||||
val z = `in`.nextInt()
|
|
||||||
val w = `in`.nextInt()
|
|
||||||
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
return Vector4i(x, y, z, w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object Vector4dTypeAdapter : TypeAdapter<Vector4d>() {
|
|
||||||
override fun write(out: JsonWriter, value: Vector4d) {
|
|
||||||
`out`.beginArray()
|
|
||||||
`out`.value(value.x)
|
|
||||||
`out`.value(value.y)
|
|
||||||
`out`.value(value.z)
|
|
||||||
`out`.value(value.w)
|
|
||||||
`out`.endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): Vector4d {
|
|
||||||
`in`.beginArray()
|
|
||||||
|
|
||||||
val x = `in`.nextDouble()
|
|
||||||
val y = `in`.nextDouble()
|
|
||||||
val z = `in`.nextDouble()
|
|
||||||
val w = `in`.nextDouble()
|
|
||||||
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
return Vector4d(x, y, z, w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object Vector2iTypeAdapter : TypeAdapter<Vector2i>() {
|
|
||||||
override fun write(out: JsonWriter, value: Vector2i) {
|
|
||||||
`out`.beginArray()
|
|
||||||
`out`.value(value.x)
|
|
||||||
`out`.value(value.y)
|
|
||||||
`out`.endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): Vector2i {
|
|
||||||
`in`.beginArray()
|
|
||||||
|
|
||||||
val x = `in`.nextInt()
|
|
||||||
val y = `in`.nextInt()
|
|
||||||
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
return Vector2i(x, y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object Vector2fTypeAdapter : TypeAdapter<Vector2f>() {
|
|
||||||
override fun write(out: JsonWriter, value: Vector2f) {
|
|
||||||
`out`.beginArray()
|
|
||||||
`out`.value(value.x)
|
|
||||||
`out`.value(value.y)
|
|
||||||
`out`.endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): Vector2f {
|
|
||||||
`in`.beginArray()
|
|
||||||
|
|
||||||
val x = `in`.nextDouble().toFloat()
|
|
||||||
val y = `in`.nextDouble().toFloat()
|
|
||||||
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
return Vector2f(x, y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object Vector2dTypeAdapter : TypeAdapter<Vector2d>() {
|
|
||||||
override fun write(out: JsonWriter, value: Vector2d) {
|
|
||||||
`out`.beginArray()
|
|
||||||
`out`.value(value.x)
|
|
||||||
`out`.value(value.y)
|
|
||||||
`out`.endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): Vector2d {
|
|
||||||
`in`.beginArray()
|
|
||||||
|
|
||||||
val x = `in`.nextDouble()
|
|
||||||
val y = `in`.nextDouble()
|
|
||||||
|
|
||||||
`in`.endArray()
|
|
||||||
|
|
||||||
return Vector2d(x, y)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.json
|
package ru.dbotthepony.kstarbound.json
|
||||||
|
|
||||||
import com.google.gson.JsonElement
|
import com.google.gson.JsonElement
|
||||||
import ru.dbotthepony.kstarbound.io.readBinaryString
|
import ru.dbotthepony.kommons.io.readBinaryString
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
|
||||||
data class VersionedJson(val identifier: String, val version: Int?, val content: JsonElement) {
|
data class VersionedJson(val identifier: String, val version: Int?, val content: JsonElement) {
|
||||||
|
@ -22,13 +22,13 @@ import it.unimi.dsi.fastutil.ints.IntArrayList
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.kommons.core.Either
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.defs.util.enrollList
|
import ru.dbotthepony.kstarbound.defs.util.enrollList
|
||||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||||
import ru.dbotthepony.kstarbound.defs.util.flattenJsonElement
|
import ru.dbotthepony.kstarbound.defs.util.flattenJsonElement
|
||||||
import ru.dbotthepony.kstarbound.json.consumeNull
|
import ru.dbotthepony.kstarbound.json.consumeNull
|
||||||
import ru.dbotthepony.kstarbound.json.value
|
import ru.dbotthepony.kstarbound.json.value
|
||||||
import ru.dbotthepony.kstarbound.util.Either
|
|
||||||
import java.lang.reflect.Constructor
|
import java.lang.reflect.Constructor
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.function.Function
|
import java.util.function.Function
|
||||||
|
@ -3,7 +3,7 @@ package ru.dbotthepony.kstarbound.json.builder
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.TypeAdapter
|
import com.google.gson.TypeAdapter
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
import kotlin.reflect.KMutableProperty1
|
import kotlin.reflect.KMutableProperty1
|
||||||
import kotlin.reflect.KProperty1
|
import kotlin.reflect.KProperty1
|
||||||
|
@ -24,13 +24,10 @@ import org.classdump.luna.runtime.AbstractFunction4
|
|||||||
import org.classdump.luna.runtime.AbstractFunctionAnyArg
|
import org.classdump.luna.runtime.AbstractFunctionAnyArg
|
||||||
import org.classdump.luna.runtime.ExecutionContext
|
import org.classdump.luna.runtime.ExecutionContext
|
||||||
import org.classdump.luna.runtime.LuaFunction
|
import org.classdump.luna.runtime.LuaFunction
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2i
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct3i
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct4i
|
||||||
import ru.dbotthepony.kstarbound.json.InternedJsonElementAdapter
|
import ru.dbotthepony.kstarbound.json.InternedJsonElementAdapter
|
||||||
import ru.dbotthepony.kvector.api.IStruct2i
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct3i
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct4i
|
|
||||||
import java.lang.ClassCastException
|
|
||||||
import java.lang.IllegalArgumentException
|
|
||||||
import java.lang.IndexOutOfBoundsException
|
|
||||||
|
|
||||||
fun ArgumentIterator.nextOptionalFloat(): Double? {
|
fun ArgumentIterator.nextOptionalFloat(): Double? {
|
||||||
if (hasNext()) {
|
if (hasNext()) {
|
||||||
|
@ -6,8 +6,8 @@ import org.classdump.luna.runtime.Dispatch
|
|||||||
import org.classdump.luna.runtime.ExecutionContext
|
import org.classdump.luna.runtime.ExecutionContext
|
||||||
import org.classdump.luna.runtime.Resumable
|
import org.classdump.luna.runtime.Resumable
|
||||||
import org.classdump.luna.runtime.UnresolvedControlThrowable
|
import org.classdump.luna.runtime.UnresolvedControlThrowable
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
|
||||||
class StateMachine : Resumable {
|
class StateMachine : Resumable {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.dbotthepony.kstarbound.math
|
package ru.dbotthepony.kstarbound.math
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.util.AABB
|
||||||
|
import ru.dbotthepony.kommons.util.AABBi
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABBi
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
|
|
||||||
fun AABB.encasingIntAABB(): AABBi {
|
fun AABB.encasingIntAABB(): AABBi {
|
||||||
return AABBi(
|
return AABBi(
|
||||||
|
@ -4,9 +4,8 @@ import com.google.gson.Gson
|
|||||||
import com.google.gson.TypeAdapter
|
import com.google.gson.TypeAdapter
|
||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kommons.vector.Vector2f
|
||||||
import ru.dbotthepony.kstarbound.json.consumeNull
|
import ru.dbotthepony.kstarbound.json.consumeNull
|
||||||
import ru.dbotthepony.kvector.vector.Vector2f
|
|
||||||
|
|
||||||
data class LineF(val start: Vector2f, val end: Vector2f) {
|
data class LineF(val start: Vector2f, val end: Vector2f) {
|
||||||
class Adapter(gson: Gson) : TypeAdapter<LineF>() {
|
class Adapter(gson: Gson) : TypeAdapter<LineF>() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.math
|
package ru.dbotthepony.kstarbound.math
|
||||||
|
|
||||||
import ru.dbotthepony.kvector.util.linearInterpolation
|
import ru.dbotthepony.kommons.math.linearInterpolation
|
||||||
import java.util.random.RandomGenerator
|
import java.util.random.RandomGenerator
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
import kotlin.math.sin
|
import kotlin.math.sin
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.kstarbound.server
|
package ru.dbotthepony.kstarbound.server
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.util.MailboxExecutorService
|
||||||
import ru.dbotthepony.kstarbound.client.network.packets.JoinWorldPacket
|
import ru.dbotthepony.kstarbound.client.network.packets.JoinWorldPacket
|
||||||
import ru.dbotthepony.kstarbound.server.network.ServerChannels
|
import ru.dbotthepony.kstarbound.server.network.ServerChannels
|
||||||
import ru.dbotthepony.kstarbound.server.network.ServerConnection
|
import ru.dbotthepony.kstarbound.server.network.ServerConnection
|
||||||
import ru.dbotthepony.kstarbound.server.world.ServerWorld
|
import ru.dbotthepony.kstarbound.server.world.ServerWorld
|
||||||
import ru.dbotthepony.kstarbound.util.MailboxExecutorService
|
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
|
@ -4,6 +4,7 @@ import io.netty.channel.ChannelHandlerContext
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.client.network.packets.ForgetChunkPacket
|
import ru.dbotthepony.kstarbound.client.network.packets.ForgetChunkPacket
|
||||||
import ru.dbotthepony.kstarbound.client.network.packets.InitialChunkDataPacket
|
import ru.dbotthepony.kstarbound.client.network.packets.InitialChunkDataPacket
|
||||||
import ru.dbotthepony.kstarbound.client.network.packets.SpawnWorldObjectPacket
|
import ru.dbotthepony.kstarbound.client.network.packets.SpawnWorldObjectPacket
|
||||||
@ -15,7 +16,6 @@ import ru.dbotthepony.kstarbound.network.packets.HelloPacket
|
|||||||
import ru.dbotthepony.kstarbound.server.StarboundServer
|
import ru.dbotthepony.kstarbound.server.StarboundServer
|
||||||
import ru.dbotthepony.kstarbound.server.world.ServerWorld
|
import ru.dbotthepony.kstarbound.server.world.ServerWorld
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ServerConnection(val server: StarboundServer, type: ConnectionType) : Connection(ConnectionSide.SERVER, type, UUID(0L, 0L)) {
|
class ServerConnection(val server: StarboundServer, type: ConnectionType) : Connection(ConnectionSide.SERVER, type, UUID(0L, 0L)) {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.kstarbound.server.network.packets
|
package ru.dbotthepony.kstarbound.server.network.packets
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.network.IServerPacket
|
import ru.dbotthepony.kstarbound.network.IServerPacket
|
||||||
import ru.dbotthepony.kstarbound.server.network.ServerConnection
|
import ru.dbotthepony.kstarbound.server.network.ServerConnection
|
||||||
import ru.dbotthepony.kstarbound.io.readVec2d
|
import ru.dbotthepony.kstarbound.io.readVec2d
|
||||||
import ru.dbotthepony.kstarbound.io.writeVec2d
|
import ru.dbotthepony.kstarbound.io.writeVec2d
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
import java.io.DataOutputStream
|
import java.io.DataOutputStream
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.dbotthepony.kstarbound.server.world
|
package ru.dbotthepony.kstarbound.server.world
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.arrays.Object2DArray
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
||||||
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
||||||
import ru.dbotthepony.kvector.arrays.Object2DArray
|
|
||||||
|
|
||||||
interface IChunkSaver {
|
interface IChunkSaver {
|
||||||
fun saveCells(pos: ChunkPos, data: Object2DArray<out AbstractCell>)
|
fun saveCells(pos: ChunkPos, data: Object2DArray<out AbstractCell>)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package ru.dbotthepony.kstarbound.server.world
|
package ru.dbotthepony.kstarbound.server.world
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
import ru.dbotthepony.kommons.arrays.Object2DArray
|
||||||
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
||||||
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
||||||
import ru.dbotthepony.kvector.arrays.Object2DArray
|
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
|
|
||||||
interface IChunkSource {
|
interface IChunkSource {
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package ru.dbotthepony.kstarbound.server.world
|
package ru.dbotthepony.kstarbound.server.world
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.kommons.arrays.Object2DArray
|
||||||
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
|
import ru.dbotthepony.kommons.io.readVarInt
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.io.BTreeDB
|
import ru.dbotthepony.kstarbound.io.BTreeDB
|
||||||
import ru.dbotthepony.kstarbound.io.readVarInt
|
|
||||||
import ru.dbotthepony.kstarbound.json.VersionedJson
|
import ru.dbotthepony.kstarbound.json.VersionedJson
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
|
||||||
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
||||||
import ru.dbotthepony.kstarbound.world.api.MutableCell
|
import ru.dbotthepony.kstarbound.world.api.MutableCell
|
||||||
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
||||||
import ru.dbotthepony.kvector.arrays.Object2DArray
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.dbotthepony.kstarbound.server.world
|
package ru.dbotthepony.kstarbound.server.world
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
||||||
|
import ru.dbotthepony.kommons.arrays.Object2DArray
|
||||||
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE
|
||||||
import ru.dbotthepony.kstarbound.world.Chunk
|
import ru.dbotthepony.kstarbound.world.Chunk
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
||||||
import ru.dbotthepony.kstarbound.world.api.ImmutableCell
|
import ru.dbotthepony.kstarbound.world.api.ImmutableCell
|
||||||
import ru.dbotthepony.kvector.arrays.Object2DArray
|
|
||||||
|
|
||||||
class ServerChunk(world: ServerWorld, pos: ChunkPos) : Chunk<ServerWorld, ServerChunk>(world, pos) {
|
class ServerChunk(world: ServerWorld, pos: ChunkPos) : Chunk<ServerWorld, ServerChunk>(world, pos) {
|
||||||
fun copyCells(): Object2DArray<ImmutableCell> {
|
fun copyCells(): Object2DArray<ImmutableCell> {
|
||||||
|
@ -4,10 +4,10 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectFunction
|
|||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet
|
import it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
||||||
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.server.StarboundServer
|
import ru.dbotthepony.kstarbound.server.StarboundServer
|
||||||
import ru.dbotthepony.kstarbound.server.network.ServerConnection
|
import ru.dbotthepony.kstarbound.server.network.ServerConnection
|
||||||
import ru.dbotthepony.kstarbound.util.KOptional
|
|
||||||
import ru.dbotthepony.kstarbound.util.composeFutures
|
import ru.dbotthepony.kstarbound.util.composeFutures
|
||||||
import ru.dbotthepony.kstarbound.world.ChunkPos
|
import ru.dbotthepony.kstarbound.world.ChunkPos
|
||||||
import ru.dbotthepony.kstarbound.world.World
|
import ru.dbotthepony.kstarbound.world.World
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.dbotthepony.kstarbound.tools
|
package ru.dbotthepony.kstarbound.tools
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
|
import ru.dbotthepony.kommons.io.readVarInt
|
||||||
import ru.dbotthepony.kstarbound.io.readHeader
|
import ru.dbotthepony.kstarbound.io.readHeader
|
||||||
import ru.dbotthepony.kstarbound.io.readString
|
import ru.dbotthepony.kstarbound.io.readString
|
||||||
import ru.dbotthepony.kstarbound.io.readVarInt
|
|
||||||
import ru.dbotthepony.kstarbound.json.readJsonElement
|
import ru.dbotthepony.kstarbound.json.readJsonElement
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.util
|
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.json.EitherTypeAdapter
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Представляет собой контейнер с "или тот или другой" значениями
|
|
||||||
*
|
|
||||||
* JSON адаптер реализуется через [EitherTypeAdapter]
|
|
||||||
*/
|
|
||||||
class Either<L, R> private constructor(val left: KOptional<L>, val right: KOptional<R>) {
|
|
||||||
val isLeft: Boolean get() = left.isPresent
|
|
||||||
val isRight: Boolean get() = right.isPresent
|
|
||||||
|
|
||||||
inline fun <T> map(left: (L) -> T, right: (R) -> T): T {
|
|
||||||
this.left.ifPresent {
|
|
||||||
return left.invoke(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
return right.invoke(this.right.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <NL, NR> flatMap(left: (L) -> NL, right: (R) -> NR): Either<NL, NR> {
|
|
||||||
this.left.ifPresent {
|
|
||||||
return left(left.invoke(it))
|
|
||||||
}
|
|
||||||
|
|
||||||
return right(right.invoke(this.right.value))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws NoSuchElementException
|
|
||||||
*/
|
|
||||||
fun left(): L = left.value
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws NoSuchElementException
|
|
||||||
*/
|
|
||||||
fun right(): R = right.value
|
|
||||||
|
|
||||||
inline fun leftOrElse(orElse: () -> L): L {
|
|
||||||
if (isLeft)
|
|
||||||
return left()
|
|
||||||
else
|
|
||||||
return orElse.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun rightOrElse(orElse: () -> R): R {
|
|
||||||
if (isRight)
|
|
||||||
return right()
|
|
||||||
else
|
|
||||||
return orElse.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
return other === this || other is Either<*, *> && other.left == left && other.right == right
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return left.hashCode() * 31 + right.hashCode()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
if (isLeft) {
|
|
||||||
return "Either.left[${left.value}]"
|
|
||||||
} else {
|
|
||||||
return "Either.right[${right.value}]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmStatic
|
|
||||||
fun <L, R> left(value: L): Either<L, R> {
|
|
||||||
return Either(KOptional.of(value), KOptional.empty())
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun <L, R> right(value: R): Either<L, R> {
|
|
||||||
return Either(KOptional.empty(), KOptional.of(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.util
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray
|
|
||||||
import com.google.gson.JsonElement
|
|
||||||
import java.util.function.BiConsumer
|
|
||||||
import java.util.function.BinaryOperator
|
|
||||||
import java.util.function.Function
|
|
||||||
import java.util.function.Supplier
|
|
||||||
import java.util.stream.Collector
|
|
||||||
|
|
||||||
object JsonArrayCollector : Collector<JsonElement, JsonArray, JsonArray> {
|
|
||||||
override fun supplier(): Supplier<JsonArray> {
|
|
||||||
return Supplier { JsonArray() }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun accumulator(): BiConsumer<JsonArray, JsonElement> {
|
|
||||||
return BiConsumer { t, u -> t.add(u) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun combiner(): BinaryOperator<JsonArray> {
|
|
||||||
return BinaryOperator { t, u -> t.addAll(u); t }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun finisher(): Function<JsonArray, JsonArray> {
|
|
||||||
return Function.identity()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun characteristics(): Set<Collector.Characteristics> {
|
|
||||||
return setOf(Collector.Characteristics.IDENTITY_FINISH)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,152 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.util
|
|
||||||
|
|
||||||
import java.util.function.Supplier
|
|
||||||
|
|
||||||
fun <T> KOptional(value: T) = KOptional.of(value)
|
|
||||||
fun KOptional(value: Boolean) = KOptional.of(value)
|
|
||||||
fun KOptional(value: Boolean?) = KOptional.of(value)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [java.util.Optional] supporting nulls
|
|
||||||
*
|
|
||||||
* This is done for structures, where value can be absent,
|
|
||||||
* or can be present, including literal "null" as possible present value,
|
|
||||||
* in more elegant solution than handling nullable Optionals
|
|
||||||
*/
|
|
||||||
class KOptional<T> private constructor(private val _value: T, val isPresent: Boolean) : Supplier<T> {
|
|
||||||
/**
|
|
||||||
* @throws NoSuchElementException
|
|
||||||
*/
|
|
||||||
val value: T get() {
|
|
||||||
if (isPresent) {
|
|
||||||
return _value
|
|
||||||
}
|
|
||||||
|
|
||||||
throw NoSuchElementException("No value is present")
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun ifPresent(block: (T) -> Unit): KOptional<T> {
|
|
||||||
if (isPresent) {
|
|
||||||
block.invoke(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun ifNotPresent(block: () -> Unit): KOptional<T> {
|
|
||||||
if (!isPresent) {
|
|
||||||
block.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <R> map(block: (T) -> R): KOptional<R> {
|
|
||||||
if (isPresent) {
|
|
||||||
return of(block.invoke(value))
|
|
||||||
} else {
|
|
||||||
return empty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun orElse(value: T): T {
|
|
||||||
if (isPresent) {
|
|
||||||
return this.value
|
|
||||||
} else {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun orElse(value: () -> T): T {
|
|
||||||
if (isPresent) {
|
|
||||||
return this.value
|
|
||||||
} else {
|
|
||||||
return value.invoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
infix fun or(value: KOptional<T>): KOptional<T> {
|
|
||||||
if (isPresent) {
|
|
||||||
return this
|
|
||||||
} else {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
return this === other || other is KOptional<*> && isPresent == other.isPresent && _value == other._value
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return _value.hashCode() + 43839429
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
if (isPresent) {
|
|
||||||
return "KOptional[value = $value]"
|
|
||||||
} else {
|
|
||||||
return "KOptional[empty]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun get(): T {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
// gson hack since type token can't diff between nullable and non-null types
|
|
||||||
@Deprecated("internal class")
|
|
||||||
internal class Nullable<T : Any?> private constructor()
|
|
||||||
@Deprecated("internal class")
|
|
||||||
internal class NotNull<T : Any> private constructor()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val EMPTY = KOptional(null, false)
|
|
||||||
private val NULL = KOptional(null, true)
|
|
||||||
private val TRUE = KOptional(true, true)
|
|
||||||
private val FALSE = KOptional(false, true)
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun <T> empty(): KOptional<T> {
|
|
||||||
return EMPTY as KOptional<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun <T> of(value: T): KOptional<T> {
|
|
||||||
if (value == null) {
|
|
||||||
return NULL as KOptional<T>
|
|
||||||
} else {
|
|
||||||
return KOptional(value, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun <T> ofNullable(value: T): KOptional<T> {
|
|
||||||
if (value == null) {
|
|
||||||
return EMPTY as KOptional<T>
|
|
||||||
} else {
|
|
||||||
return KOptional(value, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun of(value: Boolean): KOptional<Boolean> {
|
|
||||||
if (value) {
|
|
||||||
return TRUE
|
|
||||||
} else {
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun of(value: Boolean?): KOptional<Boolean> {
|
|
||||||
if (value == null) {
|
|
||||||
return NULL as KOptional<Boolean>
|
|
||||||
} else if (value) {
|
|
||||||
return TRUE
|
|
||||||
} else {
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,396 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.util
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.Futures
|
|
||||||
import java.util.LinkedList
|
|
||||||
import java.util.concurrent.Callable
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue
|
|
||||||
import java.util.concurrent.Delayed
|
|
||||||
import java.util.concurrent.Future
|
|
||||||
import java.util.concurrent.FutureTask
|
|
||||||
import java.util.concurrent.RejectedExecutionException
|
|
||||||
import java.util.concurrent.ScheduledExecutorService
|
|
||||||
import java.util.concurrent.ScheduledFuture
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import java.util.concurrent.locks.LockSupport
|
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
|
||||||
import kotlin.concurrent.withLock
|
|
||||||
|
|
||||||
private fun <E : Comparable<E>> LinkedList<E>.enqueue(value: E) {
|
|
||||||
if (isEmpty()) {
|
|
||||||
add(value)
|
|
||||||
} else if (first >= value) {
|
|
||||||
addFirst(value)
|
|
||||||
} else if (last <= value) {
|
|
||||||
addLast(value)
|
|
||||||
} else {
|
|
||||||
val iterator = listIterator()
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
val i = iterator.next()
|
|
||||||
|
|
||||||
if (i >= value) {
|
|
||||||
iterator.previous()
|
|
||||||
iterator.add(value)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MailboxExecutorService(thread: Thread = Thread.currentThread()) : ScheduledExecutorService {
|
|
||||||
@Volatile
|
|
||||||
var thread: Thread = thread
|
|
||||||
private set
|
|
||||||
|
|
||||||
private val futureQueue = ConcurrentLinkedQueue<FutureTask<*>>()
|
|
||||||
|
|
||||||
private val timers = LinkedList<Timer<*>>()
|
|
||||||
private val repeatableTimers = LinkedList<RepeatableTimer>()
|
|
||||||
private val executionLock = ReentrantLock()
|
|
||||||
|
|
||||||
@Volatile
|
|
||||||
private var isShutdown = false
|
|
||||||
@Volatile
|
|
||||||
private var isTerminated = false
|
|
||||||
|
|
||||||
private val timeOrigin = JVMTimeSource()
|
|
||||||
|
|
||||||
private inner class Timer<T>(task: Callable<T>, val executeAt: Long) : FutureTask<T>(task), ScheduledFuture<T> {
|
|
||||||
override fun compareTo(other: Delayed): Int {
|
|
||||||
return getDelay(TimeUnit.NANOSECONDS).compareTo(other.getDelay(TimeUnit.NANOSECONDS))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDelay(unit: TimeUnit): Long {
|
|
||||||
return unit.convert(executeAt, TimeUnit.NANOSECONDS) - timeOrigin.nanos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class RepeatableTimer(
|
|
||||||
task: Runnable,
|
|
||||||
initialDelay: Long,
|
|
||||||
val period: Long,
|
|
||||||
val fixedDelay: Boolean,
|
|
||||||
): FutureTask<Unit>({ task.run() }), ScheduledFuture<Unit> {
|
|
||||||
var next = initialDelay
|
|
||||||
private set
|
|
||||||
|
|
||||||
public override fun runAndReset(): Boolean {
|
|
||||||
if (fixedDelay) {
|
|
||||||
next += period
|
|
||||||
return super.runAndReset()
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return super.runAndReset()
|
|
||||||
} finally {
|
|
||||||
next += period
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun compareTo(other: Delayed): Int {
|
|
||||||
return getDelay(TimeUnit.NANOSECONDS).compareTo(other.getDelay(TimeUnit.NANOSECONDS))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDelay(unit: TimeUnit): Long {
|
|
||||||
return unit.convert(next, TimeUnit.NANOSECONDS) - timeOrigin.nanos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isSameThread(): Boolean {
|
|
||||||
return Thread.currentThread() === thread
|
|
||||||
}
|
|
||||||
|
|
||||||
fun executeQueuedTasks() {
|
|
||||||
thread = Thread.currentThread()
|
|
||||||
|
|
||||||
if (isShutdown) {
|
|
||||||
if (!isTerminated) {
|
|
||||||
isTerminated = true
|
|
||||||
|
|
||||||
executionLock.withLock {
|
|
||||||
timers.clear()
|
|
||||||
repeatableTimers.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
executionLock.withLock {
|
|
||||||
var next = futureQueue.poll()
|
|
||||||
|
|
||||||
while (next != null) {
|
|
||||||
if (isTerminated) return
|
|
||||||
next.run()
|
|
||||||
Thread.interrupted()
|
|
||||||
next = futureQueue.poll()
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!timers.isEmpty()) {
|
|
||||||
if (isTerminated) return
|
|
||||||
val first = timers.first
|
|
||||||
|
|
||||||
if (first.isCancelled) {
|
|
||||||
timers.removeFirst()
|
|
||||||
} else if (first.executeAt <= timeOrigin.nanos) {
|
|
||||||
first.run()
|
|
||||||
Thread.interrupted()
|
|
||||||
timers.removeFirst()
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (repeatableTimers.isNotEmpty()) {
|
|
||||||
val executed = LinkedList<RepeatableTimer>()
|
|
||||||
|
|
||||||
while (repeatableTimers.isNotEmpty()) {
|
|
||||||
if (isTerminated) return
|
|
||||||
val first = repeatableTimers.first
|
|
||||||
|
|
||||||
if (first.isDone) {
|
|
||||||
repeatableTimers.removeFirst()
|
|
||||||
} else if (first.next <= timeOrigin.nanos) {
|
|
||||||
first.runAndReset()
|
|
||||||
executed.add(first)
|
|
||||||
repeatableTimers.removeFirst()
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
executed.forEach { repeatableTimers.enqueue(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun execute(command: Runnable) {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
if (isSameThread()) {
|
|
||||||
command.run()
|
|
||||||
} else {
|
|
||||||
futureQueue.add(FutureTask(command, Unit))
|
|
||||||
LockSupport.unpark(thread)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun shutdown() {
|
|
||||||
isShutdown = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun shutdownNow(): MutableList<Runnable> {
|
|
||||||
isShutdown = true
|
|
||||||
isTerminated = true
|
|
||||||
|
|
||||||
val result = ArrayList<Runnable>()
|
|
||||||
|
|
||||||
executionLock.withLock {
|
|
||||||
futureQueue.forEach {
|
|
||||||
it.cancel(false)
|
|
||||||
result.add(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
futureQueue.clear()
|
|
||||||
|
|
||||||
timers.forEach { it.cancel(false) }
|
|
||||||
repeatableTimers.forEach { it.cancel(false) }
|
|
||||||
|
|
||||||
timers.clear()
|
|
||||||
repeatableTimers.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isShutdown(): Boolean {
|
|
||||||
return isShutdown
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isTerminated(): Boolean {
|
|
||||||
return isTerminated
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean {
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : Any?> submit(task: Callable<T>): Future<T> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
if (isSameThread()) return Futures.immediateFuture(task.call())
|
|
||||||
return FutureTask(task).also { futureQueue.add(it); LockSupport.unpark(thread) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : Any?> submit(task: Runnable, result: T): Future<T> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
if (isSameThread()) { task.run(); return Futures.immediateFuture(result) }
|
|
||||||
return FutureTask { task.run(); result }.also { futureQueue.add(it); LockSupport.unpark(thread) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun submit(task: Runnable): Future<*> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
if (isSameThread()) { task.run(); return Futures.immediateVoidFuture() }
|
|
||||||
return FutureTask { task.run() }.also { futureQueue.add(it); LockSupport.unpark(thread) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : Any?> invokeAll(tasks: Collection<Callable<T>>): List<Future<T>> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
if (isSameThread()) {
|
|
||||||
return tasks.map { Futures.immediateFuture(it.call()) }
|
|
||||||
} else {
|
|
||||||
return tasks.map { submit(it) }.onEach { it.get() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : Any?> invokeAll(
|
|
||||||
tasks: Collection<Callable<T>>,
|
|
||||||
timeout: Long,
|
|
||||||
unit: TimeUnit
|
|
||||||
): List<Future<T>> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
if (isSameThread()) {
|
|
||||||
return tasks.map { Futures.immediateFuture(it.call()) }
|
|
||||||
} else {
|
|
||||||
return tasks.map { submit(it) }.onEach { it.get(timeout, unit) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : Any?> invokeAny(tasks: Collection<Callable<T>>): T {
|
|
||||||
if (tasks.isEmpty())
|
|
||||||
throw NoSuchElementException("Provided task list is empty")
|
|
||||||
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
if (isSameThread()) {
|
|
||||||
return tasks.first().call()
|
|
||||||
} else {
|
|
||||||
return submit(tasks.first()).get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T : Any?> invokeAny(tasks: Collection<Callable<T>>, timeout: Long, unit: TimeUnit): T {
|
|
||||||
if (tasks.isEmpty())
|
|
||||||
throw NoSuchElementException("Provided task list is empty")
|
|
||||||
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
if (isSameThread()) {
|
|
||||||
return tasks.first().call()
|
|
||||||
} else {
|
|
||||||
return submit(tasks.first()).get(timeout, unit)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <V> join(future: Future<V>): V {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
if (!isSameThread())
|
|
||||||
return future.get()
|
|
||||||
|
|
||||||
while (!future.isDone) {
|
|
||||||
executeQueuedTasks()
|
|
||||||
LockSupport.parkNanos(1_000_000L)
|
|
||||||
}
|
|
||||||
|
|
||||||
return future.get()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun schedule(command: Runnable, delay: Long, unit: TimeUnit): ScheduledFuture<*> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
val timer = Timer({ command.run() }, timeOrigin.nanos + TimeUnit.NANOSECONDS.convert(delay, unit))
|
|
||||||
|
|
||||||
if (isSameThread() && delay <= 0L) {
|
|
||||||
timer.run()
|
|
||||||
Thread.interrupted()
|
|
||||||
} else if (isSameThread()) {
|
|
||||||
timers.enqueue(timer)
|
|
||||||
} else {
|
|
||||||
execute {
|
|
||||||
if (timer.isCancelled) {
|
|
||||||
// do nothing
|
|
||||||
} else if (timer.executeAt <= timeOrigin.nanos) {
|
|
||||||
timer.run()
|
|
||||||
Thread.interrupted()
|
|
||||||
} else {
|
|
||||||
timers.enqueue(timer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return timer
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <V : Any?> schedule(callable: Callable<V>, delay: Long, unit: TimeUnit): ScheduledFuture<V> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
val timer = Timer(callable, timeOrigin.nanos + TimeUnit.NANOSECONDS.convert(delay, unit))
|
|
||||||
|
|
||||||
if (isSameThread() && delay <= 0L) {
|
|
||||||
timer.run()
|
|
||||||
Thread.interrupted()
|
|
||||||
} else if (isSameThread()) {
|
|
||||||
timers.enqueue(timer)
|
|
||||||
} else {
|
|
||||||
execute {
|
|
||||||
if (timer.isCancelled) {
|
|
||||||
// do nothing
|
|
||||||
} else if (timer.executeAt <= timeOrigin.nanos) {
|
|
||||||
timer.run()
|
|
||||||
Thread.interrupted()
|
|
||||||
} else {
|
|
||||||
timers.enqueue(timer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return timer
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun scheduleAtFixedRate(
|
|
||||||
command: Runnable,
|
|
||||||
initialDelay: Long,
|
|
||||||
period: Long,
|
|
||||||
unit: TimeUnit
|
|
||||||
): ScheduledFuture<*> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
return RepeatableTimer(
|
|
||||||
command,
|
|
||||||
timeOrigin.nanos + TimeUnit.NANOSECONDS.convert(initialDelay, unit),
|
|
||||||
TimeUnit.NANOSECONDS.convert(period, unit), true)
|
|
||||||
.also {
|
|
||||||
execute {
|
|
||||||
if (it.isCancelled) {
|
|
||||||
// do nothing
|
|
||||||
} else {
|
|
||||||
repeatableTimers.enqueue(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun scheduleWithFixedDelay(
|
|
||||||
command: Runnable,
|
|
||||||
initialDelay: Long,
|
|
||||||
delay: Long,
|
|
||||||
unit: TimeUnit
|
|
||||||
): ScheduledFuture<*> {
|
|
||||||
if (isShutdown) throw RejectedExecutionException("This mailbox is shutting down")
|
|
||||||
|
|
||||||
return RepeatableTimer(
|
|
||||||
command,
|
|
||||||
timeOrigin.nanos + TimeUnit.NANOSECONDS.convert(initialDelay, unit),
|
|
||||||
TimeUnit.NANOSECONDS.convert(delay, unit), false)
|
|
||||||
.also {
|
|
||||||
execute {
|
|
||||||
if (it.isCancelled) {
|
|
||||||
// do nothing
|
|
||||||
} else {
|
|
||||||
repeatableTimers.enqueue(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.util
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [Either] but with 3 values
|
|
||||||
*/
|
|
||||||
class OneOf<A, B, C> private constructor(
|
|
||||||
val v0: KOptional<A>,
|
|
||||||
val v1: KOptional<B>,
|
|
||||||
val v2: KOptional<C>,
|
|
||||||
) {
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
return other === this || other is OneOf<*, *, *> && v0 == other.v0 && v1 == other.v1 && v2 == other.v2
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return v0.hashCode() + v1.hashCode() * 31 + v2.hashCode() * 31 * 31
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
return "OneOf[$v0, $v1, $v2]"
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun <A, B, C> first(value: A): OneOf<A, B, C> {
|
|
||||||
return OneOf(KOptional.of(value), KOptional.empty(), KOptional.empty())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <A, B, C> second(value: B): OneOf<A, B, C> {
|
|
||||||
return OneOf(KOptional.empty(), KOptional.of(value), KOptional.empty())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <A, B, C> third(value: C): OneOf<A, B, C> {
|
|
||||||
return OneOf(KOptional.empty(), KOptional.empty(), KOptional.of(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.util
|
|
||||||
|
|
||||||
interface ITimeSource {
|
|
||||||
/**
|
|
||||||
* Время в наносекундах
|
|
||||||
*/
|
|
||||||
val nanos: Long
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Время в микросекундах
|
|
||||||
*/
|
|
||||||
val micros: Long get() = nanos / 1_000L
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Время в миллисекундах
|
|
||||||
*/
|
|
||||||
val millis: Long get() = nanos / 1_000_000L
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Время в секундах, с точностью до микросекунд
|
|
||||||
*/
|
|
||||||
val seconds: Double get() = (nanos / 1_000L) / 1_000_000.0
|
|
||||||
}
|
|
||||||
|
|
||||||
class JVMTimeSource : ITimeSource {
|
|
||||||
private val origin = System.nanoTime()
|
|
||||||
|
|
||||||
override val nanos: Long
|
|
||||||
get() = System.nanoTime() - origin
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmField
|
|
||||||
val INSTANCE = JVMTimeSource()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ArtificialTimeSource(nanos: Long = 0L) : ITimeSource {
|
|
||||||
override var nanos: Long = nanos
|
|
||||||
private set
|
|
||||||
|
|
||||||
fun advance(nanos: Long) {
|
|
||||||
this.nanos += nanos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PausableTimeSource(private val parent: ITimeSource) : ITimeSource {
|
|
||||||
override val nanos: Long get() {
|
|
||||||
if (isPaused) {
|
|
||||||
return pausedSince - skipped
|
|
||||||
} else {
|
|
||||||
return parent.nanos - skipped
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var isPaused = false
|
|
||||||
private var pausedSince = 0L
|
|
||||||
private var skipped = 0L
|
|
||||||
|
|
||||||
fun pause() {
|
|
||||||
if (!isPaused) {
|
|
||||||
isPaused = true
|
|
||||||
pausedSince = parent.nanos
|
|
||||||
} else {
|
|
||||||
isPaused = false
|
|
||||||
skipped += parent.nanos - pausedSince
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableSet
|
|||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonElement
|
import com.google.gson.JsonElement
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
|
import ru.dbotthepony.kommons.core.KOptional
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import java.lang.ref.Reference
|
import java.lang.ref.Reference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -3,6 +3,9 @@ package ru.dbotthepony.kstarbound.world
|
|||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet
|
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet
|
||||||
|
import ru.dbotthepony.kommons.arrays.Object2DArray
|
||||||
|
import ru.dbotthepony.kommons.util.AABB
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
||||||
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
||||||
import ru.dbotthepony.kstarbound.world.api.ImmutableCell
|
import ru.dbotthepony.kstarbound.world.api.ImmutableCell
|
||||||
@ -10,9 +13,6 @@ import ru.dbotthepony.kstarbound.world.api.OffsetCellAccess
|
|||||||
import ru.dbotthepony.kstarbound.world.api.TileView
|
import ru.dbotthepony.kstarbound.world.api.TileView
|
||||||
import ru.dbotthepony.kstarbound.world.entities.Entity
|
import ru.dbotthepony.kstarbound.world.entities.Entity
|
||||||
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
import ru.dbotthepony.kstarbound.world.entities.WorldObject
|
||||||
import ru.dbotthepony.kvector.arrays.Object2DArray
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import kotlin.concurrent.withLock
|
import kotlin.concurrent.withLock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.world
|
package ru.dbotthepony.kstarbound.world
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.math.roundByAbsoluteValue
|
import ru.dbotthepony.kommons.core.IStruct2i
|
||||||
import ru.dbotthepony.kstarbound.world.CHUNK_SIZE_BITS
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kvector.api.IStruct2d
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct2i
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
|
|
||||||
private fun circulate(value: Int, bounds: Int): Int {
|
private fun circulate(value: Int, bounds: Int): Int {
|
||||||
require(bounds > 0) { "Bounds must be positive ($bounds given)" }
|
require(bounds > 0) { "Bounds must be positive ($bounds given)" }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ru.dbotthepony.kstarbound.world
|
package ru.dbotthepony.kstarbound.world
|
||||||
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
|
||||||
enum class Direction(val normal: Vector2d) {
|
enum class Direction(val normal: Vector2d) {
|
||||||
UP(Vector2d.POSITIVE_Y),
|
UP(Vector2d.POSITIVE_Y),
|
||||||
|
@ -2,11 +2,11 @@ package ru.dbotthepony.kstarbound.world
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntArraySet
|
import it.unimi.dsi.fastutil.ints.IntArraySet
|
||||||
import org.lwjgl.BufferUtils
|
import org.lwjgl.BufferUtils
|
||||||
|
import ru.dbotthepony.kommons.arrays.Object2DArray
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct4f
|
||||||
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.kommons.math.linearInterpolation
|
||||||
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
||||||
import ru.dbotthepony.kvector.api.IStruct4f
|
|
||||||
import ru.dbotthepony.kvector.arrays.Object2DArray
|
|
||||||
import ru.dbotthepony.kvector.util.linearInterpolation
|
|
||||||
import ru.dbotthepony.kvector.vector.RGBAColor
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.kstarbound.world
|
package ru.dbotthepony.kstarbound.world
|
||||||
|
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.math.roundTowardsNegativeInfinity
|
import ru.dbotthepony.kstarbound.math.roundTowardsNegativeInfinity
|
||||||
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
||||||
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
import ru.dbotthepony.kstarbound.world.api.AbstractCell
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2i
|
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
import kotlin.math.sqrt
|
import kotlin.math.sqrt
|
||||||
|
@ -5,8 +5,13 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList
|
|||||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet
|
import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet
|
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet
|
||||||
|
import ru.dbotthepony.kommons.arrays.Object2DArray
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2d
|
||||||
|
import ru.dbotthepony.kommons.core.IStruct2i
|
||||||
|
import ru.dbotthepony.kommons.util.AABB
|
||||||
|
import ru.dbotthepony.kommons.util.MailboxExecutorService
|
||||||
|
import ru.dbotthepony.kommons.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.math.*
|
import ru.dbotthepony.kstarbound.math.*
|
||||||
import ru.dbotthepony.kstarbound.util.MailboxExecutorService
|
|
||||||
import ru.dbotthepony.kstarbound.util.ParallelPerform
|
import ru.dbotthepony.kstarbound.util.ParallelPerform
|
||||||
import ru.dbotthepony.kstarbound.util.filterNotNull
|
import ru.dbotthepony.kstarbound.util.filterNotNull
|
||||||
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
import ru.dbotthepony.kstarbound.world.api.ICellAccess
|
||||||
@ -19,11 +24,6 @@ import ru.dbotthepony.kstarbound.world.physics.CollisionType
|
|||||||
import ru.dbotthepony.kstarbound.world.physics.Poly
|
import ru.dbotthepony.kstarbound.world.physics.Poly
|
||||||
import ru.dbotthepony.kstarbound.world.physics.getBlockPlatforms
|
import ru.dbotthepony.kstarbound.world.physics.getBlockPlatforms
|
||||||
import ru.dbotthepony.kstarbound.world.physics.getBlocksMarchingSquares
|
import ru.dbotthepony.kstarbound.world.physics.getBlocksMarchingSquares
|
||||||
import ru.dbotthepony.kvector.api.IStruct2d
|
|
||||||
import ru.dbotthepony.kvector.api.IStruct2i
|
|
||||||
import ru.dbotthepony.kvector.arrays.Object2DArray
|
|
||||||
import ru.dbotthepony.kvector.util2d.AABB
|
|
||||||
import ru.dbotthepony.kvector.vector.Vector2d
|
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
import java.util.concurrent.ForkJoinPool
|
import java.util.concurrent.ForkJoinPool
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user