1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2026-05-31 01:42:06 +00:00
Commit Graph

315 Commits

Author SHA1 Message Date
Jonathan Coates 4a6ec54813 Remove "CC may be installed incorrectly" message
It /technically/ may be the case, but in the days of modern mod loaders,
much less likely. Normally this is user error.

Closes #2372.
2026-01-25 09:39:13 +00:00
Jonathan Coates d5e0b0ad2a Bump CC:T to 1.117.0
A day early, but my commitment to the bit is waning.
2025-12-24 09:07:02 +00:00
Jonathan Coates 24fd27d2a3 Add test for potion durations 2025-12-24 08:51:15 +00:00
Jonathan Coates 90e7307fb4 Fix websocket_closed not always being queued on failure
- Reorganise the HTTP test code to make it a bit more extensible. Add
   support for sending messages to connected websockets.
 - Provide a friendlier message for too-large-payload errors.
 - Return failure reason from Websocket.receive

Fixes #2149.
2025-12-19 21:12:37 +00:00
Jonathan Coates 1520bebb6c Simplify event code in LuaTaskContext
We remove support for multiple event listeners, and now just use a
simple event queue again. This makes the code a little simpler, and
removes the risk of race conditions where we do do something, and it
queues the event before we call pullEvent().
2025-12-19 21:12:31 +00:00
Jonathan Coates f820cd8b43 Rewrite the GPS setup guide
Mostly trying to avoid the number of asides, to make it a bit more
straightforward. I'm not entirely sure I succeeded.

Fixes #1681, closes #1542.
2025-12-18 13:30:12 +00:00
Jonathan Coates 4b1541154b Add Websocket.getResponseHeaders method
Closes #1387
2025-12-17 23:11:12 +00:00
Jonathan Coates 7659c608a6 Dynamically pick the port in HTTP tests 2025-12-17 14:03:38 +00:00
Jonathan Coates f31d8febbf Handle more of Windows's weird paths
AFAICT, any sequence of ".[ .]*" (except from "") is equivalent to "."
on Windows. Let's handle that in our path sanitisation code.

Fixes #2151.
2025-12-15 23:48:54 +00:00
Jonathan Coates ff9f038275 Another build tooling bump
- Update to latest MDG, to avoid decompiling Minecraft in CI.
 - Fix several Gradle warnings.
 - Bump ErrorProne, and fix a few more nits.
2025-12-15 12:42:38 +00:00
Jonathan Coates 28682aa468 Rewrite computer input handling (again)
Hey, it lasted almost a year!

Computer input is somewhat stateful, as we need to track things like
which key(s) are currently held, and what the last mouse button/position
was. This code is currently duplicated in several places (specifically
TerminalWidget, ServerInputState and the standalone emulator).

In order to implement lectern pocket computer mouse interactions, we'd
have to duplicate this logic once again. Instead, we move this code into
a common class.

 - Replace the InputHandler interface with a simpler ComputerInput one
   (this no longer has computer actions, like reboot or terminate). This
   interface never made much sense (aside from hiding implementation
   details), as code only ever consumed a single implementation of it.

   On the client, this requires a new "ClientComputerActions" class.
   This feels a bit clunky to me, but it's simple and it works.

 - Replace ComputerEvents with a EventComputerInput class (terrible
   name, I know!), which queues events on a computer.

 - Move common input state tracking and validation into a single
   UserComputerInput class, which wraps an existing ComputerInput. This
   is used by both the terminal widget, and the server-side input state.
2025-12-14 16:53:18 +00:00
Jonathan Coates 2a35d17906 Clarify behaviour around drawImage cursor 2025-12-09 23:15:45 +00:00
Tomodachi94 61e9626302 Retroactively document changes to os.version() (#2323) 2025-11-23 13:49:55 +00:00
JackMacWindows 307bebd5d2 Fix missing return value docs in shell.openTab (#2333) 2025-11-22 08:16:58 +00:00
Jonathan Coates 18f3426f1d Bump CC:T to 1.116.2 2025-11-01 19:40:52 +00:00
Jonathan Coates 569de7fafb Update to Gradle 9.2
- Update to Loom 1.12. This requires Java 21, so we now build with Java
   21, but targetting 17. The new "-release" flag does make this much
   easier, so hopefully shouldn't cause too many issues.

 - Bump versions of a lot of other things.

 - Fix various errorprone/checkstyle grumbles.
2025-10-31 19:50:44 +00:00
Jonathan Coates b9ed66983d Fix some isues in SNBT parsing
- Accept the full range of unquoted strings
 - Fix error when failing to parse an unquoted string

See #2277. This is not sufficient to close the issue (wow, there's so
much more wrong with the code), but at least stops unserialiseJSON
crashing.
2025-08-31 12:11:34 +01:00
Zirunis a683697e8c Fixed two typos in dfpwm.lua (#2272) 2025-08-27 06:47:42 +01:00
Zirunis 9e233a916f Fixed typo in docstring of textutils.serializeJSON (#2260) 2025-08-08 10:45:46 +01:00
Jonathan Coates 5f16909d4b Remove empty-argument optimisation
This doesn't work with getTableUnsafe, as empty arguments are considered
closed already. We could argubly special-case the empty args, but the
optimisation has very minor benefits, so I don't think worrying about too
much.

Fixes #2246.
2025-07-19 22:24:32 +01:00
Jonathan Coates 00475b9bb0 Support LuaTable arguments in @LuaFunction 2025-07-14 08:11:35 +01:00
Jonathan Coates 018ce7c8a5 Bump CC:T to 1.116.1 2025-07-12 18:57:05 +01:00
Jonathan Coates 8344c0a5c2 Bump CC:T to 1.116.0 2025-06-28 11:03:52 +01:00
Jonathan Coates a292d33830 Syntax highlighting for multiline tokens in edit
I don't love the implementation of this (see discussion in #2220), but
it's better than nothing. Wow, the editor really needs a bit of a
rewrite, the code is kinda messy.

Fixes #1396.
2025-06-25 22:50:23 +01:00
Jonathan Coates 341d1c7bc2 Move paint/edit menu bar into common module
I want to add a menu bar to the edit runner too, so let's make this code
a little more reusable first.
2025-06-25 22:14:09 +01:00
Adit Cahya Ramadhan 1f3da5205c Miniscule typo fix in the shell.path() doc comment
Noticed this when reading the shell API page in the wiki.
2025-06-21 22:29:04 +07:00
Jonathan Coates 7c0f79fc3c Move edit_runner into its own module
I've a few more features I'd like to add to it. Moving it out makes it
slightly easier to maintain.
2025-06-17 17:55:24 +01:00
Jonathan Coates b35cefc5dd Switch from path to parentPath
I've been putting this off for a while, as I had issues in the past with
people using old Node versions (e.g. #1806), but it no long works on my
machine, so time to make the switch.

Also do a bit of a package update. Hit a rollup bug while doing this
(https://github.com/rollup/plugins/issues/1877), so holding that update
back for now.
2025-06-17 17:46:10 +01:00
Jonathan Coates 69353a4fcf Use lexer for edit's syntax highlighting
This is slightly more accurate for long strings and comments. Note that
we still work a line at a time (and in a non-incremental manner), so
doesn't actaully support multi-line strings (#1396).

We do now treat goto as a keyword (fixes #1653). We don't currently
support labels — those *technically* aren't a token (`:: foo --[[ a
comment ]] ::` is a valid label!), but maybe we could special-case the
short `::foo::` form.
2025-06-15 13:25:21 +01:00
LorneHyde 1c51282426 Fix syntax highlighting for strings ending in an escaped backslash (#2194) 2025-06-08 19:55:14 +00:00
Wojbie 2557dd0af9 Update motd path in startup.lua
Removes situations where shell resolution caused arbitrary program called `motd` at root get executed instead of expected /rom one.
2025-06-03 01:03:02 +02:00
Jonathan Coates b5c0c6e104 Fix out-of-bounds when pasting too-long text
Used a `<=` instead of a `<`! How did I mess this up!?

Fixes #2209
2025-06-02 08:58:43 +01:00
SpartanSoftware 876fd8ddb8 Fix 0 being treated as a valid colour (#2211) 2025-05-31 07:46:03 +00:00
JackMacWindows b440b964b7 Add notes about minor changed file handle behavior in 1.109.0 (#2203) 2025-05-25 20:24:26 +00:00
Jonathan Coates 947001104d Update Cobalt to 0.9.6
- Allow heterogenous __lt/__le.
2025-04-21 14:36:44 +01:00
Jonathan Coates 8711512769 Remove allocation tracking for computers
Reverts 76968f2f28. We'd originally added
this to gather some numbers for #1580, with the hope that it would also
be useful for server admins. Sadly, it's not as accurate as I originally
hoped — the number sometimes goes down for unclear reasons (something to
do with the TLAB maybe??).

Closes #1739.
2025-04-21 08:32:03 +01:00
Jonathan Coates 9c0ce27ce6 Switch a few more places to use Java 17 features
New ErrorProne hint, and one which is actually pretty useful!
2025-03-22 09:39:47 +00:00
Jonathan Coates c458360b18 Bump versions of build tooling
The main thing of note is Spotless, which also bumps the version of
Ktlint. I've been putting this off for a while[^1], as this changed a
bunch of formatting, and Spotless's (broken) caching was making it hard
to test. Ended up downloading ktlint and running it localy.

[^1]: 8204944b5f
2025-03-21 14:28:31 +00:00
Jonathan Coates b6f41a0df5 Fix several issues with char/paste event validation
- Fix isValidClipboard always returning true.
 - Fix characters >=128 being rejected. We changed the signature from a
   byte to an int in 0f123b5efd, but
   didn't update all call sites.

   Valhalla cannot come soon enough. I would love to be able to have
   (cheap) wrapper classes for some of these types.

See Zeus-guy's comments in #860.
2025-03-16 14:07:15 +00:00
Drew Edwards 97e28516fb docs: specify valid types for settings.define 2025-03-13 01:40:08 +00:00
Jonathan Coates b97634b717 Flesh out LuaTable a bit
Add a whole buncha helper methods for parsing values, much like
IArguments. This allows us to remove TableHelper. Gosh, that dates back
to 2018!
2025-03-08 23:39:11 +00:00
Jonathan Coates dd7e8fcefc Bump CC:T to 1.115.1 2025-03-01 22:35:29 +00:00
Jonathan Coates 0998acaa82 Switch to JSpecify annotations
Now, hear me out, what if instead of having three @Nullable annotations,
we had *four*?

I've been wanting to switch away from javax.annoations for a while. The
library has been deprecated for ever and, unlike other @Nullable
annotations, the annotation is attached to the parameter/function
itself, rather than the type.

We use JSpecify rather than one of the alternatives (JetBrains,
CheckerFramework) mostly because it's what NullAway recommends. We keep
CheckerFramework around for @DefaultQualifier, and JB's for @Contract.

There are some ugly changes here — for instance, `@Nullable byte[]` is
replace by `byte @Nullable`, and `@Nullable ILuaMachine.Factory` is
`ILuaMachine.@Nullable Factory`. Ughr, I understand why, but it does not
spark joy :).
2025-02-16 18:09:15 +00:00
Jonathan Coates 0a8d505323 Bump CC:T to 1.115.0 2025-02-14 20:20:30 +00:00
Jonathan Coates 237a0ac3bb Expose printout contents to the API
Closes #2099
2025-02-14 18:13:20 +00:00
Jonathan Coates b185d088b3 Suggest alternative table keys on nil errors (#2097)
We now suggest alternative table keys when code errors with "attempt
to index/call 'foo' (a nil value)". For example: "redstone.getinput()",
will now suggest "Did you mean: getInput".

This is a bit tricky to get right! In the above example, our code reads
like:

   1    GETTABUP 0 0 0 ; r0 := _ENV["redstone"]
   2    GETFIELD 0 0 1 ; r0 := r0["getinput"]
   3    CALL 0 1 1     ; r0()

Note, that when we get to the problematic line, we don't have access to
the original table that we attempted to index. In order to do this, we
borrow ideas from Lua's getobjname — we effectively write an evaluator
that walks back over the code and tries to reconstruct the expression
that resulted in nil.

For example, in the above case:
 - We know an instruction happened at pc=3, so we try to find the
   expression that computed r0.
 - We know this was set at pc=2, so we step back one. This is a GETFIELD
   instruction, so we check the key (it's a constant, so worth
   reporting), and then try to evaluate the table.
 - This version of r0 was set at pc=1, so we step back again. It's a
   GETTABUP instruction, so we can just evaluate that directly.

We then use this information (indexing _ENV.redstone with "getinput") to
find alternative keys (e.g. getInput, getOutput, etc...) and then pick
some likely suggestions with Damerau-Levenshtein/OSD.

I'm not entirely thrilled by the implementation here. The core
interpretation logic is implemented in Java. Which is *fine*, but a)
feels a little cheaty and b) means we're limited to what Lua bytecode
can provide (for instance, we can't inspect outer functions, or list all
available names in scope). We obviously can expand the bytecode if
needed, but something we'd want to be careful with.

The alternative approach would be to handle all the parsing in
Lua. Unfortunately, this is quite hard to get right — I think we'd need
some lazy parsing strategy to avoid constructing the whole AST, while
still retaining all the scope information we need.

I don't know. We really could make this as complex as we like, and I
don't know what the right balance is. It'd be cool to detect patterns
like the following, but is it *useful*?

    local monitor = peripheral.wrap("left")
    monitor.write("Hello")
        -- ^ monitor is nil. Is there a peripheral to the left of the
        -- computer?

For now, the current approach feels the easiest, and should allow us to
prototype things and see what does/doesn't work.
2025-02-13 21:57:29 +00:00
Jonathan Coates 051c70a731 Propagate exceptions from parallel where possible (#2095)
In the original implementation of our prettier runtime errors (#1320), we
wrapped the errors thrown within parallel functions into an exception
object. This means the call-stack is available to the catching-code, and
so is able to report a pretty exception message.

Unfortunately, this was a breaking change, and so we had to roll that
back. Some people were pcalling the parallel function, and matching on
the result of the error.

This is a second attempt at this, using a technique I've affectionately
dubbed "magic throws". The parallel API is now aware of whether it is
being pcalled or not, and thus able to decide whether to wrap the error
into an exception or not:

 - Add a new `cc.internal.tiny_require` module. This is a tiny
   reimplementation of require, for use in our global APIs.

 - Add a new (global, in the debug registry) `cc_try_barrier` function.
   This acts as a marker function, and is used to store additional
   information about the current coroutine.

   Currently this stores the parent coroutine (used to walk the full call
   stack) and a cache of whether any `pcall`-like function is on the
   stack.

   Both `parallel` and `cc.internal.exception.try` add this function to
   the root of the call stack.

 - When an error occurs within `parallel`, we walk up the call stack,
   using `cc_try_barrier` to traverse up the parent coroutine's stack
   too. If we do not find any `pcall`-like functions, then we know the
   error is never intercepted by user code, and so its safe to throw a
   full exception.
2025-02-13 17:38:57 +00:00
Jonathan Coates 0f123b5efd Ignore unrepresentable characters when typing
In 94ad6dab0e, we changed it so typing
characters outside of CC's codepage were replaced with '?' rather than
ignored. This can be quite annoying for non-European users (where latin1
isn't very helpful!), so it makes sense to revert this change.

See discussion in #860 for more context.
2025-02-12 18:45:40 +00:00
Jonathan Coates 88cb03be6b Clean up the parallel API
- Store the filter alongside the coroutine rather than in a separate
   table (like we do in multishell).

 - Remove the redudant (I think!) second loop that checks for dead
   coroutines. We already check for dead coroutines in the main loop.

 - Rename some variables to be a bit more consistent. This makes this
   commit look noisier than it is. Sorry!
2025-02-09 16:53:59 +00:00
Jonathan Coates 4360485880 Bump CC:T to 1.114.4 2025-01-31 21:09:57 +00:00