Commit Graph
792 Commits
Author SHA1 Message Date
Jonathan Coates 071ca050be Write some tests for bandwidth/traffic limits
Just to prove to myself that it works! Specifically, I have some
concerns with HTTP streaming about how that will interact with bandwidth
limits, so having this in place should make it easier to write further
tests.

7c60ed109f already proving useful. As we
no longer have any global state we can run these tests in parallel.
2026-10-01 18:04:44 +01:00
Jonathan Coates 11d5f1a0b7 Property testing for GPS logic
I wrote this ages ago when looking at alternative GPS arrays for #1681.
None of the designs I've tried seem any more reliable, and still have
some positions where they fail, hence this test being marked "pending".
2026-10-01 13:18:40 +01:00
Jonathan Coates 27f3e82d8e Make SNBT parsing more conformant
- Split JSON and SNBT parsers up, and move them into their own
   modules. While there is a lot of overlap, there's sufficient
   difference it's not worth trying to keep them the same.

 - Update SNBT parser to support most of 26.3's features.

Fixes #2277.
2026-09-30 12:54:55 +01:00
Jonathan Coates 5f69f7acd6 Fix several bugs with websocket closing
- Correctly send a close websocket frame when a websocket is manually
   closed (status code 1000) or is garbage collected (1001). Computer
   shutdowns still just close the socket, as we don't/can't wait for the
   socket to cleanly shutdown.

 - After a user calls close(), don't mark the websocket as closed until
   we receive the server's close response. This means we now have a
   slightly awkward interstitial state where we can receive messages but
   not send them, but I don't think there's much we can do about that.

Fixes #2096
2026-09-29 20:52:10 +01:00
Jonathan Coates f0cfd0929b Move some common Netty code into NetworkUtils 2026-09-29 16:59:54 +01:00
Jonathan Coates 5dcbdced10 Replace ResourceQueue with a Cleaner
A bit simpler, means we don't have to poll it every tick.

I had one test failure in the websocket code where the websocket was
GCed and closed too early, so adding some reference fences in here. I've
not been able to reproduce this, so fingers crossed it works.
2026-09-29 16:59:14 +01:00
Jonathan Coates d4a8d270f2 Small perfomance improvements to vector
- Localise setmetatable
 - Provide a fast-path for vector.new which skips number coercion when
   we know the input will be a number.
2026-09-28 11:24:16 +01:00
Jonathan Coates 7c60ed109f Abstract our HTTP implementation away
Add a new HttpHandler interface, which handles checkUrl, request and
websocket calls for a computer. The default implementation is provided
by a NettyHttp class, which also stores any related HTTP config and
state.

This is a little over-engineered, but has two advantages:
 - Our Javascript/TeaVM implementation can now just implement this
   interface, rather than patching/overwriting classes.
 - This removes the final (large) bits of global state/config from
   CC:T's core. Our tests no longer need to temporarily override global
   address rules, and the traffic shaping handler no longer requires
   resetting.

It might be a bit nicer to move all the netty-specific code into a
dan200.computercraft.apis.http.netty package, so there's some cleaner
separation from the common code, but I'm trying to avoid moving code
about any more than I have to.
2026-09-24 15:31:57 +01:00
Jonathan Coates 14e8dc93f0 Make ComputerContext ctor's public
Within our TeaVM code we currently do some class rewriting magic to
replace individual classes, such as ComputerThread. However, all our
code is written to allow changing these implementations already, it's
just TeaVM isn't smart enough to look through our builder and realise
it's dead code!

We now make the ComputerContext's constructor public (though
deprecated), which allows our TeaVM code to call it directly.
2026-09-24 12:51:19 +01:00
Jonathan Coates 16ede90191 Restrict GlobalEnvironment for the actual files we use
These technically supported any mod ID and file, but in practice only
ever were used for the Lua ROM and bios.
2026-09-24 10:32:05 +01:00
Jonathan Coates 9f27bcff64 Support non-slotted Fabric inventories
Unlike (Neo)Forge, Fabric's transfer API distinguishes between slotted
containers (such as chests) and non-slotted ones (such as bundles). Our
current code (and interface) currently assumes everything to have slots,
but for #2213, we need a way to support non-slotted containers.

We can't really change the interface here, so instead we go the other
route: treat the Iterable<StorageView<...>> as a list of slots. This is
pretty gross (which is why I've put it off for so long), but easy enough
to implement.
2026-09-21 15:02:30 +01:00
devvie 670c2092be Check argument types to shell.run (#2507) 2026-09-21 12:00:44 +00:00
Jonathan Coates 93e4ecd350 Refresh redstone output when first creating a computer
This is an identical fix to 013f2e500f,
but for computers rather than redstone integrators.

I don't love the duplication — it might make more sense to move this
into RedstoneState.updateOutput and have an "initial tick" flag there
instead.

Fixes #2392.
2026-09-18 11:06:26 +01:00
Jonathan Coates 1a7f9ce995 Update computer position in transferStateTo instead
No change in behaviour, just feels a little cleaner. And one fewer
places where we call createServerComputer()...
2026-09-18 10:47:35 +01:00
Jonathan Coates fbbee65c84 Update MinecraftExec to work with config cache
- Switch withFileContents/withFileSource to be normal inputs.
 - Download complementary shaders from Maven instead.
2026-09-17 14:52:57 +01:00
Jonathan Coates cc54413718 Fix reference to core-api in common javadoc task 2026-09-16 14:35:08 +01:00
Jonathan Coates c04b7599de Replace 26.2 with 26.3 in issue template 2026-09-15 21:48:57 +01:00
Jonathan Coates 019855dfb2 Some more Gradle tweaks
- Fix missing license header and some over-eager gitignore removals.
 - Fix several isolated project errors. I think all the remaining ones
   come from limitations in other projects:
    - MDG's mod configs don't support referencing source sets from other
      projects.
    - idea-ext is terrible in every way.

   There's some nastiness in MergeTrees where we can't do
   `resources.elements.map { it.single() }` as it throws a configuration
   cache error, so we now use a ConfigurableFileCollection. Somehow it
   still works.
2026-09-12 10:54:59 +01:00
Jonathan Coates a4d172bcbe Gradle cleanup/overhaul.
- Fix a whole bunch of ErrorProne warnings. It's still quite noisy, but
   most of the remaining ones now come from Java.

 - Move some config from java-conventions to a new base-conventions,
   which can be used for non-Java projects. As part of this, we now kill
   the CCTweaked plugin, and just install the cct extension in
   base-conventions instead.

 - Kill inlineProject/externalSources. We now:
    - Add an embeddedProject configuration which is used to define
      projects that are embedded within the final jar. We do some fun
      variant resolution in ExternalProjectArtifacts to extract the
      class/resource/source directories from the configuration.
    - Add a new verifyClassesMatch task which recompiles the game and
      ensures compiling everything against the loader's version of
      Minecraft gives us the same result.
2026-09-11 20:10:58 +01:00
Jonathan Coates b634ef80c8 Move buildSrc to build-logic
What Gradle recommends seems to have gone pretty back-and-forth on this,
but it seems like this is the standard these days.
2026-09-11 12:15:46 +01:00
Jonathan Coates d449cbc3e7 Some basic datapack documentation 2026-09-09 10:07:36 +01:00
Jonathan Coates 358a6e6263 Relax supported HTTP verbs
There's some really awkward duplication in the HTTP API right now, where
the Lua code reimplements the validation the Java implementation
provides, in order to throw errors at the right level.

In this particular case, our Lua validation was stricter than the Java,
only permitting a known set of verbs. This commit:

 - Makes the Java-side validation a little stricter, to only allow verbs
   matching [A-Z_-]{1,32}. This is strictly much stricter than what the
   HTTP spec allows, but I think makes sense as a restriction.

 - Update the Lua wrapper to match this logic, rather than being
   stricter.

Fixes #2501.
2026-08-28 20:36:19 +01:00
Jonathan Coates 3469060b6b Update Gradle and dependencies
- Fix *some* cross-project isolation issues. This appears to be the
   bare minimum to make the configuration cache happy. There is
   obviously a lot more work to do here.

 - Enable Configuration cache.

 - Fix some new checkstyle/errorprone/nullaway warnings.
2026-08-27 16:33:36 +01:00
Jonathan Coates 99e9c72686 Fix a whole bunch of spelling mistakes
Using typos[^1]. I wrote a config for this years ago, but never checked
it in. All things considered, there's fewer than I expected.

Fun fact: the CCPL contains the text "if added to to the main
repository", and I can't/shouldn't fix it, because it's an external
license!

[^1]: https://github.com/crate-ci/typos/
2026-08-26 14:40:04 +01:00
Jonathan Coates 7d05fa9ac2 Remove MC version from project name
This dates back from when we had multiple MC versions in a single
project (see the build-tools branch). We don't do this any more, so no
need for it.

(More importantly, something has changed in IDEA/Gradle so that the
1.20.1 now is escaped as 1_20_1, which breaks Fabric Loom).
2026-08-25 14:56:45 +01:00
Jonathan Coates 7b7039c677 Fix turtle.place() not skipping ItemStack.useOn 2026-08-21 13:53:02 +01:00
Jonathan Coates 8bdea64474 Fix multishell not culling after changing focus
When we resume a process, the code looks like:

  resumeProcess(nCurrentProcess, ...)
  if cullProcess(nCurrentProcess, ...) then ... end

However, if the focused tab changes while resuming (via
multishell.setFocus), then we don't cull the correct process!

To fix this, we just add a helper function which resumes+culls, meaning
we only read the mutable global once.
2026-08-14 16:45:46 +01:00
ItsVingtdeux 9c1a9a6319 Fix random indentation of two lines in bios.lua (#2495)
The "type" field definitions for the "edit.autocomplete" and
"lua.autocomplete" settings were both randomly indented, compared to the
rest of the setting definitions.
2026-08-14 09:54:16 +01:00
Jonathan Coates 67732ace06 Sync translations from Crowdin 2026-08-08 17:04:50 +01:00
Jonathan Coates c3cfb206de Bump CC:T to 1.120.2 2026-08-08 10:13:48 +01:00
Jonathan Coates d37793d29a Some small cleanup to the block placing code
Just clarify a couple of things which are a little confusing.

 - Explicitly initialise the position within deployOnEntity, rather than
   relying on getWithPosition above.
 - Rename "position" to "blockPos" in deployOnBlock to make it clearer
   whose position it is.
 - Clarify that we need to call use(...) for all directions.
2026-07-26 12:36:34 +01:00
Jonathan Coates f2161f0765 Add all turtle/pocket upgrades to the search creative tab
This means we no longer need to register additional stacks with recipe
mods, as they'll pick them up from the creative tab instead.

Closes #2463.
2026-07-26 10:41:17 +01:00
Tomodachi94 2b0adaea5c Document sleep()'s optional parameter (#2488) 2026-07-26 07:40:00 +00:00
Jonathan Coates e0c530efe2 Add missing @GuardedBy 2026-07-22 13:21:19 +01:00
Jonathan Coates 1ec5d53a68 Add test for brewing stand item limit
See #2480.
2026-07-22 12:01:35 +01:00
Jonathan Coates db070d7737 Add missing @Nullability annotations to arg lists
The *contents* of the array is nullable, but the array itself isn't.
2026-07-22 11:48:58 +01:00
Jonathan Coates e83fdd2d5d Fix several BE render bounds
- Monitors were one block taller/wider than they should be.
 - Lecterns are higher than one block, so got cut off if just looking at
   the top.
2026-07-21 11:59:02 +01:00
Jonathan Coates 6f16cd6b0e Reset pocket computer if family changes
When we upgrade a normal pocket computer to an advanced one, we need to
create a new ServerComputer instance (and destroy the old one).

On 1.20.1 the ComputerUpgradeRecipe does not preserve the
instance/session ID on the resulting stack. When the item is next
ticked, we create a new computer, with the old computer no longer being
kept alive and eventually dying.

On 1.21.1 we copy all components, *including* the the current computer
reference. This means a new computer is never created and so we continue
to use the old one (with the wrong family). We could exclude the
computer component from the recipe (and so have the same behaviour as
1.20.1), but by adding a hook in onCraftedBy we can destroy the old
computer immediately, ensuring it no longer continues to run.

Fixes #2479.
2026-07-12 16:30:46 +01:00
Jonathan Coates 1cf0ff299e Fix shell crashing if read() doesn't yield
This never happens normally, but can happen if read() is overridden.
2026-07-07 14:03:27 +01:00
Jonathan Coates 3404dcbbd8 Lower size/time-taken in base64 test
This sometimes fails in CI, as the GHA machines are slower than my own.
2026-07-05 11:23:20 +01:00
Jonathan Coates 1fa227d573 Link to write/print in term.write docs 2026-07-03 09:03:53 +01:00
Jonathan Coates b4805fd765 Add tests to check dynamic recipes are well-formed
- Check whether impostor recipes (and other custom shaped/shapeless
   recipes) match the "real" recipe.
 - Check whether our upgrade recipe generator generates valid recipes.
   Reasoning about left/right upgrades (and top/back ones on 26.2) is a
   bit confusing, so this should prevent any errors.
2026-07-02 15:03:00 +01:00
Jonathan Coates 0e8600b10c Clarify text mode changes in 1.109
Fixes #2470.
2026-06-28 22:35:23 +01:00
Jonathan Coates 143a5b2918 Replace 26.1 with 26.2 in issue template 2026-06-16 17:38:20 +01:00
Jonathan Coates 715d2e01db Bump CC:T to 1.120.0 2026-06-15 22:30:32 +01:00
Jonathan Coates 3ecc17ec90 Update dependencies
- Update Loom — required for MC 26.2.
 - Update TeaVM, using the new reflection API.
2026-06-15 20:33:55 +01:00
Jonathan Coates a76220b395 Revert redundant indexOf
I'd considered moving this into the HostRange in
27137c67f7, but eventually decided against
it. Just didn't fully revert the commit!
2026-06-15 18:39:49 +01:00
Jonathan Coates 27137c67f7 Refactor host rule code a little
Now we just use builtin INetAddress predicates or HostRange, rather than
a mix of custom predicates, sets and HostRange.

Also add some other ranges from the reserved list, and link to that list
to make it a bit easier to find stuff in the future.
2026-06-08 13:47:29 +01:00
Jonathan Coates 57ea451d60 Fix a few small typos
Well, mostly my inability to spell.
2026-06-06 11:39:29 +01:00
Jonathan Coates d1bfb2571d Block RFC 8215-style addresses too.
I don't konw if this actually matters, but better safe than sorry.
Everything here confuses me — my understanding of RFC 6052 was that
private IP addresses cannot be used with NAT64, but AWS apparently
allows it? Not sure if I or Amazon is wrong (or both!).
2026-06-05 09:42:41 +01:00