Commit Graph

1990 Commits

Author SHA1 Message Date
Jonathan Coates 0cfdd7b5e9
Move some more build logic to buildSrc
Look, I don't enjoy having 600 LOC long build.gradle files, it's just
very easy to do! This at least moves some of the complexity elsewhere,
so the build script is a little more declarative.
2022-10-22 20:47:47 +01:00
Jonathan Coates af5d816798
Use spotless for enforcing licenses
It's more verbose as the default license plugin doesn't support multiple
license headers. However, it also gives us some other goodies (namely
formatting Kotlin and removing unused imports), so worth doing.
2022-10-22 18:19:51 +01:00
Jonathan Coates 57cf6084e2
Manage ComputerThread's lifecycle in ComputerContext
This converts ComputerThread from a singleton into a proper object,
which is setup when starting a computer, and tore down when the
ComputerContext is closed.

While this is mostly for conceptual elegance, it does offer some
concrete benefits:
 - You can now adjust the thread count without restarting the whole
   game (just leaving and rentering the world). Though, alas, no effect
   on servers.
 - We can run multiple ComputerThreads in parallel, which makes it much
   easier to run tests in parallel. This allows us to remove our rather
   silly IsolatedRunner test helper.
2022-10-22 14:36:25 +01:00
Jonathan Coates e9cde9e1bf
Refactor out main thread tasks into an interface
Computers now use a MainThreadScheduler to construct a
MainThreadScheduler.Executor, which is used to submit tasks. Our
previous (singleton) MainThread and MainThreadExecutor now implement
these interfaces.

The main purpose of this is to better manage the lifetime of the server
thread tasks. We've had at least one bug caused by us failing to reset
its state, so good to avoid those! This also allows us to use a fake
implementation in tests where we don't expect main thread tasks to run.

As we're now passing a bunch of arguments into our Computer, we bundle
the "global" ones into ComputerContext (which now also includes the Lua
machine factory!). This definitely isn't the nicest API, so we might
want to rethink this one day.
2022-10-22 14:13:06 +01:00
Jonathan Coates 68da044ff2
Merge branch 'feature/new-metrics' into mc-1.16.x 2022-10-22 12:21:41 +01:00
Jonathan Coates 18d9993fa7
Merge branch 'feature/more-datagen' into mc-1.16.x 2022-10-22 12:04:07 +01:00
Jonathan Coates 0c3de1087e
Switch to vanilla's model data generators
In some ways this isn't as nice as the Forge version (requires ATs,
doesn't check texture/model existence). However, it's more multi-loader
friendly and in some cases has much less boilerplate.

Blockstate JSON files are incredibly verbose, so we add a custom JSON
pretty printer which writes things in a slightly more compact manner.

This also changes how turtle upgrades are loaded - we now support
standard ResourceLocations (so computercraft:blocks/some_turtle_upgrade)
as well as ModelResourceLocations (computercraft:items/some_turtle_upgrade#inventory).
I don't think any resource packs need to touch our upgrades, but
apologies if this breaks anything.
2022-10-22 11:55:30 +01:00
Jonathan Coates ff89e5feeb
Some datagen improvements
- Convert remaining recipes over to datagen.

 - Switch loot tables to use vanilla's loot table generator. It's
   honestly not too different, just the earlier system confused me too
   much :).

Alas, a positive diff because the JSON is so verbose. I've got a really
nice patch which makes the JSON more compact, but alas the Mixin doesn't
apply on 1.16 :(.
2022-10-22 10:50:10 +01:00
Jonathan Coates 0b26ab366d
Rewrite the metrics system
- Remove TrackingField and replace it with a Metric abstract class.
   This has two concrete subclasses - Counter and Event. Events carry an
   additional piece of data each time it is observed, such as HTTP
   response size.

 - Computers now accept a MetricsObserver, which tracks metrics for this
   particular computer. This allows us to decouple Computer classes and
   metrics information. The concrete MetricsObserver class we use within
   Minecraft exposes the ServerComputer directly, so we no longer need to
   do the awkward mapping and lookups!

 - The /computercraft command can now do aggregates (count, avg, max)
   over all Event metrics. This removes the need for special handling of
   computer and server time.

There's also a small number of changes in removing the coupling between
Computer and some of its dependencies (ILuaMachine, MainThreadExecutor).
This makes some future refactorings easier, I promise!
2022-10-22 01:35:13 +01:00
Jonathan Coates cb9731306c
Give up on ComputerThreadTest being accurate
It's just too timing dependent right now. I'd like to fix this in the
future, but doing so is hard.
2022-10-22 00:42:21 +01:00
Jonathan Coates 5d833ac634
Expose getters for the detail registry too (#1188) 2022-10-22 00:42:07 +01:00
Jonathan Coates 9db3e6d2a0
Load the CC API with services loaders
This is a little odd (it's more complex for one!), but means we can
reuse the internal API interface in other classes, which is useful for
the data provider refactor I'm about to do.

This is much nicer in Java 17 :D (records, ServiceLoader.stream()),
but such is the perils of still targetting 1.16.
2022-10-21 23:50:44 +01:00
Jonathan Coates 1e703f1b07
Fix several off-by-one issues in UploadFileMessage
We now fuzz UploadFileMessage, generating random files and checking they
round-trip correctly.

The joy of having a long-lasting refactor branch with an absolutely
massive diff, is that you end up spotting bugs, and then it's a massive
pain to merge the fix back into trunk!
2022-10-21 23:10:18 +01:00
Jonathan Coates b663028f42
Start work on curtailing our global state
The last 4 or 5 commits have simplified things. I can now have some
unnecessary complexity as a treat!

This is some initial work on better tying the lifecycle of
computers (and ComputerCraft) related state to the lifecycle of the
current Minecraft server.

 - Move server-wide methods in IComputerEnvironment (such as creating
   resource mounts) into a separate interface.
 - Add a new ServerContext class, which now holds the ID Assigner,
   server computer registry, and some other tiny bits and bobs. This can
   only be accessed by ServerContect.get(MinecraftServer), forcing
   slightly better discipline for how we use these globals.

This does allow us to nuke some of the ugliest bits in IDAssigner. Even
if it makes things much longer!
2022-10-21 21:02:24 +01:00
Jonathan Coates cee60cdb5b
Require computers to have a fixed ID
Moves ID assigning out of the Computer class and into wherever we
construct the ServerComputer (so in computer blocks and pocket computer
items).

This is definitely not perfect - it'd be nice to make ServerComputers
more responsible for managing the lifecycle of computers (so assigning
ids, handling auto-starting, etc...), but I've not found a good way to
handle this yet!
2022-10-21 19:51:41 +01:00
Jonathan Coates 695ef0542a
Don't store a mutable array in Colour
It's kinda bad form, and we no longer need it anyway!
2022-10-21 19:07:58 +01:00
Jonathan Coates c0d20b72c9
Remove ClientTerminal/ServerTerminal
They bring very little to the table now that computers do their own
thing! This also helps simplify the code in ServerMonitor a bit - turns
out we had two "dirty" flags in the implementation!
2022-10-21 19:00:29 +01:00
Jonathan Coates cf05ab1db1
Store colour support in the Terminal
Previously we stored it alongside the terminal. While this makes sense -
it's not a property of the terminal itself, it ends up duplicating code
in a bunch of places.

We now track the colour flag on the terminal itself. This allows us to
simplify a couple of things:

 - The palette now also knows whether it supports colours or not, and so
   performs greyscale conversion. This means we no longer need to thread
   a "greyscale" flag throughout terminal rendering.

 - Remove isColour() getters from a whole load of
   places (TerminalMethods, ServerTerminal, IComputerEnvironment).
2022-10-21 18:26:57 +01:00
Jonathan Coates c49547b962
Remove ClientComputer
Historically CC has maintained two computer registries; one on the
server (which runs the actual computer) and one on the client (which
stores the terminal and some small bits of additional data).

This means when a user opens the computer UI, we send the terminal
contents and store it in the client computer registry. We then send the
instance id alongside the "open container" packet, which is used to look
up the client computer (and thus terminal) in our client-side registry.

This patch makes the computer menu syncing behaviour more consistent
with vanilla. The initial terminal contents is sent alongside the "open
container" packet, and subsequent terminal changes apply /just/ to the
open container. Computer on/off state is synced via a vanilla
ContainerData/IIntArray.

Likewise, sending user input to the server now targets the open
container, rather than an arbitrary instance id.

The one remaining usage of ClientComputer is for pocket computers. For
these, we still need to sync the current on/off/blinking state and the
pocket computer light.

We don't need the full ClientComputer interface for this case (after
all, you can't send input to a pocket computer someone else is
holding!). This means we can tear out ClientComputer and
ClientComputerRegistry, replacing it with a much simpler
ClientPocketComputers store.

This in turn allows the following changes:

 - Remove IComputer, as we no longer need to abstract over client and
   server computers.

 - Likewise, we can merge ComputerRegistry into the server
   registry. This commit also cleans up the handling of instance IDs a
   little bit: ServerComputers are now responsible for generating their
   ID and adding/removing themselves from the registry.

 - As the client-side terminal will never be null, we can remove a whole
   bunch of null checks throughout the codebase.

 - As the terminal is available immediately, we don't need to explicitly
   pass in terminal sizes to the computer GUIs. This means we're no
   longer reliant on those config values on the client side!

 - Remove the "request computer state" packet. Pocket computers now
   store which players need to know the computer state, automatically
   sending data when a new player starts tracking the computer.
2022-10-21 18:17:43 +01:00
Jonathan Coates a9b74dc979
Make IRC links https 2022-10-09 11:22:24 +01:00
Jonathan Coates 12b8a0393f
Dump Cobalt's internal state on timeouts
Closes #1180
2022-10-09 11:22:16 +01:00
Jonathan Coates cbfd83c2ba
Merge pull request #1182 from Quezler/patch-2
Add all but 3 of the missing dutch translations
2022-10-08 20:54:34 +01:00
Patrick 'Quezler' Mounier 8564c1e54b
Add all but 3 of the missing dutch translations 2022-10-08 21:00:58 +02:00
Jonathan Coates 5be290a1e2
Bump version to 1.100.10
One more version and then it's a palendrome! Sort of.
2022-10-01 12:33:06 +01:00
Jonathan Coates 371f931140
Always add HTTP programs to the path (#1172) 2022-09-30 09:00:07 +00:00
Jonathan Coates da5956e943
Make the sidebar a little wider
I was going to do something productive tonight, but then this happened.

Whatever, I'm retired, I'm allowed to make my entire existence just
adding 50px to things. Heck, maybe I'll do the same tomorrow too.
2022-09-29 22:21:38 +01:00
Jonathan Coates e7533f2353
Improve community links a little 2022-09-29 22:01:51 +01:00
roland-a 0b7fbcde53
Send block updates to client when the turtle moves #1167 (#1170)
Fixes #1167
2022-09-29 17:49:02 +00:00
Jonathan Coates c3b7302108
Remove some unused arguments in LuaDateTime
See comments in #1157
2022-09-11 15:03:09 +01:00
Jonathan Coates 61ac48c99f
Mention audio formats in speaker help
Closes #1133. I'm not super happy about any of the versions proposed
there, but I think this is better than nothing.

Co-authored-by: JackMacWindows <jackmacwindowslinux@gmail.com>
2022-09-11 14:57:45 +01:00
Jonathan Coates d22e138413
Fix numerous off-by-one errors in help program
We clamped various values to the height of the screen, rather than the
height of the content box (height-1). We didn't notice this most of the
time as the last line of a file is empty - it only really mattered when
a file was the same height as the computer's screen.

We now do the following:
 - Strip the trailing new line from a file when reading.
 - Replace most usages of height with height-1.
2022-09-11 14:57:34 +01:00
Jonathan Coates ba64e06ca7
Use a Gradle plugin to download illuaminate
Previously illumainate required manual users to manually download it and
place it in ./bin/. This is both inconvenient for the user, and makes it
hard to ensure people are running the "right" version.

We now provide a small Gradle plugin which registers illuaminate as a
ependency, downloading the appropriate (now versioned!) file. This also
theoretically supports Macs, though I don't have access to one to test
this.

This enables the following changes:

 - The Lua lint script has been converted to a Gradle task (./gradle
   lintLua).

 - illuaminateDocs now uses a task definition with an explicit output
   directory. We can now consume this output as an input to another
   task, and get a task dependency implicitly.

 - Move the pre-commit config into the root of the tree. We can now use
   the default GitHub action to run our hooks.

 - Simplify CONTRIBUTING.md a little bit. Hopefully it's less
   intimidating now.
2022-09-11 14:11:33 +01:00
Jonathan Coates db8c979a06
Merge pull request #1156 from IvoLeal72/patch-1
Fixed usage example of textuils.pagedTabulate
2022-08-28 16:41:40 +01:00
Ivo Leal 9d18487dc5
Fixed usage example of textuils.pagedTabulate 2022-08-28 15:24:47 +01:00
Jonathan Coates e2041f7438
Bump version to 1.100.9 2022-07-27 08:25:31 +01:00
Jonathan Coates d61202e2b8
Fix location of language file 2022-07-27 07:52:05 +01:00
Weblate 6ce88a7dcf Translations for Norwegian Bokmål
Co-authored-by: Erlend <erlend.bergersen@sandnesskolen.no>
2022-07-26 13:17:57 +00:00
Weblate 5d65b3e654 Added translation for Norwegian Bokmål
Co-authored-by: Erlend <erlend.bergersen@sandnesskolen.no>
2022-07-24 15:45:46 +00:00
Erlend abf857f864
Clearify GPS documentation note (#1139) 2022-07-22 20:27:27 +00:00
Jonathan Coates ebef3117f2
Update npm packages 2022-07-21 20:38:44 +01:00
Jonathan Coates b28c1ac8e0
Test various time locales exist
Not clear if we can really test their behaviour too much.

See 69b211b4fb.
2022-07-21 09:44:40 +01:00
Jonathan Coates ba976f9a16
Fix monitor depth blocker being too small
This allowed you to see transparent blocks through the bottom/right
margins of the monitor when using the VBO renderer.
2022-07-16 22:07:15 +01:00
Luiz Krüger 969feb4a1c
ItemGroup info on getItemDetail (#1127) 2022-07-16 20:30:20 +00:00
JackMacWindows bd5de11ad5
Add WAV support to speaker program (#1112) 2022-07-09 08:59:35 +01:00
Jonathan Coates 5366fcb9c8
Point people towards the http.rules config option
Rather than blanket disabling http with http.enabled. I think it's still
useful to keep the option around, but hopefully make it clearer what the
ramifications are.
2022-07-08 22:13:39 +01:00
Jonathan Coates 6335e77da6
Add a code of conduct
Been meaning to do this for years, woops.
2022-07-08 22:08:50 +01:00
heap-underflow 4cfd0a2d1c
Fix off-by-1 error in generic inventory's getItemLimit() (#1131) 2022-07-08 07:44:13 +00:00
Jonathan Coates be3a960273
Check for duplicate ids when registering channels
Should prevent #1130 occurring again. Possibly worth submitting a PR to
Forge for this too.
2022-07-08 08:27:37 +01:00
Jonathan Coates 954254e7e4
Update Minecraft versions 2022-07-07 21:06:32 +01:00
Jonathan Coates 56f0e0674f
Fix term.blit failing on substrings
Hahah. Serves me right for trying to optimise too much. Fixes #1123.
2022-07-02 16:47:43 +01:00