mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-08 01:12:59 +00:00
Compare commits
12 Commits
v1.21.8-1.
...
v1.21.1-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f87984bac | ||
|
|
18f3426f1d | ||
|
|
0ec46fe38e | ||
|
|
569de7fafb | ||
|
|
157ce4fa55 | ||
|
|
b9ed66983d | ||
|
|
d0fbec6c6b | ||
|
|
a683697e8c | ||
|
|
9e233a916f | ||
|
|
5a9e21ccc3 | ||
|
|
5f16909d4b | ||
|
|
00475b9bb0 |
@@ -101,7 +101,7 @@ about how you can build on that until you've covered everything!
|
||||
|
||||
[new-issue]: https://github.com/cc-tweaked/CC-Tweaked/issues/new/choose "Create a new issue"
|
||||
[community]: README.md#community "Get in touch with the community."
|
||||
[Adoptium]: https://adoptium.net/temurin/releases?version=17 "Download OpenJDK 17"
|
||||
[Adoptium]: https://adoptium.net/temurin/releases?version=21 "Download OpenJDK 21"
|
||||
[illuaminate]: https://github.com/SquidDev/illuaminate/ "Illuaminate on GitHub"
|
||||
[docs]: https://tweaked.cc/ "CC: Tweaked documentation"
|
||||
[ldoc]: http://stevedonovan.github.io/ldoc/ "ldoc, a Lua documentation generator."
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
|
||||
import cc.tweaked.gradle.JUnitExt
|
||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
||||
import net.fabricmc.loom.util.gradle.SourceSetHelper
|
||||
import org.jetbrains.gradle.ext.*
|
||||
import org.jetbrains.gradle.ext.Application
|
||||
|
||||
plugins {
|
||||
publishing
|
||||
alias(libs.plugins.taskTree)
|
||||
alias(libs.plugins.githubRelease)
|
||||
alias(libs.plugins.gradleVersions)
|
||||
alias(libs.plugins.versionCatalogUpdate)
|
||||
@@ -70,7 +68,7 @@ idea.project.settings.runConfigurations {
|
||||
val fabricProject = evaluationDependsOn(":fabric")
|
||||
val classPathGroup = fabricProject.extensions.getByType<LoomGradleExtensionAPI>().mods
|
||||
.joinToString(File.pathSeparator + File.pathSeparator) { modSettings ->
|
||||
SourceSetHelper.getClasspath(modSettings, project).joinToString(File.pathSeparator) { it.absolutePath }
|
||||
modSettings.modFiles.joinToString(File.pathSeparator) { it.absolutePath }
|
||||
}
|
||||
|
||||
vmParameters = "-ea -Dfabric.classPathGroups=$classPathGroup"
|
||||
@@ -115,8 +113,12 @@ idea.project.settings.compiler.javac {
|
||||
.toMap()
|
||||
}
|
||||
|
||||
repositories() {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
versionCatalogUpdate {
|
||||
sortByKey = false
|
||||
pin { versions.addAll("fastutil", "guava", "netty", "slf4j") }
|
||||
keep { keepUnusedLibraries = true }
|
||||
keep { keepUnusedVersions = true }
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ repositories {
|
||||
name = "Fabric"
|
||||
content {
|
||||
includeGroup("net.fabricmc")
|
||||
includeGroup("net.fabricmc.unpick")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +70,6 @@ gradlePlugin {
|
||||
|
||||
versionCatalogUpdate {
|
||||
sortByKey = false
|
||||
keep { keepUnusedLibraries = true }
|
||||
keep { keepUnusedVersions = true }
|
||||
catalogFile = file("../gradle/libs.versions.toml")
|
||||
}
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
|
||||
/** Default configuration for Fabric projects. */
|
||||
|
||||
import cc.tweaked.gradle.CCTweakedExtension
|
||||
import cc.tweaked.gradle.CCTweakedPlugin
|
||||
import cc.tweaked.gradle.IdeaRunConfigurations
|
||||
import cc.tweaked.gradle.MinecraftConfigurations
|
||||
import cc.tweaked.gradle.*
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
@@ -67,3 +64,19 @@ dependencies {
|
||||
tasks.ideaSyncTask {
|
||||
doLast { IdeaRunConfigurations(project).patch() }
|
||||
}
|
||||
|
||||
tasks.named("checkDependencyConsistency", DependencyCheck::class.java) {
|
||||
val libs = project.extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
// Minecraft depends on lwjgl, but Fabric forces it to a more recent version
|
||||
for (lwjgl in listOf(
|
||||
"lwjgl",
|
||||
"lwjgl-glfw",
|
||||
"lwjgl-jemalloc",
|
||||
"lwjgl-openal",
|
||||
"lwjgl-opengl",
|
||||
"lwjgl-stb",
|
||||
"lwjgl-tinyfd",
|
||||
)) {
|
||||
override("org.lwjgl", lwjgl, "3.3.2")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ plugins {
|
||||
checkstyle
|
||||
id("com.diffplug.spotless")
|
||||
id("net.ltgt.errorprone")
|
||||
// Required for cross-project dependencies in Fabric
|
||||
id("net.fabricmc.fabric-loom-companion")
|
||||
}
|
||||
|
||||
val modVersion: String by extra
|
||||
@@ -28,9 +30,9 @@ version = modVersion
|
||||
base.archivesName.convention("cc-tweaked-$mcVersion-${project.name}")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = CCTweakedPlugin.JAVA_VERSION
|
||||
}
|
||||
toolchain { languageVersion = CCTweakedPlugin.JDK_VERSION }
|
||||
sourceCompatibility = CCTweakedPlugin.JAVA_VERSION
|
||||
targetCompatibility = CCTweakedPlugin.JAVA_VERSION
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
@@ -78,6 +80,8 @@ dependencies {
|
||||
// Configure default JavaCompile tasks with our arguments.
|
||||
sourceSets.all {
|
||||
tasks.named(compileJavaTaskName, JavaCompile::class.java) {
|
||||
// Explicitly set release, as that limits the APIs we can use to the right version of Java.
|
||||
options.release = CCTweakedPlugin.JAVA_TARGET.asInt()
|
||||
|
||||
options.compilerArgs.addAll(
|
||||
listOf(
|
||||
@@ -100,6 +104,7 @@ sourceSets.all {
|
||||
check("NonOverridingEquals", CheckSeverity.OFF) // Peripheral.equals makes this hard to avoid
|
||||
check("FutureReturnValueIgnored", CheckSeverity.OFF) // Too many false positives with Netty
|
||||
check("InvalidInlineTag", CheckSeverity.OFF) // Triggered by @snippet. Can be removed on Java 21.
|
||||
option("UnusedMethod:ExemptingMethodAnnotations", "dan200.computercraft.api.lua.LuaFunction")
|
||||
|
||||
check("NullAway", CheckSeverity.ERROR)
|
||||
option(
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* See notes in [cc.tweaked.gradle.MinecraftConfigurations] for the general design behind these cursed ideas.
|
||||
*/
|
||||
|
||||
import cc.tweaked.gradle.CCTweakedPlugin
|
||||
import cc.tweaked.gradle.MinecraftConfigurations
|
||||
import cc.tweaked.gradle.clientClasses
|
||||
import cc.tweaked.gradle.commonClasses
|
||||
@@ -52,3 +53,5 @@ dependencies {
|
||||
|
||||
testImplementation(testFixtures(project))
|
||||
}
|
||||
|
||||
kotlin.compilerOptions.jvmTarget = CCTweakedPlugin.KOTLIN_TARGET
|
||||
|
||||
@@ -223,7 +223,7 @@ abstract class CCTweakedExtension(private val project: Project) {
|
||||
).resolve().single()
|
||||
}
|
||||
|
||||
private fun <T> gitProvider(default: T, command: List<String>, process: (String) -> T): Provider<T> {
|
||||
private fun <T: Any> gitProvider(default: T, command: List<String>, process: (String) -> T): Provider<T> {
|
||||
val baseResult = project.providers.exec {
|
||||
commandLine = listOf("git", "-C", project.rootDir.absolutePath) + command
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
package cc.tweaked.gradle
|
||||
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
@@ -13,6 +14,7 @@ import org.gradle.plugins.ide.idea.model.IdeaModel
|
||||
import org.jetbrains.gradle.ext.IdeaExtPlugin
|
||||
import org.jetbrains.gradle.ext.runConfigurations
|
||||
import org.jetbrains.gradle.ext.settings
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
/**
|
||||
* Configures projects to match a shared configuration.
|
||||
@@ -42,6 +44,17 @@ class CCTweakedPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
companion object {
|
||||
val JAVA_VERSION = JavaLanguageVersion.of(21)
|
||||
/**
|
||||
* The version we run with. We use Java 21 here, as our Gradle build requires that.
|
||||
*/
|
||||
val JDK_VERSION = JavaLanguageVersion.of(21)
|
||||
|
||||
/**
|
||||
* The Java version we target. Should be the same as what Minecraft uses.
|
||||
*/
|
||||
val JAVA_TARGET = JavaLanguageVersion.of(21)
|
||||
|
||||
val JAVA_VERSION = JavaVersion.toVersion(JAVA_TARGET.asInt())
|
||||
val KOTLIN_TARGET = JvmTarget.fromTarget(JAVA_TARGET.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ abstract class DependencyCheck : DefaultTask() {
|
||||
overrides.putAll(project.provider { mutableMapOf(module.get().module.toString() to version) })
|
||||
}
|
||||
|
||||
fun override(group: String, module: String, version: String) {
|
||||
overrides.put("$group:$module", version)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a configuration to check.
|
||||
*/
|
||||
|
||||
@@ -140,7 +140,7 @@ class CloseScope : AutoCloseable {
|
||||
}
|
||||
|
||||
/** Proxy method to avoid overload ambiguity. */
|
||||
fun <T> Property<T>.setProvider(provider: Provider<out T>) = set(provider)
|
||||
fun <T: Any> Property<T >.setProvider(provider: Provider<out T>) = set(provider)
|
||||
|
||||
/** Short-cut method to get the absolute path of a [FileSystemLocation] provider. */
|
||||
fun Provider<out FileSystemLocation>.getAbsolutePath(): String = get().asFile.absolutePath
|
||||
|
||||
@@ -40,7 +40,6 @@ class MinecraftConfigurations private constructor(private val project: Project)
|
||||
|
||||
// Set up an API configuration for clients (to ensure it's consistent with the main source set).
|
||||
val clientApi = configurations.maybeCreate(client.apiConfigurationName).apply {
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = false
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ neogradle.subsystems.conventions.runs.enabled=false
|
||||
|
||||
# Mod properties
|
||||
isUnstable=true
|
||||
modVersion=1.116.1
|
||||
modVersion=1.116.2
|
||||
|
||||
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
|
||||
mcVersion=1.21.1
|
||||
|
||||
@@ -23,17 +23,17 @@ netty = "4.1.97.Final"
|
||||
slf4j = "2.0.9"
|
||||
|
||||
# Core dependencies (independent of Minecraft)
|
||||
asm = "9.6"
|
||||
asm = "9.9"
|
||||
autoService = "1.1.1"
|
||||
checkerFramework = "3.42.0"
|
||||
cobalt = { strictly = "0.9.6" }
|
||||
commonsCli = "1.6.0"
|
||||
jetbrainsAnnotations = "24.1.0"
|
||||
checkerFramework = "3.51.1"
|
||||
cobalt = { strictly = "0.9.7" }
|
||||
commonsCli = "1.10.0"
|
||||
jetbrainsAnnotations = "26.0.2-1"
|
||||
jspecify = "1.0.0"
|
||||
jzlib = "1.1.3"
|
||||
kotlin = "2.1.10"
|
||||
kotlin-coroutines = "1.10.1"
|
||||
nightConfig = "3.8.1"
|
||||
kotlin = "2.2.21"
|
||||
kotlin-coroutines = "1.10.2"
|
||||
nightConfig = "3.8.3"
|
||||
|
||||
# Minecraft mods
|
||||
emi = "1.1.7+1.21"
|
||||
@@ -48,35 +48,34 @@ sodium-fabric = "mc1.21-0.6.0-beta.1-fabric"
|
||||
sodium-forge = "mc1.21-0.6.0-beta.1-neoforge"
|
||||
mixinExtra = "0.3.5"
|
||||
create-forge = "6.0.0-6"
|
||||
create-fabric = "0.5.1-f-build.1467+mc1.20.1"
|
||||
create-fabric = "6.0.7.0+mc1.20.1-build.1716"
|
||||
|
||||
# Testing
|
||||
hamcrest = "2.2"
|
||||
jqwik = "1.8.2"
|
||||
junit = "5.11.4"
|
||||
junitPlatform = "1.11.4"
|
||||
hamcrest = "3.0"
|
||||
jqwik = "1.9.3"
|
||||
junit = "6.0.1"
|
||||
junitPlatform = "6.0.1"
|
||||
jmh = "1.37"
|
||||
|
||||
# Build tools
|
||||
cctJavadoc = "1.8.4"
|
||||
checkstyle = "10.23.1"
|
||||
errorProne-core = "2.38.0"
|
||||
errorProne-plugin = "4.1.0"
|
||||
fabric-loom = "1.10.4"
|
||||
checkstyle = "12.1.1"
|
||||
errorProne-core = "2.43.0"
|
||||
errorProne-plugin = "4.3.0"
|
||||
fabric-loom = "1.12.3"
|
||||
githubRelease = "2.5.2"
|
||||
gradleVersions = "0.50.0"
|
||||
ideaExt = "1.1.7"
|
||||
gradleVersions = "0.53.0"
|
||||
ideaExt = "1.3"
|
||||
illuaminate = "0.1.0-83-g1131f68"
|
||||
lwjgl = "3.3.3"
|
||||
lwjgl = "3.3.6"
|
||||
minotaur = "2.8.7"
|
||||
modDevGradle = "2.0.95"
|
||||
nullAway = "0.12.7"
|
||||
shadow = "8.3.1"
|
||||
spotless = "7.0.2"
|
||||
taskTree = "2.1.1"
|
||||
teavm = "0.13.0-SQUID.1"
|
||||
modDevGradle = "2.0.116"
|
||||
nullAway = "0.12.11"
|
||||
shadow = "9.2.2"
|
||||
spotless = "8.0.0"
|
||||
teavm = "0.13.0-SQUID.2"
|
||||
vanillaExtract = "0.2.1"
|
||||
versionCatalogUpdate = "0.8.1"
|
||||
versionCatalogUpdate = "1.0.1"
|
||||
|
||||
[libraries]
|
||||
# Normal dependencies
|
||||
@@ -176,7 +175,6 @@ githubRelease = { id = "com.github.breadmoirai.github-release", version.ref = "g
|
||||
gradleVersions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersions" }
|
||||
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
|
||||
taskTree = { id = "com.dorongold.task-tree", version.ref = "taskTree" }
|
||||
versionCatalogUpdate = { id = "nl.littlerobots.version-catalog-update", version.ref = "versionCatalogUpdate" }
|
||||
|
||||
[bundles]
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
754
package-lock.json
generated
754
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -83,7 +83,7 @@ val luaJavadoc by tasks.registering(Javadoc::class) {
|
||||
options.addStringOption("project-root", rootProject.file(".").absolutePath)
|
||||
options.noTimestamp(false)
|
||||
|
||||
javadocTool = javaToolchains.javadocToolFor { languageVersion = CCTweakedPlugin.JAVA_VERSION }
|
||||
javadocTool = javaToolchains.javadocToolFor { languageVersion = CCTweakedPlugin.JDK_VERSION }
|
||||
}
|
||||
|
||||
val lintLua by tasks.registering(IlluaminateExec::class) {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -61,7 +60,6 @@ final class InvariantChecker {
|
||||
return okay;
|
||||
}
|
||||
|
||||
@Contract("")
|
||||
private static <T> @Nullable T makeNullable(T object) {
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ import java.util.function.UnaryOperator;
|
||||
|
||||
/**
|
||||
* Registers ComputerCraft's registry entries and additional objects, such as {@link CauldronInteraction}s and
|
||||
* {@link DetailProvider}s
|
||||
* {@link DetailProvider}s.
|
||||
* <p>
|
||||
* The functions in this class should be called from a loader-specific class.
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Stops a sound on the client
|
||||
* Stops a sound on the client.
|
||||
* <p>
|
||||
* Called when a speaker is broken.
|
||||
*
|
||||
|
||||
@@ -305,7 +305,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements Wi
|
||||
return wrappers == null ? null : wrappers.get(remoteName);
|
||||
}
|
||||
|
||||
private static class RemotePeripheralWrapper implements IComputerAccess, GuardedLuaContext.Guard {
|
||||
private static final class RemotePeripheralWrapper implements IComputerAccess, GuardedLuaContext.Guard {
|
||||
private final WiredModemElement element;
|
||||
private final IPeripheral peripheral;
|
||||
private final IComputerAccess computer;
|
||||
@@ -331,13 +331,13 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements Wi
|
||||
methodMap = methods;
|
||||
}
|
||||
|
||||
public void attach() {
|
||||
private void attach() {
|
||||
attached = true;
|
||||
peripheral.attach(this);
|
||||
computer.queueEvent("peripheral", getAttachmentName());
|
||||
}
|
||||
|
||||
public void detach() {
|
||||
private void detach() {
|
||||
peripheral.detach(this);
|
||||
computer.queueEvent("peripheral_detach", getAttachmentName());
|
||||
attached = false;
|
||||
@@ -352,19 +352,19 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements Wi
|
||||
}
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
private String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Set<String> getAdditionalTypes() {
|
||||
private Set<String> getAdditionalTypes() {
|
||||
return additionalTypes;
|
||||
}
|
||||
|
||||
public Collection<String> getMethodNames() {
|
||||
private Collection<String> getMethodNames() {
|
||||
return methodMap.keySet();
|
||||
}
|
||||
|
||||
public MethodResult callMethod(ILuaContext context, String methodName, IArguments arguments) throws LuaException {
|
||||
private MethodResult callMethod(ILuaContext context, String methodName, IArguments arguments) throws LuaException {
|
||||
var method = methodMap.get(methodName);
|
||||
if (method == null) throw new LuaException("No such method " + methodName);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public final class InventoryUtil {
|
||||
*/
|
||||
public static int getInventorySlotFromCompartment(Player player, int slot, ItemStack stack) {
|
||||
if (stack.isEmpty()) throw new IllegalArgumentException("Cannot search for empty stack");
|
||||
if (player.getInventory().getItem(slot) == stack) return slot;
|
||||
if (slot >= 0 && slot < Inventory.INVENTORY_SIZE && player.getInventory().getItem(slot) == stack) return slot;
|
||||
if (player.getInventory().getItem(Inventory.SLOT_OFFHAND) == stack) return Inventory.SLOT_OFFHAND;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class NetworkBenchmark {
|
||||
return networks;
|
||||
}
|
||||
|
||||
private static class Grid<T> {
|
||||
private static final class Grid<T> {
|
||||
private final int size;
|
||||
private final T[] box;
|
||||
|
||||
@@ -151,7 +151,7 @@ public class NetworkBenchmark {
|
||||
this.box = (T[]) new Object[size * size * size];
|
||||
}
|
||||
|
||||
public T get(BlockPos pos) {
|
||||
private T get(BlockPos pos) {
|
||||
int x = pos.getX(), y = pos.getY(), z = pos.getZ();
|
||||
|
||||
return x >= 0 && x < size && y >= 0 && y < size && z >= 0 && z < size
|
||||
@@ -159,7 +159,7 @@ public class NetworkBenchmark {
|
||||
: null;
|
||||
}
|
||||
|
||||
public void forEach(BiConsumer<T, BlockPos> transform) {
|
||||
private void forEach(BiConsumer<T, BlockPos> transform) {
|
||||
for (var x = 0; x < size; x++) {
|
||||
for (var y = 0; y < size; y++) {
|
||||
for (var z = 0; z < size; z++) {
|
||||
@@ -169,7 +169,7 @@ public class NetworkBenchmark {
|
||||
}
|
||||
}
|
||||
|
||||
public void map(BiFunction<T, BlockPos, T> transform) {
|
||||
private void map(BiFunction<T, BlockPos, T> transform) {
|
||||
for (var x = 0; x < size; x++) {
|
||||
for (var y = 0; y < size; y++) {
|
||||
for (var z = 0; z < size; z++) {
|
||||
|
||||
@@ -61,4 +61,14 @@ public class ObjectLuaTable implements LuaTable<Object, Object> {
|
||||
public Set<Entry<Object, Object>> entrySet() {
|
||||
return map.entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || o instanceof Map<?, ?> otherMap && map.equals(otherMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return map.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
import cc.tweaked.gradle.CCTweakedPlugin
|
||||
import cc.tweaked.gradle.getAbsolutePath
|
||||
|
||||
plugins {
|
||||
@@ -39,6 +40,8 @@ dependencies {
|
||||
testRuntimeOnly(libs.slf4j.simple)
|
||||
}
|
||||
|
||||
kotlin.compilerOptions.jvmTarget = CCTweakedPlugin.KOTLIN_TARGET
|
||||
|
||||
tasks.processResources {
|
||||
inputs.property("gitHash", cct.gitHash)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.*;
|
||||
* @hidden
|
||||
*/
|
||||
public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChangeListener {
|
||||
private class PeripheralWrapper extends ComputerAccess implements GuardedLuaContext.Guard {
|
||||
private final class PeripheralWrapper extends ComputerAccess implements GuardedLuaContext.Guard {
|
||||
private final String side;
|
||||
private final IPeripheral peripheral;
|
||||
|
||||
@@ -49,32 +49,32 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
methodMap = peripheralMethods.getSelfMethods(peripheral);
|
||||
}
|
||||
|
||||
public IPeripheral getPeripheral() {
|
||||
private IPeripheral getPeripheral() {
|
||||
return peripheral;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
private String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Set<String> getAdditionalTypes() {
|
||||
private Set<String> getAdditionalTypes() {
|
||||
return additionalTypes;
|
||||
}
|
||||
|
||||
public Collection<String> getMethods() {
|
||||
private Collection<String> getMethods() {
|
||||
return methodMap.keySet();
|
||||
}
|
||||
|
||||
public synchronized boolean isAttached() {
|
||||
private synchronized boolean isAttached() {
|
||||
return attached;
|
||||
}
|
||||
|
||||
public synchronized void attach() {
|
||||
private synchronized void attach() {
|
||||
attached = true;
|
||||
peripheral.attach(this);
|
||||
}
|
||||
|
||||
public void detach() {
|
||||
private void detach() {
|
||||
// Call detach
|
||||
peripheral.detach(this);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
attached = false;
|
||||
}
|
||||
|
||||
public MethodResult call(ILuaContext context, String methodName, IArguments arguments) throws LuaException {
|
||||
private MethodResult call(ILuaContext context, String methodName, IArguments arguments) throws LuaException {
|
||||
PeripheralMethod method;
|
||||
synchronized (this) {
|
||||
method = methodMap.get(methodName);
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.net.URI;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* Checks a URL using {@link NetworkUtils#getAddress(String, int, boolean)}}
|
||||
* Checks a URL using {@link NetworkUtils#getAddress(String, int, boolean)}.
|
||||
* <p>
|
||||
* This requires a DNS lookup, and so needs to occur off-thread.
|
||||
*/
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract class Resource<T extends Resource<T>> implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up any pending resources
|
||||
* Clean up any pending resources.
|
||||
* <p>
|
||||
* Note, this may be called multiple times, and so should be thread-safe and
|
||||
* avoid any major side effects.
|
||||
|
||||
@@ -47,7 +47,7 @@ final class Generator<T> {
|
||||
private static final MethodHandle ARG_GET_OBJECT, ARG_GET_ENUM, ARG_OPT_ENUM, ARG_GET_STRING_COERCED, ARG_GET_BYTES_COERCED;
|
||||
|
||||
private record ArgMethods(MethodHandle get, MethodHandle opt) {
|
||||
public static ArgMethods of(Class<?> type, String name) throws ReflectiveOperationException {
|
||||
private static ArgMethods of(Class<?> type, String name) throws ReflectiveOperationException {
|
||||
return new ArgMethods(
|
||||
LOOKUP.findVirtual(IArguments.class, "get" + name, MethodType.methodType(type, int.class)),
|
||||
LOOKUP.findVirtual(IArguments.class, "opt" + name, MethodType.methodType(Optional.class, int.class))
|
||||
@@ -73,6 +73,22 @@ final class Generator<T> {
|
||||
addArgType(argMethodMap, Map.class, "Table");
|
||||
addArgType(argMethodMap, String.class, "String");
|
||||
addArgType(argMethodMap, ByteBuffer.class, "Bytes");
|
||||
argMethodMap.put(LuaTable.class, new ArgMethods(
|
||||
// i -> new ObjectLuaTable(getTable(i))
|
||||
MethodHandles.filterReturnValue(
|
||||
LOOKUP.findVirtual(IArguments.class, "getTable", MethodType.methodType(Map.class, int.class)),
|
||||
LOOKUP.findConstructor(ObjectLuaTable.class, MethodType.methodType(void.class, Map.class))
|
||||
.asType(MethodType.methodType(LuaTable.class, Map.class))
|
||||
),
|
||||
// i -> optTable(i).map(ObjectLuaTable::new)
|
||||
MethodHandles.filterReturnValue(
|
||||
LOOKUP.findVirtual(IArguments.class, "optTable", MethodType.methodType(Optional.class, int.class)),
|
||||
MethodHandles.insertArguments(
|
||||
LOOKUP.findVirtual(Optional.class, "map", MethodType.methodType(Optional.class, Function.class)),
|
||||
1, (Function<Map<?, ?>, LuaTable<?, ?>>) ObjectLuaTable::new
|
||||
)
|
||||
)
|
||||
));
|
||||
argMethods = Map.copyOf(argMethodMap);
|
||||
|
||||
ARG_TABLE_UNSAFE = ArgMethods.of(LuaTable.class, "TableUnsafe");
|
||||
@@ -335,10 +351,9 @@ final class Generator<T> {
|
||||
}
|
||||
|
||||
private static @Nullable ArgMethods getArgMethods(Class<?> type, boolean unsafe) {
|
||||
var getter = argMethods.get(type);
|
||||
if (getter != null) return getter;
|
||||
if (type == LuaTable.class && unsafe) return ARG_TABLE_UNSAFE;
|
||||
return null;
|
||||
|
||||
return argMethods.get(type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -740,7 +740,7 @@ public final class ComputerThread implements ComputerScheduler {
|
||||
}
|
||||
|
||||
private final class ExecutorImpl implements Executor {
|
||||
public static final AtomicReferenceFieldUpdater<ExecutorImpl, ExecutorState> STATE = AtomicReferenceFieldUpdater.newUpdater(
|
||||
private static final AtomicReferenceFieldUpdater<ExecutorImpl, ExecutorState> STATE = AtomicReferenceFieldUpdater.newUpdater(
|
||||
ExecutorImpl.class, ExecutorState.class, "$state"
|
||||
);
|
||||
|
||||
|
||||
@@ -20,13 +20,8 @@ import static org.squiddev.cobalt.Constants.NAME;
|
||||
final class VarargArguments implements IArguments {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(VarargArguments.class);
|
||||
|
||||
private static final VarargArguments EMPTY = new VarargArguments(Constants.NONE);
|
||||
private static boolean reportedIllegalGet;
|
||||
|
||||
static {
|
||||
EMPTY.escapes = EMPTY.closed = true;
|
||||
}
|
||||
|
||||
private final Varargs varargs;
|
||||
|
||||
private volatile boolean closed;
|
||||
@@ -51,7 +46,7 @@ final class VarargArguments implements IArguments {
|
||||
}
|
||||
|
||||
static VarargArguments of(Varargs values) {
|
||||
return values == Constants.NONE ? EMPTY : new VarargArguments(values);
|
||||
return new VarargArguments(values);
|
||||
}
|
||||
|
||||
boolean isClosed() {
|
||||
@@ -138,9 +133,7 @@ final class VarargArguments implements IArguments {
|
||||
if (count < 0) throw new IllegalStateException("count cannot be negative");
|
||||
if (count == 0) return this;
|
||||
|
||||
var newArgs = varargs.subargs(count + 1);
|
||||
if (newArgs == Constants.NONE) return EMPTY;
|
||||
return new VarargArguments(newArgs, this, count);
|
||||
return new VarargArguments(varargs.subargs(count + 1), this, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -616,7 +616,8 @@ do
|
||||
end
|
||||
|
||||
local function parse_ident(str, pos)
|
||||
local _, last, val = find(str, '^([%a][%w_]*)', pos)
|
||||
local _, last, val = find(str, '^([%w_+.-]+)', pos)
|
||||
if not last then error_at(pos, "Expected object key") end
|
||||
return val, last + 1
|
||||
end
|
||||
|
||||
@@ -864,7 +865,7 @@ values do not serialise cleanly into JSON.
|
||||
A consequence of this is that an empty table will always be serialised to an object,
|
||||
not an array. [`textutils.empty_json_array`] may be used to express an empty array.
|
||||
|
||||
- Lua strings are an a sequence of raw bytes, and do not have any specific encoding.
|
||||
- Lua strings are a sequence of raw bytes, and do not have any specific encoding.
|
||||
However, JSON strings must be valid unicode. By default, non-ASCII characters in a
|
||||
string are serialised to their unicode code point (for instance, `"\xfe"` is
|
||||
converted to `"\u00fe"`). The `unicode_strings` option may be set to treat all input
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# New features in CC: Tweaked 1.116.2
|
||||
|
||||
Several bug fixes:
|
||||
* Update Create compatibility to Create Fabric 6.0.
|
||||
* Various documentation fixes (Zirunis).
|
||||
* Fix crash with Inventorio.
|
||||
* Various fixes to SNBT parsing.
|
||||
* Fix Regex DDoS in string pattern matching.
|
||||
|
||||
# New features in CC: Tweaked 1.116.1
|
||||
|
||||
* Update translations.
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
New features in CC: Tweaked 1.116.1
|
||||
New features in CC: Tweaked 1.116.2
|
||||
|
||||
* Update translations.
|
||||
|
||||
One bug fix:
|
||||
* Fix NPE when mcfunction files contain CC commands.
|
||||
Several bug fixes:
|
||||
* Update Create compatibility to Create Fabric 6.0.
|
||||
* Various documentation fixes (Zirunis).
|
||||
* Fix crash with Inventorio.
|
||||
* Various fixes to SNBT parsing.
|
||||
* Fix Regex DDoS in string pattern matching.
|
||||
|
||||
Type "help changelog" to see the full version history.
|
||||
|
||||
@@ -8,8 +8,8 @@ Convert between streams of DFPWM audio data and a list of amplitudes.
|
||||
DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec designed by GreaseMonkey. It's a relatively compact
|
||||
format compared to raw PCM data, only using 1 bit per sample, but is simple enough to encode and decode in real time.
|
||||
|
||||
Typically DFPWM audio is read from [the filesystem][`fs.ReadHandle`] or a [a web request][`http.Response`] as a string,
|
||||
and converted a format suitable for [`speaker.playAudio`].
|
||||
Typically DFPWM audio is read from [the filesystem][`fs.ReadHandle`] or [a web request][`http.Response`] as a string,
|
||||
and converted to a format suitable for [`speaker.playAudio`].
|
||||
|
||||
## Encoding and decoding files
|
||||
This module exposes two key functions, [`make_decoder`] and [`make_encoder`], which construct a new decoder or encoder.
|
||||
|
||||
@@ -10,6 +10,7 @@ import dan200.computercraft.core.computer.ComputerSide;
|
||||
import dan200.computercraft.core.methods.LuaMethod;
|
||||
import dan200.computercraft.core.methods.NamedMethod;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
@@ -123,6 +124,17 @@ public class GeneratorTest {
|
||||
assertThrows(LuaException.class, () -> apply(methods, new EnumMethods(), "getEnum", "not as side"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLuaTable() throws LuaException {
|
||||
var methods = GENERATOR.getMethods(TableMethods.class);
|
||||
assertThat(methods, containsInAnyOrder(named("getTable"), named("optTable")));
|
||||
|
||||
assertThat(apply(methods, new TableMethods(), "getTable", Map.of("x", "y")), one(is(Map.of("x", "y"))));
|
||||
assertThat(apply(methods, new TableMethods(), "optTable", Map.of("x", "y")), one(is(Map.of("x", "y"))));
|
||||
assertThat(apply(methods, new TableMethods(), "optTable"), one(nullValue()));
|
||||
assertThrows(LuaException.class, () -> apply(methods, new TableMethods(), "getTable", "not a table"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMainThread() throws LuaException {
|
||||
var methods = GENERATOR.getMethods(MainThread.class);
|
||||
@@ -277,6 +289,18 @@ public class GeneratorTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TableMethods {
|
||||
@LuaFunction
|
||||
public final LuaTable<?, ?> getTable(LuaTable<?, ?> table) {
|
||||
return table;
|
||||
}
|
||||
|
||||
@LuaFunction
|
||||
public final @Nullable LuaTable<?, ?> optTable(Optional<LuaTable<?, ?>> table) {
|
||||
return table.orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MainThread {
|
||||
@LuaFunction(mainThread = true)
|
||||
public final void go() {
|
||||
@@ -288,10 +312,6 @@ public class GeneratorTest {
|
||||
public final void withUnsafe(LuaTable<?, ?> table) {
|
||||
}
|
||||
|
||||
@LuaFunction
|
||||
public final void withoutUnsafe(LuaTable<?, ?> table) {
|
||||
}
|
||||
|
||||
@LuaFunction(unsafe = true, mainThread = true)
|
||||
public final void invalid(LuaTable<?, ?> table) {
|
||||
}
|
||||
|
||||
@@ -246,11 +246,25 @@ describe("The textutils library", function()
|
||||
describe("parses using NBT-style syntax", function()
|
||||
local function exp(x)
|
||||
local res, err = textutils.unserializeJSON(x, { nbt_style = true })
|
||||
if not res then error(err, 2) end
|
||||
if not res then fail(err) end
|
||||
return expect(res)
|
||||
end
|
||||
|
||||
local function exp_err(x)
|
||||
local res, err = textutils.unserializeJSON(x, { nbt_style = true })
|
||||
if res ~= nil then
|
||||
fail(("Expected %q not to parse, but returned %s"):format(x, textutils.serialise(res)))
|
||||
end
|
||||
return expect(err)
|
||||
end
|
||||
|
||||
it("basic objects", function()
|
||||
exp([[{ a: 1, b:2 }]]):same { a = 1, b = 2 }
|
||||
exp("{ a: 1, b:2 }"):same { a = 1, b = 2 }
|
||||
exp("{0+_-.aA: 1}"):same { ["0+_-.aA"] = 1 }
|
||||
exp("{}"):same {}
|
||||
|
||||
exp_err("{: 123}"):eq("Malformed JSON at position 2: Expected object key")
|
||||
exp_err("{#: 123}"):eq("Malformed JSON at position 2: Expected object key")
|
||||
end)
|
||||
|
||||
it("suffixed numbers", function()
|
||||
@@ -258,9 +272,21 @@ describe("The textutils library", function()
|
||||
exp("1.1d"):eq(1.1)
|
||||
end)
|
||||
|
||||
it("strings", function()
|
||||
exp("'123'"):eq("123")
|
||||
exp("\"123\""):eq("123")
|
||||
describe("strings", function()
|
||||
it("empty quoted strings", function()
|
||||
exp("''"):eq("")
|
||||
exp("\"\""):eq("")
|
||||
end)
|
||||
|
||||
pending("unquoted strings", function()
|
||||
exp("hello"):eq("hello")
|
||||
exp("0+_-.aA"):eq("0+_-.aA")
|
||||
end)
|
||||
|
||||
it("quoted strings", function()
|
||||
exp("'123'"):eq("123")
|
||||
exp("\"123\""):eq("123")
|
||||
end)
|
||||
end)
|
||||
|
||||
it("typed arrays", function()
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.DisplayNameGeneration;
|
||||
import org.junit.jupiter.api.DisplayNameGenerator;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@link DisplayNameGenerator} which replaces underscores with spaces. This is equivalent to
|
||||
@@ -17,7 +18,7 @@ import java.lang.reflect.Method;
|
||||
*/
|
||||
public class ReplaceUnderscoresDisplayNameGenerator extends DisplayNameGenerator.ReplaceUnderscores {
|
||||
@Override
|
||||
public String generateDisplayNameForMethod(Class<?> testClass, Method testMethod) {
|
||||
public String generateDisplayNameForMethod(List<Class<?>> enclosingInstanceTypes, Class<?> testClass, Method testMethod) {
|
||||
return testMethod.getName().replace('_', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ configurations {
|
||||
val localImplementation by registering {
|
||||
isCanBeResolved = false
|
||||
isCanBeConsumed = false
|
||||
isVisible = false
|
||||
}
|
||||
compileClasspath { extendsFrom(localImplementation.get()) }
|
||||
runtimeClasspath { extendsFrom(localImplementation.get()) }
|
||||
@@ -118,7 +117,6 @@ dependencies {
|
||||
|
||||
loom {
|
||||
accessWidenerPath = project(":common").file("src/main/resources/computercraft.accesswidener")
|
||||
mixin.useLegacyMixinAp = false
|
||||
|
||||
mods {
|
||||
register("computercraft") {
|
||||
|
||||
@@ -39,11 +39,11 @@ public class FabricDataProviders implements DataGeneratorEntrypoint {
|
||||
private record PlatformGeneratorsImpl(
|
||||
FabricDataGenerator.Pack generator, CompletableFuture<HolderLookup.Provider> registries
|
||||
) implements DataProviders.GeneratorSink {
|
||||
public <T extends DataProvider> T addWithFabricOutput(FabricDataGenerator.Pack.Factory<T> factory) {
|
||||
private <T extends DataProvider> T addWithFabricOutput(FabricDataGenerator.Pack.Factory<T> factory) {
|
||||
return generator.addProvider((FabricDataOutput p) -> new PrettyDataProvider<>(factory.create(p))).provider();
|
||||
}
|
||||
|
||||
public <T extends DataProvider> T addWithRegistries(FabricDataGenerator.Pack.RegistryDependentFactory<T> factory) {
|
||||
private <T extends DataProvider> T addWithRegistries(FabricDataGenerator.Pack.RegistryDependentFactory<T> factory) {
|
||||
return generator.addProvider((r, p) -> new PrettyDataProvider<>(factory.create(r, p))).provider();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
package dan200.computercraft.shared.integration;
|
||||
|
||||
import com.simibubi.create.content.contraptions.BlockMovementChecks;
|
||||
import com.simibubi.create.content.contraptions.BlockMovementChecks.CheckResult;
|
||||
import com.simibubi.create.api.contraption.BlockMovementChecks;
|
||||
import com.simibubi.create.api.contraption.BlockMovementChecks.CheckResult;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableBlock;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemBlock;
|
||||
|
||||
|
||||
@@ -147,7 +147,6 @@ configurations {
|
||||
val localImplementation by registering {
|
||||
isCanBeResolved = false
|
||||
isCanBeConsumed = false
|
||||
isVisible = false
|
||||
}
|
||||
compileClasspath { extendsFrom(localImplementation.get()) }
|
||||
runtimeClasspath { extendsFrom(localImplementation.get()) }
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
import cc.tweaked.gradle.CCTweakedPlugin
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("cc-tweaked.java-convention")
|
||||
@@ -29,6 +31,8 @@ dependencies {
|
||||
testRuntimeOnly(libs.bundles.testRuntime)
|
||||
}
|
||||
|
||||
kotlin.compilerOptions.jvmTarget = CCTweakedPlugin.KOTLIN_TARGET
|
||||
|
||||
tasks.test {
|
||||
jvmArgs(
|
||||
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
|
||||
@@ -19,6 +19,7 @@ import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.commons.cli.help.HelpFormatter;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -31,9 +32,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@@ -70,10 +70,10 @@ public class Main {
|
||||
}
|
||||
|
||||
private record TermSize(int width, int height) {
|
||||
public static final TermSize DEFAULT = new TermSize(51, 19);
|
||||
public static final Pattern PATTERN = Pattern.compile("^(\\d+)x(\\d+)$");
|
||||
private static final TermSize DEFAULT = new TermSize(51, 19);
|
||||
private static final Pattern PATTERN = Pattern.compile("^(\\d+)x(\\d+)$");
|
||||
|
||||
public static TermSize parse(String value) throws ParseException {
|
||||
private static TermSize parse(String value) throws ParseException {
|
||||
var matcher = TermSize.PATTERN.matcher(value);
|
||||
if (!matcher.matches()) throw new ParseException("'" + value + "' is not a valid terminal size.");
|
||||
|
||||
@@ -82,9 +82,9 @@ public class Main {
|
||||
}
|
||||
|
||||
private record MountPaths(Path src, String dest) {
|
||||
public static final Pattern PATTERN = Pattern.compile("^([^:]+):([^:]+)$");
|
||||
private static final Pattern PATTERN = Pattern.compile("^([^:]+):([^:]+)$");
|
||||
|
||||
public static MountPaths parse(String value) throws ParseException {
|
||||
private static MountPaths parse(String value) throws ParseException {
|
||||
var matcher = MountPaths.PATTERN.matcher(value);
|
||||
if (!matcher.matches()) throw new ParseException("'" + value + "' is not a mount spec.");
|
||||
|
||||
@@ -115,26 +115,26 @@ public class Main {
|
||||
Option resourceOpt, computerOpt, termSizeOpt, allowLocalDomainsOpt, helpOpt, mountOpt, mountRoOpt;
|
||||
options.addOption(resourceOpt = Option.builder("r").argName("PATH").longOpt("resources").hasArg()
|
||||
.desc("The path to the resources directory")
|
||||
.build());
|
||||
.get());
|
||||
options.addOption(computerOpt = Option.builder("c").argName("PATH").longOpt("computer").hasArg()
|
||||
.desc("The root directory of the computer. Defaults to a temporary directory.")
|
||||
.build());
|
||||
.get());
|
||||
options.addOption(termSizeOpt = Option.builder("t").argName("WIDTHxHEIGHT").longOpt("term-size").hasArg()
|
||||
.desc("The size of the terminal, defaults to 51x19.")
|
||||
.build());
|
||||
.get());
|
||||
options.addOption(allowLocalDomainsOpt = Option.builder("L").longOpt("allow-local-domains")
|
||||
.desc("Allow accessing local domains with the HTTP API.")
|
||||
.build());
|
||||
.get());
|
||||
options.addOption(mountOpt = Option.builder().longOpt("mount").hasArg().argName("SRC:DEST")
|
||||
.desc("Mount a folder SRC at directory DEST on the computer.")
|
||||
.build());
|
||||
.get());
|
||||
options.addOption(mountRoOpt = Option.builder().longOpt("mount-ro").hasArg().argName("SRC:DEST")
|
||||
.desc("Mount a read-only folder SRC at directory DEST on the computer.")
|
||||
.build());
|
||||
.get());
|
||||
|
||||
options.addOption(helpOpt = Option.builder("h").longOpt("help")
|
||||
.desc("Print help message")
|
||||
.build());
|
||||
.get());
|
||||
|
||||
Path resourcesDirectory;
|
||||
Path computerDirectory;
|
||||
@@ -144,7 +144,11 @@ public class Main {
|
||||
try {
|
||||
var cli = new DefaultParser().parse(options, args);
|
||||
if (cli.hasOption(helpOpt)) {
|
||||
new HelpFormatter().printHelp("standalone.jar", options, true);
|
||||
try {
|
||||
HelpFormatter.builder().get().printHelp("standalone.jar", "", options, "", true);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!cli.hasOption(resourceOpt)) throw new ParseException("--resources directory is required");
|
||||
@@ -157,10 +161,7 @@ public class Main {
|
||||
readOnlyMounts = getParsedOptionValues(cli, mountRoOpt, MountPaths::parse);
|
||||
} catch (ParseException e) {
|
||||
System.err.println(e.getLocalizedMessage());
|
||||
|
||||
var writer = new PrintWriter(System.err, false, StandardCharsets.UTF_8);
|
||||
new HelpFormatter().printUsage(writer, HelpFormatter.DEFAULT_WIDTH, "standalone.jar", options);
|
||||
writer.flush();
|
||||
System.err.println(HelpFormatter.builder().get().toSyntaxOptions(options));
|
||||
|
||||
System.exit(1);
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.jspecify.annotations.Nullable;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
|
||||
@@ -38,7 +39,7 @@ public class TransformingClassLoader extends ClassLoader {
|
||||
private final Map<String, Path> remappedResources = new HashMap<>();
|
||||
private final List<BiFunction<String, ClassVisitor, ClassVisitor>> transformers = new ArrayList<>();
|
||||
|
||||
private final Remapper remapper = new Remapper() {
|
||||
private final Remapper remapper = new Remapper(Opcodes.ASM9) {
|
||||
@Override
|
||||
public String map(String internalName) {
|
||||
return remappedClasses.getOrDefault(internalName, internalName);
|
||||
|
||||
@@ -187,9 +187,9 @@ class EmulatedComputer implements ComputerEnvironment, ComputerHandle {
|
||||
public void addFile(String path, JSObject contents) {
|
||||
byte[] bytes;
|
||||
if (JavascriptConv.isArrayBuffer(contents)) {
|
||||
bytes = bytesOfBuffer(contents.cast());
|
||||
bytes = bytesOfBuffer((ArrayBuffer) contents);
|
||||
} else {
|
||||
JSString string = contents.cast();
|
||||
var string = (JSString) contents;
|
||||
bytes = string.stringValue().getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class THttpRequest extends Resource<THttpRequest> {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayBuffer buffer = request.getResponse().cast();
|
||||
var buffer = (ArrayBuffer) request.getResponse();
|
||||
SeekableByteChannel contents = new ArrayByteChannel(JavascriptConv.asByteArray(buffer));
|
||||
var reader = new ReadHandle(contents, binary);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ pluginManagement {
|
||||
content {
|
||||
includeGroup("fabric-loom")
|
||||
includeGroup("net.fabricmc")
|
||||
includeGroup("net.fabricmc.unpick")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user