1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 12:10:30 +00:00
Commit Graph

2122 Commits

Author SHA1 Message Date
Jonathan Coates
bdf590fa30
Clean up data generators a little 2022-11-09 22:02:47 +00:00
Jonathan Coates
0c4fd2b29e
Make the shader mod system a little more flexible
Mostly for multi-loader support, but also /technically/ makes it easier
to support multiple loaders in the future.
2022-11-09 21:05:27 +00:00
Jonathan Coates
8a7156785d
Refactor turtle actions for easier multi-loader support
- TurtlePlayer now returns a fake player, rather than extending from
   Forge's implementation.

 - Remove "turtle obeys block protection" config option.

 - Put some of the more complex turtle actions behind the
   PlatformHelper.
2022-11-09 20:50:43 +00:00
Jonathan Coates
4d50b48ea6
Remove all references to the ComputerCraft class
Another ugly commit, not thrilled about it:
 - Move all config values to a separate Config class.
 - Replace ComputerCraft.log with class-specific loggers.
 - Replace ComputerCraft.MOD_ID with ComputerCraftAPI.MOD_ID
2022-11-09 20:10:24 +00:00
Jonathan Coates
48285404b9
Move the rendering monitor code to the client side
It's kinda funny looking at all the pre-CC:T proxy code, how much this
has come full circle. I think this design is nicer than what 1.12 did,
but it's still slighly embarassing.
2022-11-09 19:55:42 +00:00
Jonathan Coates
b36b96e0bc
Make the main mod non-null by default
This was actually much more work than I thought it would be. Tests pass,
but I'm sure there's some regressions in here.
2022-11-09 18:59:51 +00:00
Jonathan Coates
34c7fcf750
Refactor the turtle model code a little
Should make it easier to use in a multi-loader setting. This probably
still needs a bit more work: Dinnerbone turtles are still very broken.
2022-11-09 17:21:29 +00:00
Jonathan Coates
cc73fcd85d
Move many Forge-specific methods behind PlatformHelper
There's still a lot of work to be done on turtles (TurtlePlayer, all the
turtle tool stuff), but we're a good way along now.
2022-11-09 14:41:46 +00:00
Jonathan Coates
22729f6f16
Abstract our our use of Forge's tags 2022-11-09 10:59:05 +00:00
Jonathan Coates
55494b7671
Rewrite how we do inventory transfers
- Add a new ContainerTransfer class to handle moving items between
   containers. This is now used for turtle.drop/turtle.suck as well as
   inventory methods.

 - Any other usages of IItemHandler (which are mostly on turtle
   inventories) now use Container and a couple of helper methods.
2022-11-08 21:31:24 +00:00
Jonathan Coates
7d47b219c5
Access capabilities using PlatformHelper
We provide a new abstraction: ComponentAccess, which is a view of
capabilities (or block lookups for Fabric) for adjacent blocks.
2022-11-08 17:44:06 +00:00
Jonathan Coates
320007dbc6
Improve packaging of published jars
- Publish javadoc again: for now this is just the common-api

 - Remove all dependencies from the published Forge jar. This is
   technically not needed (fg.deobf does this anyway), but seems
   sensible.
2022-11-08 16:43:27 +00:00
Jonathan Coates
0908acbe9b
Move all event handlers to a common class
While this does now involve a little more indirection, by having a
single location for all hooks it's much easier to keep event listeners
consistent between loaders.

The diff is pretty noisy (I've inlined some classes, and ClientRegistry
got a big restructure), but functionality should be the same.
2022-11-08 10:48:22 +00:00
Jonathan Coates
e8f9cdd221
Attach capabilities to our BlockEntities externally
Previously we overrode getCapability on our BlockEntity implementations.
While this is the Proper way to do things, it's obviously impossible to
do in a multi-loader environment.

We now subscribe to the AttachCapabilitiesEvent and add our caps that
way. This does require[^1] some nasty invalidation of caps in a couple
of places, which I'm not wild about.

[^1]: I'm not actually sure it does: we invalidate peripherals and wired
elements when neighbours change, so the explicit invalidation probably
isn't useful.
2022-11-06 22:26:07 +00:00
Jonathan Coates
53abe5e56e
Make net code more multi-loader friendly
NetworkMessage follows vanilla's Packet much more closely now: the
handler takes a context argument, which varies between the client and
server.

 - The server handler just returns the ServerPlayer who sent the
   message.
 - The client context provides handleXyz(...) methods for each
   clientbound packet. Our packet subclasses call the appropriate
   method - the implementation of which contains the actual
   implementation.

Doing this allows us to move a whole bunch of client-specific code into
the main client package, dropping several @OnlyIn annotations and
generally reducing the risk of accidentally loading client classes on
the server.

We also abstract out some packet sending and general networking code to
make it easier to use in a multi-loader context.
2022-11-06 20:13:04 +00:00
Jonathan Coates
564752c8dd
Flesh out our registry abstraction layer
- Replace our usages of DeferredRegistry with a custom
   RegistrationHelper. This effectively behaves the same, just without
   any references to Forge code!

 - Replace any references to ForgeRegistries with a home-grown
   Registries class. This just fetches the underlying registry and
   proxies the method calls.

 - Change recipe serialisers and loot item conditions to be registered
   the same way as other entries.

 - Move any Forge specific registration code off to the main
   ComputerCraft class.
2022-11-06 18:37:00 +00:00
Jonathan Coates
6d665ad841
Rename Registry to ModRegistry
Avoids the conflict with Minecraft's built-in registry class
2022-11-06 18:37:00 +00:00
Jonathan Coates
9cd728fea9
Update parse-reports to handle new paths 2022-11-06 18:37:00 +00:00
Oliver Caha
1c890e5a5c
Fix typo in speaker documentation (#1209) 2022-11-06 18:33:46 +00:00
Jonathan Coates
955b9c7d28
Default Forge/Common API to non-null 2022-11-06 15:50:24 +00:00
Jonathan Coates
76710eec9d
Move our public API into separate modules
This adds two new modules: common-api and forge-api, which contain the
common and Forge-specific interfaces for CC's Minecraft-specific API.

We add a new PlatformHelper interface, which abstracts over some of the
loader-specific functionality, such as reading registries[^1] or calling
Forge-specific methods. This interface is then implemented in the main
mod, and loaded via ServiceLoaders.

Some other notes on this:

 - We now split shared and client-specific source code into separate
   modules. This is to make it harder to reference client code on the
   server, thus crashing the game.

   Eventually we'll split the main mod up too into separate source sets
   - this is, of course, a much bigger problem!

 - There's currently some nastiness here due to wanting to preserve
   binary compatibility of the API. We'll hopefully be able to remove
   this when 1.19.3 releases.

 - In order to build a separate Forge-specific API jar, we compile the
   common sources twice: once for the common jar and once for the Forge
   jar.

   Getting this to play nicely with IDEs is a little tricky and so we
   provide a cct.inlineProject(...) helper to handle everything.

[^1]: We /can/ do this with vanilla's APIs, but it gives a lot of
deprecation warnings. It just ends up being nicer to abstract over it.
2022-11-06 15:07:13 +00:00
Jonathan Coates
d8e2161f15
Move website source/build logic to projects/web
Mostly useful as it moves some of our build logic out of the main
project, as that's already pretty noisy!
2022-11-06 13:37:07 +00:00
Jonathan Coates
c82f37d3bf
Switch the core library to be non-null by default
See comments in c8c128d335 for further
details. This requires /relatively/ few changes - mostly cases we were
missing @Nullable annotations.
2022-11-06 11:55:26 +00:00
Jonathan Coates
c8c128d335
Switch the core-api to be non-null by default
We'll do this everywhere eventually, but much easier to do it
incrementally:

 - Use checker framework to default all field/methods/parameters to
   @Nonnull.

 - Start using ErrorProne[1] and NullAway[2] to check for possible null
   pointer issues. I did look into using CheckerFramework, but it's much
   stricter (i.e. it's actually Correct). This is technically good, but
   is a much steeper migration path, which I'm not sure we're prepared
   for yet!

[1]: https://github.com/google/error-prone
[2]: https://github.com/uber/NullAway
2022-11-06 10:28:49 +00:00
Jonathan Coates
acc254a1ef
Move dan200.computercraft.core into a separate module
This is a very big diff in changed files, but very small in actual
changes.
2022-11-06 10:02:14 +00:00
Jonathan Coates
a17b001950
Move the core API into a separate module
It should be possible to consume the ComputerCraft's core (i.e.
non-Minecraft code) in other projects, such as emulators.  While this
has been possible for years, it's somewhat tricky from a maintenance
perspective - it's very easy to accidentally add an MC dependency
somewhere!

By publishing a separate "core" jar, we can better distinguish the
boundaries between our Lua runtime and the Minecraft-specific code.

Ideally we could have one core project (rather than separate core and
core-api modules), and publish a separate "api" jar, like we do for the
main mod. However, this isn't really possible to express using Maven
dependencies, and so we must resort to this system.

Of course, this is kinda what the Java module system is meant to solve,
but unfortunately getting that working with Minecraft is infeasible.
2022-11-04 21:41:59 +00:00
Jonathan Coates
e4e528e5bf
Prepare dan200.computercraft.core for splitting off
- Move core-specific config options to a separate CoreConfig class.
 - Use class-specific loggers, instead of a global one.
 - Use log markers instead of a logComputerErrors option.
2022-11-04 19:58:57 +00:00
Jonathan Coates
6cc86b0ae5
Exclude the previous commit from git blame
This can be added by running the following command:

    git config --global blame.ignoreRevsFile .git-blame-ignore-revs
2022-11-04 13:42:00 +00:00
Jonathan Coates
f478c4ffc4
Reformat everything
- Switch to a fairly standard code format. This is largely based on
   IntelliJ defaults, with some minor tweaks applied via editor config.
   Should mean people don't need to import a config!

 - Use "var" everywhere instead of explicit types. Type inference is a
   joy, and I intend to use it to its fullest.

 - Start using switch expressions: we couldn't use them before because
   IntelliJ does silly things with our previous brace style, but now we
   have the luxury of them!
2022-11-04 13:41:38 +00:00
Jonathan Coates
7df0412c2d
Bump CC:T to 1.101.1
Our last palendrome for a while!
2022-11-03 20:41:47 +00:00
Jonathan Coates
998efcc950
Move our test thread scheduler into the main jar
While useless in-game, both CCEmuX and eval.tweaked.cc ended up
reimplementing it, so might as well expose it!
2022-11-03 20:41:47 +00:00
Jonathan Coates
45c5de73bb
Correctly register turtle refuel handlers
And actually test them! Along with a whole load of other turtle tests.

Fixes #1202
2022-11-03 20:41:46 +00:00
Alessandro Proto
c919011a7e
Check for valid nSender field on RedNet message receive (#1200) 2022-11-03 08:40:37 +00:00
Jonathan Coates
0f1f5247ca
Merge branch 'mc-1.18.x' into mc-1.19.x 2022-11-02 09:55:10 +00:00
Jonathan Coates
0db32bd0fe
Merge branch 'mc-1.16.x' into mc-1.18.x 2022-11-02 09:55:10 +00:00
Jonathan Coates
1d3ecb551d
Improvee changelog 2022-11-02 07:58:31 +00:00
Jonathan Coates
aefda6a381
Fix a couple of issues with the release process
Only way to test these is in prod, alas :D:
2022-11-01 21:53:05 +00:00
Jonathan Coates
c1bf9f0b24
Prepare the public API for multi-loader support
Well, sort of. For now, we just mark a whole bunch of stuff as
@Deprecated.
2022-11-01 21:05:24 +00:00
Jonathan Coates
629abb65e3
Merge branch 'mc-1.18.x' into mc-1.19.x 2022-11-01 20:11:36 +00:00
Jonathan Coates
11ac865877
Merge branch 'mc-1.16.x' into mc-1.18.x 2022-11-01 20:07:15 +00:00
Jonathan Coates
6b93fafc46
Bump CC:T to 1.101.0
These version numbers are very hard to type correctly.
2022-11-01 20:01:21 +00:00
Jonathan Coates
1acb8441ec
Add a couple of tests for file autocompletion 2022-11-01 19:22:07 +00:00
Ivo Leal
4b0988768d
Add include_hidden option to fs.complete (#1194) 2022-11-01 14:50:15 +00:00
Jonathan Coates
f528046535
Add a whole bunch of missing @since annotations 2022-10-31 20:09:47 +00:00
Jonathan Coates
93f747fb54
Fix incorrect reboot tooltip
This tooltip was a) using the wrong text and b) incorrect anyway!
Rebooting an off computer does nothing, rather than turning it on.
2022-10-31 20:08:50 +00:00
Jonathan Coates
5d4c34fbac
Merge branch 'mc-1.16.x' into mc-1.18.x 2022-10-31 18:03:39 +00:00
Jonathan Coates
4c5b3a6ee5
Clear Origin header on websockets
Technically this removes Sec-Websocket-Origin, as that's what the
current version of Netty uses. We'll need to change this on 1.18+.

Closes ##1197.
2022-10-31 17:46:02 +00:00
Jonathan Coates
7701b343fb
Make PartialOptions immutable
- Switch to using OptionalInt/OptionalLong instead of @Nullable
   Long/Integers. I know IntelliJ complains, but it avoids the risk of
   implicit unboxing.

 - Instead of mutating PartialOptions, we now define a merge() function
   which returns the new options. This simplifies the logic in
   AddressRule a whole bunch.
2022-10-31 09:13:40 +00:00
Jonathan Coates
14cb97cba1
Sort NBT when writing
This should fix the worst cases of #1196.
2022-10-30 16:47:26 +00:00
Jonathan Coates
1490ca8624
Bump Cobalt version
Adds debug.getregistry() support
2022-10-30 16:39:25 +00:00