diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml
index ca60bfdc4..331f3177b 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yaml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yaml
@@ -10,9 +10,9 @@ body:
description: |
What version of Minecraft are you using? If your version is not listed, please try to reproduce on one of the supported versions.
options:
- - 1.20.1
- - 1.21.1
- - 1.21.7
+ - "1.20.1"
+ - "1.21.1"
+ - "26.1"
validations:
required: true
- type: input
diff --git a/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts b/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts
index 576b8a877..36282429a 100644
--- a/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts
+++ b/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts
@@ -55,7 +55,6 @@ repositories {
includeGroup("me.shedaniel.cloth")
includeGroup("me.shedaniel")
includeGroup("mezz.jei")
- includeGroup("org.teavm")
includeModule("com.terraformersmc", "modmenu")
}
}
diff --git a/doc/reference/feature_compat.md b/doc/reference/feature_compat.md
index 1fc50c355..405d25cee 100644
--- a/doc/reference/feature_compat.md
+++ b/doc/reference/feature_compat.md
@@ -91,6 +91,12 @@ compatibility for these newer versions.
| Remove `*` from `file:read` modes | ✔ | |
| Metamethods respected in `table.*`, `ipairs` | ✔ | |
+## Lua 5.5
+| Feature | Supported? | Notes |
+|------------------------------------|------------|-------|
+| `table.create` | ✔ | |
+| `utf8.offset` returns end position | ✔ | |
+
## Lua 5.0
| Feature | Supported? | Notes |
|----------------------------------|------------|--------------------------------------------------|
diff --git a/gradle.properties b/gradle.properties
index 0512ef0e1..31fa1f3a3 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -12,7 +12,7 @@ neogradle.subsystems.conventions.runs.enabled=false
# Mod properties
isUnstable=true
-modVersion=1.118.1
+modVersion=1.119.0
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
mcVersion=26.1.2
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index d9e886b70..d7c87f326 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -22,14 +22,14 @@ slf4j = "2.0.17"
# Core dependencies (independent of Minecraft)
asm = "9.9.1"
autoService = "1.1.1"
-checkerFramework = "3.51.1"
-cobalt = { strictly = "0.9.7" }
-commonsCli = "1.10.0"
-jetbrainsAnnotations = "26.0.2-1"
+checkerFramework = "4.0.0"
+cobalt = { strictly = "0.9.9" }
+commonsCli = "1.11.0"
+jetbrainsAnnotations = "26.1.0"
jspecify = "1.0.0"
-kotlin = "2.3.20"
+kotlin = "2.3.21"
kotlin-coroutines = "1.10.2"
-nightConfig = "3.8.3"
+nightConfig = "3.8.4"
# Minecraft mods
fabricPermissions = "0.3.3"
@@ -47,29 +47,29 @@ create-fabric = "6.0.7.0+mc1.20.1-build.1716"
# Testing
hamcrest = "3.0"
jqwik = "1.9.3"
-junit = "6.0.1"
-junitPlatform = "6.0.1"
+junit = "6.0.3"
+junitPlatform = "6.0.3"
jmh = "1.37"
# Build tools
cctJavadoc = "1.9.0"
-checkstyle = "12.1.1"
-errorProne-core = "2.45.0"
+checkstyle = "13.4.1"
+errorProne-core = "2.49.0"
errorProne-plugin = "4.3.0"
fabric-loom = "1.16.1"
githubRelease = "2.5.2"
-gradleVersions = "0.53.0"
+gradleVersions = "0.54.0"
ideaExt = "1.3"
illuaminate = "0.1.0-83-g1131f68"
-lwjgl = "3.3.6"
+lwjgl = "3.4.1"
minotaur = "2.8.7"
modDevGradle = "2.0.141"
-nullAway = "0.12.14"
-shadow = "9.2.2"
-spotless = "8.0.0"
-teavm = "0.14.0-SQUID.1"
+nullAway = "0.13.4"
+shadow = "9.4.1"
+spotless = "8.4.0"
+teavm = "0.14.0"
vanillaExtract = "0.3.1"
-versionCatalogUpdate = "1.0.1"
+versionCatalogUpdate = "1.1.0"
[libraries]
# Normal dependencies
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 61285a659..b1b8ef56b 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index c61a118f7..b52fb7e71 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
networkTimeout=10000
+retries=0
+retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index adff685a0..b9bb139f7 100755
--- a/gradlew
+++ b/gradlew
@@ -57,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
diff --git a/gradlew.bat b/gradlew.bat
index c4bdd3ab8..24c62d56f 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -23,8 +23,8 @@
@rem
@rem ##########################################################################
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
+@rem Set local scope for the variables, and ensure extensions are enabled
+setlocal EnableExtensions
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@@ -51,7 +51,7 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
-goto fail
+"%COMSPEC%" /c exit 1
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -65,7 +65,7 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
-goto fail
+"%COMSPEC%" /c exit 1
:execute
@rem Setup the command line
@@ -73,21 +73,10 @@ goto fail
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
+@rem which allows us to clear the local environment before executing the java command
+endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
-:end
-@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-set EXIT_CODE=%ERRORLEVEL%
-if %EXIT_CODE% equ 0 set EXIT_CODE=1
-if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
-exit /b %EXIT_CODE%
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+:exitWithErrorLevel
+@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
+"%COMSPEC%" /c exit %ERRORLEVEL%
diff --git a/package-lock.json b/package-lock.json
index 64499e04d..08cfea40c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -971,9 +971,9 @@
}
},
"node_modules/@swc/core": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.30.tgz",
- "integrity": "sha512-R8VQbQY1BZcbIF2p3gjlTCwAQzx1A194ugWfwld5y+WgVVWqVKm7eURGGOVbQVubgKWzidP2agomBbg96rZilQ==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.32.tgz",
+ "integrity": "sha512-/eWL0n43D64QWEUHLtTE+jDqjkJhyidjkDhv6f0uJohOUAhywxQ9wXYp845DNNds0JpCdI4Uo0a9bl+vbXf+ew==",
"dev": true,
"hasInstallScript": true,
"license": "Apache-2.0",
@@ -989,18 +989,18 @@
"url": "https://opencollective.com/swc"
},
"optionalDependencies": {
- "@swc/core-darwin-arm64": "1.15.30",
- "@swc/core-darwin-x64": "1.15.30",
- "@swc/core-linux-arm-gnueabihf": "1.15.30",
- "@swc/core-linux-arm64-gnu": "1.15.30",
- "@swc/core-linux-arm64-musl": "1.15.30",
- "@swc/core-linux-ppc64-gnu": "1.15.30",
- "@swc/core-linux-s390x-gnu": "1.15.30",
- "@swc/core-linux-x64-gnu": "1.15.30",
- "@swc/core-linux-x64-musl": "1.15.30",
- "@swc/core-win32-arm64-msvc": "1.15.30",
- "@swc/core-win32-ia32-msvc": "1.15.30",
- "@swc/core-win32-x64-msvc": "1.15.30"
+ "@swc/core-darwin-arm64": "1.15.32",
+ "@swc/core-darwin-x64": "1.15.32",
+ "@swc/core-linux-arm-gnueabihf": "1.15.32",
+ "@swc/core-linux-arm64-gnu": "1.15.32",
+ "@swc/core-linux-arm64-musl": "1.15.32",
+ "@swc/core-linux-ppc64-gnu": "1.15.32",
+ "@swc/core-linux-s390x-gnu": "1.15.32",
+ "@swc/core-linux-x64-gnu": "1.15.32",
+ "@swc/core-linux-x64-musl": "1.15.32",
+ "@swc/core-win32-arm64-msvc": "1.15.32",
+ "@swc/core-win32-ia32-msvc": "1.15.32",
+ "@swc/core-win32-x64-msvc": "1.15.32"
},
"peerDependencies": {
"@swc/helpers": ">=0.5.17"
@@ -1012,9 +1012,9 @@
}
},
"node_modules/@swc/core-darwin-arm64": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.30.tgz",
- "integrity": "sha512-VvpP+vq08HmGYewMWvrdsxh9s2lthz/808zXm8Yu5kaqeR8Yia2b0eYXleHQ3VAjoStUDk6LzTheBW9KXYQdMA==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.32.tgz",
+ "integrity": "sha512-/YWMvJDPu+AAwuUsM2G+DNQ/7zhodURGzdQyewEqcvgklAdDHs3LwQmLLnyn6SJl8DT8UOxkbzK+D1PmPeelRg==",
"cpu": [
"arm64"
],
@@ -1029,9 +1029,9 @@
}
},
"node_modules/@swc/core-darwin-x64": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.30.tgz",
- "integrity": "sha512-WiJA0hiZI3nwQAO6mu5RqigtWGDtth4Hiq6rbZxAaQyhIcqKIg5IoMRc1Y071lrNJn29eEDMC86Rq58xgUxlDg==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.32.tgz",
+ "integrity": "sha512-KOTXJXdAhWL+hZ77MYP3z+4pcMFaQhQ74yqyN1uz093q0YnbxpqMtYpPISbYvMHzVRNNx5kN+9RZAXEaadhWVA==",
"cpu": [
"x64"
],
@@ -1046,9 +1046,9 @@
}
},
"node_modules/@swc/core-linux-arm-gnueabihf": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.30.tgz",
- "integrity": "sha512-YANuFUo48kIT6plJgCD0keae9HFXfjxsbvsgevqc0hr/07X/p7sAWTFOGYEc2SXcASaK7UvuQqzlbW8pr7R79g==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.32.tgz",
+ "integrity": "sha512-oOoxLweljlc0A4X8ybsgxV7cVaYTwBOg2iMDJcFR3Sr48C+lsv9VzSmqdK/IVIXF4W4GjLc3VqTAdSMXlfVLuQ==",
"cpu": [
"arm"
],
@@ -1063,9 +1063,9 @@
}
},
"node_modules/@swc/core-linux-arm64-gnu": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.30.tgz",
- "integrity": "sha512-VndG8jaR4ugY6u+iVOT0Q+d2fZd7sLgjPgN8W/Le+3EbZKl+cRfFxV7Eoz4gfLqhmneZPdcIzf9T3LkgkmqNLg==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.32.tgz",
+ "integrity": "sha512-oDzEkdl6D6BAWdMtU5KGO7y3HR5fJcvByNLyEk9+ugj8nP5Ovb7P4kBcStBXc4MPExFGQryehiINMlmY8HlclA==",
"cpu": [
"arm64"
],
@@ -1083,9 +1083,9 @@
}
},
"node_modules/@swc/core-linux-arm64-musl": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.30.tgz",
- "integrity": "sha512-1SYGs2l0Yyyi0pR/P/NKz/x0kqxkoiw+BXeJjLUdecSk/KasncWlJrc6hOvFSgKHOBrzgM5jwuluKtlT8dnrcA==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.32.tgz",
+ "integrity": "sha512-omcqjoZP/b8D8PuczVoRwJieC6ibj7qIxTftNYokz4/aSmKFHvsd7nIFfPk5ZvtzncbH4AY7+Dkr/Lp2gWxYeA==",
"cpu": [
"arm64"
],
@@ -1103,9 +1103,9 @@
}
},
"node_modules/@swc/core-linux-ppc64-gnu": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.30.tgz",
- "integrity": "sha512-TXREtiXeRhbfDFbmhnkIsXpKfzbfT73YkV2ZF6w0sfxgjC5zI2ZAbaCOq25qxvegofj2K93DtOpm9RLaBgqR2g==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.32.tgz",
+ "integrity": "sha512-KGkTMyz/Tbn3PBNu0AVZ4GTDFKnICrYcTiNPZq8DrvK42pnFsf3GNDrIG9E5AtQlTmC0YigkWKmu0eMcfTrmgA==",
"cpu": [
"ppc64"
],
@@ -1123,9 +1123,9 @@
}
},
"node_modules/@swc/core-linux-s390x-gnu": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.30.tgz",
- "integrity": "sha512-DCR2YYeyd6DQE4OuDhImouuNcjXEiEdnn1Y0DyGteugPEDvVuvYk8Xddi+4o2SgWH6jiW8/I+3emZvbep1NC+g==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.32.tgz",
+ "integrity": "sha512-G3Aa4tVS/3OGZBkoNIwUF9F6RAy+Osb4GOlo62SinLmDiErz/ykmM7KH0wkz6l9kM8jJq1HyAM6atJTUEbBk7g==",
"cpu": [
"s390x"
],
@@ -1143,9 +1143,9 @@
}
},
"node_modules/@swc/core-linux-x64-gnu": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.30.tgz",
- "integrity": "sha512-5Pizw3NgfOJ5BJOBK8TIRa59xFW2avESTOBDPTAYwZYa1JNDs+KMF9lUfjJiJLM5HiMs/wPheA9eiT0q9m2AoA==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.32.tgz",
+ "integrity": "sha512-ERsjfGcj6CBmj3vJnGDO8m8rTvw6RqMcWo1dogOtNx3/+/0+NNpJiXDobJrr1GwInI/BHAEkvSFIH6d2LqPcUQ==",
"cpu": [
"x64"
],
@@ -1163,9 +1163,9 @@
}
},
"node_modules/@swc/core-linux-x64-musl": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.30.tgz",
- "integrity": "sha512-qyqydP/wyH8alcIP4a2hnGSjHLJjm9H7yDFup+CPy9oTahFgLLwnNcv5UHXqO2Qs3AIND+cls5f/Bb6hqpxdgA==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.32.tgz",
+ "integrity": "sha512-N4Ggahe/8SUbTX50P6EdhbW9YWcgbZVb52R4cq6MK+zsoMjRq7rGvV5ztA05QnbaCYqMYx8rTY7KAIA3Crdo4Q==",
"cpu": [
"x64"
],
@@ -1183,9 +1183,9 @@
}
},
"node_modules/@swc/core-win32-arm64-msvc": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.30.tgz",
- "integrity": "sha512-CaQENgDHVGOg1mSF5sQVgvfFHG9kjMor2rkLMLeLOkfZYNj13ppnJ9+lfaBZLZUMMbnlGQnavCJb8PVBUOso7Q==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.32.tgz",
+ "integrity": "sha512-01yN0o9jvo8xBTP12aPK2wW8b41jmOlGbDDlAnoynotc4pO6xA0zby9f1z6j++qXDpGBttLySq1omgVrlQKYcw==",
"cpu": [
"arm64"
],
@@ -1200,9 +1200,9 @@
}
},
"node_modules/@swc/core-win32-ia32-msvc": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.30.tgz",
- "integrity": "sha512-30VdLeGk6fugiUs/kUdJ/pAg7z/zpvVbR11RH60jZ0Z42WIeIniYx0rLEWN7h/pKJ3CopqsQ3RsogCAkRKiA2g==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.32.tgz",
+ "integrity": "sha512-fLagI9XZYNpTcmlqAcp3KBtmj7E19WCmYD80Jxj1Kn5tGNa7yxNLd3NNdWxuZGUPl5iC0/KqZru7g08gF6Fsrw==",
"cpu": [
"ia32"
],
@@ -1217,9 +1217,9 @@
}
},
"node_modules/@swc/core-win32-x64-msvc": {
- "version": "1.15.30",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.30.tgz",
- "integrity": "sha512-4iObHPR+Q4oDY110EF5SF5eIaaVJNpMdG9C0q3Q92BsJ5y467uHz7sYQhP60WYlLFsLQ1el2YrIPUItUAQGOKg==",
+ "version": "1.15.32",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.32.tgz",
+ "integrity": "sha512-gbc2bQ/T2CiR+w0OvcVKwLOFAcPZBvmWmolbwpg1E8UrpeC03DGtyMUApOHNXNYWA3SHFrYXCQtosrcMza1YFg==",
"cpu": [
"x64"
],
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java
index 1336b3832..61ec717e6 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java
@@ -165,6 +165,18 @@ public class CommandAPI implements ILuaAPI {
return Collections.unmodifiableList(result);
}
+ /**
+ * Get the name of the dimension the current command computer is in, such as {@code minecraft:overworld}.
+ *
+ * @return The dimension the computer is in.
+ * @see #getBlockPosition()
+ * @since 1.119.0
+ */
+ @LuaFunction
+ public final String getDimension() {
+ return computer.getLevel().dimension().identifier().toString();
+ }
+
/**
* Get the position of the current command computer.
*
@@ -173,10 +185,10 @@ public class CommandAPI implements ILuaAPI {
* @cc.treturn number This computer's y position.
* @cc.treturn number This computer's z position.
* @cc.see gps.locate To get the position of a non-command computer.
+ * @see #getDimension()
*/
@LuaFunction
public final Object[] getBlockPosition() {
- // This is probably safe to do on the Lua thread. Probably.
var pos = computer.getPosition();
return new Object[]{ pos.getX(), pos.getY(), pos.getZ() };
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java b/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java
index 77bf748c6..44828f0c6 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java
@@ -43,6 +43,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
+import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
import org.jspecify.annotations.Nullable;
@@ -277,19 +278,17 @@ public interface PlatformHelper {
/**
* Interact with an entity, for instance feeding cows.
*
- * Implementations should follow Minecraft behaviour - we try {@link Entity#interactAt(Player, Vec3, InteractionHand)}
- * and then {@link Player#interactOn(Entity, InteractionHand)}. Loader-specific hooks should also be called.
+ * Implementations should call {@link Player#interactOn(Entity, InteractionHand, Vec3)} and any loader-specific
+ * hooks.
*
* @param player The player which is interacting with the entity.
- * @param entity The entity we're interacting with.
- * @param hitPos The position our ray trace hit the entity. This is a position in-world, unlike
- * {@link Entity#interactAt(Player, Vec3, InteractionHand)} which is relative to the entity.
+ * @param hit The entity and position we're interacting with. Note the hit's position is world-relative,
+ * unlike {@link Entity#interact(Player, InteractionHand, Vec3)} which is relative to the entity.
* @return Whether any interaction occurred.
- * @see Entity#interactAt(Player, Vec3, InteractionHand)
- * @see Player#interactOn(Entity, InteractionHand)
+ * @see Player#interactOn(Entity, InteractionHand, Vec3)
* @see ServerGamePacketListenerImpl#handleInteract
*/
- boolean interactWithEntity(ServerPlayer player, Entity entity, Vec3 hitPos);
+ boolean interactWithEntity(ServerPlayer player, EntityHitResult hit);
/**
* The result of attempting to use an item on a block.
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java
index 712892a7f..e859c8799 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java
@@ -102,11 +102,8 @@ public class TurtlePlaceCommand implements TurtleCommand {
if (!(hit instanceof EntityHitResult entityHit)) return false;
// Start claiming entity drops
- var hitEntity = entityHit.getEntity();
- var hitPos = entityHit.getLocation();
-
- DropConsumer.set(hitEntity);
- var placed = PlatformHelper.get().interactWithEntity(turtlePlayer.player(), hitEntity, hitPos);
+ DropConsumer.set(entityHit.getEntity());
+ var placed = PlatformHelper.get().interactWithEntity(turtlePlayer.player(), entityHit);
TurtleUtil.stopConsumingPlayer(turtle, turtlePlayer);
return placed;
}
diff --git a/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java b/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java
index c5b00ebe9..f38f37a00 100644
--- a/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java
+++ b/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java
@@ -43,7 +43,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
-import net.minecraft.world.phys.Vec3;
+import net.minecraft.world.phys.EntityHitResult;
import org.jspecify.annotations.Nullable;
import java.nio.file.Path;
@@ -143,7 +143,7 @@ public class TestPlatformHelper extends AbstractComputerCraftAPI implements Plat
}
@Override
- public boolean interactWithEntity(ServerPlayer player, Entity entity, Vec3 hitPos) {
+ public boolean interactWithEntity(ServerPlayer player, EntityHitResult hit) {
throw new UnsupportedOperationException("Cannot interact with the world inside tests");
}
diff --git a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ManagedComputers.kt b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ManagedComputers.kt
index af6ea57cc..993626f1a 100644
--- a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ManagedComputers.kt
+++ b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ManagedComputers.kt
@@ -69,7 +69,9 @@ object ManagedComputers : ILuaMachine.Factory {
val label = os.computerLabel
return when {
id != 1 -> CobaltLuaMachine(environment, bios)
+
label != null && label[0] != null -> KotlinMachine(environment, label[0] as String)
+
else -> {
LOGGER.error("Kotlin Lua machine must have a label")
CobaltLuaMachine(environment, bios)
diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTable.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTable.java
index fa42b1395..ecc091565 100644
--- a/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTable.java
+++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTable.java
@@ -21,6 +21,19 @@ import static dan200.computercraft.api.lua.LuaValues.*;
* @see ObjectArguments
*/
public interface LuaTable extends Map {
+ /**
+ * Return the value to which a specific integer key is mapped, or {@code null} if there is no mapping for the key.
+ *
+ * This should be used when accessing integer keys, as numeric keys within the table are typically normalised to
+ * doubles.
+ *
+ * @param index The key to look up.
+ * @return The corresponding value, or {@code null} if not present.
+ */
+ default @Nullable Object get(int index) {
+ return get((double) index);
+ }
+
/**
* Compute the length of the array part of this table.
*
@@ -42,7 +55,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default double getDouble(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (!(value instanceof Number number)) throw badTableItem(index, "number", getType(value));
return number.doubleValue();
}
@@ -70,7 +83,7 @@ public interface LuaTable extends Map {
* @throws LuaException If the value is not an integer.
*/
default long getLong(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (!(value instanceof Number number)) throw badTableItem(index, "number", getType(value));
checkFiniteIndex(index, number.doubleValue());
return number.longValue();
@@ -145,7 +158,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default boolean getBoolean(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (!(value instanceof Boolean bool)) throw badTableItem(index, "boolean", getType(value));
return bool;
}
@@ -173,7 +186,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default String getString(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (!(value instanceof String string)) throw badTableItem(index, "string", getType(value));
return string;
}
@@ -204,7 +217,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default Map, ?> getTable(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (!(value instanceof Map, ?> table)) throw badTableItem(index, "table", getType(value));
return table;
}
@@ -236,7 +249,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default Optional optDouble(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (value == null) return Optional.empty();
if (!(value instanceof Number number)) throw badTableItem(index, "number", getType(value));
return Optional.of(number.doubleValue());
@@ -267,7 +280,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default Optional optLong(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (value == null) return Optional.empty();
if (!(value instanceof Number number)) throw badTableItem(index, "number", getType(value));
checkFiniteIndex(index, number.doubleValue());
@@ -351,7 +364,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default Optional optBoolean(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (value == null) return Optional.empty();
if (!(value instanceof Boolean bool)) throw badTableItem(index, "boolean", getType(value));
return Optional.of(bool);
@@ -381,7 +394,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default Optional optString(int index) throws LuaException {
- Object value = get((double) index);
+ var value = get(index);
if (value == null) return Optional.empty();
if (!(value instanceof String string)) throw badTableItem(index, "string", getType(value));
return Optional.of(string);
@@ -414,7 +427,7 @@ public interface LuaTable extends Map {
* @since 1.116
*/
default Optional