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

1667 Commits

Author SHA1 Message Date
Jonathan Coates
114261944a
Tick pocket computers in item entity form
See #995. And no, just because I'm adding this doesn't mean it's not a
terrible issue.
2021-12-20 17:37:42 +00:00
Jonathan Coates
4d10639efb
Use correct Java annotations package 2021-12-20 12:19:52 +00:00
Jonathan Coates
aa36b49c50
Enqueue audio when receiving it
While Minecraft will automatically push a new buffer when one is
exhausted, this doesn't help if there's only a single buffer in the
queue, and you end up with stutter.

By enquing a buffer when receiving sound we ensure there's always
something queued. I'm not 100% happy with this solution, but it does
alleviate some of the concerns in #993.

Also reduce the size of the client buffer to 0.5s from 1.5s. This is
still enough to ensure seamless audio when the server is running slow (I
tested at 13 tps, but should be able to go much worse).
2021-12-19 19:50:43 +00:00
Jonathan Coates
8a1067940d
Account for the game being paused when tracking sound progress
When the game is paused in SSP world, speakers are not ticked. However,
System.nanoTime() continues to increase, which means the next tick
speakers believe there has been a big jump and so schedule a bunch of
extra audio.

To avoid this, we keep track of how long the game has been paused offset
nanoTime by that amount.

Fixes #994
2021-12-19 16:29:06 +00:00
Jonathan Coates
0477b2742c
Use duplicate() instead of rewind()
It's just more confusing having to keep track of where the ByteBuffer is
at. In this case, I think we were forgetting to rewind after computing
the digest.

Hopefully we'll be able to drop some of these in 1.17 as Java 16 has
a few more ByteBuffer methods

Fixes #992
2021-12-18 11:23:12 +00:00
Jonathan Coates
b048b6666d
Add arbitrary audio support to speakers (#982)
Speakers can now play arbitrary PCM audio, sampled at 48kHz and with a
resolution of 8 bits. Programs can build up buffers of audio locally,
play it using `speaker.playAudio`, where it is encoded to DFPWM, sent
across the network, decoded, and played on the client.

`speaker.playAudio` may return false when a chunk of audio has been
submitted but not yet sent to the client. In this case, the program
should wait for a speaker_audio_empty event and try again, repeating
until it works.

While the API is a little odd, this gives us fantastic flexibility (we
can play arbitrary streams of audio) while still being resilient in the
presence of server lag (either TPS or on the computer thread).

Some other notes:
 - There is a significant buffer on both the client and server, which
   means that sound take several seconds to finish after playing has
   started. One can force it to be stopped playing with the new
  `speaker.stop` call.

 - This also adds a `cc.audio.dfpwm` module, which allows encoding and
   decoding DFPWM1a audio files.

 - I spent so long writing the documentation for this. Who knows if it'll
   be helpful!
2021-12-13 22:56:59 +00:00
Jonathan Coates
e16f66e128
Some bits of rednet cleanup
- Remove all the hungrarian notation in variables. Currently leaving
   the format of rednet messages for now, while I work out whether this
   counts as part of the public API or not.

 - Fix the "repeat" program failing with broadcast packets. This was
   introduced in #900, but I don't think anybody noticed. Will be more
   relevant when #955 is implemented though.
2021-12-13 14:30:13 +00:00
Jonathan Coates
1cfad31a0d
Separate breaking progress for wired modems
This means that if the current player is breaking a cable/wired modem,
only the part they're looking at has breaking progress. Closes #355.

A mixin is definitely not the cleanest way to do this. There's a couple
of alternatives:

 - CodeChickenLib's approach of overriding the BlockRendererDispatcher
   instance with a delegating subclasss. One mod doing this is fine,
   several is Not Great.o

 - Adding a PR to Forge: I started this, and it's definitely the ideal
   solution, but any event for this would have a ton of fields and just
   ended up looking super ugly.
2021-12-13 13:30:43 +00:00
Jonathan Coates
92a0ef2b75
Bump CC:T version 2021-12-11 07:37:10 +00:00
Jonathan Coates
1f6e0f287d
Ensure the origin monitor is valid too
Blurh, still not sure if this is Correct or anything, but have no clue
what's causing this. Fixes #985. Hopefully.
2021-12-10 13:13:31 +00:00
Jonathan Coates
0e4b7a5a75
Prevent terminal buttons stealing focus
I have shutdown my computer by accident far too many times now.
2021-12-08 23:16:53 +00:00
Jonathan Coates
47ad7a35dc
Fix NPE when pulling an event with no type
I assume people have broken coroutine dispatchers - I didn't think it
was possible to queue an actual event with no type.

See cc-tweaked/cc-restitched#31. Will fix it too once merged downstream!
2021-12-08 22:47:21 +00:00
Jonathan Coates
3eab2a9b57
Add support for a zero-copy Lua table
The API is entirely designed for the needs of the speaker right now, so
doesn't do much else.
2021-12-07 18:27:29 +00:00
Jonathan Coates
c4024a4c4c
Use an admonition instead 2021-12-02 22:41:58 +00:00
MCJack123
e18ba8a2c2
Add package.searchpath 2021-12-01 18:55:24 -05:00
Jonathan Coates
1851ed31cd
Release keys when opening the offhand pocket computer screen
Opening a screen KeyBinding.releaseAll(), which forces all inputs to be
considered released. However, our init() function then calls
grabMouse(), which calls Keybinding.setAll(), undoing this work.

The fix we're going for here is to call releaseAll() one more time[^1]
after grabbing the mouse. I think if this becomes any more of a problem,
we should roll our own grabMouse which _doesn't_ implement any specific
behaviour.

Fixes #975

[^1]: Obvious problem here is that we do minecraft.screen=xyz rather
      than setScreen. We need to - otherwise we'd just hit a stack
      overflow - but it's not great.
2021-12-01 20:09:38 +00:00
Jonathan Coates
3929dba4a5
Only send update packets on the TEs which need it
More bits of #658
2021-11-30 22:01:09 +00:00
Jonathan Coates
5927e9bb10
Bump CC:T version 2021-11-29 18:54:54 +00:00
Jonathan Coates
53811f8169
Allow peripherals to have multiple types (#963)
Peripherals can now have multiple types:
 - A single primary type. This is the same as the current idea of a
   type - some identifier which (mostly) uniquely identifies this kind
   of peripheral. For instance, "speaker" or "minecraft:chest".

 - 0 or more "additional" types. These are more like traits, and
   describe what other behaviour the peripheral has - is it an
   inventory? Does it supply additional peripherals (like a wired
   modem)?.

This is mostly intended for the generic peripheral system, but it might
prove useful elsewhere too - we'll have to see!

 - peripheral.getType (and modem.getTypeRemote) now returns 1 or more
   values, rather than exactly one.
 - Add a new peripheral.hasType (and modem.hasTypeRemote) function which
   determines if a peripheral has the given type (primary or
   additional).
 - Change peripheral.find and all internal peripheral methods to use
   peripheral.hasType instead.
 - Update the peripherals program to show all types

This effectively allows you to do things like
`peripheral.find("inventory")` to find all inventories.

This also rewrites the introduction to the peripheral API, hopefully
making it a little more useful.
2021-11-29 17:37:30 +00:00
Jonathan Coates
298f339376
Invalidate peripherals during the computer's tick instead
- Capability invalidation and tile/block entity changes set a dirty bit
   instead of refetching the peripheral immediately.
 - Then on the block's tick we recompute the peripheral if the dirty bit
   is set.

Fixes #696 and probably fixes #882. Some way towards #893, but not
everything yet.

This is probably going to break things horribly. Let's find out!
2021-11-28 20:03:27 +00:00
Jonathan Coates
9d44f1ca66
Make capability invalidation callbacks less strict
Forge!! *shakes fist*.
2021-11-28 12:47:08 +00:00
Jonathan Coates
306e06a79a
Do not allow transferring into removed blocks
See #893.
2021-11-28 12:32:31 +00:00
Jonathan Coates
4f11549112
Remove space in fs API 2021-11-27 16:35:44 +00:00
Jonathan Coates
7f3490591d
Some fixes to the web-based emulator
- Bump copy-cat version to have support for initial files in
   directories and the blit fixes.
 - Add an example nft image and move example nfp into a data/ directory.
 - Fix nft parser not resetting colours on the start of each line.
2021-11-27 12:27:40 +00:00
Lupus590
8ffd45c66e
"cc.pretty".pretty_print shortcut function (#965) 2021-11-26 21:13:15 +00:00
Jonathan Coates
e247bd823e
Bump Gradle and Kotlin versions
I think we need this for 1.18
2021-11-26 21:12:20 +00:00
Jonathan Coates
276956eed8
Fix command block config not being read 2021-11-26 20:58:58 +00:00
Jonathan Coates
18d66bd727
Add dimension parameter to commands.getBlockInfo{,s}
Closes #130. Worth noting it doesn't add an additional argument to
getBlockPosition - want to leave that off for now.
2021-11-24 19:31:54 +00:00
Jonathan Coates
d3563a3854
Cleanup resource mount reloading
- Subscribe to the "on add reload listener" event, otherwise we don't
   get reloads beyond the first one! This means we no longer need to
   cast the resource manager to a reloadable one.
 - Change the mount cache so it's keyed on path, rather than "path ✕
   manager".
 - Update the reload listener just to use the mount cache, rather than
   having its own separate list. I really don't understand what I was
   thinking before.
2021-11-24 19:07:12 +00:00
Jonathan Coates
c2dc8bf675
Rewrite monitor resizing
- Some improvements to validation of monitors. This rejects monitors
   with invalid dimensions, specifically those with a width or height
   of 0. Should fix #922.

 - Simplify monitor collapsing a little. This now just attempts to
   resize the four "corner" monitors (where present) and then expands
   them if needed. Fixes #913.

 - Rewrite monitor expansion so that it's no longer recursive. Instead
   we track the "origin" monitor and replace it whenever we resize to
   the left or upwards.

   Also add a upper bound on the loop count, which should prevent things
   like #922 happening again. Though as mentioned above, validation
   should prevent this anyway.

 - Some small bits of cleanup to general monitor code.

I have absolutely no confidence that this code is any better behaved
than the previous version. Let's find out I guess!
2021-11-24 13:35:57 +00:00
Jonathan Coates
603119e1e6
Replace magic values with Forge constants
Gonna have to replace these in 1.17 as Minecraft exposes these by
default!
2021-11-23 21:17:34 +00:00
Jonathan Coates
d9b3f17b52
Add a debug overlay for monitors and turtles
Monitors is probably the more useful thing here (well, for me at
least). It is a _debug_ overlay after all :p.
2021-11-23 21:14:06 +00:00
Jonathan Coates
993bccc51f
Resort language files
Slightly annoying that weblate keeps getting this wrong. I don't think
any of the addons allow me to enforce an ordering either.
2021-11-23 19:48:47 +00:00
Weblate
96d3b27064 Translations for Korean
Co-authored-by: E. Kim <mindy15963@naver.com>
2021-11-23 19:43:15 +00:00
Jonathan Coates
f33f57ea35
Allow generic peripherals to specify a custom source
- Add a new GenericPeripheral interface. We don't strictly speaking
   need this - could put this on GenericSource - but the separation
   seems cleaner.

 - GenericPeripheral.getType() returns a new PeripheralType class, which
   can either be untyped() or specify a type name. This is a little
   over-engineered (could just be a nullable string), but I'm planning
   to allow multiple types in the future, so want some level of
   future-proofing.

 - Thread this PeripheralType through the method gathering code and
   expose it to the GenericPeripheralProvider, which then chooses an
   appropriate name.

   This is a little ugly (we're leaking information about peripherals
   everywhere), but I think is fine for now. It's all private internals
   after all!

Closes #830
2021-11-22 18:05:13 +00:00
Jonathan Coates
070479d901
Make executeMainThreadTask a default method
- Move TaskCallback into the API and make it package private. This
   effectively means it's not an API class, just exists there for
   convenience reasons.
 - Replace any usage of TaskCallback.make with
   ILuaContext.executeMainThreadTask.
 - Some minor formatting/checkstyle changes to bring us inline with
   IntelliJ config.
2021-11-21 11:19:02 +00:00
Jonathan Coates
2fe40f669d
Don't send packets when the server is stopping
Fixes #956
2021-11-20 23:20:27 +00:00
Weblate
814d5cbcd1 Translations for Italian
Co-authored-by: Alessandro <ale.proto00@gmail.com>
2021-11-17 14:24:23 +00:00
Anavrins
4d8862c78e
Optimize peripheral calls in rednet.run (#954) 2021-11-14 06:57:47 +00:00
Weblate
6cc2f035db Translations for Japanese (ja_jp)
Co-authored-by: MORIMORI0317 <morimori.0317@outlook.jp>
2021-11-13 06:24:20 +00:00
Jonathan Coates
ea7a218f4a
Make turtle breaking a little more data driven
- Allow any tool to break an "instabreak" block (saplings, plants,
   TNT). Oddly this doesn't include bamboo or bamboo sapings (they're
   marked as instabreak, only to have their strength overridden again!),
   so we also provide a tag for additional blocks to allow.

 - Hoes and shovels now allow breaking any block for which this tool is
   effective.

 - Use block tags to drive any other block breaking capabilities. For
   instance, hoes can break pumpkins and cactuses despite not being
   effective.

This should get a little nicer in 1.17, as we can just use block tags
for everything.
2021-10-27 19:32:58 +01:00
Jonathan Coates
544bcaa599
Clear the entity drop list as well as cancelling
Fixes #940
2021-10-24 19:11:21 +01:00
Jonathan Coates
ab6b861cd6
Move repo to cc-tweaked org
Let's see how this goes.
 - Update references to the new repo
 - Use rrsync on the server, meaning make-doc.sh uploads relative to the
   website root.
 - Bump Gradle wrapper to 7.2. Not related to this change, but possibly
   fixes running under Java 16. Possibly.
2021-10-17 18:14:32 +01:00
Jonathan Coates
72e8fc03d3
Fix upload bandwidth limit not being set
Lol, woops.
2021-10-13 17:56:12 +01:00
Jonathan Coates
482ae0d22e
Fix recipe book upgrade recipes
- Flip turtle/pocket and upgrade item.
 - Correctly set NBT on pocket upgrade recipe output.
2021-10-11 12:17:45 +01:00
Jonathan Coates
6dd33f7099
Play sounds using ResourceLocation rather than SoundEvent
The latter is not registered when sounds are added via resource packs.

Fixes #938. Probably.
2021-10-10 22:35:45 +01:00
Jonathan Coates
045472577a
Improve motd a hundred fold
Yes, I know this is a terrible feature. But it's been a long week and
I'm so tired.

Also fix the ordering in motd_spec. Who thought putting the month first
was reasonable?
2021-10-08 20:49:37 +01:00
JackMacWindows
9f539dbd59
Add about program for easier version identification (#936) 2021-10-08 11:29:52 +01:00
Weblate
f6fd0ad172 Translations for Russian (ru_ru)
Translations for French

Translations for English

Co-authored-by: SquidDev <git@squiddev.cc>
2021-10-07 10:25:23 +00:00
Weblate
13779d6ad3 Translations for French
Translations for German

Co-authored-by: SquidDev <bonzoweb@hotmail.co.uk>
2021-10-06 16:09:38 +00:00
Jonathan Coates
d700f1f500
Bump the image comparison threshold again
Not sure what the right long-term solution is here. An alternative image
comparison? Take multiple screenshots?
2021-10-03 11:21:37 +01:00
i develop things
06bf84f151
Make color arguments to term.blit case-insensitive (#929) 2021-10-03 11:11:31 +01:00
Jonathan Coates
8ba20985d7
Store additional state in WiredModemPeripheral
This means wired peripherals now correctly track their current mounts
and attached state, rather than inheriting from the origin wired modem.

Closes #890
2021-09-27 22:18:32 +01:00
JackMacWindows
7bb7b5e638
Make Rednet deduplication more efficient (#925) 2021-09-26 21:15:37 +01:00
Alessandro
297426419b
Fix computer IDs greater than 65535 crashing Rednet (#900) 2021-09-26 17:13:26 +01:00
Jonathan Coates
eb61c5c5d7
Add a overly-complex test harness for rednet
Allows us to run multiple "computers" in parallel and send messages
betwene them. I don't think this counts as another test framework, but
it's sure silly.
2021-09-26 16:45:23 +01:00
Jonathan Coates
cf2bc667c1
Add more tests for monitor and printout rendering 2021-09-26 11:10:41 +01:00
Jonathan Coates
662bead8be
Several fixes and improvements for client tests
- Fix broken /cctest marker
 - Correctly wait for the screenshot to be taken before continuing.
 - Filter out client tests in a different place, meaning we can remove
   the /cctest runall command
 - Bump kotlin version
2021-09-26 09:48:58 +01:00
Jonathan Coates
acaa61a720
Make the monitor depth blocker slightly larger 2021-09-25 16:46:37 +01:00
MAGGen-hub
647902c019
Allow using mouse in off-hand pocket computer screen (#918) 2021-09-19 11:24:55 +01:00
Jonathan Coates
2aa70b49c1
Add invisible slots to computer GUIs
This ensures inventory slots are synced while the container is open,
meaning the hotbar (which is visible underneath the GUI) correctly
updates.

Fixes #915
2021-09-19 11:18:24 +01:00
Wojbie
94ad106272
Several improvements to textutils.serialise (#920)
- Handle nan and infinity, by emitting them as 0/0 and 0/1.
- Differentiate between repeated and recursive tables in the
  error message.
2021-09-17 10:30:23 +01:00
xXTurner
dc9edf26ec
Fixed typo in the javadoc of CommandsAPI class (#924) 2021-09-15 19:35:32 +01:00
Jonathan Coates
048c7bda23
Allow opening pocket computers without rendering a terminal
When placed in the off hand, pocket computers now render a different
screen when opened in the off-hand, just rendering text at the top of
the screen rather than "opening" the whole computer.

This means you can view the world and computer in your hand at the
same time, effectively allowing you to emulate the
Plethora/MoarPeripherals keyboard (and much more).

This currently requires you to move the pocket computer to the other
hand to open it normally. I did look into allowing for shift+right click
to open normally, but this is awkward when you're looking at a something
like a monitor - you need to shift as otherwise you'd click the block!

Plethora hooks into onItemUseFirst instead, and this might be an option
in the future - meaning that right click would always open some computer
GUI and never the blocks. This may be something we change in the future
- let's get some feedback first!

Closes #861. Apologies for this essay, but if you got this far you were
probably interested!
2021-08-30 18:52:02 +01:00
Jonathan Coates
9e82209aab
Split uploaded files across multiple packets
Still not 100% sure of the correctness here, but it appears to work.
Closes #887.
2021-08-29 16:58:02 +01:00
JackMacWindows
340ade170f
Add the rest of the feature introduction versions to the docs (#908) 2021-08-26 08:02:58 +01:00
ralphgod3
7cac8401e8
Uncomment remaining keys (#907) 2021-08-25 22:45:10 +01:00
Jonathan Coates
0f899357c2
Some documentation bits and bobs
More #853, closes #858
2021-08-25 22:33:55 +01:00
Jonathan Coates
3396fe2871
Make UserLevel.OWNER a little more strict
Closes #904
2021-08-25 22:09:24 +01:00
Jonathan Coates
9fbcbae5b3
Bump version to 1.98.2 2021-08-22 17:39:32 +01:00
Jonathan Coates
36a779dc18
Use data generators in a few more places
As always, a massive diff which is largely just moving files between
projects. This does fix a couple of issues with advancements, but
otherwise should behave the same.

Speaking of which, should probably go and test some of these recipes...
2021-08-21 15:50:01 +01:00
Jonathan Coates
d3a5d1e314
Add tests for transmitting via wired modems
It crashes on 1.17 right now, so worth checking!
2021-08-20 18:35:00 +01:00
Jonathan Coates
56010382fb
Rethink how computers run tests in game
Instead of using ids for each computer each computer is spawned with id
0 but has a label which matches up to its test name. This has several
advantages:

 - No more confusing IDs: the test code now just does thenComputerOk()
   and that's it - the computer to track is inferred from the test name.
 - All files are stored on one computer, which means we can write code
   which is shared between tests.
2021-08-20 17:05:27 +01:00
Jonathan Coates
0ff6b0ca70
Client-side tests
This spins up a Minecraft instance (much like we do for the server) and
instructs the client to take screenshots at particular times. We then
compare those screenshots and assert they match (modulo some small
delta).
2021-08-20 17:05:13 +01:00
Jonathan Coates
4b33306940
Refactor the test code to be closer to 1.17
Basically mimic the actual API that Minecraft would expose if the
methods hadn't been stripped. Lots of ATs and unsafe hacks to get this
working, but thankfully the API we can expose to the user is pretty
nice. Yay for Kotlin?

Anyway, will cause some immediate pain (yay merge conflicts) but should
make keeping the two in sync much easier.
2021-08-20 17:05:13 +01:00
Jonathan Coates
4dea3dff36
Move some Forge hooks into a separate class 2021-08-20 17:05:13 +01:00
Jonathan Coates
62baa72457
Add some tests for wired modems 2021-08-18 12:55:58 +01:00
Jonathan Coates
5eb711da87
Relocate test mod to testMod source set
This'll be fun to rebase 1.17 on to :).
2021-08-18 12:55:58 +01:00
Jonathan Coates
79c5df1d92
Fix weblate exporting the wrong language
Ughghgr.
2021-08-18 12:53:19 +01:00
Weblate
1d160641a4 Translations for Japanese
Co-authored-by: MORIMORI0317 <morimori.0317@outlook.jp>
2021-08-18 10:53:58 +00:00
Weblate
c2b3d914f7 Added translation for Japanese
Co-authored-by: MORIMORI0317 <morimori.0317@outlook.jp>
2021-08-18 10:22:58 +00:00
Jonathan Coates
8aa7695fdd
Some doc updates
- Fix some spacing in code blocks
 - Rewrite the index page
 - You can't see it, but update illuaminate.
2021-08-13 22:35:08 +01:00
Jonathan Coates
fa78818069
Several fixes to speaker volume
- Use linear attenuation.
 - Fix speakers being 16 times as loud as they should be. They correctly
   cut off at the right distance, but didn't fade out as one might
   expect.
 - Clamp volume at 0, not 1. Fixes #892
2021-08-12 18:19:53 +01:00
Jonathan Coates
62172c6049
Fix depending on a client-only class
I checked matrix but not transformationmatrix >_>.
2021-08-08 12:38:06 +01:00
Jonathan Coates
39f3cf8cbe
Cache the tool's transformation matrix 2021-08-08 12:28:25 +01:00
Jonathan Coates
01ddb2b4e4
A couple of documentation improvements
- Add some missing to the turtle API docs
 - Version history for peripheral and redstone. I /think/ this is
   complete.
2021-08-05 19:25:10 +01:00
Jonathan Coates
bdd38fb061
Update changelog and whatsnew for release 2021-08-02 20:15:32 +01:00
DrHesperus
06f35e4997
Update and rename 2021-08-02 19:49:50 +01:00
Jonathan Coates
2d95c32892
Reformat language files 2021-08-02 19:48:16 +01:00
Jonathan Coates
6f4d4540b2
Update location of several langauge files
Looks like weblate was misconfigured here. These should be picked up -
fingers crossed!
2021-08-02 19:05:10 +01:00
Jonathan Coates
96316cddaa
Fix monitor resize checks being entirely wrong
Fixes #879
2021-08-02 18:46:00 +01:00
Jonathan Coates
e84ddef877
Bump version to 1.98.0 2021-08-01 09:02:05 +01:00
Jonathan Coates
11b40bb6d5
Identify unknown upgrades as ComputerCraft instead
When the mod id is null, the namespace is given as "minecraft". This is
not what we want, so use CC there instead.
2021-08-01 08:48:02 +01:00
Jonathan Coates
686c6a4c44
Use cc.strings.wrap inside slowWrite
Means we don't end up re-wrapping text and producing incorrect results.
Fixes #865
2021-08-01 08:43:37 +01:00
Jonathan Coates
7b8650bbc8 Fix fs.getCapacity docs
Slightly embarassing the state this was in
2021-07-29 09:59:21 +00:00
Jonathan Coates
0285260e97
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-07-28 16:18:27 +01:00
Jonathan Coates
10a3a223a0
Bump version to 1.97.1
Plan here is to release 1.98 for 1.16.x and 1.17.x and 1.97.1 for
1.15.x. However, will let this sit for a few days while I sort out 1.98
and the 1.17 port just in case any more bugs pop up.
2021-07-28 16:15:32 +01:00
Jonathan Coates
2dc970a8bb
Don't error when given a malformed URL
Sometimes the pattern fails to match and so the file name ends up being
nil.
2021-07-28 16:00:31 +01:00
Jonathan Coates
f74c4cc83c
Add config options for a global bandwidth limit
This uses Netty's global traffic shaping handlers to limit the rate at
which packets can be sent and received. If the bandwidth limit is hit,
we'll start dropping packets, which will mean remote servers send
traffic to us at a much slower pace.

This isn't perfect, as there is only a global limit, and not a
per-computer one. As a result, its possible for one computer to use
all/most bandwidth, and thus slow down other computers.

This would be something to improve on in the future. However, I've spent
a lot of time reading the netty source code and docs, and the
implementation for that is significantly more complex, and one I'm not
comfortable working on right now.

For the time being, this satisfies the issues in #33 and hopefully
alleviates server owner's concerns about the http API. Remaining
problems can either be solved by moderation (with help of the
//computercraft track` command) or future updates.

Closes #33
2021-07-28 15:53:22 +01:00
Jonathan Coates
7012ac7163
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-07-25 16:42:22 +01:00
Jonathan Coates
227b444d81
Accept client_no_context_takeover in websockets
Doesn't fix #695, but Good Enough(TM).
2021-07-25 16:40:27 +01:00
Jonathan Coates
d50db8a6f3
Add a fancy test system for async methods
Written in order to ~avoid working on~ test #695. Sadly, no luck there.
2021-07-25 16:25:59 +01:00
Jonathan Coates
3a80b51a9f
Ensure monitors are well-formed when placed
Closes #36
2021-07-25 14:18:07 +01:00
Jonathan Coates
03396cf07a
Fix help crashing on terminal resize
Closes #870. Woops.
2021-07-24 22:58:23 +01:00
Jonathan Coates
5b57f7509d
Add back executeMainThreadTask
Closes #868
2021-07-24 12:04:21 +01:00
Jonathan Coates
0568c86628
Hopefully fix flakiness in rednet test 2021-07-24 00:00:37 +01:00
Jonathan Coates
b31e66686d
Make rednet.run a little more strict
Also add a test for rednet message sending. Hopefully gives some of the
modem and networking code a little bit of coverage (which is clearly the
same as being right :p).
2021-07-23 23:53:40 +01:00
Jonathan Coates
924b8ef30f
Do not access the current server from the client
Just missing some guards in a few places.

Fixes #867
2021-07-23 23:35:13 +01:00
Jonathan Coates
7bcc16bb40 Some examples for rednet 2021-07-23 10:52:44 +00:00
JackMacWindows
8b952e7e1e
Fix parallel.* hanging when called with no args (#863) 2021-07-19 11:20:35 +01:00
SkyTheCodeMaster
04e97f7b86
Fix & enhance some docs (#857) 2021-07-18 17:36:09 +01:00
Angalexik
333410e4cd
Fixed typo in paintutils documentation 2021-07-18 12:37:16 +02:00
Jonathan Coates
999a39a3e6
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-07-15 13:05:31 +01:00
Jonathan Coates
82ca19c296
Add type check for http.checkURL 2021-07-15 13:04:44 +01:00
Jonathan Coates
56d8a5d585
Don't update block states when there is no world
Fixes #856
2021-07-15 12:13:38 +01:00
Jonathan Coates
aa5fbb2980
Use heap buffers rather than direct ones
Closes #855, even if it doesn't really fix it.
2021-07-15 11:55:52 +01:00
Jonathan Coates
db0bb071f5
Add motd for file uploading 2021-07-15 10:58:52 +01:00
Jonathan Coates
ab702e2ba1
Correctly render turtles' selected slot
We had the wrong texture bound, which meant nothing was being rendered!

Fixes #852
2021-07-15 10:58:40 +01:00
SkyTheCodeMaster
d4efacd40a
Turn a nil to a string
Makes a `nil` a string inside of an expect in `define`, allowing `nil` to be passed.
2021-07-15 10:54:30 +01:00
SkyTheCodeMaster
8dbc930c2f
Turn a nil to a string
Makes a `nil` a string inside of an expect in `define`, allowing `nil` to be passed.
2021-07-04 20:54:55 -04:00
Jonathan Coates
61eb67849d
Some fs examples
See #566
2021-07-03 14:05:41 +01:00
Jonathan Coates
efa2be2821
Update changelog for 1.16.x-only features 2021-06-28 22:58:13 +01:00
Jonathan Coates
670db97fc7
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-06-28 22:52:05 +01:00
Jonathan Coates
1650b72edb
Prepare for 1.97.0 release 2021-06-28 22:52:01 +01:00
Jonathan Coates
a5bca3f0df
File uploading (#840) 2021-06-28 22:49:45 +01:00
Jonathan Coates
88f41314c7
Make io handles opaque to the docs
Yep, this is kinda gross. But also a nice refactor
2021-06-28 22:47:56 +01:00
Jonathan Coates
5ef8d52c13
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-06-28 18:37:24 +01:00
Jonathan Coates
a256b70685
Allow setting the subprotocol header
Fixes #828, closes #829
2021-06-24 20:48:28 +01:00
Lupus590
b3f2f14e96
remove extra , 2021-06-23 15:14:01 +01:00
Jonathan Coates
3ace49d27f
Remove config option for debug API
And also remove the "is present" guards within the various APIs. I'm
happy at this point that debug is safe, and think we can guarantee its
presence.
2021-06-22 21:01:05 +01:00
Jonathan Coates
9bd662d8dc
Fix CraftTweaker actions being applied twice
By default CT applies them on the client and server. In a single player
world, this means we try to create two upgrades, which obviously fails!

Fixes #721
2021-06-22 19:39:46 +01:00
Jonathan Coates
df7a40354e
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-06-19 15:18:12 +01:00
Jonathan Coates
c489d4bc4f
Fix exiting paint typing "e" in the shell
When exiting paint via the keyboard by typing "Ctrl" then "E"
separately, we consume the "key" event within paint, leaving the shell
to consume "read".

To avoid this, we run a sleep(0) to gobble any other left-over events.

Note, it's generally not enough to run a queueEvent/pullEvent here, as
the char event may not have ended up on the queue yet. Alas, as this
solution is pretty ugly.
2021-06-19 15:13:26 +01:00
Jonathan Coates
2b029bd506
Refactor some computer screen logic
- Move some shared Gui{Computer,Turtle} code into a new class. Using
   entirely different naming conventions because of course (they are
   consistent with MojMap, just not the rest of CC:T).
 - Fix some mouse scaling issues in the terminal.
2021-06-19 14:18:12 +01:00
Jonathan Coates
2227845658
Remove NetworkMessage.fromBytes
Always build packets using a PacketBuffer constructor instead.
2021-06-19 13:01:43 +01:00
Jonathan Coates
2d3e88ef59
Replace mixin with access transformers
Hadn't realised I could use these to touch final modifiers! More
importantly, Mixin doesn't work with FG 5.0, so we needed an alternative
:).
2021-06-19 12:52:07 +01:00
Jonathan Coates
0bfe960cbd
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-06-19 12:41:30 +01:00
Jonathan Coates
a735f23e1f
Fix a couple of bugs with wget
- Provide a friendly message when writing to a file fails.
 - Correctly write empty files

Fixes #832, closes #833
2021-06-19 11:59:15 +01:00
Jonathan Coates
de6f27ceaf
Rewrite speaker networking code
Speakers now play sounds using a custom set of packets.
 - When playing a sound, we send the resource id, position, volume,
   pitch and a UUID for the _speaker_ to all nearby clients.
 - This UUID is then used when we need to update the sound. When the
   speaker is moved or destroyed, we send a new packet to clients and
   update accordingly.

This does have one side effect, that speakers can now only play one
sound at a time. I think this is accceptable - otherwise it's possible
to spam ward in a loop.

Notes still use the old networking code, and so will not be affected.

Closes #823
2021-06-18 22:23:04 +01:00
Jonathan Coates
2fab1a3054
Minor code style fixups
- Add missing @Override annotations. I can't find a way to enforce this
   with checkstyle - maybe I need spotbugs too D:.
 - Remove superflous "this"es.
2021-06-12 22:18:35 +01:00
Jonathan Coates
d4745ae47e
Don't override isMouseOver
Minecraft's Widget class implements this for us!
2021-06-12 22:02:03 +01:00
Jonathan Coates
d71bf225cc
Add very simple markdown support to the help viewer (#819)
- Allow help files to use the ".md" suffix, and move changelog/whatsnew
   to use them.

 - When files end with ".md", the "help" program attempts to highlight
   them. This involves:
   - Colour code blocks with a lightGrey background.
   - Replace lists to use bullet points instead of "-"/"*".
   - Colours headings yellow.
   The implementation of this is a bit janky because a) I wrote this and
   b) we need to run this step before text wrapping, but preserve
   colours and section positions over wrapping (thanks to Jack for
   getting this working).

 - Add section navigation to the help viewer, with left/right to move to
   the next/previous section.

Closes #569
2021-06-12 19:48:41 +01:00
Wojbie
b323db30ee
Add cc.shell.completion programWithArgs completion. (#815)
And expand monitor, shell, fg and bg to use it
2021-06-07 22:02:45 +01:00
JackMacWindows
53efd6b303
Fixed error handling in scale subcommand (#816) 2021-06-07 20:47:15 +01:00
Jonathan Coates
97faa1b3bc
Fix several sidebar textures
There was an off by one here!
2021-06-07 18:34:57 +01:00
Jonathan Coates
7404133d40
Fix alternative localhost domain
lvh.me is dead. Let's kick the can down the road!
2021-06-07 18:22:49 +01:00
Jonathan Coates
e18e24407e
Add additional buttons to the computer GUI (#809)
Adds a sidebar to the computer and turtle GUI. This currently provides
 - A power indicator, which turns on/shuts down a computer.
 - Button to queue a "terminate" event
2021-06-06 19:32:52 +01:00
Jonathan Coates
026afa7f73
Put some limits on various external queues
Ideally turtle functions would error, but wrangling that is more pain
than it's worth.
2021-06-06 19:26:20 +01:00
Jonathan Coates
29cc5bb86b
Shut down computers on errors
Previously we would attempt to resume them, which then caused confusing
behaviour if the Lua VM was in an inconsistent state.

Closes #811
2021-06-06 18:33:52 +01:00
Jonathan Coates
aa9d3c8269
Refactor LuaContext into a separate class
This isn't tied to Cobalt any more!
2021-06-06 18:33:52 +01:00
Matthew Wilbern
f8074636bc
Allow craft program to craft unlimited items (#807) 2021-06-06 06:52:01 +01:00
Jonathan Coates
db2cde4a4c
Add MoreRed support
I've written three or four integrations with bundled cables now over the
various versions, and I'm still not convinced this one is right. It
appears to work though, so we'll see.

We need depend on the main jar here (rather than the API jar), as
otherwise our javadoc tools fails - the API references some internal
classes which aren't on our classpath.

It might be nice to write tests for this (and CT) in the future -
goodness knows these features are fragile - but that'll require some
more gradle work which I don't want to do right now.

Closes #772
2021-06-05 14:48:38 +01:00
Jonathan Coates
5eec7d9172
Bump to 1.16.5
I don't think anyone still uses 1.16.4, so no point worrying about it.

Closes #808
2021-06-05 12:32:40 +01:00
Jonathan Coates
8b9735d72e
Fix background not rendering on (pocket) computers 2021-06-05 11:46:10 +01:00
Jonathan Coates
1866916cb8
Fix coloured pocket computers using the wrong texture 2021-06-05 11:36:36 +01:00
Jonathan Coates
f38a6a9d43
Merge branch 'mc-1.15.x' into mc-1.16.x 2021-06-05 11:36:30 +01:00
Jonathan Coates
0f6db63020
Remove "*Proxy" classes
- Move registry code into the various *Registry classes.

   I'm not sure this is any more sensible, but things being registered
   in different places kinda irked me.

 - Everything else (i.e. event listeners) goes in a {Client,Common}Hooks
   class right now. It's not ideal, but I don't think we can split it up
   much.
2021-06-05 10:09:28 +01:00
Jonathan Coates
51fcd83b87
Clean up turtle model loading code
Looks like Forge has had hooks for this for years, I've just never
noticed.
2021-06-05 09:14:18 +01:00
Jonathan Coates
c2190e1318
Improve error message for SSL failures
Fixes #803
2021-06-01 22:10:11 +01:00
Ronan Hanley
c40a13558c
Fixed side input consistency issue when a turtle upgrade is removed (#743) 2021-06-01 19:12:35 +01:00
Jonathan Coates
02695aea51
Reduce some block updates
- Fix double updateOutput() call in TileComputerBase - I guess a
   merge/rebase gone wrong in the past.
 - Don't call updateBlock() when creating a server computer. This used
   to be needed when we sent the computer to the client, but this is no
   longer the case.
 - Don't call updateBlock() on TileMonitors when updating from the
   client. We don't need to do a redraw here, as this is all stored in
   the block state now.
 - Don't update the block when reading turtle upgrades. See #643 for
   some background here.

See #658
2021-06-01 18:55:12 +01:00
Jonathan Coates
d5be1aca0e
Always accept command output for command computers
Fixes #799
2021-05-31 19:36:43 +01:00
Jonathan Coates
8ff8b78ed8
Better error handling in treasure disks
- Return a more sensible string for empty treasure disks (i.e. those
   given by /give). This should help identify packs which are giving
   items in non-supported ways.
 - Fix NPE when the treasure mount doesn't exist.

Fixes #801
2021-05-31 19:24:38 +01:00
Matthew Wilbern
7fc55aa9a0
Add __eq metamethod and equals method to the vector api. (#800) 2021-05-31 13:58:46 +01:00
magiczocker10
38335ca187
Add some options for textutils.serialize (#664) 2021-05-29 17:46:58 +01:00
JackMacWindows
e0e194099c
Add a scale subcommand to monitor.lua (#623) 2021-05-29 16:55:55 +01:00
Ronan Hanley
8063059764
Unit tests for Terminal (#740) 2021-05-29 16:24:42 +01:00
Jonathan Coates
f96d923b2a
Allow cleaning dyed turtles in a cauldron
Fixes #771. This does not allow clearing pocket computers or disks right
now - neither normally responds very well to water!
2021-05-29 15:18:53 +01:00
Jonathan Coates
9142ccfc93
Rewrite turtle placing logic
- Simplify how the turtle's inventory is processed. We now copy all
   items into the player inventory, attempt to place, and then copy the
   items back.

   This also fixes the problem where turtle.place() wouldn't (always)
   update the item which was placed.

   I'm also hoping this is more "correct" in how we process drops from
   entities and whatnot. Though I've not had any reports of issues, so
   it's probably fine.

 - Replace the "error message" string array with an actual object. It'd
   be nicer all these functions returned a TurtleCommandResult, but
   merging error messages from that is a little harder.

Fun facts: the test suite was actually helpful here, and caught the fact
that hoeing was broken!
2021-05-29 15:18:26 +01:00
Jonathan Coates
9f7cc00fcb
Add button to view computer's folder
Implementation is a little awkward, as we can't send OPEN_FILE links
from the server, so we ensure the client runs a
/computercraft open-computer ID command instead. We then intercept this
on the client side and use that to open the folder.
2021-05-28 22:19:04 +01:00
Jonathan Coates
b129ae627b
Make cc.pretty internals more opaque
I wish I had an actual type system.
2021-05-28 21:28:56 +01:00
Jonathan Coates
f9fb0619fa
Swap CSS over to use illuaminate's variables
Closes #797
2021-05-28 21:18:38 +01:00
Jonathan Coates
7f9b86a78e
Add basic JMX monitoring on dedicated servers
Closes #482
2021-05-27 21:36:56 +01:00
Weblate
58ea7a275e Translations for French
Translations for French

Translations for German

Co-authored-by: Anavrins <xanavrins@gmail.com>
Co-authored-by: Jummit <jummit@web.de>
Co-authored-by: Naheulf <newheulf@gmail.com>
2021-05-24 01:01:57 +00:00
Jonathan Coates
8b8692ba53 Merge branch 'mc-1.15.x' into mc-1.16.x 2021-05-20 18:30:10 +01:00
Jonathan Coates
1f385f5b35 Bump version to 1.94.0 2021-05-20 18:29:57 +01:00
Jonathan Coates
34baa09b6c Set stack size when crafting coloured items
Fixes #793
2021-05-20 18:12:30 +01:00
JackMacWindows
e0a288bcb9
Add the ability to call cc.expect directly 2021-05-19 20:14:13 -04:00
Jonathan Coates
4592534a18 Fix mount suggestion always being printed out 2021-05-18 09:44:11 +00:00
Lupus590
28165bfcd6
Add cc.expect.range (#790) 2021-05-17 17:49:48 +01:00
Jonathan Coates
e10e30f82b Use a separate region for the bottom pocket computer border
This is definitely not a good solution, but it's probably the best we
can do right now given resizable computers are a thing.

Fixes #775, closes #776
2021-05-16 18:40:18 +01:00
Jonathan Coates
aeb1fa0e7e Optimise all textures
using "optipng -o7 -strip all". I ran this a few years ago and had some
issues, but aren't seeing any problems now. I don't know if this is a
graphics card change, or just optipng fixed some bugs.

These are fairly minimal changes, but hopefully save a few bytes!
2021-05-16 18:00:47 +01:00
Jonathan Coates
349a7543b0 Fix build failures
- Add license headers. Also check these during pre-commit.
 - Fix javadoc issue.
2021-05-15 21:27:48 +01:00
Jonathan Coates
3d589eda4a Expose GenericSource to the public API
- Remove the service provider code and require people to explicitly
   register these. This is definitely more ugly, but easier than people
   pulling in AutoService or similar!
 - Add an API for registering capabilities.
 - Expand the doc comments a little. Not sure how useful they'll be, but
   let's see!

There's still so much work to be done on this, but it's a "good enough"
first step.
2021-05-15 21:11:09 +01:00
Jonathan Coates
de646b66b6 Allow turtles to use compostors 2021-05-14 18:32:52 +01:00
Jonathan Coates
4f0d311df7 Add example to turtle.inspect
A pretty common but non-trivial API, so worth having something. Even if
not perfect.
2021-05-14 18:06:51 +01:00
Jonathan Coates
d6e3c9a7fa Add inventory.getItemLimit
Closes #781
2021-05-13 18:12:49 +01:00
Jonathan Coates
b0e30fdce1 Use lightGrey for folders on normal computers
This way we still get some differences between files and folders on
normal computers. I did try with just green, but I think the contrast is
too low.

Closes #656
2021-05-05 22:10:19 +01:00
Jonathan Coates
4e15afa254 Add tests for placing monitors from turtles (#691) 2021-05-05 21:49:25 +01:00
Jonathan Coates
84bac06178 Merge remote-tracking branch 'baeuric/mc-1.15.x' into mc-1.15.x 2021-05-05 21:46:47 +01:00
Jonathan Coates
1fecb995c9 Don't close file handles from ResourceMounts
Unlike short handles, we don't read these immediately, and so we can't
close it right away. Otherwise the file is considered empty!

Fixes SquidDev-CC/treasure-programs#1
2021-05-05 21:26:17 +01:00
Euric
99b719299c Defer monitor tile update when placed by another TE 2021-05-04 14:24:58 -07:00
Jonathan Coates
fb9590467d Add some examples to inventory methods
Closes #761. It's not perfect, but it's a little better. Maybe??
2021-05-04 19:23:35 +01:00
Jonathan Coates
bc8e090873 Simplify our overrides of load/loadstring
- Remove auto-prefixing of load/loadstring
 - Use Cobalt's normal load implementation, with a simple hook to
   set _ENV on the environment.
2021-05-04 18:30:28 +01:00
Jonathan Coates
cf0f67265f Correctly handle sparse arrays in cc.pretty
This also swaps the order we display mixed array/maps in, so that the
array part comes first. I think this is more sensible.

Closes #777
2021-05-04 18:05:56 +01:00
Jonathan Coates
eb2d617ed8 Add a pre commit hook to lint code
This uses pre-commit [1] to check patches are well formed and run
several linters on them. We currently do some boring things (check files
are syntactically valid) as well as some project-specific ones:
 - Run illuaminate on the Lua files
 - Run checkstyle on Java

[1]: https://pre-commit.com/
2021-04-28 21:24:27 +01:00
Jonathan Coates
74dae4ec17 That's it, I'm adding pre-commit hooks 2021-04-28 08:19:09 +01:00
Jonathan Coates
3cb25b3525 Various VM tests
These are largely copied across from Cobalt's test suite, with some
minor tweaks. It actually exposed one bug in Cobalt, which is pretty
nice.

One interesting thing from the coroutine tests, is that Lua 5.4 (and
one assumes 5.2/5.3) doesn't allow yielding from within the error
handler of xpcall - I rather thought it might.

This doesn't add any of the PUC Lua tests yet - I got a little
distracted.

Also:
 - Allow skipping "keyword" tests, in the style of busted. This is
   implemented on the Java side for now.
 - Fix a bug with os.date("%I", _) not being 2 characters wide.
2021-04-27 22:25:46 +01:00
Jonathan Coates
f387730b88 Merge branch 'mc-1.15.x' into mc-1.16.x 2021-04-24 11:50:23 +01:00
Jonathan Coates
c45221a2d0 Fix checkstyle
This is gonna be 50% of my commits at this rate.
2021-04-13 13:03:26 +01:00