Commit Graph

806 Commits

Author SHA1 Message Date
Jonathan Coates 51d3b091da "Finish" documentation for several modules
- Add remaining docs for the turtle API
 - Add documentation for the fluid storage peripheral.
 - Enforce undocumented warning for most modules (only io and window
   remaining).

"Finish" in quotes, because these are clearly a long way from perfect.
I'm bad at writing docs, OK!
2021-04-03 12:45:54 +01:00
Ronan Hanley 3a147c78a8
Refactor and add tests for TextBuffer (#738) 2021-03-16 21:19:54 +00:00
Jonathan Coates 0ee3d10fda Add User-Agent to Websockets
I think, haven't actually tested this :D:. Closes #730.
2021-03-12 09:14:52 +00:00
Jonathan Coates eb722a74cd Clarify the turtle.place docs a little
Closes #714
2021-02-20 20:19:22 +00:00
Jonathan Coates 1825f67eee Lazily load models in data generators
Fixes #701 (well, hopefully). Our BlockModelProvider is created when
running other mods' data generators (thought not run), which causes
issues as none of the models are considered as "existing files".
2021-02-13 13:02:24 +00:00
SkyTheCodeMaster 396cf15a1f
Fix `redstone.getBundledInput(side)` returning the output of said side. 2021-02-05 14:10:11 -05:00
Jonathan Coates 1316d6a3c9 Migrate all examples to use tweaked.cc
Might as well, I've got the server capacity to spare. Hopefully.
2021-01-23 14:58:08 +00:00
Jonathan Coates 6d367e08a3 ./gradlew checkstyleMain
Every time I forget to run this before pushing, I get very sad.
2021-01-19 21:15:18 +00:00
Jonathan Coates eaa7359c8c Add a whole bunch of tests
Coverage graph goes woosh. Hopefully.

More importantly, all of these are historic regressions, so very much
worth tracking.
2021-01-19 20:02:45 +00:00
SquidDev 657ceda3af Switch back to reobfuscated name in RecordMedia
Fixes #688
2021-01-19 13:43:49 +00:00
Jonathan Coates 1544749282 Defer sending monitor updates until tick end
We send monitor updates when a player starts watching a chunk. However,
the block/tile data has not been sent when this event is fired, and so
the packet is entirely ignored.

Instead, we now queue a "send this" task, which is then dispatched on
the next tick end.

I have memories of this working on 1.12, so either something changed in
an update or I'm a complete idiot. Both are possible.

Fixes #687
2021-01-18 22:20:48 +00:00
Jonathan Coates 9d1ee6f61d Remove m_ (#658)
IT'S GONE!

Not looking forward to the merge conflicts on this one.
2021-01-15 16:35:49 +00:00
Jonathan Coates b90611b4b4 Preserve registration order of upgrades
Makes them display in a more reasonable order within JEI. Closes #647
(note, the title is an entirley separate issue)!
2021-01-15 15:32:11 +00:00
Jonathan Coates 58054ad2d1 Reformat src/main/java
Removes several pointless imports. And, more importantly, fixes the
build.
2021-01-14 09:09:02 +00:00
Jonathan Coates 1255bd00fd Fix mounts being usable after a disk is ejected
This probably fails "responsible disclosure", but it's not an RCE and
frankly the whole bug is utterly hilarious so here we are...

It's possible to open a file on a disk drive and continue to read/write
to them after the disk has been removed:

    local disk = peripheral.find("drive")
    local input = fs.open(fs.combine(disk.getMountPath(), "stream"), "rb")
    local output = fs.open(fs.combine(disk.getMountPath(), "stream"), "wb")
    disk.ejectDisk()

    -- input/output can still be interacted with.

This is pretty amusing, as now it allows us to move the disk somewhere
else and repeat - we've now got a private tunnel which two computers can
use to communicate.

Fixing this is intuitively quite simple - just close any open files
belonging to this mount. However, this is where things get messy thanks
to the wonderful joy of how CC's streams are handled.

As things stand, the filesystem effectively does the following flow::
 - There is a function `open : String -> Channel' (file modes are
   irrelevant here).

 - Once a file is opened, we transform it into some <T extends
   Closeable>. This is, for instance, a BufferedReader.

 - We generate a "token" (i.e. FileSystemWrapper<T>), which we generate
   a week reference to and map it to a tuple of our Channel and T. If
   this token is ever garbage collected (someone forgot to call close()
   on a file), then we close our T and Channel.

 - This token and T are returned to the calling function, which then
   constructs a Lua object.

The problem here is that if we close the underlying Channel+T before the
Lua object calls .close(), then it won't know the underlying channel is
closed, and you get some pretty ugly errors (e.g. "Stream Closed"). So
we've moved the "is open" state into the FileSystemWrapper<T>.

The whole system is incredibly complex at this point, and I'd really
like to clean it up. Ideally we could treat the HandleGeneric as the
token instead - this way we could potentially also clean up
FileSystemWrapperMount.

BBut something to play with in the future, and not when it's 10:30pm.

---

All this wall of text, and this isn't the only bug I've found with disks
today :/.
2021-01-13 22:10:44 +00:00
Jonathan Coates 34b5ede326 Switch to Mojang mappings
ForgeGradle (probably sensibly) yells at me about doing this. However:
 - There's a reasonable number of mods doing this, which establishes
   some optimistic precedent.
 - The licence update in Aug 2020 now allows you to use them for
   "development purposes". I guess source code counts??
 - I'm fairly sure this is also compatible with the CCPL - there's an
   exception for Minecraft code.

The main motivation for this is to make the Fabric port a little
easier. Hopefully folks (maybe me in the future, we'll see) will no
longer have to deal with mapping hell when merging - only mod loader
hell.
2021-01-09 19:22:58 +00:00
Jonathan Coates c864576619 Fix impostor recipes for disks
Well, this is embarrassing. See #652
2021-01-09 18:30:07 +00:00
Jonathan Coates 247c05305d Fix problem with RepeatArgumentType
The whole "flatten" thing can probably be dropped TBH. We don't use it
anywhere. Fixes #661
2021-01-08 17:50:26 +00:00
Lupus590 41226371f3
Add isReadOnly to fs.attributes (#639) 2021-01-07 16:36:25 +00:00
Jonathan Coates 92be0126df Fix disk recipes
Closes #652. This has been broken since the 1.13 update. Not filling
myself with confidence here.
2021-01-06 21:17:26 +00:00
Jonathan Coates dd6f97622e Prevent reflection errors crashing the game
.getMethods() may throw if a method references classes which don't exist
(such as client-only classes on a server). This is an Error, and so is
unchecked - hence us not handling it before.

Fixes #645
2021-01-06 18:21:03 +00:00
Jonathan Coates 2c9f51db89 Don't fatally error if CraftTweaker items have NBT
CT now adds {Damage:0}, which means turtle upgrades not registered any
more for tools. Fixes #647.
2021-01-06 18:08:19 +00:00
Jonathan Coates 542b66c79a Add back command computer block drops
This has been broken for almost a year (28th Jan 2020), and I never
noticed. Good job me.

Fixes #641, closes #648 (basically the same, but targetting 1.15.x)
2021-01-06 17:27:52 +00:00
Jonathan Coates e4b0a5b3ce 2020 -> 2021
Oh, the most useless part of my build process.
2021-01-06 17:13:40 +00:00
JackMacWindows 8b17ec76a8
Fixed missing argument names in file handle docs (#632) 2020-12-28 07:02:37 +00:00
Jonathan Coates 24bb92007a Fix licence issues
I knew I shouldn't do modding on things which aren't my main computer.

I actually did run checkstyleMain before committing, but entirely forgot
about this one. Go me.
2020-12-23 15:58:40 +00:00
Jonathan Coates 2f0cae0bc1 Make upgrade recipe requirements a little more lax
- Move some common upgrade code to IUpgradeBase. 99% sure this this
   preserves binary compatibility (on the JVM at least).

 - Instead of requiring the share tag to match, allow upgrades to
   specify their own predicate. IMO this is a little ugly, but required
   to fix #614 as other mods chuck their own NBT on items.
2020-12-23 15:52:33 +00:00
Jonathan Coates e3a672099c Fix JEI integration with turtle/pocket upgrades
- Remove incorrect impostor recipes for pocket computers. We were
   generating them from the list of turtle upgrades instead!
 - Fix JEI plugin not blocking impostor recipes as of the data-generator
   rewrite.
2020-12-23 15:46:27 +00:00
Jonathan Coates abf425dfb5 Fix overflow in os.epoch
Closes #611
2020-12-23 12:33:47 +00:00
Jonathan Coates 663859d2e5 Fix double URL decode
Closes #613
2020-12-23 12:18:20 +00:00
Jonathan Coates f5eb6ce03e
Fix copy-paste error in inventory docs
I'm a very silly squid.
2020-12-15 09:31:12 +00:00
SquidDev 5865e9c41a Not sure what irritates me more
The fact that I didn't run checkstyle before pushing or checkstyle
itself. I wish this ran fast enough I could put it as a commit hook.
2020-12-11 21:41:29 +00:00
SquidDev 85cf2d5ff1 Docs for energy and inventory methods
The inventory transfer methods really need a proper tutorial with
screenshots and everything else, but this is a good starting point, I
guess.
2020-12-11 21:26:36 +00:00
SquidDev 05c3c8ad32 Generate docs for generic peripherals
This was the easy bit. Now I've got to write them!
2020-12-10 22:16:49 +00:00
SquidDev bb8f4c624b Some sanity checks for get{Direction,Orientation}
Silly bodge, but should fix #600.
2020-12-10 19:13:49 +00:00
SquidDev ea3a160367 Remove a couple of todos 2020-12-10 19:05:52 +00:00
SquidDev 737b3cb576 Don't use capabilities for generic peripherals
Maybe the capability system was a mistake in retrospect, as we don't
store the peripheral outside, so there's no way to reuse it. That will
probably come in a later change.

As a smaller fix, we pass the invalidate listener directly. The lifetime
of this is the same as the computer, so we don't create a new one each
time.

There's still the potential to leak memory if people break/replace a
computer (as listeners aren't removed), but that's an unavoidable flaw
with capabilities.

Fixes #593
2020-12-10 19:05:44 +00:00
SquidDev d83a68f3ff Allow $private HTTP rule to block any private IP
This is a little magic compared with our previous approach of "list
every private IP range", but given then the sheer number we were
missing[1][2] this feels more reasonable.

Also refactor out some of the logic into separate classes, hopefully to
make things a little cleaner.

Fixes #594.

[1]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
[2]: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
2020-12-05 11:32:00 +00:00
JackMacWindows 826797cbd5
Added documentation for global functions (#592) 2020-11-29 11:24:18 +00:00
SquidDev 24af36743d Try to handle a turtle being broken while ticked
Hopefully fixes #585. Hopefully.
2020-11-28 13:13:35 +00:00
SquidDev e2761bb315 Woops
I ran the tests, just not checkstyle.
2020-11-28 12:13:43 +00:00
SquidDev 6734a0e112 Also generate computer models
I'm getting quite addicted to this. Maybe less savings than monitors,
but still worth doing due to the number of files created.

Also fix our angle calculations for monitors. Thankfully we hadn't
shipped this yet :).
2020-11-28 12:06:46 +00:00
SquidDev d4199064ae Make fs.combine accept multiple arguments
Means we can now do fs.combine("a", "b", "c"). Of course, one may just
write "a/b/c" in this case, but it's definitely useful elsewhere.

This is /technically/ a breaking change as fs.combine(a, b:gsub(...))
will no longer function (as gsub returns multiple arguments). However,
I've done a quick search through GH and my Pastebin archives and can't
find any programs which would break. Fingers crossed.
2020-11-28 11:41:03 +00:00
Stephen Gibson f194f4fa3a Fix epoch documentation to use milliseconds (#580) 2020-11-13 17:27:28 +00:00
SquidDev c8aeddedd4 Auto-generate monitor models
I didn't think it was worth it, and then I found myself needing to
update a dozen of them. The code isn't especially pretty, but it works,
so that's fine.

Also fixes several issues with us using the wrong texture (closes #572).
I've put together a wiki page[1] which describes each texture in a
little more detail.

[1] https://github.com/SquidDev-CC/CC-Tweaked/wiki/Monitor-texture-reference
2020-11-11 21:14:53 +00:00
SquidDev a6fcfb6af2 Draw in-hand pocket computers with blending
It might be worth switching to RenderTypes here, rather than a pure
Tesselator, but this'll do for now.

Fixes Zundrel/cc-tweaked-fabric#20.
2020-11-01 11:12:28 +00:00
SquidDev 17a9329207 Bump cct-javadoc version
Documentation will now be sorted (somewhat) correctly!
2020-10-31 12:50:03 +00:00
SquidDev f6160bdc57 Fix players not getting advancements when they own turtles
When we construct a new ServerPlayerEntity (and thus TurtlePlayer), we
get the current (global) advancement state and call .setPlayer() on it.

As grantCriterion blocks FakePlayers from getting advancements, this
means a player will no longer receive any advancements, as the "wrong"
player object is being consulted.

As a temporary work around, we attempt to restore the previous player to
the advancement store. I'll try to upstream something into Forge to
resolve this properly.

Fixes #564
2020-10-31 10:59:24 +00:00
SquidDev 6aae4e5766 Remove superfluous imports
Hah, this is embarassing
2020-10-31 10:09:54 +00:00
SquidDev 84a6bb1cf3 Make generic peripherals on by default
This is a long way away from "feature complete" as it were. However,
it's definitely at a point where it's suitable for general usage - I'm
happy with the API, and don't think I'm going to be breaking things any
time soon.

That said, things aren't exposed yet for Java-side public consumption. I
was kinda waiting until working on Plethora to actually do that, but not
sure if/when that'll happen.

If someone else wants to work on an integration mod (or just adding
integrations for their own mod), do get in touch and I can work out how
to expose this.

Closes #452
2020-10-31 10:03:09 +00:00