1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-28 16:13:22 +00:00
Commit Graph

406 Commits

Author SHA1 Message Date
SquidDev
741ee447ca A wee bit of a cleanup of the API
- Move some method over to defaulted methods
 - Use Objects rather than Preconditions
2018-12-17 21:33:49 +00:00
SquidDev
86569533e9 The big massive reformat
- Normalise all line endings to be LF rather than CLRF
 - Trim all trailing whitespace
 - Remove any tabs
2018-12-17 18:09:31 +00:00
SquidDev
97c2421a22 Add a couple more modem methods for back compat 2018-12-10 08:26:46 +00:00
SquidDev
f765b6a487 Set keyHandled on the terminal GUI
This allows us to block JEI processing key events such as "o", meaning
the GUI is not constantly toggled when interacting with a turtle.

Also clean up the widget code, as there's a lot of functionality here
which only is needed in CCEdu.
2018-12-08 23:19:56 +00:00
SquidDev
3e6f6467af Allow copying peripheral names from wired modems when attaching/detaching
This is implemented in a rather ugly way: we register a client command
(/computercraft_copy) which updates the clipboard, and run that via a
click handler on the chat message.

This hopefully makes wired modems a little easier to use. We'll see.
2018-11-29 12:21:14 +00:00
SquidDev
7e6eb62504 Move the /computer command into the main computercraft command
I don't think anyone has actually ended up using this, so it's unlikely
to break anything (though do tell me if this is the case). On the flip
side, this allows us to queue events on multiple computers, and means
we can provide a little more documentation.
2018-11-29 11:57:52 +00:00
SquidDev
949b71d40c Use longs instead of ints within .seek
Some crazy person decided they wanted a 20GB file. I'm not judging.
2018-11-28 18:02:52 +00:00
SquidDev
afdfcb21b7 Merge pull request #582 from SquidDev-CC/ComputerCraft/hotfix/extract-overflow
Fix InventoryUtil ignoring the stack limit when extracting items
2018-11-27 17:43:42 +00:00
SquidDev
776a786e1b Fix InventoryUtil ignoring the stack limit when extracting items
Using turtle.suck on an inventory filled with tools would fill the
entire chest with said item, rather than extracting a single item. In
order to avoid that, we clamp the extract limit to the max stack size
when first extracting an item.

This also inlines the makeSlotList logic, which means we can avoid
creating an array for each inventory operation. This probably won't
have any meaninful performance impact (even on large inventories), but
is a nice optimisation to make.
2018-11-27 17:17:39 +00:00
SquidDev
8ae65d1bdd A couple of minor cleanups on the last commit
- Remove a redundant logger
 - Provide a getter for the ComputerCraft thread group. This allows us
   to monitor child threads within prometheus.
 - Replace a deprecated call with a fastutils alternative.
2018-11-22 12:48:06 +00:00
SquidDev
0829506176 Remove last usage of Trove
Minecraft uses it internally, so we can rely on this always being
around. I do not belive Trove exists within 1.13.
2018-11-22 12:15:55 +00:00
SquidDev
71ee692da0 Some more improvements to threading
- Put all ComputerCraft threads into a thread group
 - Be a little more aggressive in when we cleanup/abandon threads.
2018-11-22 12:09:24 +00:00
SquidDev
acd0092ed5 Add back JarMount for backwards compatibility
Some mods (*cough* Computronics *cough*) directly access this class,
rather than using the API. We add this back to ensure they still behave
as expected.

Truth be told, I can't really complain, as Plethora also does dodgy
thing with CC internals.
2018-11-22 10:06:43 +00:00
SquidDev
1160ffbf9e Bump version and require a minimum version of Forge 2018-11-21 18:11:14 +00:00
SquidDev
93cb6547bd Improvements for coroutine creation
- Keep track of the number of created and destroyed coroutines for each
   computer.
 - Run coroutines with a thread pool executor, which will keep stale
   threads around for 60 seconds. This substantially reduces the
   pressure from short-lived coroutines.
 - Update to the latest Cobalt version.
2018-11-21 16:47:06 +00:00
SquidDev
f9c91f288f Try to remove some locking
Ideally we would be able to avoid locking at all on the main thread, but
needs must.
2018-11-19 20:56:44 +00:00
SquidDev
62cf921cc6 Allow modems to handle being attached to multiple computers
- Introduce a ModemState, which shares the open channels across all
   modem instances of a wired modem.
 - Keep a set of computers for all modem peripherals.
 - Keep a map of computers -> (string, peripheral) for wired modem
   peripherals. We shouldn't need this one, as you cannot attach one
   modem to another, but it's good to be consistent.

One major change here is that modems will continue to be "on", even if
no computers are attached. This would substantially increase
implementation complexity, so I think this is an acceptable compromise
for now.

Should fix #74
2018-11-17 11:52:12 +00:00
SquidDev
4bd7381827 Add support for Forge's ISelectiveResourceReloadListener
This means we don't reload turtles every time someone just reloads
shaders or the language pack.
2018-11-17 10:54:42 +00:00
SquidDev
43459ec825 Fix read methods failing on malformed unicode.
Java configured the charset decoders/encoders for streams to REPLACE
malformed characters rather than the default REPORT. It does not do the
same for channels, and so we were catching an IO exception and returning
null.
2018-11-16 20:58:49 +00:00
SquidDev
5fa01f8b96 Truncate files when writing them
This is performed by default, but as we don't pass any options, this
flag is removed.

Closes #75
2018-11-16 13:09:12 +00:00
SquidDev
67d5693d2a Fix tile entities being registered with incorrect names
We'd somehow added spaces, which means they weren't registered under the
computercraft domain (rather, the "computercraft " one). We also create
a datafixer to ensure old worlds are handled correctly.
2018-11-16 12:29:29 +00:00
SquidDev
d53a73e7e7 Fix resource handle loading
See #70
2018-10-29 15:59:43 +00:00
SquidDev
7e334bd4a5 Fix a couple of other bugs with the fs rewrite
- Fix stdin not being considered a "readable" input
 - Return an unsigned byte rather than a signed one for no-args .read()
2018-10-28 08:39:44 +00:00
SquidDev
8080699030 Couple of minor improvements to the alternative mount implementation
- Rename openStreamFor* methods to more accurate openChannelFor*
 - Fix ArrayByteChannel having an incorrect .position() implementation

Cherry-picked from the PR against dan200/ComputerCraft
2018-10-24 12:39:22 +01:00
SquidDev
e555f9f7f0 Merge pull request #575 from SquidDev-CC/ComputerCraft/feature/file-seeking
Rewrite file systems to use ByteChannels
2018-10-24 12:20:53 +01:00
SquidDev
822db6e9b5 Add support for binary websockets
- Add an argument to send which controls whether it's a binary message
   or not. This is a little ugly, but it's probably more effective than
   anything else.
 - Fix binary frames not correctly queueing the correct data in the
   message event.

Closes #69
2018-10-23 12:15:40 +01:00
SquidDev
ac1f30ef43 Clamp the volume for all sounds, rather than just notes
This restores the previous behaviour.
2018-10-12 12:05:31 +01:00
SquidDev
0fc1b8c46b Merge pull request #578 from SquidDev-CC/ComputerCraft/feature/speaker-sound
Change speakers to use the SPacketCustomSound packet instead
2018-10-10 16:57:34 +01:00
SquidDev
e7c19bcf55 Change speakers to use the SPacketCustomSound packet instead
The method to register new SoundEvents is private, which means that few
(if any) mods actually register them. Consequently, one could not use
the speaker to play any modded sound, as they weren't registered on the
server side.

Using SPacketCustomSound does mean we can no longer determine if a sound
exists or not, but I think a price I'm willing to pay in order to allow
playing modded sounds.
2018-10-10 08:46:30 +01:00
SquidDev
33fad2da15 Merge pull request #577 from SquidDev-CC/ComputerCraft/feature/get-blink
Add .getCursorBlink to monitors and terminals
2018-09-28 16:23:00 +01:00
SquidDev
518eefbe10 Rewrite file systems to use ByteChannels
This replaces the existing IMount openFor* method with openChannelFor*
ones, which return an appropriate byte channel instead.

As channels are not correctly closed when GCed, we introduce a
FileSystemWrapper. We store a weak reference to this, and when it is
GCed or the file closed, we will remove it from our "open file" set and
ensure any underlying buffers are closed.

While this change may seem a little odd, it does introduce some
benefits:

 - We can replace JarMount with a more general FileSystemMount. This
   does assume a read-only file system, but could technically be used
   for other sources.

 - Add support for seekable (binary) handles. We can now look for
   instances of SeekableByteChannel and dynamically add it. This works
   for all binary filesystem and HTTP streams.

 - Rewrite the io library to more accurately emulate PUC Lua's
   implementation. We do not correctly implement some elements (most
   noticably "*n", but it's a definite improvement.
2018-09-26 10:00:17 +01:00
SquidDev
1ba73454c1 Add .getCursorBlink to monitors and terminals
Closes #576
2018-09-23 09:34:28 +01:00
SquidDev
c6bd88f3ad Attempt to cut out a lot of synchronized calls
A lot of these don't actually have any effect as they'll only be called
on the main thread or they are getters where the state is guaranteed to
be consistent whenever it is accessed.

Hopefully this'll reduce the chance of world updates being blocked by
waiting for peripheral locks to be released.
2018-08-25 21:17:48 +01:00
apemanzilla
89c7183a1d Prevent stack overflows when using turtle.place() with a full inventory 2018-08-23 07:56:50 +01:00
SquidDev
d2a9e7e458 Reset a few more flags when rendering printouts
Closes #63
2018-08-13 22:25:58 +01:00
SquidDev
093132533d Add charset bundled cable integration
- Bump MinecraftForge version so we don't crash on load. Oh boy, all
   the deprecation warnings.
 - Inject IBundledEmitter and IBundledReceiver capabilities onto all
   TileGenerics.
 - Register a IBundledRedstoneProvider instance for IBundledEmitter.
2018-08-11 10:49:21 +01:00
SquidDev
f40733e9a6 Error when missing computers after executing the command
This allows you to automate running various commands and still have them
"work" if some computers are not loaded.

Closes #47
2018-08-04 10:39:44 +01:00
SquidDev
b8957cab5c Update to the latest mappings
This is a preliminary for updating to 1.13, as many of the name changes
apply to both. This will make it harder to remain consistent with
actual CC, though that will be less of a consideration when 1.13 hits.
2018-07-24 09:27:05 +01:00
SquidDev
17dace979a Merge pull request #562 from SquidDev-CC/ComputerCraft/hotfix/turtle-sign-place
Be a little smarter about our detection of the placed sign
2018-07-09 20:57:42 +01:00
SquidDev
d405316a4b Be a little smarter about our detection of the placed sign
When placing a sign against a tile entity (such as a turtle or chest),
we would consider that block the "placed" one instead, meaning the text
was never set. This solution isn't entirely ideal either, but short of
capturing block snapshots I'm not sure of a better solution.

Fixes #552
2018-07-09 20:53:49 +01:00
SquidDev
7e18f2cead Clear the turtle's inventory on load 2018-07-09 18:22:42 +01:00
SquidDev
000786a1a7 Merge pull request #560 from SquidDev-CC/ComputerCraft/hotfix/turtle-destroy
Rewrite turtle block destroying
2018-07-08 23:01:13 +01:00
SquidDev
0bf13562b9 Provide a more direct way to get the related computer
Effectively shift extracting the computer away from Plethora into CC:T.
Ideally we wouldn't need this at all, but Plethora does some funky
things with tick timings.

See SquidDev-CC/plethora#125
2018-07-08 22:48:50 +01:00
SquidDev
45a189e834 Cache a turtle's fake player
Player construction can get a little expensive, and this is exacerbated
by Sponge. We now cache a turtle's fake player (updating the position
every time it is requested) in order to reduce this overhead.
2018-07-08 15:21:42 +01:00
SquidDev
0ce6f34a09 Rewrite printout rendering
- The current page is always centred when rendering in a GUI, with
   the turned pages moving from the sides.
 - Pages are no longer evenly distributed from the centre - they follow
   an exponential decay curve, so ones further out are closer together
   (a bit like an open book).
 - Render pages and books in item frames/in-hand (rather than just
   single pages).

This currently does some very dirty things with z values in order to
prevent z-fighting. It would be nice to avoid that, though turning off
writing to the z buffer causes issues with the bounding box.
2018-07-07 19:59:20 +01:00
SquidDev
4d984dc5ee Rewrite turtle block destroying
- Try to make drop capturing a little more generic. This now allows for
   capturing a block's drop at a given position, as well as any drop
   within a bounding box (for things which don't play nicely).

 - Use as much of Minecraft's block breaking logic as possible,
   hopefully simplifying things and making it more consistent with other
   mods.
2018-07-06 18:49:15 +01:00
SquidDev
984d358930 Provide .getNameLocal on modems
This provides the local modem's name on the remote network. Let's be
honest, I'll probably end up renaming this soon.
2018-06-29 20:29:04 +01:00
SquidDev
a95893b823 Send the terminal state to the pocket computer's player
As we only send the terminal to players using the GUI, the map interface
was never updated. We now will also send the terminal state to whoever
has the computer in their inventory.

This also marks the terminal as dirty when a new player picks the pocket
computer up, hopefully preventing any desync issues which might occur
then.

Fixes #42.
2018-06-24 19:18:30 +01:00
SquidDev
81aaead032 Improve using /computercraft as a non-player
- Fix text table only showing the first row (fixes #40)
 - Do not emit alignment characters in monospace environments
 - Reduce padding in monospace environments

Also make the output of dump consistent with that of the profiler: we
provide tp and view shortcuts for each computer.
2018-06-22 08:28:36 +01:00
SquidDev
fd10ed6f62 Merge pull request #553 from SquidDev-CC/ComputerCraft/feature/fancy-printout
Fancy rendering of printouts
2018-06-19 19:44:51 +01:00