1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-07-07 04:14:26 +00:00
Commit Graph

181 Commits

Author SHA1 Message Date
Weblate
6635edd35c Translations for French
Translations for German

Translations for German

Co-authored-by: Sammy <SammyKoch@pm.me>
Co-authored-by: SquidDev <git@squiddev.cc>
2023-10-09 22:33:03 +00:00
Jonathan Coates
93ad40efbb
Ensure the terminal exists when creating a monitor peripheral
Previously we had the invariant that if we had a server monitor, we also
had a terminal. When a monitor shrank into a place, we deleted the
monitor, and then recreated it when a peripheral was requested.

As of ab785a0906 this has changed
slightly, and we now just delete the terminal (keeping the ServerMonitor
around). However, we didn't adjust the peripheral code accordingly,
meaning we didn't recreate the /terminal/ when a peripheral was
requested.

The fix for this is very simple - most of the rest of this commit is
some additional code for ensuring monitor invariants hold, so we can
write tests with a little more confidence.

I'm not 100% sold on this approach. It's tricky having a double layer of
nullable state (ServerMonitor, and then the terminal). However, I think
this is reasonable - the ServerMonitor is a reference to the multiblock,
and the Terminal is part of the multiblock's state.

Even after all the refactors, monitor code is still nastier than I'd
like :/.

Fixes #1608
2023-10-09 22:09:01 +01:00
Jonathan Coates
905d4cb091
Fix crash when joining a dedicated server
We can't use FriendlyByte.readCollection to read to a
pre-allocated/array-backed NonNullList, as that doesn't implement
List.add. Instead, we just need to do a normal loop.

We add a couple of tests to round-trip our recipe specs. Unfortunately
we can't test the recipes themselves as our own registries aren't set
up, so this'll have to do for now.
2023-10-08 15:22:32 +01:00
Jonathan Coates
ab785a0906
Fix monitors being warped after a resize
Oh, this was a really nasty bug to reproduce. I'm not sure why - it's
very simple - I guess I've only just seen screenshots of it, and never
sat down to try myself. Reminder to actually report your bugs folks!

In this case:

 1. Place down three down three monitors and then a computer.
 2. Display something on the monitor (monitor left paint a) is my go-to.
 3. Break the middle monitor.

We'd expect the left most monitor to be cleared, however it actually
preserves the monitor contents, resizing (and skewing it) to fit on its
new size!

This is because we clear the server monitor, but never sync that over to
the client, so the client monitor retains the old contents. To fix that,
instead of nulling out the server monitor, we null out the underlying
Terminal. This causes the change to be synced, fixing the bug.
2023-10-03 18:20:44 +01:00
Spongecade
747a5a53b4
Update Minecraft wiki links to new domain (#1601) 2023-10-03 15:55:20 +00:00
Jonathan Coates
96b6947ef2
Flesh out MemoryMount into a writable mount
This moves MemoryMount to the main core module, and converts it to be a
"proper" WritableMount. It's still naively implemented - definitely
would be good to flesh out our tests in the future - but enough for what
we need it for.

We also do the following:
 - Remove the FileEntry.path variable, and instead pass the path around
   as a variable.
 - Clean up BinaryReadableHandle to use ByteBuffers in a more idiomatic
   way.
 - Add a couple more tests to our FS tests. These are in a bit of an odd
   place, where we want both Lua tests (for emulator compliance) and
   Java tests (for testing different implementations) - something to
   think about in the future.
2023-09-29 22:15:23 +01:00
Jonathan Coates
e7a1065bfc
Move file transfer API to the code library
This is useful for emulators, which might want to emulate the event.
2023-09-29 21:09:23 +01:00
Jonathan Coates
e6125bcf60
Try to make recipe serialisers more reusable
This attempts to reduce some duplication in recipe serialisation (and
deserialisation) by moving the structure of a recipe (group, category,
ingredients, result) into seprate types.

 - Add ShapedRecipeSpec and ShapelessRecipeSpec, which store the core
   properties of shaped and shapeless recipes. There's a couple of
   additional classes here for handling some of the other shared or
   complex logic.

 - These classes are now used by two new Custom{Shaped,Shapeless}Recipe
   classes, which are (mostly) equivalent to Minecraft's
   shaped/shapeless recipes, just with support for nbt in results.

 - All the other similar recipes now inherit from these base classes,
   which allows us to reuse a lot of this serialisation code. Alas, the
   total code size has still gone up - maybe there's too much
   abstraction here :).

 - Mostly unrelated, but fix the skull recipes using the wrong UUID
   format.

This allows us to remove our mixin for nbt in recipes (as we just use
our custom recipe now) and simplify serialisation a bit - hopefully
making the switch to codecs a little easier.
2023-09-23 18:24:02 +01:00
Jonathan Coates
0d6c6e7ae7
Hoist some ArchiveMount logic into a new superclass
- Add AbstractInMemoryMount, which contains all of ArchiveMount's file
   tree logic, but not the caching functionality.

 - Convert MemoryMount to inherit from AbstractInMemoryMount.

 - Add a helper method to add a file to an AbstractInMemoryMount, and
   use that within {Resource,Jar}Mount.

There's definitely more work to be done here - it might be nice to split
FileEntry into separate Directory and File interfaces, or at least make
them slightly more immutable, but that's definitely a future job.
2023-09-22 07:46:39 +01:00
Jonathan Coates
b1248e4901
Add a tag for blocks wired modems should ignore
Includes wired modems (as before), but can be extended by other mods if
needed.
2023-09-11 21:29:17 +01:00
Jonathan Coates
e660192f08
Make command computer permission checks stricter
- Placing a command computer requires the player to be in creative and
   opped.
 - Breaking a command computer now requires the player to be opped, as
   well as in creative.

As we've now got a dedicated item class for command comptuers, we move
the command-specific IMedia override to that class.

Fixes #1582.
2023-09-05 18:44:16 +01:00
Jonathan Coates
07113c3e9b
Move command actions to their own methods
Rather than having a mess of lambdas, we now move the bulk of the
implemetation to their own methods. The lambdas now just do argument
extraction - it's all stringly typed, so good to keep that with the
argument definition.

This also removes a couple of exception keys (and thus their translation
keys) as we no longer use them.
2023-09-05 18:37:10 +01:00
Jonathan Coates
5dd6b9a637
Generic dependency update
A couple of changes caused by checkstyle being a little more strict.
2023-08-31 19:14:37 +01:00
Jonathan Coates
13ed422bd5
Remove getBundledRedstoneConnectivity
Wow, this is old. It looks like it's a legacy of when this method was on
TileGeneric (and so returned false by default). As all implementations
now return true (turtle tools no longer block redstone), we don't really
need this any more.
2023-08-27 23:54:27 +01:00
Jonathan Coates
5b58271b92
Fix computer sidebar buttons being invisible 2023-08-27 19:25:04 +01:00
Jonathan Coates
4e42394f33
Merge branch 'mc-1.19.x' into mc-1.20.x 2023-08-27 19:08:59 +01:00
Jonathan Coates
53546b9f57
Split some textures into sprite sheets
- Split buttons.png into individual textures.
 - Split corners_xyz.png into the following:

   - borders_xyz.png: A nine-sliced texture of the computer borders.
   - pocket_bottom_xyz.png: A horizontally 3-sliced texture of the
     bottom part of a pocket computer.
   - sidebar_xyz.png: A vertically 3-sliced texture of the computer
     sidebar.

While not splitting the sliced textures into smaller ones may seem a
little odd, it's consistent with what vanilla does in 1.20.2, and I
think will make editing them easier than juggling 9 textures.

I do want to make this more data-driven in the future, but that will
have to wait until the changes in 1.20.2.

This also adds a tools/update-resources.py program, which performs this
transformation on a given resource pack.
2023-08-27 18:02:51 +01:00
Jonathan Coates
500406f9eb
Merge pull request #1569 from cc-tweaked/feature/no-compression
Remove compression from terminal/monitor packets
2023-08-27 14:15:56 +01:00
Jonathan Coates
b3738a7a63
Use permission APIs for the /computercraft command
- Add a generic PermissionRegistry interface. This behaves similarly to
   our ShaderMod interface, searching all providers until it finds a
   compatible one.

   We could just make this part of the platform code instead, but this
   allows us to support multiple systems on Fabric, where things are
   less standardised.

   This interface behaves like a registry, rather than a straight
   `getPermission(node, player)` method, as Forge requires us to list
   our nodes up-front.

 - Add Forge (using the built-in system) and Fabric (using
   fabric-permissions-api) implementations of the above interface.

 - Register permission nodes for our commands, and use those
   instead. This does mean that the permissions check for the root
   /computercraft command now requires enumerating all child
   commands (and so potential does 7 permission lookups), but hopefully
   this isn't too bad in practice.

 - Remove UserLevel.OWNER - we never used this anywhere, and I can't
   imagine we'll want to in the future.
2023-08-27 12:22:40 +01:00
Jonathan Coates
52b78f92cd
Use standard Markdown link syntax for references
References are now written using normal links: You now use [`print`] or
[print a string][`print`]) instead of @{print} or @{print|print a
string}.
2023-08-24 11:23:33 +01:00
Jonathan Coates
2055052a57
Switch to GitHub-style admonitions/alerts
As these are just a custom syntax on top of blockquotes, these work much
better with text editors.
2023-08-23 18:10:01 +01:00
Jonathan Coates
25776abf61
Fix address rules reading the wrong config key
Should be max_websocket_message, not just websocket_message.

Also add some additional validation to address rules, to check no
unrecognised keys are present.

Closes #1566.
2023-08-23 18:04:22 +01:00
Jonathan Coates
f7411b40a2
Remove compression from terminal/monitor packets 2023-08-23 10:06:15 +01:00
Jonathan Coates
8c8924f54e
Fix CME in monitor's set of attached computers
We're very inconsistent with whether we use locks or concurrent maps
here. Something to sort out in the future, but for now add some missing
@GuardedBy annotations.
2023-08-23 10:05:56 +01:00
Jonathan Coates
c1628d077a
Small improvements to packet reading/writing improvements
- Prefer {read,write}Nullable when possible.

 - Use SoundEvent.{writeTo,readFrom}Network, instead of sending the
   registry entries. This allows playing discs which don't register
   their SoundEvent on the server.

 - Add a couple of tests for round-tripping these packets.
2023-08-23 10:05:56 +01:00
Jonathan Coates
5b2fdec6ca
Add some jqwik arbitraries for Minecraft types
This requires supporting registries in our platform test
code. Thankfully this is mostly the same as what we can do in Fabric -
the duplication is unfortunate - but it's easy enough.
2023-08-23 10:05:56 +01:00
Petr Karmashev
92b335f45f
Fixed turtle.dropDown documentation (#1564) 2023-08-17 10:52:17 +00:00
Jonathan Coates
e6bc1e4e27
Merge branch 'mc-1.19.x' into mc-1.20.x 2023-08-05 10:36:37 +01:00
Jonathan Coates
b6632c9ed9
Fix model hook nullability
Only an issue on the latest FAPI, so we also bump that.
2023-08-05 10:32:21 +01:00
Jonathan Coates
41b6711b38
Change button text in render rather than an override
This made more sense on 1.19.2 and before, but now that we have to do
this for tooltips, we might as well do it for messages as well.

Closes #1538, though hopefully will be resolved on the VO side too.
2023-07-27 19:12:27 +01:00
Jonathan Coates
a9d31cd3c6
Re-run datagen
- Remove some unused translation keys.
 - Run tools/language.py to sort the current translations and remove the
   aforementioned unused keys.
 - Update turtle tool impostor recipes - these now include the tool NBT!
2023-07-23 22:22:48 +01:00
Weblate
55510c42db Translations for Czech
Translations for Polish

Translations for French

Translations for Spanish

Translations for German

Co-authored-by: Patriik <apatriik0@gmail.com>
Co-authored-by: Sammy <SammyKoch@pm.me>
Co-authored-by: SquidDev <git@squiddev.cc>
2023-07-23 21:22:10 +00:00
Jonathan Coates
57a944fd90
Render enchanted upgrades with a glint (#1532) 2023-07-23 10:18:22 +00:00
Jonathan Coates
940f59b116
Automatically bake models from turtle modellers (#1531)
This avoids us having to list a bunch of model locations twice, and
hopefully makes things a little cleaner for add-on authors too
2023-07-22 19:51:50 +00:00
Jonathan Coates
90ed0b24e7
Send block updates to the computer when updating redstone
Fixes #1520
2023-07-22 13:50:13 +01:00
Jonathan Coates
0ad399a528
Rewrite turtle.dig tool actions
- Move the tool action before the "is block present" check, fixes
   #1527. This is where it was before, but we flipped it around in the
   tool rewrite.

 - Don't reuse as much turtle.place logic for tool actions. This fixes
   some instances where tools could till/level dirt through solid
   blocks.
2023-07-21 08:58:02 +01:00
Jonathan Coates
1b88213eca
Make our registry wrapper implement IdMap
This allows us to use some of the byte-buffer helper methods directly
with our registries, rather than rolling our own helpers.
2023-07-19 20:20:38 +01:00
Jonathan Coates
24d74f5c80
Update to latest Fabric
- Overhaul model loading to work with the new API. This allows for
   using the emissive texture system in a more generic way, which is
   nice!

 - Convert some of our custom models to use Fabric's model hooks (i.e.
   emitItemQuads). We don't make use of this right now, but might be
   useful for rendering tools with enchantment glints.

   Note this does /not/ change any of the turtle block entity rendering
   code to use Fabric/Forge's model code. This will be a change we want
   to make in the future.

 - Some cleanup of our config API. This fixes us printing lots of
   warnings when creating a new config file on Fabric (same bug also
   occurs on Forge, but that's a loader problem).

 - Fix a few warnings
2023-07-18 19:27:27 +01:00
Jonathan Coates
48889ceb89
Merge branch 'mc-1.19.x' into mc-1.20.x 2023-07-10 20:38:25 +01:00
Jonathan Coates
c2988366d8
Add EMI compatibility
This just adds stack comparisons, so that upgrades are considered (much
like JEI and REI). No dynamic recipes, as EMI doesn't support those :(.
2023-07-10 20:31:06 +01:00
Weblate
b94e34f372 Translations for Italian
Co-authored-by: Alessandro <ale.proto00@gmail.com>
2023-07-10 15:03:03 +00:00
Jonathan Coates
af3263dec2
Allow disabling generic methods
Suddenly so easy as of the refactoring in 910a63214e395ecae6993d8e0487384c725b3dd3!

Closes #1382
2023-07-09 19:59:08 +01:00
Jonathan Coates
9ca3efff3c
Add data generator support for required mods
We've supported resource conditions in the upgrade JSON for an age, but
don't expose it in our data generators at all.

Indeed, using these hooks is a bit of a pain to do in multi-loader
setups, as the JSON is different between the two loaders. We could
generate the JSON for all loaders at once, but it feels nicer to use
the per-loader APIs to add the conditions.

For now, we just support generating a single condition - whether a mod
is loaded not, via the requireMod(...) method.
2023-07-09 14:09:44 +01:00
Jonathan Coates
9519448e43
Don't render toast text with a shadow 2023-07-07 18:08:47 +01:00
Jonathan Coates
915b6f9d81
Switch away from Forge's loot modifiers
We switched to Forge's loot modifier system in the 1.20 update, as
LootTable.addPool had been removed. Turns out this was by accident, and
so we switch back to the previous implementation, as it's much simpler
and efficient.
2023-07-07 10:18:16 +01:00
Jonathan Coates
a98f3b2a4c
Merge branch 'mc-1.19.x' into mc-1.20.x 2023-07-07 00:18:50 +01:00
Jonathan Coates
5d71770931
Several command permission fixes
- Attach permission checks to the first argument (so the literal
   command name) rather than the last argument. This fixes commands
   showing up when they shouldn't.

 - HelpingArgumentBuilder now inherits permissions of its leaf nodes.
   This only really impacts the "track" subcommand.

 - Don't autocomplete the computer selector for the "queue" subcommand.
   As everyone has permission for this command, it's possible to find
   all computer ids and labels in the world.

   I'm in mixed minds about this, but don't think this is an exploit -
   computer ids/labels are sent to in-range players so shouldn't be
   considered secret - but worth patching none-the-less.
2023-07-06 23:16:22 +01:00
Jonathan Coates
cab9c9772a
Add some tests for new turtle tool functionality
- Normalise upgrade keys, to be "allowEnchantments" and
   "consumeDurability". We were previously inconsistent with
   allow/allows and consumes.
 - Add tests for durability and enchantments of pickaxes.
 - Fix a couple of issues with the original upgrade NBT being modified.
 - Now store the item's tag under a separate key rather than on the
   root. This makes syncing the NBT between the two much nicer.
2023-07-06 22:28:56 +01:00
Weblate
efa92b741b Translations for Russian (ru_ru)
Translations for French

Co-authored-by: chesiren <chesiren63@gmail.com>
Co-authored-by: ego-rick <vsevidcev@gmail.com>
2023-07-04 23:03:03 +00:00
Jonathan Coates
a91ac6f214
Make turtle tools a little more flexible
Turtle tools now accept two additional JSON fields

 - allowEnchantments: Whether items with enchantments (or any
   non-standard NBT) can be equipped.
 - consumesDurability: Whether durability will be consumed. This can be
   "never" (the current and default behaviour), "always", and
   "when_enchanted".

Closes #1501.
2023-07-03 22:14:31 +01:00