Commit Graph

1359 Commits

Author SHA1 Message Date
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
SquidDev 04f9644ae7 Allow strings or numbers in textutils.*tabulate
A little dubious, but apparently CC used to support it. This means we're
consistent with methods like io.write or string.len which accept strings
or numbers.

Fixes #591
2020-11-27 21:29:11 +00:00
JackMacWindows 486f41f082
Fixed length check on function name in `expect` (#589) 2020-11-26 19:46:03 +00:00
Lupus590 fff8353451
Remove extra space (#586) 2020-11-21 12:25:19 +00:00
Lupus590 9a749642d2
Strict Globals (#583) 2020-11-21 12:11:40 +00:00
SquidDev c35707725f More examples
Yay!
2020-11-20 21:59:17 +00:00
SquidDev b0651082f4 Cleanup examples for the various modules 2020-11-20 19:36:28 +00:00
SquidDev aab0cd34cd Use term.blit on original paint render
This makes it super speedy, meaning an initial refresh doesn't take ages
to load.
2020-11-20 15:06:47 +00:00
Luca d2a1a00dc4
Clear gets an option to reset the palette (#582)
Fixes #555.
2020-11-17 12:53:20 +00:00
Stephen Gibson f194f4fa3a Fix epoch documentation to use milliseconds (#580) 2020-11-13 17:27:28 +00:00
SquidDev 7f90f2f7ca Clean up some examples a little bit
Would be good if they didn't crash and burn on entry :).
2020-11-12 19:40:18 +00:00
Jonathan Coates a4c9e89370
Runnable examples (#576)
Provides a basic interface for running examples on tweaked.cc. This is probably
janky as anything, but it works on my machine.

This is the culmination of 18 months of me building far too much infrastructure
(copy-cat, illuaminate), so that's nice I guess.

I should probably get out more.
2020-11-12 19:01:50 +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 74ac5bb3d1 Bump to 1.94.0 2020-11-07 12:43:57 +00:00
Lupus590 d13bd2cce8
use arg[0] in all usage printouts (#571) 2020-11-04 14:03:08 +00:00
SquidDev cc96e41d3e Remove stray copy-paste error from changelog 2020-11-03 14:37:24 +00:00
Drew Lemmy 741adfa7bb
Use blit to draw boxes, add colors.toBlit (#570) 2020-11-01 19:28:18 +00:00
SquidDev 666e83cf4f Fix JSON objects failing to pass
Maybe I should run the whole test suite, not just the things I think
matter? Nah....
2020-11-01 11:48:19 +00:00
SquidDev c58441b29c Various SNBT parsing improvements
Correctly handle:
 - Typed arrays ([I; 1, 2, 3])
 - All suffixed numbers (1.2d)
 - Single-quoted strings

Fixes #559
2020-11-01 11:36:48 +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
SquidDev c334423d42 Add function to get window visibility
Closes #562

Co-authored-by: devomaa <lmao@distruzione.org>
2020-10-31 09:54:38 +00:00
SquidDev 61fb4caaad Bump to 1.93.1 2020-10-23 17:44:52 +01:00
Drew Lemmy bf6053906d Fix TBO norm issues on old GPUs 2020-10-21 10:28:12 +01:00
Drew Lemmy 93068402a2
Document remaining OS functions (#554) 2020-10-11 22:38:18 +01:00
Drew Lemmy 34a2c835d4
Add color table to docs (#553) 2020-10-11 21:37:56 +01:00
Jonathan Coates 30d35883b8
Fix my docs
Thanks @plt-hokusai. Kinda embarrassing this slipped through - I
evidently need to lint examples too.
2020-10-08 09:48:36 +01:00
SquidDev 334ca65482 Bump to 1.93.0 2020-10-04 11:19:43 +01:00
Jonathan Coates 8472112fc1
Don't propagate adjacent redstone signals for computers (#549)
Minecraft propagates "strong" redstone signals (such as those directly
from comparators or repeaters) through solid blocks. This includes
computers, which is a little annoying as it means one cannot feed
redstone wire from one side and a repeater from another.

This changes computers to not propagate strong redstone signals, in the
same way transparent blocks like glass do.

Closes #548.
2020-10-04 11:14:22 +01:00
SquidDev 84036d97d9 Fix io.open documentation
Well, that was silly.
2020-10-02 21:21:53 +01:00
Weblate 0832974725 Translations for Swedish
Co-authored-by: David Isaksson <davidisaksson93@gmail.com>
2020-09-30 08:25:57 +00:00
SquidDev 6cee4efcd3 Fix incorrect open container check
Was this always broken, or did it happen in a Minecraft update? Don't
know, but it's a very silly mistake either way. Fixes #544
2020-09-24 17:47:30 +01:00
SquidDev 6f868849ab Use tags to check if something is a dye
We half did this already, just needed to change a couple of checks.
Closes #541.
2020-09-16 21:27:59 +01:00
SquidDev 275ca58a82 HTTP rules now allow filtering by port
The HTTP filtering system becomes even more complex! Though in this
case, it's pretty minimal, and definitely worth doing.

For instance, the following rule will allow connecting to localhost on
port :8080.

    [[http.rules]]
    host = "127.0.0.1"
    port = 8080
    action = "allow"

    # Other rules as before.

Closes #540
2020-09-15 22:05:27 +01:00
SquidDev 87393e8aef Fix additional `-` in docs
Why isn't this automatically stripped! Bad squid.
2020-09-13 17:56:12 +01:00
SquidDev 86bf57e3cd My inability to spell will be immortalsied in the changelog 2020-09-12 11:03:18 +01:00
SquidDev 748ebbe66b Bump to 1.92.0
A tiny release, but there's new features so it's technically a minor
bump.
2020-09-12 09:27:47 +01:00
SquidDev 59de21eae2 Handle tabs when parsing JSON
Fixes #539
2020-09-11 18:02:23 +01:00
SquidDev cefde3f003 Also block 0.0.0.0/8
See MightyPirates/OpenComputers#3356
2020-09-08 18:12:20 +01:00
Weblate ae6124d1f4 Translations for Vietnamese
Co-authored-by: Boom <boom@flyingpackets.net>
2020-09-08 03:57:52 +00:00
Weblate 7e121ff72f Translations for Vietnamese
Co-authored-by: Boom <boom@flyingpackets.net>
2020-09-07 06:37:58 +00:00
Weblate 5155e18de2 Added translation for Vietnamese
Co-authored-by: Boom <boom@flyingpackets.net>
2020-09-07 03:33:36 +00:00
SquidDev 7365741088 Don't use entity.captureDrops at all.
This really should have been removed in 9e2232d240.
Otherwise we don't drop these items into the world at all. Fixes #537.
2020-09-05 11:02:24 +01:00
JackMacWindows d5368d0719
Add date-specific MOTDs (like Minecraft) (#533) 2020-09-04 17:35:46 +01:00
Bluenaxela 74b9f5dcb0
Fix FileSystemWrapperMount.isDirectory()
Pretty sure FileSystemWrapperMount.isDirectory() should call Filesystem.isDir(), not Filesystem.exists()
2020-08-24 23:55:24 -07:00
SquidDev 183b342071 Bump for 1.91.0 2020-08-23 15:35:58 +01:00
SquidDev 0bb5515055 Fix checkstyle problems 2020-08-22 19:31:49 +01:00
SquidDev 9acfc0316f Expose NBT hashes of items to users
This just uses the same approach as Plethora, so we should have aparity
for .list() now.
2020-08-22 16:09:35 +01:00
SquidDev 29fb0baa09 Use Forge's packet methods for sending SoundEvents
Doesn't fix #515 (arguably makes it worse in the sense that it's more
likely to throw). However it should provide better error reporting, and
make it more clear that it's not CC:T's fault.
2020-08-22 15:31:48 +01:00
R93950X d5de39ebd4
Fix time formatting (#527)
Fixes #525.

Co-authored-by: R93950X <R93950X@users.noreply.github.com>
2020-08-22 15:17:12 +01:00
SquidDev 0faf76e4bd Fix if statement never being hit
Let's been honest, this bit's probably never been tested, because it
should never happen. Fixes #528.
2020-08-22 15:03:38 +01:00
SquidDev e8e2ed9fe5 Fix incorrect lower bound in mods.toml
It appears I had failed to update this when last bumping the Forge
version. Closes #521 - we're relying on a feature only added in Forge
31.1.16, and they're using 3.1.14.
2020-08-09 21:51:55 +01:00
SquidDev 9f72448ecd Properly deprecate colors.rgb8 2020-08-04 19:50:36 +01:00
hydraz 0e2ce3c634
Make the key for mtime "modified" in fs.attributes (#512) 2020-07-31 18:39:09 +01:00
Jonathan Coates cd879b067f
Merge pull request #508 from neumond/mc-1.15.x
Fix JSON serialization of strings
2020-07-25 17:51:46 +01:00
neumond 053cb1b53c Fix JSON serialization of strings
Control characters become escaped as JSON requires
Non-ASCII characters get escaped as well for better interoperability
We assume here that lua strings represent only first 256 code points of unicode
2020-07-25 19:40:06 +03:00
SquidDev ac7979fb46 Bump for 1.90.2 2020-07-25 11:53:46 +01:00
SquidDev d51851e763 Use FML's scan data to gather annotations
We can just scrape them from the @AutoService annotation, which saves us
having to duplicate any work. Hopefully fixes #501, but I haven't tested
in a non-dev environment yet.
2020-07-23 22:41:20 +01:00
SquidDev 2f323f23d7 Update changelog for release 2020-07-18 12:23:36 +01:00
SquidDev 95554a53d1 Move getResourceFile to CCAPIImpl
Just means we've got all the resource processing code in one place, and
keeps (most) MC code out of CC itself.
2020-07-18 10:31:28 +01:00
SquidDev 89c1b2771d Allow configuring max monitor render distance
64 blocks out to be enough for anyone. But just in case. Closes #494
2020-07-18 10:26:34 +01:00
SquidDev 8f069a9b72 Remove absolute file path from FS errors
When dealing with invalid paths (for instance, ones which are too long
or malformed), Java may throw a FileSystemException. This contains the
absolute path (i.e. C:/Users/Moi/.../.minecraft/...), which is printed
to the user within CC - obviously not ideal!

We simply catch this exception within the MountWrapper and map it back
to the local path. The disadvantage of doing it here is that we can't
map the path in the exception back to the computer - we'd need to catch
it in FileMount for that - so we just assume it referrs to the original
path instead.

Doing it in FileMount ends up being a little uglier, as we already do
all the exception wrangling in FileWrapper, so this'll do for now.

Fixes #495
2020-07-18 10:13:43 +01:00
SquidDev 2e9d6603e3 Correct IPeripheral documentation
It's no longer possible to implement this on the tile, due to the
conflict in getType. Given this is a really bad idea, it's not a big
issue, but we should mention it in the documentation.

Fixes #496.
2020-07-14 19:53:10 +01:00
SquidDev a6a1b9b8e5
Add a whole tonne of documentation
There's a bit of duplication here, so we might try to clean this up, but
it's a good starting point.
2020-07-09 21:59:19 +01:00
SquidDev 3f277a7a7b Bump version to 1.90.0
Going to let this stew for a couple of days - there's probably something
else which'll break.
2020-07-06 15:38:09 +01:00
SquidDev 90c5d3f1e8 Don't load the chunk when watching monitors
Hopefully fixes #493
2020-07-06 15:21:14 +01:00
Naheulf a5f7cf8334
Add enchantments and unbreakable to ItemData.java. (#488) 2020-07-06 14:18:07 +01:00
JackMacWindows 3075f89797
Added Javadoc for currently undocumented functions (#490)
This PR adds some documentation for APIs that did not have docs in the
source yet. This includes the:

* drive peripheral
* FS API
* OS PAI
* printer peripheral
* speaker peripheral
2020-07-05 08:26:37 +01:00
Weblate 45297665c6 Translations for Russian
Translations for French

Co-authored-by: neumond <alice.johnson@yandex.ru>
Co-authored-by: Naheulf <newheulf@gmail.com>
2020-07-05 03:41:59 +00:00
Jonathan Coates ddbf3fc111
Merge pull request #491 from neumond/mc-1.15.x
Add port to Host http header if necessary
2020-07-04 21:48:20 +01:00
Weblate da82b89676 Added translation for Russian
Co-authored-by: neumond <alice.johnson@yandex.ru>
2020-07-04 20:41:15 +00:00
neumond d5f1a2c817 Add port to Host http header if necessary 2020-07-04 22:16:48 +03:00
SquidDev d2a52a8b5d Fix turtle.craft failing when missing an argument.
Stupid typo, stupid squid.
2020-07-03 21:37:14 +01:00
SquidDev 9f8774960f Generate documentation stubs from Javadocs
illuaminate does not handle Java files, for obvious reasons. In order to
get around that, we have a series of stub files within /doc/stub which
mirrored the Java ones. While this works, it has a few problems:

 - The link to source code does not work - it just links to the stub
   file.
 - There's no guarantee that documentation remains consistent with the
   Java code. This change found several methods which were incorrectly
   documented beforehand.

We now replace this with a custom Java doclet[1], which extracts doc
comments from @LuaFunction annotated methods and generates stub-files
from them. These also contain a @source annotation, which allows us to
correctly link them back to the original Java code.

There's some issues with this which have yet to be fixed. However, I
don't think any of them are major blockers right now:

 - The custom doclet relies on Java 9 - I think it's /technically/
   possible to do this on Java 8, but the API is significantly uglier.
   This means that we need to run javadoc on a separate JVM.

   This is possible, and it works locally and on CI, but is definitely
   not a nice approach.

 - illuaminate now requires the doc stubs to be generated in order for
   the linter to pass, which does make running the linter locally much
   harder (especially given the above bullet point).

   We could notionally include the generated stubs (or at least a cut
   down version of them) in the repo, but I'm not 100% sure about that.

[1]: https://docs.oracle.com/javase/9/docs/api/jdk/javadoc/doclet/package-summary.html
2020-07-03 13:31:26 +01:00
SquidDev 36bb8b67c9 Clean up data-gathering code
- Refer to this as "data" rather than "metadata". I'm still not sure
   where the meta came from - blame OpenPeripheral I guess.
 - Likewise, use getItemDetail within inventory methods, rather than
   getItemMeta.
 - Refactor common data-getting code into one class. This means that
   turtle.getItemDetail, turtle.inspect and commands.getBlockInfo all
   use the same code.
 - turtle.getItemDetail now accepts a second "detailed" parameter which
   will include the full metadata (#471, #452).
 - Tags are now only included in the detailed list. This is a breaking
   change, however should only affect one version (1.89.x) and I'm not
   convinced that the previous behaviour was safe.
2020-06-30 12:35:39 +01:00
SquidDev 8f3a56dd32 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-06-30 11:31:41 +01:00
SquidDev 113d5d982f Merge branch 'master' into mc-1.14.x 2020-06-30 11:28:56 +01:00
SquidDev 37a447e745 Bump version to 1.89.2
Somewhat reluctant to do this, but it's a pretty major bug.
2020-06-30 11:10:26 +01:00
SquidDev 9e2232d240 Clean up entity drop code
We were incorrectly using captureDrops directly - it's more reasonable
to listen to the drop event. Fixes #486
2020-06-30 11:10:24 +01:00
Jonathan Coates 514db30fb1
Add configuration options to control terminal sizes (#475)
This allows for configuring the size of computers and pocket computers, 
as well as the max size of monitors.

There's several limitations with the current implementation, but it's
still "good enough" for an initial release:
 - Turtles cannot be resized.
 - GUIs do not scale themselves, so "large" sizes will not render within
   the default resolution.
2020-06-28 16:33:03 +01:00
Jonathan Coates 08181f72d4
Generic peripherals for any tile entities (#478)
This exposes a basic peripheral for any tile entity which does not have methods
already registered. We currently provide the following methods:

 - Inventories: size, list, getItemMeta, pushItems, pullItems.
 - Energy storage: getEnergy, getEnergyCapacity
 - Fluid tanks: tanks(), pushFluid, pullFluid.

These methods are currently experimental - it must be enabled through 
`experimental.generic_peripherals`. While this is an initial step towards
implementing #452, but is by no means complete.
2020-06-27 10:47:31 +01:00
SquidDev 613a28a5af Switch to Forge's DeferredRegister
Well, mostly. We currently don't do recipe serializers as I'm a little
too lazy. For items, blocks and TE types this does make registration
nicer - we've some helper functions which help reduce duplication.

Some types (containers, TEs, etc..) are a little less nice, as we now
must define the registry object (i.e. the WhateverType<?>) in a separate
class to the class it constructs. However, it's probably a worthwhile
price to pay.
2020-06-27 10:23:51 +01:00
Weblate e4c422d6f9 Translations for German
Co-authored-by: Jummit <jummit@web.de>
2020-06-27 01:59:35 +00:00
Weblate 478f992dea Translations for German
Co-authored-by: Jummit <jummit@web.de>
2020-06-25 16:49:08 +00:00
JakobDev b54519d0e6
Add functions for parsing and drawing nft (#458) 2020-06-25 09:08:35 +01:00
Jonathan Coates 9499654757
Add documentation for peripherals
No clue how we're going to do this for the dynamic peripheral system
if/when that ships, but this is a good first stage.

Like the Java APIs, this relies on stub files, so we can't link to the
implementation which is a bit of a shame. However, it's a good first
step.
2020-06-24 12:12:06 +01:00
SquidDev c5138c535c Fix write method missing from printers
I'm really not very good at this modding lark am I? I've done a basic
search for other missing methods, and can't see anything, but goodness
knows.

Fixes #480
2020-06-23 10:01:44 +01:00
SquidDev 5bd8d84d14 Add missing config option for command computers
Fixes #479
2020-06-22 11:35:21 +01:00
Weblate ab0310e27c Translations for Italian
Translations for French

Translations for French

Co-authored-by: hds <hds536jhmk@gmail.com>
Co-authored-by: Anavrins <xanavrins@gmail.com>
Co-authored-by: AxelFontarive <afontarive@gmail.com>
2020-06-21 16:42:35 +00:00
SquidDev 1efabccd14 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-06-21 12:09:28 +01:00
SquidDev 029374e9aa Merge branch 'master' into mc-1.14.x 2020-06-21 12:08:30 +01:00
SquidDev 2a8efb3fd5 Fix crashes when rendering monitors of varying sizes
When calling .flip(), we limit the size of the buffer. However, this
limit is not reset when writing the next time, which means we get
out-of-bounds errors, even if the buffer is /technically/ big enough.

Clearing the buffer before drawing (rather than just resetting the
position) is enough to fix this.

Fixes #476 (and closes #477, which is a duplicate)
2020-06-21 12:03:24 +01:00
SquidDev 48edcde4ef Fix handling of CC: T's version
We never added back replacing of ${version} strings, which means that CC
was reporting incorrect version numbers in _HOST, the user agent and
network versions. This meant we would allow connections even on
mismatched versions (#464).

We shift all version handling into ComputerCraftAPI(Impl) - this now
relies on Forge code, so we don't want to run it in emulators.
2020-06-19 18:49:27 +01:00
Weblate 58a2995bbc Translations for Dutch
Translations for Chinese (Simplified)

Translations for Korean

Translations for German

Co-authored-by: SquidDev <bonzoweb@hotmail.co.uk>
2020-06-18 14:10:23 +00:00
SquidDev a35dcb28ef Import translations and clean up
- Strip any gui._.config options. These haven't been used since 1.12
   and while they may return, it doesn't seem worth it right now.
 - Fix a couple of typos in the English translations.
 - Import from https://i18n.tweaked.cc. There's definitely some problems
   with the import - empty translations are still included, so we write
   a script to strip them.
2020-06-18 13:10:51 +01:00
SquidDev 2b077554f7 Merge branch 'mc-1.14.x' into mc-1.15.x
# Conflicts:
#	gradle.properties
#	src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java
#	src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java
#	src/main/java/dan200/computercraft/core/apis/handles/HandleGeneric.java
#	src/main/java/dan200/computercraft/shared/Config.java
#	src/main/java/dan200/computercraft/shared/network/NetworkHandler.java
#	src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java
#	src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java
#	src/main/resources/data/computercraft/lua/rom/help/changelog.txt
#	src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt
2020-06-16 09:24:14 +01:00
SquidDev 9134f243c1 Merge branch 'master' into mc-1.14.x 2020-06-15 22:05:02 +01:00
SquidDev c0f3ca81fb Bump to 1.89.0 2020-06-15 21:37:08 +01:00
SquidDev 190ed4fd20 Fix incorrect disk drive method name
The previous comment was wrong, and I never double checked. Closes #472.
2020-06-11 21:19:14 +01:00
SquidDev b9ff9b7f90 Allow returning lua functions
Not sure how this will play with persistence when it happens (badly,
most likely), but it's not a bad idea to support it.

Closes #466
2020-06-03 21:44:08 +01:00
SquidDev b9b8121be9 Expose tags for turtle.{inspect,getItemDetail}
This is simply exposed as a table from tag -> true. While this is less
natural than an array, it allows for easy esting of whether a tag is
present.

Closes #461
2020-06-01 11:17:05 +01:00
Lignum 014bf55cd4 Cherry pick several improvements from #455
- Use texture over texture2D - the latter was deprecated in GLSL 1.30.
 - Cache the tbo buffer - this saves an allocation when monitors update.

Closes #455. While the rest of the PR has some nice changes, it
performs signlificantly worse on my system.
2020-05-31 17:23:49 +01:00
Lignum 085ae2e74a
Use an older version of GLSL (#459)
This ensures that the MVP matrix is available within the monitor
fragment shader, without requiring the ARB_compatibility extension.
2020-05-28 11:06:14 +01:00
Lignum 4ff33f165d
Fetch MVP matrix in monitor shader instead (#454) 2020-05-25 11:19:03 +01:00
SquidDev d929c02d2a Fix settings loading failing for defined settings
Yes, this was the only piece of code which wasn't tested :/. Fixes #457.
2020-05-24 12:16:51 +01:00
Jonathan Coates d50a08a549
Rewrite monitor networking (#453)
This moves monitor networking into its own packet, rather than serialising
using NBT. This allows us to be more flexible with how monitors are
serialised.

We now compress terminal data using gzip. This reduces the packet size
of a max-sized-monitor from ~25kb to as little as 100b.

On my test set of images (what I would consider to be the extreme end of
the "reasonable" case), we have packets from 1.4kb bytes up to 12kb,
with a mean of 6kb. Even in the worst case, this is a 2x reduction in
packet size.

While this is a fantastic win for the common case, it is not abuse-proof.
One can create a terminal with high entropy (and so uncompressible). This
will still be close to the original packet size.

In order to prevent any other abuse, we also limit the amount of monitor
data a client can possibly receive to 1MB (configurable).
2020-05-20 08:44:44 +01:00
SquidDev c493d668c8 Bump version 2020-05-17 17:02:17 +01:00
SquidDev 53477fd3a1 Fix several AIOB exceptions
Closes #450
2020-05-17 16:58:19 +01:00
SquidDev e02ccdcb1a Fix incorrect shadowing 2020-05-16 10:19:25 +01:00
SquidDev f36f532c63 Migrate config to the server (rather than common) 2020-05-15 23:05:14 +01:00
SquidDev 5a816917d5 Normalise config names 2020-05-15 23:04:04 +01:00
SquidDev 7af63d052d Make many more http options domain-specific
timetout, max_upload, max_download and max_websocket_message may now be
configured on a domain-by-domain basis. This uses the same system that
we use for the block/allow-list from before:

Example:

    [[http.rules]]
        host = "*"
        action = "allow"
	max_upload = 4194304
	max_download = 16777216
	timeout = 30000
2020-05-15 23:04:04 +01:00
SquidDev 4f8217d1ab Implement IPeripheral.getTarget on a few additional TEs
Also make it nullable. Hopefully this will allow us to distinguish
between non-default implementations more easily.
2020-05-15 17:34:00 +01:00
SquidDev 5409d441b5 Expose peripherals as a capability
This registers IPeripheral as a capability. As a result, all (Minecraft
facing) functionality operates using LazyOptional<_>s instead.

Peripheral providers should now return a LazyOptional<IPeripheral> too.
Hopefully this will allow custom peripherals to mark themselves as
invalid (say, because a dependency has changed).

While peripheral providers are somewhat redundant, they still have their
usages. If a peripheral is applied to a large number of blocks (for
instance, all inventories) then using capabilities does incur some
memory overhead.

We also make the following changes based on the above:
 - Remove the default implementation for IWiredElement, migrating the
   definition to a common "Capabilities" class.

 - Remove IPeripheralTile - we'll exclusively use capabilities now.
   Absurdly this is the most complex change, as all TEs needed to be
   migrated too.

   I'm not 100% sure of the correctness of this changes so far - I've
   tested it pretty well, but blocks with more complex peripheral logic
   (wired/wireless modems and turtles) are still a little messy.

 - Remove the "command block" peripheral provider, attaching a
   capability instead.
2020-05-15 17:09:12 +01:00
Jonathan Coates d5f82fa458
Replace getMethodNames/callMethod with annotations (#447)
When creating a peripheral or custom Lua object, one must implement two
methods:

 - getMethodNames(): String[] - Returns the name of the methods
 - callMethod(int, ...): Object[] - Invokes the method using an index in
   the above array.

This has a couple of problems:
 - It's somewhat unwieldy to use - you need to keep track of array
   indices, which leads to ugly code.
 - Functions which yield (for instance, those which run on the main
   thread) are blocking. This means we need to spawn new threads for
   each CC-side yield.

We replace this system with a few changes:

 - @LuaFunction annotation: One may annotate a public instance method
   with this annotation. This then exposes a peripheral/lua object
   method.

   Furthermore, this method can accept and return a variety of types,
   which often makes functions cleaner (e.g. can return an int rather
   than an Object[], and specify and int argument rather than
   Object[]).

 - MethodResult: Instead of returning an Object[] and having blocking
   yields, functions return a MethodResult. This either contains an
   immediate return, or an instruction to yield with some continuation
   to resume with.

   MethodResult is then interpreted by the Lua runtime (i.e. Cobalt),
   rather than our weird bodgey hacks before. This means we no longer
   spawn new threads when yielding within CC.

 - Methods accept IArguments instead of a raw Object array. This has a
   few benefits:
   - Consistent argument handling - people no longer need to use
     ArgumentHelper (as it doesn't exist!), or even be aware of its
     existence - you're rather forced into using it.
   - More efficient code in some cases. We provide a Cobalt-specific
     implementation of IArguments, which avoids the boxing/unboxing when
     handling numbers and binary strings.
2020-05-15 13:21:16 +01:00
SquidDev d0deab3519 Update changelog to include some missing things 2020-05-15 10:48:31 +01:00
SquidDev d5a8df753a Merge branch 'mc-1.14.x' into mc-1.15.x 2020-05-15 10:36:23 +01:00
SquidDev 13de2c4dd0 Fix location of cc.require
Yay for 1.12->1.13 changes!
2020-05-15 10:28:35 +01:00
SquidDev 906280225e Merge branch 'master' into mc-1.14.x 2020-05-15 10:19:57 +01:00
SquidDev 161a5b4707 Document and test the redstone library
The tests may be a little agressive, but I wanted some sanity checks for
the 1.15 API rewrite.
2020-05-15 10:03:47 +01:00
SquidDev c6b6b4479c Update changelog and fix doc typo 2020-05-14 19:23:57 +01:00
SquidDev 96e7b60285 Display function arguments and positions in the REPL
- cc.pretty.pretty now accepts two additional options:
   - function_args: Show function arguments
   - function_source: Show where functions are defined.
 - Expose the two options as lua.* settings (defaulting function_args to
   true, and function_source to false).
   These are then used in the Lua REPL.

Closes #361
2020-05-14 19:11:57 +01:00
SquidDev 086fccd997 Move the package library into a separate module
Hopefully this makes it a little easier for people to use in custom
shells (and anything else where it might be useful).
2020-05-14 17:27:50 +01:00
Jonathan Coates 5dfaf6eee9 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-05-13 15:28:05 +01:00
Jonathan Coates e251dd066c Fix test failures 2020-05-13 15:27:50 +01:00
SquidDev 9abcfe56ea Create the coverage directory before writing
Odd that this failed - we should make the directory within the test
suite - but let's see if this helps.
2020-05-13 14:41:50 +01:00
SquidDev abbc641fd4 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-05-13 14:36:39 +01:00
SquidDev c60dcb4f5a Fix deprecated usage 2020-05-13 14:04:32 +01:00
SquidDev 4be0b15afa Merge branch 'master' into mc-1.14.x 2020-05-13 14:04:28 +01:00
SquidDev a4ae36b6b3 Bump version to 1.88.0
There's probably some other stuff I'll get in before release, but let's
do this just in case.
2020-05-13 13:43:40 +01:00
SquidDev ac075d9f53 Allow using command computers in survival mode
I'm really not a fan of this change, but it's gated behind a config
option and there's apparently sufficient demand that it's worthwhile.
Closes #442.
2020-05-13 10:26:59 +01:00
Lupus590 05d7be0362
Improvements to the various file system programs (rm, mv, rename) (#440)
This enforces several sanity checks before actually attempting
the move, allowing us to produce friendlier error messages.
2020-05-12 11:32:48 +01:00
SquidDev 9a71dc1a26 Copy across a bunch of 5.1/5.3 io tests
I've been meaning to do this for ages. Woops.
2020-05-11 18:05:40 +01:00
SquidDev 156023b154 Create more work for myself
This ensures no lines start with an empty line, and all files finish
with exactly one "\n".
2020-05-11 16:08:25 +01:00
SquidDev 6b3773a862 Run tests with coverage
- Use jacoco for Java-side coverage. Our Java coverage is /terrible
   (~10%), as we only really test the core libraries. Still a good thing
   to track for regressions though.

 - mcfly now tracks Lua side coverage. This works in several stages:
   - Replace loadfile to include the whole path
   - Add a debug hook which just tracks filename->(lines->count). This
     is then submitted to the Java test runner.
   - On test completion, we emit a luacov.report.out file.

   As the debug hook is inserted by mcfly, this does not include any
   computer startup (such as loading apis, or the root of bios.lua),
   despite they're executed.

   This would be possible to do (for instance, inject a custom header
   into bios.lua). However, we're not actually testing any of the
   behaviour of startup (aside from "does it not crash"), so I'm not
   sure whether to include it or not. Something I'll most likely
   re-evaluate.
2020-05-11 15:47:30 +01:00
Jonathan Coates 376d628cf0
Make the local Lua message a little shorter
Co-authored-by: exerro <benedict.allen2514@gmail.com>
2020-05-09 08:30:55 +01:00
Lupus590 44062ebd52
Allow lua REPL to warn about using local variables (#367)
`local varname = value` results in `varname` being inaccessible in
the next REPL input. This is often unintended and can lead to confusing
behaviour. We produce a warning when this occurs.
2020-05-08 16:07:33 +01:00
Jonathan Coates 5739285fc2
Finish off documentation for the commands API 2020-05-05 21:17:52 +01:00
Jonathan Coates 70b457ed18
Add a monitor renderer using TBOs (#443)
This uses the system described in #409, to render monitors in a more
efficient manner.

Each monitor is backed by a texture buffer object (TBO) which contains
a relatively compact encoding of the terminal state. This is then
rendered using a shader, which consumes the TBO and uses it to index
into main font texture.

As we're transmitting significantly less data to the GPU (only 3 bytes
per character), this effectively reduces any update lag to 0. FPS appears
to be up by a small fraction (10-15fps on my machine, to ~110), possibly
as we're now only drawing a single quad (though doing much more work in
the shader).

On my laptop, with its Intel integrated graphics card, I'm able to draw
120 full-sized monitors (with an effective resolution of 3972 x 2330) at
a consistent 60fps. Updates still cause a slight spike, but we always
remain above 30fps - a significant improvement over VBOs, where updates
would go off the chart.

Many thanks to @Lignum and @Lemmmy for devising this scheme, and helping
test and review it! ♥
2020-05-05 13:05:23 +01:00
SquidDev ca2995ed38 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-05-04 10:28:55 +01:00
SquidDev 6816931659 Merge branch 'master' into mc-1.14.x 2020-05-04 10:28:15 +01:00
SquidDev 1547ecbeb3 Fix incorrect palette serialisation 2020-05-04 10:26:33 +01:00
SquidDev e918f55b58 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-05-04 10:05:32 +01:00
SquidDev c28b468844 Update languages and language script 2020-05-04 09:57:38 +01:00
SquidDev 052cf8ee7d Merge branch 'master' into mc-1.14.x 2020-05-04 09:39:54 +01:00
SquidDev 550ada2f9e Restore previous behaviour for unknown colours
Unknown blit colours, such as " " will be translated to black for the
background or white for the foreground. This restores the behaviour from
before #412.
2020-05-04 09:15:23 +01:00
SquidDev 17b7727262 Improve serialisation of terminals
- Write to a PacketBuffer instead of generating an NBT tag. This is
   then converted to an NBT byte array when we send across the network.
 - Pack background/foreground colours into a single byte.

This derives from some work I did back in 2017, and some of the changes
made/planned in #409. However, this patch does not change how terminals
are represented, it simply makes the transfer more compact.

This makes the patch incredibly small (100 lines!), but also limited in
what improvements it can make compared with #409. We send 26626 bytes
for a full-sized monitor. While a 2x improvement over the previous 58558
bytes, there's a lot of room for improvement.
2020-05-03 10:38:31 +01:00
Jonathan Coates 4553e404b2
Merge pull request #437 from SquidDev-CC/feature/keep-ids
Preserve computer ids on unlabelled computers
2020-05-03 06:54:04 +01:00
Drew Lemmy a565a571f9
Return the peripheral name when wrapping (#436) 2020-05-03 06:53:42 +01:00
SquidDev fb64b6017b Add shell.execute
This functions the same as shell.run, but does not tokenise the
arguments. This allows us to pass command line arguments through to
another program without having to re-quote them.

Closes #417
2020-05-02 11:05:09 +01:00
SquidDev ed4229ab70 Keep ids of unlabelled computers and turtles 2020-05-02 10:38:18 +01:00
SquidDev 3fb906ef6c Show computer/disk ids in the tool tip more often
- Remove the parenthesis around the text (so it's now
   "Computer ID: 12"), rather than "(Computer ID: 12").
 - Show the tooltip if the computer has an ID and no label (as well as
   when in advanced mode).
2020-05-02 10:38:17 +01:00
Jonathan Coates e1663f3df0
Fix malformed doc comments 2020-05-01 08:50:44 +01:00
SquidDev 52c6584c81 Fix treasure disk colour handler 2020-04-30 11:33:31 +01:00
SquidDev 9f87eda5de Load treasure disks from various loot tables 2020-04-30 11:19:46 +01:00
SquidDev 697e9449cf Delete existing treasure disks 2020-04-30 10:59:55 +01:00
SquidDev 76c3e4c155 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-04-29 17:37:53 +01:00
SquidDev 358289b5f9 Merge branch 'master' into mc-1.14.x 2020-04-29 17:37:36 +01:00
SquidDev 5eec24676f Prevent computers scanning peripherals twice 2020-04-29 17:37:02 +01:00
SquidDev f52b8fa2de Bump mappings version 2020-04-29 16:23:18 +01:00
Jonathan Coates 447c3ab125
Clean up dance.lua
Not sure what keys.escape was doing there. That's very old.
2020-04-28 09:51:06 +01:00
Jonathan Coates 8fac68386e
Fix usages of global variables
- Lint references to unknown fields of modules, excluding the keys and
   colours modules. This caught several silly errors in our stub files,
   but nothing else.
 - Lint on using unknown globals. This highlighted a couple of really
   silly mistakes. Fixes #427.
 - Add documentation for fs.attributes, fs.getCapacity and pocket, as
   they were not defined before.

Co-authored-by: JackMacWindows <jackmacwindowslinux@gmail.com>
2020-04-28 09:42:34 +01:00
SquidDev a3021c4697 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-04-24 18:44:29 +01:00
SquidDev b7c61f9c6d Bump version 2020-04-24 18:34:01 +01:00
SquidDev 08a0342618 Fix block drop data being generated in the incorrect place
Fixes half of #421
2020-04-24 16:41:46 +01:00
SquidDev 33260a7747 Merge branch 'mc-1.14.x' into mc-1.15.x 2020-04-23 10:04:37 +01:00
SquidDev a049502d12 Merge branch 'master' into mc-1.14.x 2020-04-23 10:03:45 +01:00
SquidDev ae7ef66dfa Bump version
Oh no. I don't want to have to beta test this :D:.
2020-04-23 09:56:56 +01:00
JakobDev 9748679484
Add mouse support for the menu in edit and paint (#419) 2020-04-23 09:33:35 +01:00
SquidDev da419b24e7 Enable motd on non-pocket and command computers
- I'm excluding pocket computers, as they have such a tiny screen I'm
   not sure the screen estate is worth it.
   Pocket computers /generally/ aren't people's starter machine, so I
   think this is fine.
 - Prune the motd list, and try to make them a little shorter. I think
   this list is more of the interesting ones. We can modify this list in
   the future, as we get more feedback.[^1]
 - Also fix paint/edit not adding an extension when they should. This
   was caused by the settings rewrite, as the explicitly provided
   default shadowed the one provided by bios.lua.

[^1]: ~5 months ago I asked for some feedback about enabling motds by
      default. I only got something constructive back today >_>.
2020-04-22 17:45:06 +01:00
Jonathan Coates 2f42a4e85b
Add documentation for shell and multishell
Heh, one place we're more complete than cc.cc :p.
2020-04-22 14:39:39 +01:00
SquidDev af40f5ae5c Add back CraftTweaker integration 2020-04-22 11:11:02 +01:00
SquidDev 759d02a249 Some post-merge cleanup 2020-04-22 11:04:29 +01:00
SquidDev d7729337ac Merge branch 'mc-1.14.x' into mc-1.15.x 2020-04-22 10:39:00 +01:00
SquidDev ee391ae9ea Register a fake renderer for turtle players
Fixes #383, probably.
2020-04-22 10:17:31 +01:00
SquidDev e5cc345f49 Some cleanup to the Lua programs 2020-04-22 10:00:43 +01:00
SquidDev d847a4d9e0 Merge branch 'master' into mc-1.14.x
This also deletes display list support - MC 1.14 now requires VBOs to be
supported in some capacity.
2020-04-22 09:45:23 +01:00
Jonathan Coates f106733d71
Redo how http block/allow lists are stored. (#396)
This replaces the allow/block lists with a series of rules. Each rule
takes the form

    [[http.rules]]
    host = "127.0.0.0/8"
    action = "block"

This is pretty much the same as the previous config style, in that hosts
may be domains, wildcards or in CIDR notation. However, they may also be
mixed, so you could allow a specific IP, and then block all others.
2020-04-22 08:58:21 +01:00
JakobDev f3de97d67f
Remove / and \ at the start of shell.setDir() (#410)
Uses fs.combine to normalise the file path. This removes leading/trailing
slashes, as well as any redundant "../"s within the path.
2020-04-22 06:30:49 +01:00
Wojbie 463635a459
Fix save() sPath param. 2020-04-21 18:28:55 +02:00
SquidDev 3b7b845930 Some tiny bits of documentation cleanup
I'm really good at this English lark :D:.
2020-04-21 12:12:44 +01:00
Jonathan Coates 1fc0214857
Some redesigning of the settings API (#408)
- The store is now split into two sections:
   - A list of possible options, with some metadata about them.
   - A list of values which have been changed.
 - settings.define can be used to register a new option. We have
   migrated all existing options over to use it. This can be used to
   define a default value, description, and a type the setting must have
   (such as `string` or `boolean).

 - settings.{set,unset,clear,load,store} operate using this value list.
   This means that only values which have been changed are stored to
   disk.
   Furthermore, clearing/unsetting will reset to the /default/ value,
   rather than removing entirely.

 - The set program will now display descriptions.

 - settings.{load,save} now default to `.settings` if no path is given.
2020-04-21 11:37:56 +01:00
Jonathan Coates 11bf601db9
Backport 1.15's terminal rendering code (#412)
This is a backport of 1.15's terminal rendering code with some further
improvements. This duplicates a fair bit of code, and is much more
efficient.

I expect the work done in #409 will supersede this, but that's unlikely
to make its way into the next release so it's worth getting this in for
now.

 - Refactor a lot of common terminal code into
   `FixedWithFontRenderer`. This shouldn't change any behaviour, but
   makes a lot of our terminal renderers (printed pages, terminals,
   monitors) a lot cleaner.

 - Terminal rendering is done using a single mode/vertex format. Rather
   than drawing an untextured quad for the background colours, we use an
   entirely white piece of the terminal font. This allows us to batch
   draws together more elegantly.

 - Some minor optimisations:
   - Skip rendering `"\0"` and `" "` characters. These characters occur
     pretty often, especially on blank monitors and, as the font is empty
     here, it is safe to skip them.
   - Batch together adjacent background cells of the same colour. Again,
     most terminals will have large runs of the same colour, so this is a
     worthwhile optimisation.

   These optimisations do mean that terminal performance is no longer
   consistent as "noisy" terminals will have worse performance. This is
   annoying, but still worthwhile.

 - Switch monitor rendering over to use VBOs.

   We also add a config option to switch between rendering backends. By
   default we'll choose the best one compatible with your GPU, but there
   is a config option to switch between VBOS (reasonable performance) and
   display lists (bad).

When benchmarking 30 full-sized monitors rendering a static image, this
improves my FPS[^1] from 7 to 95. This is obviously an extreme case -
monitor updates are still slow, and so more frequently updating screens
will still be less than stellar.

[^1]: My graphics card is an Intel HD Graphics 520. Obviously numbers
      will vary.
2020-04-21 10:43:26 +01:00
SquidDev 7c1154ddfc Avoid shadowing of names in peripheral.isPresent
Fixes #415
2020-04-21 08:51:49 +01:00
SquidDev df557e03fa Fix turtles incorrectly handling waterlogged blocks
This would return true for any block with a fluid in it, including
waterlogged blocks. This resulted in much broken behaviour

 - Turtles cannot place blocks when waterlogged (fixedd #385)
 - Turtles could move into waterlogged blocks (such as fences),
   replacing them.
2020-04-20 20:25:09 +01:00
SquidDev 524b6f1d8a Make a bunch of config fields private 2020-04-20 20:24:16 +01:00
SquidDev c5f918ad95 Increase the maximum limit for websocket messages
The constructor for the websocket handshaker has a default
maxFramePayloadLength of 64kb, hence me being confused.

Closes #376
2020-04-19 21:29:39 +01:00
Jonathan Coates b14c7842fc
Add textutils.unserialiseJSON (#407)
This is relatively unoptimised right now, but should be efficient enough
for most practical applications.

 - Add textutils.json_null. This will be serialized into a literal
   `null`. When deserializing, and parse_null is true, this will be
   returned instead of a nil.

 - Add textutils.unserializeJSON (and textutils.unserializeJSON). This
   is a standard compliant JSON parser (hopefully).

 - Passing in nbt_style to textutils.unserializeJSON will handle
   stringified NBT (no quotes around object keys, numeric suffices). We
   don't currently support byte/long/int arrays - something to add in
   a future commit.
2020-04-19 15:08:46 +01:00
SquidDev eead8b5755 A small amount of Lua documentation
I'd forgotten how tedious this was. I can't say any of these docs are
especially good, but it's something.
2020-04-18 21:42:59 +01:00
SquidDev 10a27a7a25 Add utility to check table keys
expect.field acts very similarly to expect.expect, though checks a
specific table key rather than a function argument.
2020-04-18 14:38:20 +01:00
SquidDev 865fc239a0 Reformat bracketed expressions in Lua
- Parenthesised expressions (function calls, arguments, etc...) should
   never have spaces in them.
 - Tables always will have spaces inside.
2020-04-18 10:09:40 +01:00
SquidDev cb8135a0d1 Bump Cobalt version
- Remove stub for table.pack/table.unpack.
 - Remove Lua 5.3 bitlib stub. We're not on 5.3, there's no
   point emulating it.
 - Change peripheral.call to correctly adjust the error level. This is a
   terrible hack, but I believe the only good option.

It'd be good to remove load as well, but it's a little more complex due
to our injecting of _ENV.

Closes #363
2020-04-16 10:48:26 +01:00
SquidDev ef4b0a5632 Fix config name for enabling http API
It hasn't been http_enable for yonks - slightly worried I didn't notice
this earlier.
Also don't refer to ComputerCraft.cfg - the name has changed several
times across versions, so let's leave it ambiguous.
2020-04-13 11:00:31 +01:00
SquidDev 2360a6e951 Remove several deprecated methods 2020-04-10 21:26:11 +01:00
SquidDev f4f71185ae Add back map rendering
Closes #357. Also bump Forge and mappings versions - it includes a
couple of bug fixes we need.
2020-04-10 21:17:31 +01:00