1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-04 23:40:00 +00:00

Merge branch 'mc-1.20.x' into mc-1.21.x

This commit is contained in:
Jonathan Coates 2024-06-29 10:50:44 +01:00
commit aca1d43550
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
21 changed files with 145 additions and 128 deletions

View File

@ -8,10 +8,8 @@ body:
label: Minecraft Version
description: What version of Minecraft are you using?
options:
- 1.16.x
- 1.18.x
- 1.19.x
- 1.20.x
- 1.20.1
- 1.21.x
validations:
required: true
- type: input

View File

@ -39,7 +39,7 @@ on is present.
```groovy
repositories {
maven {
url "https://squiddev.cc/maven/"
url "https://maven.squiddev.cc"
content {
includeGroup("cc.tweaked")
}

View File

@ -32,7 +32,7 @@ repositories {
}
}
maven("https://squiddev.cc/maven") {
maven("https://maven.squiddev.cc") {
name = "SquidDev"
content {
includeGroup("cc.tweaked.vanilla-extract")

View File

@ -38,7 +38,7 @@ java {
repositories {
mavenCentral()
val mainMaven = maven("https://squiddev.cc/maven") {
val mainMaven = maven("https://maven.squiddev.cc/mirror") {
name = "SquidDev"
}
@ -133,8 +133,8 @@ tasks.processResources {
tasks.withType(AbstractArchiveTask::class.java).configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = Integer.valueOf("755", 8)
fileMode = Integer.valueOf("664", 8)
filePermissions {}
dirPermissions {}
}
tasks.jar {

View File

@ -38,7 +38,7 @@ publishing {
}
repositories {
maven("https://squiddev.cc/maven") {
maven("https://maven.squiddev.cc") {
name = "SquidDev"
credentials(PasswordCredentials::class)

View File

@ -25,13 +25,13 @@ as documentation for breaking changes and "gotchas" one should look out for betw
- Update to Lua 5.2:
- Support for Lua 5.0's pseudo-argument `arg` has been removed. You should always use `...` for varargs.
- Environments are no longer baked into the runtime, and instead use the `_ENV` local or upvalue. `getfenv`/`setfenv`
now only work on Lua functions with an `_ENV` upvalue. `getfenv` will return the global environment when called
with other functions, and `setfenv` will have no effect.
- `load`/`loadstring` defaults to using the global environment (`_G`) rather than the current coroutine's
- Environments are no longer baked into the runtime, and instead use the `_ENV` local or upvalue. [`getfenv`]/[`setfenv`]
now only work on Lua functions with an `_ENV` upvalue. [`getfenv`] will return the global environment when called
with other functions, and [`setfenv`] will have no effect.
- [`load`]/[`loadstring`] defaults to using the global environment (`_G`) rather than the current coroutine's
environment.
- Support for dumping functions (`string.dump`) and loading binary chunks has been removed.
- `math.random` now uses Lua 5.4's random number generator.
- Support for dumping functions ([`string.dump`]) and loading binary chunks has been removed.
- [`math.random`] now uses Lua 5.4's random number generator.
- File handles, HTTP requests and websockets now always use the original bytes rather than encoding/decoding to UTF-8.
@ -44,7 +44,7 @@ as documentation for breaking changes and "gotchas" one should look out for betw
`keys.enter` constant was queued when the key was pressed)
- Minecraft 1.13 removed the concept of item damage and block metadata (see ["The Flattening"][flattening]). As a
result `turtle.inspect` no longer provides block metadata, and `turtle.getItemDetail` no longer provides damage.
result [`turtle.inspect`] no longer provides block metadata, and [`turtle.getItemDetail`] no longer provides damage.
- Block states (`turtle.inspect().state`) should provide all the same information as block metadata, but in a much
more understandable format.
@ -70,7 +70,7 @@ as documentation for breaking changes and "gotchas" one should look out for betw
- Unlabelled computers and turtles now keep their ID when broken, meaning that unlabelled computers/items do not stack.
## ComputerCraft 1.80pr1 {#cc-1.80}
- Programs run via `shell.run` are now started in their own isolated environment. This means globals set by programs
- Programs run via [`shell.run`] are now started in their own isolated environment. This means globals set by programs
will not be accessible outside of this program.
- Programs containing `/` are looked up in the current directory and are no longer looked up on the path. For instance,

View File

@ -60,7 +60,7 @@ checkstyle = "10.14.1"
curseForgeGradle = "1.1.18"
errorProne-core = "2.27.0"
errorProne-plugin = "3.1.0"
fabric-loom = "1.6.7"
fabric-loom = "1.7.1"
githubRelease = "2.5.2"
gradleVersions = "0.50.0"
ideaExt = "1.1.7"
@ -71,7 +71,7 @@ neoGradle = "7.0.145"
nullAway = "0.10.25"
spotless = "6.23.3"
taskTree = "2.1.1"
teavm = "0.10.0-SQUID.4"
teavm = "0.11.0-SQUID.1"
vanillaExtract = "0.1.3"
versionCatalogUpdate = "0.8.1"

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

2
gradlew vendored
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/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/.

View File

@ -7,7 +7,6 @@ package dan200.computercraft.shared.computer.core;
import com.google.common.annotations.VisibleForTesting;
import dan200.computercraft.api.filesystem.FileOperationException;
import dan200.computercraft.core.filesystem.ArchiveMount;
import dan200.computercraft.core.filesystem.FileSystem;
import net.minecraft.ResourceLocationException;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
@ -65,9 +64,10 @@ public final class ResourceMount extends ArchiveMount<ResourceMount.FileEntry> {
existingNamespace = file.getNamespace();
if (!file.getNamespace().equals(namespace)) continue;
if (!FileSystem.contains(subPath, file.getPath())) continue; // Some packs seem to include the parent?
var localPath = FileSystem.toLocal(file.getPath(), subPath);
var localPath = getLocalPath(file.getPath(), subPath);
if (localPath == null) continue;
try {
getOrCreateChild(newRoot, localPath, this::createEntry);
} catch (ResourceLocationException e) {

View File

@ -1,38 +1,37 @@
{
"parent": "block/block",
"textures": {
"particle": "computercraft:block/turtle_rainbow_overlay",
"texture": "computercraft:block/turtle_rainbow_overlay"
},
"elements": [
{
"name": "Flag",
"from": [1.5, 13, 10.5],
"to": [2, 16.5, 15.5],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [0, 0, 1, 6], "texture": "#texture"},
"east": {"uv": [0, 0, 7, 6], "texture": "#texture"},
"south": {"uv": [0, 0, 1, 6], "texture": "#texture"},
"west": {"uv": [0, 0, 7, 6], "texture": "#texture"},
"up": {"uv": [15, 0, 16, 6], "texture": "#texture"},
"down": {"uv": [8, 0, 9, 6], "texture": "#texture"}
}
},
{
"name": "Stick",
"from": [1.5, 10.5, 10.5],
"to": [2, 13, 11],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"east": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"south": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"west": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"up": {"uv": [12, 6, 13, 7], "texture": "#texture"},
"down": {"uv": [13, 6, 14, 7], "texture": "#texture"}
}
}
],
"display": {}
"parent": "block/block",
"textures": {
"particle": "computercraft:block/turtle_rainbow_overlay",
"texture": "computercraft:block/turtle_rainbow_overlay"
},
"elements": [
{
"name": "Flag",
"from": [1.5, 13.5, 10.5],
"to": [2, 16.5, 15.5],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [0, 0, 1, 6], "texture": "#texture"},
"east": {"uv": [0, 0, 7, 6], "texture": "#texture"},
"south": {"uv": [0, 0, 1, 6], "texture": "#texture"},
"west": {"uv": [0, 0, 7, 6], "texture": "#texture"},
"up": {"uv": [15, 0, 16, 6], "texture": "#texture"},
"down": {"uv": [8, 0, 9, 6], "texture": "#texture"}
}
},
{
"name": "Stick",
"from": [1.5, 10.5, 10.5],
"to": [2, 13.5, 11],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"east": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"south": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"west": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"up": {"uv": [12, 6, 13, 7], "texture": "#texture"},
"down": {"uv": [13, 6, 14, 7], "texture": "#texture"}
}
}
]
}

View File

@ -1,38 +1,37 @@
{
"parent": "block/block",
"textures": {
"particle": "computercraft:block/turtle_trans_overlay",
"texture": "computercraft:block/turtle_trans_overlay"
},
"elements": [
{
"name": "Flag",
"from": [1.5, 13.5, 10.5],
"to": [2, 16.5, 15.5],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [0, 0, 1, 5], "texture": "#texture"},
"east": {"uv": [0, 0, 7, 5], "texture": "#texture"},
"south": {"uv": [0, 0, 1, 5], "texture": "#texture"},
"west": {"uv": [0, 0, 7, 5], "texture": "#texture"},
"up": {"uv": [15, 0, 16, 5], "texture": "#texture"},
"down": {"uv": [15, 0, 16, 5], "texture": "#texture"}
}
},
{
"name": "Stick",
"from": [1.5, 10.5, 10.5],
"to": [2, 13.5, 11],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"east": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"south": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"west": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"up": {"uv": [12, 6, 13, 7], "texture": "#texture"},
"down": {"uv": [13, 6, 14, 7], "texture": "#texture"}
}
}
],
"display": {}
"parent": "block/block",
"textures": {
"particle": "computercraft:block/turtle_trans_overlay",
"texture": "computercraft:block/turtle_trans_overlay"
},
"elements": [
{
"name": "Flag",
"from": [1.5, 13.5, 10.5],
"to": [2, 16, 15.5],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [0, 0, 1, 5], "texture": "#texture"},
"east": {"uv": [0, 0, 7, 5], "texture": "#texture"},
"south": {"uv": [0, 0, 1, 5], "texture": "#texture"},
"west": {"uv": [0, 0, 7, 5], "texture": "#texture"},
"up": {"uv": [15, 0, 16, 5], "texture": "#texture"},
"down": {"uv": [15, 0, 16, 5], "texture": "#texture"}
}
},
{
"name": "Stick",
"from": [1.5, 10.5, 10.5],
"to": [2, 13.5, 11],
"rotation": {"angle": 22.5, "axis": "x", "origin": [2, 11, 10.75]},
"faces": {
"north": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"east": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"south": {"uv": [12, 0, 13, 6], "texture": "#texture"},
"west": {"uv": [13, 0, 14, 6], "texture": "#texture"},
"up": {"uv": [12, 6, 13, 7], "texture": "#texture"},
"down": {"uv": [13, 6, 14, 7], "texture": "#texture"}
}
}
]
}

View File

@ -175,9 +175,9 @@ public class OSAPI implements ILuaAPI {
}
/**
* Sets an alarm that will fire at the specified in-game time. When it
* fires, * an {@code alarm} event will be added to the event queue with the
* ID * returned from this function as the first parameter.
* Sets an alarm that will fire at the specified {@linkplain #time(IArguments) in-game time}.
* When it fires, an {@code alarm} event will be added to the event queue with the
* ID returned from this function as the first parameter.
*
* @param time The time at which to fire the alarm, in the range [0.0, 24.0).
* @return The ID of the new alarm. This can be used to filter the

View File

@ -5,6 +5,7 @@
package dan200.computercraft.core.computer.computerthread;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.Keep;
import dan200.computercraft.core.ComputerContext;
import dan200.computercraft.core.Logging;
import dan200.computercraft.core.computer.TimeoutState;
@ -774,6 +775,7 @@ public final class ComputerThread implements ComputerScheduler {
/**
* The current state of this worker.
*/
@Keep
private volatile ExecutorState $state = ExecutorState.IDLE;
/**
@ -784,6 +786,7 @@ public final class ComputerThread implements ComputerScheduler {
* {@linkplain #afterWork()} finishes executing, we set this back to null and compute the difference between the
* two, updating the {@link Metrics#JAVA_ALLOCATION} metric.
*/
@Keep
private volatile @Nullable ThreadAllocation $threadAllocation = null;
/**

View File

@ -8,6 +8,7 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import dan200.computercraft.core.apis.handles.ArrayByteChannel;
import javax.annotation.Nullable;
import java.io.IOException;
import java.nio.channels.SeekableByteChannel;
import java.util.concurrent.TimeUnit;
@ -82,6 +83,24 @@ public abstract class ArchiveMount<T extends ArchiveMount.FileEntry<T>> extends
*/
protected abstract byte[] getFileContents(String path, T file) throws IOException;
/**
* Convert an absolute path to one relative to {@code root}. If this path is not a child of {@code root}, return
* {@code null}.
*
* @param path The full path.
* @param root The root directory to be relative to.
* @return The relativised path, or {@code null}.
*/
protected static @Nullable String getLocalPath(String path, String root) {
// Some packs seem to include files not under the root, so drop them immediately.
if (!path.startsWith(root)) return null;
if (path.length() == root.length()) return "";
if (path.charAt(root.length()) != '/') return null;
return path.substring(root.length() + 1);
}
protected static class FileEntry<T extends FileEntry<T>> extends AbstractInMemoryMount.FileEntry<T> {
long size = -1;
}

View File

@ -224,11 +224,11 @@ public class FileSystem {
public synchronized void copy(String sourcePath, String destPath) throws FileSystemException {
sourcePath = sanitizePath(sourcePath);
destPath = sanitizePath(destPath);
if (isReadOnly(destPath)) throw new FileSystemException("/" + destPath + ": " + ACCESS_DENIED);
if (!exists(sourcePath)) throw new FileSystemException("/" + sourcePath + ": " + NO_SUCH_FILE);
if (exists(destPath)) throw new FileSystemException("/" + destPath + ": " + FILE_EXISTS);
if (isReadOnly(destPath)) throw new FileSystemException(destPath, ACCESS_DENIED);
if (!exists(sourcePath)) throw new FileSystemException(sourcePath, NO_SUCH_FILE);
if (exists(destPath)) throw new FileSystemException(destPath, FILE_EXISTS);
if (contains(sourcePath, destPath)) {
throw new FileSystemException("/" + sourcePath + ": Can't copy a directory inside itself");
throw new FileSystemException(sourcePath, "Can't copy a directory inside itself");
}
copyRecursive(sourcePath, getMount(sourcePath), destPath, getMount(destPath), 0);
}
@ -341,7 +341,7 @@ public class FileSystem {
}
}
if (match == null) {
throw new FileSystemException("/" + path + ": Invalid Path");
throw new FileSystemException(path, "Invalid Path");
}
return match;
}
@ -404,7 +404,7 @@ public class FileSystem {
return String.join("/", outputParts);
}
public static boolean contains(String pathA, String pathB) {
private static boolean contains(String pathA, String pathB) {
pathA = sanitizePath(pathA).toLowerCase(Locale.ROOT);
pathB = sanitizePath(pathB).toLowerCase(Locale.ROOT);
@ -421,7 +421,7 @@ public class FileSystem {
}
}
public static String toLocal(String path, String location) {
static String toLocal(String path, String location) {
path = sanitizePath(path);
location = sanitizePath(location);

View File

@ -13,8 +13,12 @@ public class FileSystemException extends Exception {
@Serial
private static final long serialVersionUID = -2500631644868104029L;
FileSystemException(String s) {
super(s);
FileSystemException(String message) {
super(message);
}
FileSystemException(String path, String message) {
this("/" + path + ": " + message);
}
public static FileSystemException of(IOException e) {

View File

@ -49,10 +49,9 @@ public final class JarMount extends ArchiveMount<JarMount.FileEntry> implements
while (zipEntries.hasMoreElements()) {
var entry = zipEntries.nextElement();
var entryPath = entry.getName();
if (!entryPath.startsWith(subPath)) continue;
var localPath = getLocalPath(entry.getName(), subPath);
if (localPath == null) continue;
var localPath = FileSystem.toLocal(entryPath, subPath);
getOrCreateChild(root, localPath, x -> new FileEntry()).setup(entry);
}
}

View File

@ -129,7 +129,7 @@ class MountWrapper {
}
public void makeDirectory(String path) throws FileSystemException {
if (writableMount == null) throw exceptionOf(path, ACCESS_DENIED);
if (writableMount == null) throw new FileSystemException(path, ACCESS_DENIED);
path = toLocal(path);
try {
@ -140,7 +140,7 @@ class MountWrapper {
}
public void delete(String path) throws FileSystemException {
if (writableMount == null) throw exceptionOf(path, ACCESS_DENIED);
if (writableMount == null) throw new FileSystemException(path, ACCESS_DENIED);
path = toLocal(path);
try {
@ -151,7 +151,7 @@ class MountWrapper {
}
public void rename(String source, String dest) throws FileSystemException {
if (writableMount == null) throw exceptionOf(source, ACCESS_DENIED);
if (writableMount == null) throw new FileSystemException(source, ACCESS_DENIED);
source = toLocal(source);
dest = toLocal(dest);
@ -168,7 +168,7 @@ class MountWrapper {
}
public SeekableByteChannel openForWrite(String path, Set<OpenOption> options) throws FileSystemException {
if (writableMount == null) throw exceptionOf(path, ACCESS_DENIED);
if (writableMount == null) throw new FileSystemException(path, ACCESS_DENIED);
path = toLocal(path);
try {
@ -206,10 +206,6 @@ class MountWrapper {
private FileSystemException localExceptionOf(String path, String message) {
if (!location.isEmpty()) path = path.isEmpty() ? location : location + "/" + path;
return exceptionOf(path, message);
}
private static FileSystemException exceptionOf(String path, String message) {
return new FileSystemException("/" + path + ": " + message);
return new FileSystemException(path, message);
}
}

View File

@ -360,13 +360,13 @@ public class Main {
// And our VBA
var termVertexArray = gl.createVertexArray("Terminal VAO");
glEnableVertexArrayAttrib(termVertexArray, 0);
glVertexArrayAttribFormat(termVertexArray, 0, 2, GL_FLOAT, false, 0); // Position
glEnableVertexArrayAttrib(termVertexArray, 1);
glVertexArrayAttribFormat(termVertexArray, 1, 2, GL_FLOAT, false, 8); // UV
glEnableVertexArrayAttrib(termVertexArray, ATTRIBUTE_POSITION);
glVertexArrayAttribFormat(termVertexArray, ATTRIBUTE_POSITION, 2, GL_FLOAT, false, 0); // Position
glEnableVertexArrayAttrib(termVertexArray, ATTRIBUTE_UV);
glVertexArrayAttribFormat(termVertexArray, ATTRIBUTE_UV, 2, GL_FLOAT, false, 8); // UV
// FIXME: Can we merge this into one call?
glVertexArrayVertexBuffer(termVertexArray, 0, termVertices, 0, 16);
glVertexArrayVertexBuffer(termVertexArray, 1, termVertices, 0, 16);
glVertexArrayVertexBuffer(termVertexArray, ATTRIBUTE_POSITION, termVertices, 0, 16);
glVertexArrayVertexBuffer(termVertexArray, ATTRIBUTE_UV, termVertices, 0, 16);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

View File

@ -27,7 +27,7 @@ pluginManagement {
}
}
maven("https://squiddev.cc/maven") {
maven("https://maven.squiddev.cc") {
name = "SquidDev"
content {
includeGroup("cc.tweaked.vanilla-extract")