diff --git a/build.gradle b/build.gradle index ffcaa3e..300e418 100644 --- a/build.gradle +++ b/build.gradle @@ -78,6 +78,11 @@ allprojects { options.release = 17 } + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } + } java { withSourcesJar() } diff --git a/common/AcceleratedRaycasting-0.0.1-dev.jar b/common/AcceleratedRaycasting-0.0.1-dev.jar new file mode 100644 index 0000000..e41ebd8 Binary files /dev/null and b/common/AcceleratedRaycasting-0.0.1-dev.jar differ diff --git a/common/src/main/kotlin/net/spaceeye/someperipherals/config/ConfigTypes.kt b/common/src/main/kotlin/net/spaceeye/someperipherals/config/ConfigTypes.kt index e7629b9..c2bbd8a 100644 --- a/common/src/main/kotlin/net/spaceeye/someperipherals/config/ConfigTypes.kt +++ b/common/src/main/kotlin/net/spaceeye/someperipherals/config/ConfigTypes.kt @@ -22,6 +22,6 @@ open class BaseConfigDelegate (var it:T, var range: Pair? = null, class CInt (it:Int, description: String="No comment", range: Pair? = Pair(Int.MIN_VALUE, Int.MAX_VALUE), do_show: Boolean=true): BaseConfigDelegate (it, range, description, do_show) class CLong (it:Long, description: String="No comment", range: Pair? = Pair(Long.MIN_VALUE, Long.MAX_VALUE), do_show: Boolean=true): BaseConfigDelegate (it, range, description, do_show) -class CDouble(it:Double, description: String="No comment", range: Pair? = Pair(Double.MIN_VALUE, Double.MAX_VALUE), do_show: Boolean=true): BaseConfigDelegate (it, range, description, do_show) +class CDouble(it:Double, description: String="No comment", range: Pair? = Pair(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), do_show: Boolean=true): BaseConfigDelegate (it, range, description, do_show) class CBool (it:Boolean, description: String="No comment", do_show: Boolean=true): BaseConfigDelegate(it, null, description, do_show) class CString(it:String, description: String="No comment", do_show: Boolean=true): BaseConfigDelegate (it, null, description, do_show) \ No newline at end of file diff --git a/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/radar/scanInRadius.kt b/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/radar/scanInRadius.kt index f987ad4..399c293 100644 --- a/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/radar/scanInRadius.kt +++ b/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/radar/scanInRadius.kt @@ -9,9 +9,10 @@ import net.spaceeye.someperipherals.SomePeripheralsConfig import net.spaceeye.someperipherals.integrations.cc.makeErrorReturn import net.spaceeye.someperipherals.stuff.utils.entityToMapRadar import net.spaceeye.someperipherals.stuff.utils.getEntitiesWithTimeout +import org.valkyrienskies.core.api.ships.ServerShip import org.valkyrienskies.mod.common.getShipManagingPos +import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.toWorldCoordinates -import org.valkyrienskies.mod.common.transformToNearbyShipsAndWorld import kotlin.math.max import kotlin.math.min @@ -26,6 +27,24 @@ private fun getScanPos(level: Level, pos: BlockPos): BlockPos { } } +private fun getShipsWithinRadius(level: ServerLevel, pos: BlockPos, radius: Double): List { + val scanX = pos.x.toDouble() + val scanY = pos.y.toDouble() + val scanZ = pos.z.toDouble() + val radiusSq = radius * radius + + return level.shipObjectWorld.allShips + .asSequence() + .filterIsInstance() + .filter { ship -> + val dx = ship.transform.positionInWorld.x() - scanX + val dy = ship.transform.positionInWorld.y() - scanY + val dz = ship.transform.positionInWorld.z() - scanZ + (dx * dx + dy * dy + dz * dz) <= radiusSq + } + .distinctBy { it.id } + .toList() +} private fun scanForEntities(r: Double, level: ServerLevel, pos: BlockPos): MutableList { val pos = getScanPos(level, pos) @@ -58,14 +77,20 @@ private fun scanForShips(radius: Double, level: ServerLevel, pos: BlockPos): Mut val pos = getScanPos(level, pos) val res = mutableListOf() + val seenShips = mutableSetOf() val cur_ship = level.getShipManagingPos(pos) - if (cur_ship != null) {res.add(shipToMap(cur_ship))} + if (cur_ship != null) { + res.add(shipToMap(cur_ship)) + seenShips.add(cur_ship.id) + } - for (ship_pos in level.transformToNearbyShipsAndWorld(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble(), radius)) { - val ship = level.getShipManagingPos(ship_pos) ?: continue - if (ship == cur_ship) {continue} - res.add(shipToMap(ship)) + val allShips = getShipsWithinRadius(level, pos, radius) + for (ship in allShips) { + if (!seenShips.contains(ship.id)) { + res.add(shipToMap(ship)) + seenShips.add(ship.id) + } } return res diff --git a/fabric/build/classes/java/main/net/spaceeye/someperipherals/fabric/integrations/cc/SomePeripheralsPeripheralProviderFabric.class b/fabric/build/classes/java/main/net/spaceeye/someperipherals/fabric/integrations/cc/SomePeripheralsPeripheralProviderFabric.class new file mode 100644 index 0000000..e27cf2a Binary files /dev/null and b/fabric/build/classes/java/main/net/spaceeye/someperipherals/fabric/integrations/cc/SomePeripheralsPeripheralProviderFabric.class differ diff --git a/fabric/build/classes/kotlin/main/META-INF/Some-Peripherals.kotlin_module b/fabric/build/classes/kotlin/main/META-INF/Some-Peripherals.kotlin_module new file mode 100644 index 0000000..3aa6361 Binary files /dev/null and b/fabric/build/classes/kotlin/main/META-INF/Some-Peripherals.kotlin_module differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/ExtendedItemStackHandler.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/ExtendedItemStackHandler.class new file mode 100644 index 0000000..abed92a Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/ExtendedItemStackHandler.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricBlockEntityInventory.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricBlockEntityInventory.class new file mode 100644 index 0000000..c2c96ce Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricBlockEntityInventory.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$1.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$1.class new file mode 100644 index 0000000..a7c036f Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$1.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$2.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$2.class new file mode 100644 index 0000000..fc89340 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$2.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$3.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$3.class new file mode 100644 index 0000000..5b6f5f4 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$3.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$4.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$4.class new file mode 100644 index 0000000..c7c9e75 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$4.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$5.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$5.class new file mode 100644 index 0000000..2b6fafe Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$5.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$6.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$6.class new file mode 100644 index 0000000..00afba6 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$6.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$7.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$7.class new file mode 100644 index 0000000..47aeae2 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$7.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$8.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$8.class new file mode 100644 index 0000000..9335ac3 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder$makeItem$8.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder.class new file mode 100644 index 0000000..d5d2048 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/FabricConfigBuilder.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/PlatformUtilsImpl.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/PlatformUtilsImpl.class new file mode 100644 index 0000000..f64125f Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/PlatformUtilsImpl.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/SomePeripheralsFabric.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/SomePeripheralsFabric.class new file mode 100644 index 0000000..c1fd714 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/SomePeripheralsFabric.class differ diff --git a/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/SomePeripheralsFabricClient.class b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/SomePeripheralsFabricClient.class new file mode 100644 index 0000000..d62b305 Binary files /dev/null and b/fabric/build/classes/kotlin/main/net/spaceeye/someperipherals/fabric/SomePeripheralsFabricClient.class differ diff --git a/fabric/build/devlibs/Some-Peripherals-0.0.12-dev.jar b/fabric/build/devlibs/Some-Peripherals-0.0.12-dev.jar new file mode 100644 index 0000000..02e662c Binary files /dev/null and b/fabric/build/devlibs/Some-Peripherals-0.0.12-dev.jar differ diff --git a/fabric/build/devlibs/Some-Peripherals-0.0.12-sources.jar b/fabric/build/devlibs/Some-Peripherals-0.0.12-sources.jar new file mode 100644 index 0000000..589ac6d Binary files /dev/null and b/fabric/build/devlibs/Some-Peripherals-0.0.12-sources.jar differ diff --git a/fabric/build/kotlin/compileKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin b/fabric/build/kotlin/compileKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin new file mode 100644 index 0000000..7c0eade Binary files /dev/null and b/fabric/build/kotlin/compileKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin differ diff --git a/fabric/build/libs/Some-Peripherals-0.0.12-dev-shadow.jar b/fabric/build/libs/Some-Peripherals-0.0.12-dev-shadow.jar new file mode 100644 index 0000000..dda85bf Binary files /dev/null and b/fabric/build/libs/Some-Peripherals-0.0.12-dev-shadow.jar differ diff --git a/fabric/build/libs/Some-Peripherals-0.0.12-sources.jar b/fabric/build/libs/Some-Peripherals-0.0.12-sources.jar new file mode 100644 index 0000000..1e3087c Binary files /dev/null and b/fabric/build/libs/Some-Peripherals-0.0.12-sources.jar differ diff --git a/fabric/build/libs/Some-Peripherals-0.0.12.jar b/fabric/build/libs/Some-Peripherals-0.0.12.jar new file mode 100644 index 0000000..d63dd1f Binary files /dev/null and b/fabric/build/libs/Some-Peripherals-0.0.12.jar differ diff --git a/fabric/build/resources/main/fabric.mod.json b/fabric/build/resources/main/fabric.mod.json new file mode 100644 index 0000000..ff559d7 --- /dev/null +++ b/fabric/build/resources/main/fabric.mod.json @@ -0,0 +1,48 @@ +{ + "schemaVersion": 1, + "id": "some_peripherals", + "version": "0.0.12", + + "name": "Some Peripherals", + "description": "", + "authors": ["SpaceEye"], + "contributors": ["Illuc", "Tetrode", ", sashafiesta"], + "contact": { + "homepage": "https://modrinth.com/mod/some-peripherals", + "sources": "https://github.com/SuperSpaceEye/Some-Peripherals" + }, + + "license": "MIT", + + "environment": "*", + "entrypoints": { + "main": [ + { + "adapter": "kotlin", + "value": "net.spaceeye.someperipherals.fabric.SomePeripheralsFabric" + } + ], + "client": [ + { + "adapter": "kotlin", + "value": "net.spaceeye.someperipherals.fabric.SomePeripheralsFabricClient" + } + ] + }, + "mixins": [ + "some_peripherals-common.mixins.json" + ], + "depends": { + "fabricloader": ">=0.14.22", + "minecraft": ">=1.18", + "fabric-language-kotlin": ">=1.10.10+kotlin.1.9.10", + "fabric-api": ">=0.76.0+1.18.2", + "architectury": ">=4.11.93", + "com_electronwill_night-config_core": "*", + "com_electronwill_night-config_toml": "*" + }, + "suggests": { + "computercraft": ">=1.100.8", + "valkyrienskies": ">=2.1.0-beta.14" + } +} diff --git a/fabric/build/resources/main/some_peripherals.mixins.json b/fabric/build/resources/main/some_peripherals.mixins.json new file mode 100644 index 0000000..b134fca --- /dev/null +++ b/fabric/build/resources/main/some_peripherals.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.spaceeye.someperipherals.fabric.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric/build/tmp/.cache/expanded/expanded.lock b/fabric/build/tmp/.cache/expanded/expanded.lock new file mode 100644 index 0000000..27ea984 Binary files /dev/null and b/fabric/build/tmp/.cache/expanded/expanded.lock differ diff --git a/fabric/build/tmp/compileJava/previous-compilation-data.bin b/fabric/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..cf1c219 Binary files /dev/null and b/fabric/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/fabric/build/tmp/jar/MANIFEST.MF b/fabric/build/tmp/jar/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/fabric/build/tmp/jar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/fabric/build/tmp/remapJar/MANIFEST.MF b/fabric/build/tmp/remapJar/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/fabric/build/tmp/remapJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/fabric/build/tmp/remapSourcesJar/MANIFEST.MF b/fabric/build/tmp/remapSourcesJar/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/fabric/build/tmp/remapSourcesJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/fabric/build/tmp/shadowJar/MANIFEST.MF b/fabric/build/tmp/shadowJar/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/fabric/build/tmp/shadowJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/fabric/build/tmp/sourcesJar/MANIFEST.MF b/fabric/build/tmp/sourcesJar/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/fabric/build/tmp/sourcesJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/gradle.properties b/gradle.properties index 8ded2a4..536c131 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,11 @@ +<<<<<<< HEAD org.gradle.jvmargs=-Xmx1G +======= +org.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 +org.gradle.workers.max=2 +org.gradle.parallel=false +kotlin.compiler.execution.strategy=in-process +>>>>>>> aa60f2d (fix(radar): detect unloaded VS ships and fix radius config double clamp on 1.18.2) minecraft_version=1.18.2 @@ -16,4 +23,8 @@ forge_version=1.18.2-40.2.10 vs2_version=2.1.0-beta.14+acba7d4175 vs_core_version=1.1.0+8a93383ce5 -accelerated_raycasting_path=/home/spaceeye/IdeaProjects/Some-Peripherals/AcceleratedRaycasting-0.0.1-dev.jar \ No newline at end of file +<<<<<<< HEAD +accelerated_raycasting_path=/home/spaceeye/IdeaProjects/Some-Peripherals/AcceleratedRaycasting-0.0.1-dev.jar +======= +accelerated_raycasting_path=./AcceleratedRaycasting-0.0.1-dev.jar +>>>>>>> aa60f2d (fix(radar): detect unloaded VS ships and fix radius config double clamp on 1.18.2)