diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Registries.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Registries.kt index 7574ceec..84373d3f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Registries.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Registries.kt @@ -34,7 +34,7 @@ import ru.dbotthepony.kstarbound.defs.animation.ParticleConfig import ru.dbotthepony.kstarbound.defs.projectile.ProjectileDefinition import ru.dbotthepony.kstarbound.defs.quest.QuestTemplate import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier +import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition import ru.dbotthepony.kstarbound.defs.tile.TileDefinition import ru.dbotthepony.kstarbound.defs.world.BushVariant import ru.dbotthepony.kstarbound.defs.world.GrassVariant @@ -59,7 +59,7 @@ object Registries { } val tiles = Registry("tiles").also(registriesInternal::add).also { adapters.add(it.adapter()) } - val tileModifiers = Registry("tile modifiers").also(registriesInternal::add).also { adapters.add(it.adapter()) } + val tileModifiers = Registry("tile modifiers").also(registriesInternal::add).also { adapters.add(it.adapter()) } val liquid = Registry("liquid").also(registriesInternal::add).also { adapters.add(it.adapter()) } val species = Registry("species").also(registriesInternal::add).also { adapters.add(it.adapter()) } val statusEffects = Registry("status effect").also(registriesInternal::add).also { adapters.add(it.adapter()) } @@ -144,7 +144,7 @@ object Registries { tasks.addAll(loadTerrainSelectors(fileTree["terrain"] ?: listOf())) tasks.addAll(loadRegistry(tiles, fileTree["material"] ?: listOf(), key(TileDefinition::materialName, TileDefinition::materialId))) - tasks.addAll(loadRegistry(tileModifiers, fileTree["matmod"] ?: listOf(), key(MaterialModifier::modName, MaterialModifier::modId))) + tasks.addAll(loadRegistry(tileModifiers, fileTree["matmod"] ?: listOf(), key(TileModifierDefinition::modName, TileModifierDefinition::modId))) tasks.addAll(loadRegistry(liquid, fileTree["liquid"] ?: listOf(), key(LiquidDefinition::name, LiquidDefinition::liquidId))) tasks.addAll(loadRegistry(worldObjects, fileTree["object"] ?: listOf(), key(ObjectDefinition::objectName))) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt index 290a41f7..97f184e8 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt @@ -14,14 +14,12 @@ import ru.dbotthepony.kstarbound.client.gl.* import ru.dbotthepony.kstarbound.client.gl.shader.UberShader import ru.dbotthepony.kstarbound.client.gl.vertex.* import ru.dbotthepony.kstarbound.defs.tile.* -import ru.dbotthepony.kstarbound.util.random.staticRandom32 import ru.dbotthepony.kstarbound.util.random.staticRandomFloat import ru.dbotthepony.kstarbound.world.api.ITileAccess import ru.dbotthepony.kstarbound.world.api.AbstractTileState import ru.dbotthepony.kstarbound.world.api.TileColor import java.time.Duration import java.util.concurrent.Callable -import kotlin.math.absoluteValue import kotlin.math.roundToInt /** @@ -103,7 +101,7 @@ private class TileEqualityTester(val definition: TileDefinition) : EqualityRuleT } } -private class ModifierEqualityTester(val definition: MaterialModifier) : EqualityRuleTester { +private class ModifierEqualityTester(val definition: TileModifierDefinition) : EqualityRuleTester { override fun test(thisTile: AbstractTileState?, otherTile: AbstractTileState?): Boolean { return otherTile?.modifier?.value == definition } @@ -121,7 +119,7 @@ class TileRenderer(val renderers: TileRenderers, val def: IRenderableTile) { val equalityTester: EqualityRuleTester = when (def) { is TileDefinition -> TileEqualityTester(def) - is MaterialModifier -> ModifierEqualityTester(def) + is TileModifierDefinition -> ModifierEqualityTester(def) else -> throw IllegalStateException() } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/TileModifierDefinition.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt rename to src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/TileModifierDefinition.kt index 1cce0791..535d0bd6 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/TileModifierDefinition.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.kstarbound.json.builder.JsonFactory import ru.dbotthepony.kstarbound.json.builder.JsonFlat @JsonFactory -data class MaterialModifier( +data class TileModifierDefinition( val modId: Int, val modName: String, val itemDrop: String? = null, diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomeDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomeDefinition.kt index 04668c49..85bf90c2 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomeDefinition.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomeDefinition.kt @@ -9,7 +9,6 @@ import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.collect.WeightedList import ru.dbotthepony.kstarbound.defs.AssetReference import ru.dbotthepony.kstarbound.defs.JsonConfigFunction -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier import ru.dbotthepony.kstarbound.defs.tile.TileDefinition import ru.dbotthepony.kstarbound.json.NativeLegacy import ru.dbotthepony.kstarbound.json.builder.JsonFactory diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceables.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceables.kt index 5faa2179..a7803904 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceables.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceables.kt @@ -5,7 +5,6 @@ import com.google.common.collect.ImmutableSet import com.google.gson.Gson import com.google.gson.JsonArray import com.google.gson.JsonElement -import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException import com.google.gson.TypeAdapter @@ -21,7 +20,7 @@ import ru.dbotthepony.kstarbound.Registry import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.collect.WeightedList import ru.dbotthepony.kstarbound.defs.PerlinNoiseParameters -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier +import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition import ru.dbotthepony.kstarbound.json.NativeLegacy import ru.dbotthepony.kstarbound.json.builder.JsonFactory import ru.dbotthepony.kstarbound.json.builder.JsonFlat @@ -31,8 +30,8 @@ import java.util.stream.Stream @JsonFactory data class BiomePlaceables( - val grassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref?), - val ceilingGrassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref?), + val grassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref?), + val ceilingGrassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref?), val grassModDensity: Double = 0.0, val ceilingGrassModDensity: Double = 0.0, val itemDistributions: ImmutableList = ImmutableList.of(), diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceablesDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceablesDefinition.kt index 18859c76..63df6551 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceablesDefinition.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/BiomePlaceablesDefinition.kt @@ -10,12 +10,11 @@ import ru.dbotthepony.kstarbound.Registry import ru.dbotthepony.kstarbound.collect.WeightedList import ru.dbotthepony.kstarbound.defs.AssetReference import ru.dbotthepony.kstarbound.defs.PerlinNoiseParameters -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier +import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition import ru.dbotthepony.kstarbound.json.NativeLegacy import ru.dbotthepony.kstarbound.json.builder.IStringSerializable import ru.dbotthepony.kstarbound.json.builder.JsonFactory import ru.dbotthepony.kstarbound.json.builder.JsonFlat -import ru.dbotthepony.kstarbound.json.builder.JsonSingleton import ru.dbotthepony.kstarbound.util.random.AbstractPerlinNoise import ru.dbotthepony.kstarbound.util.random.nextRange import ru.dbotthepony.kstarbound.util.random.random @@ -23,9 +22,9 @@ import java.util.stream.IntStream @JsonFactory data class BiomePlaceablesDefinition( - val grassMod: ImmutableList> = ImmutableList.of(), + val grassMod: ImmutableList> = ImmutableList.of(), val grassModDensity: Double = 0.0, - val ceilingGrassMod: ImmutableList> = ImmutableList.of(), + val ceilingGrassMod: ImmutableList> = ImmutableList.of(), val ceilingGrassModDensity: Double = 0.0, val items: ImmutableList = ImmutableList.of(), ) { diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/json/NativeLegacy.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/json/NativeLegacy.kt index 5455a0e7..e57eea7f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/json/NativeLegacy.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/json/NativeLegacy.kt @@ -12,8 +12,7 @@ import ru.dbotthepony.kommons.util.KOptional import ru.dbotthepony.kstarbound.Registries import ru.dbotthepony.kstarbound.Registry import ru.dbotthepony.kstarbound.Starbound -import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier +import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition import ru.dbotthepony.kstarbound.defs.tile.TileDefinition import java.lang.reflect.Constructor import java.lang.reflect.ParameterizedType @@ -74,26 +73,26 @@ abstract class NativeLegacy { } } - class TileMod() : NativeLegacy, Int?>() { - constructor(tile: Registry.Entry?) : this() { + class TileMod() : NativeLegacy, Int?>() { + constructor(tile: Registry.Entry?) : this() { if (tile == null) legacyValue = KOptional(65535) else nativeValue = KOptional(tile.ref) } - constructor(tile: Registry.Ref?) : this() { + constructor(tile: Registry.Ref?) : this() { if (tile == null) legacyValue = KOptional(65535) else nativeValue = KOptional(tile) } - override fun computeLegacy(value: Registry.Ref): Int { + override fun computeLegacy(value: Registry.Ref): Int { return value.value?.modId ?: 65535 } - override fun computeNative(value: Int?): Registry.Ref { + override fun computeNative(value: Int?): Registry.Ref { value ?: return Registries.tileModifiers.emptyRef return Registries.tileModifiers.ref(value) } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/EmptyNoise.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/EmptyNoise.kt index 5d29cad3..26d6db41 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/EmptyNoise.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/EmptyNoise.kt @@ -8,14 +8,14 @@ class EmptyNoise(parameters: PerlinNoiseParameters) : AbstractPerlinNoise(parame } override fun get(x: Double): Double { - return 0.0 + throw IllegalStateException("Tried to sample uninitialized noise") } override fun get(x: Double, y: Double): Double { - return 0.0 + throw IllegalStateException("Tried to sample uninitialized noise") } override fun get(x: Double, y: Double, z: Double): Double { - return 0.0 + throw IllegalStateException("Tried to sample uninitialized noise") } } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/AbstractTileState.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/AbstractTileState.kt index aa975d31..5cd21818 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/AbstractTileState.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/AbstractTileState.kt @@ -4,16 +4,15 @@ import com.github.benmanes.caffeine.cache.Interner import ru.dbotthepony.kstarbound.Registry import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier +import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition import ru.dbotthepony.kstarbound.defs.tile.TileDefinition import ru.dbotthepony.kstarbound.network.LegacyNetworkTileState -import ru.dbotthepony.kstarbound.util.HashTableInterner import java.io.DataInputStream import java.io.DataOutputStream sealed class AbstractTileState { abstract val material: Registry.Entry - abstract val modifier: Registry.Entry? + abstract val modifier: Registry.Entry? abstract val color: TileColor abstract val hueShift: Float abstract val modifierHueShift: Float diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/ImmutableTileState.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/ImmutableTileState.kt index 99ede4f0..61b2877d 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/ImmutableTileState.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/ImmutableTileState.kt @@ -2,13 +2,13 @@ package ru.dbotthepony.kstarbound.world.api import ru.dbotthepony.kstarbound.Registry import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier +import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition import ru.dbotthepony.kstarbound.defs.tile.TileDefinition import ru.dbotthepony.kstarbound.network.LegacyNetworkTileState data class ImmutableTileState( override var material: Registry.Entry = BuiltinMetaMaterials.NULL, - override var modifier: Registry.Entry? = null, + override var modifier: Registry.Entry? = null, override var color: TileColor = TileColor.DEFAULT, override var hueShift: Float = 0f, override var modifierHueShift: Float = 0f, diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/MutableTileState.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/MutableTileState.kt index 67a6b8f3..01aaafcf 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/MutableTileState.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/api/MutableTileState.kt @@ -3,13 +3,13 @@ package ru.dbotthepony.kstarbound.world.api import ru.dbotthepony.kstarbound.Registries import ru.dbotthepony.kstarbound.Registry import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials -import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier +import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition import ru.dbotthepony.kstarbound.defs.tile.TileDefinition import java.io.DataInputStream data class MutableTileState( override var material: Registry.Entry = BuiltinMetaMaterials.NULL, - override var modifier: Registry.Entry? = null, + override var modifier: Registry.Entry? = null, override var color: TileColor = TileColor.DEFAULT, override var hueShift: Float = 0f, override var modifierHueShift: Float = 0f,