mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-15 14:07:38 +00:00
Compare commits
92 Commits
v1.14.4-1.
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1da86d6f75 | ||
![]() |
53a23f8d3d | ||
![]() |
550f63b1cb | ||
![]() |
416e87852e | ||
![]() |
7940687df2 | ||
![]() |
37a447e745 | ||
![]() |
9e2232d240 | ||
![]() |
2a8efb3fd5 | ||
![]() |
c0f3ca81fb | ||
![]() |
014bf55cd4 | ||
![]() |
085ae2e74a | ||
![]() |
4ff33f165d | ||
![]() |
d929c02d2a | ||
![]() |
d50a08a549 | ||
![]() |
161a5b4707 | ||
![]() |
c6b6b4479c | ||
![]() |
96e7b60285 | ||
![]() |
086fccd997 | ||
![]() |
a4ae36b6b3 | ||
![]() |
ac075d9f53 | ||
![]() |
05d7be0362 | ||
![]() |
9a71dc1a26 | ||
![]() |
156023b154 | ||
![]() |
6b3773a862 | ||
![]() |
376d628cf0 | ||
![]() |
44062ebd52 | ||
![]() |
5739285fc2 | ||
![]() |
70b457ed18 | ||
![]() |
1547ecbeb3 | ||
![]() |
550ada2f9e | ||
![]() |
17b7727262 | ||
![]() |
4553e404b2 | ||
![]() |
a565a571f9 | ||
![]() |
fb64b6017b | ||
![]() |
ed4229ab70 | ||
![]() |
3fb906ef6c | ||
![]() |
e1663f3df0 | ||
![]() |
447c3ab125 | ||
![]() |
8fac68386e | ||
![]() |
ae7ef66dfa | ||
![]() |
9748679484 | ||
![]() |
da419b24e7 | ||
![]() |
7f57a977a1 | ||
![]() |
2f42a4e85b | ||
![]() |
f3de97d67f | ||
![]() |
544f276ff0 | ||
![]() |
463635a459 | ||
![]() |
3b7b845930 | ||
![]() |
1fc0214857 | ||
![]() |
11bf601db9 | ||
![]() |
7c1154ddfc | ||
![]() |
cea8be7efa | ||
![]() |
c5f918ad95 | ||
![]() |
b14c7842fc | ||
![]() |
eead8b5755 | ||
![]() |
10a27a7a25 | ||
![]() |
865fc239a0 | ||
![]() |
f9f94b8304 | ||
![]() |
cb8135a0d1 | ||
![]() |
ef4b0a5632 | ||
![]() |
6a6a87489c | ||
![]() |
062977336a | ||
![]() |
e52d98ad8b | ||
![]() |
ef8da8054f | ||
![]() |
1ccd687c00 | ||
![]() |
a8ce5a5b20 | ||
![]() |
68e6bc464b | ||
![]() |
68762fe84c | ||
![]() |
0ffd5fcf85 | ||
![]() |
239bd769df | ||
![]() |
79f42e35ce | ||
![]() |
be89fc25f9 | ||
![]() |
8eae02c037 | ||
![]() |
930fd59298 | ||
![]() |
bf13bac152 | ||
![]() |
0de5969ec1 | ||
![]() |
3f98b2785e | ||
![]() |
798868427e | ||
![]() |
c79f643ba7 | ||
![]() |
1db3a14c54 | ||
![]() |
8b1773dd60 | ||
![]() |
018ecfbaa0 | ||
![]() |
4c8fd4fc35 | ||
![]() |
35c1b10224 | ||
![]() |
c1c01bef7c | ||
![]() |
a48c3d0ba8 | ||
![]() |
93a9ebc4f6 | ||
![]() |
7cc2bd43c6 | ||
![]() |
393e628721 | ||
![]() |
0bcd28e58c | ||
![]() |
42f5389fb8 | ||
![]() |
041cfe91b4 |
@@ -14,5 +14,9 @@ trim_trailing_whitespace = false
|
||||
[*.sexp]
|
||||
indent_size = 2
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
||||
|
||||
[*.properties]
|
||||
insert_final_newline = false
|
||||
|
33
.github/workflows/main-ci.yml
vendored
33
.github/workflows/main-ci.yml
vendored
@@ -1,33 +0,0 @@
|
||||
name: Build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --no-daemon
|
||||
|
||||
lint-lua:
|
||||
name: Lint Lua
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Lint Lua code
|
||||
run: |
|
||||
test -d bin || mkdir bin
|
||||
test -f bin/illuaminate || wget -q -Obin/illuaminate https://squiddev.cc/illuaminate/bin/illuaminate
|
||||
chmod +x bin/illuaminate
|
||||
bin/illuaminate lint
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,8 @@
|
||||
/logs
|
||||
/build
|
||||
/out
|
||||
/doc/**/*.html
|
||||
/doc/index.json
|
||||
|
||||
# Runtime directories
|
||||
/run
|
||||
|
36
CONTRIBUTING.md
Normal file
36
CONTRIBUTING.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Contributing to CC: Tweaked
|
||||
As with many open source projects, CC: Tweaked thrives on contributions from other people! This document (hopefully)
|
||||
provides an introduction as to how to get started in helping out.
|
||||
|
||||
If you've any other questions, [just ask the community][community] or [open an issue][new-issue].
|
||||
|
||||
## Reporting issues
|
||||
If you have a bug, suggestion, or other feedback, the best thing to do is [file an issue][new-issue]. When doing so,
|
||||
do use the issue templates - they provide a useful hint on what information to provide.
|
||||
|
||||
## Developing
|
||||
In order to develop CC: Tweaked, you'll need to download the source code and then run it. This is a pretty simple
|
||||
process.
|
||||
|
||||
- **Clone the repository:** `git clone https://github.com/SquidDev-CC/CC-Tweaked.git && cd CC-Tweaked`
|
||||
- **Setup Forge:** `./gradlew setupDecompWorkspace`
|
||||
- **Run Minecraft:** `./gradlew runClient` (or run the `GradleStart` class from your IDE).
|
||||
|
||||
If you want to run CC:T in a normal Minecraft instance, run `./gradlew build` and copy the `.jar` from `build/libs`.
|
||||
These commands may take a few minutes to run the first time, as the environment is set up, but should be much faster
|
||||
afterwards.
|
||||
|
||||
### Code linters
|
||||
CC: Tweaked uses a couple of "linters" on its source code, to enforce a consistent style across the project. While these
|
||||
are run whenever you submit a PR, it's often useful to run this before committing.
|
||||
|
||||
- **[Checkstyle]:** Checks Java code to ensure it is consistently formatted. This can be run with `./gradlew build` or
|
||||
`./gradle check`.
|
||||
- **[illuaminate]:** Checks Lua code for semantic and styleistic issues. See [the usage section][illuaminate-usage] for
|
||||
how to download and run it.
|
||||
|
||||
[new-issue]: https://github.com/SquidDev-CC/CC-Tweaked/issues/new/choose "Create a new issue"
|
||||
[community]: README.md#Community "Get in touch with the community."
|
||||
[checkstyle]: https://checkstyle.org/
|
||||
[illuaminate]: https://github.com/SquidDev/illuaminate/
|
||||
[illuaminate-usage]: https://github.com/SquidDev/illuaminate/blob/master/README.md#usage
|
18
README.md
18
README.md
@@ -1,4 +1,4 @@
|
||||
# 
|
||||
# 
|
||||
[](https://github.com/SquidDev-CC/CC-Tweaked/actions "Current build status") [](https://minecraft.curseforge.com/projects/cc-tweaked "Download CC: Tweaked on CurseForge")
|
||||
|
||||
CC: Tweaked is a fork of [ComputerCraft](https://github.com/dan200/ComputerCraft), adding programmable computers,
|
||||
@@ -37,20 +37,14 @@ several features have been included, such as full block modems, the Cobalt runti
|
||||
computers.
|
||||
|
||||
## Contributing
|
||||
Any contribution is welcome, be that using the mod, reporting bugs or contributing code. In order to start helping
|
||||
develop CC:T, you'll need to follow these steps:
|
||||
|
||||
- **Clone the repository:** `git clone https://github.com/SquidDev-CC/CC-Tweaked.git && cd CC-Tweaked`
|
||||
- **Setup Forge:** `./gradlew setupDecompWorkspace`
|
||||
- **Test your changes:** `./gradlew runClient` (or run the `GradleStart` class from your IDE).
|
||||
|
||||
If you want to run CC:T in a normal Minecraft instance, run `./gradlew build` and copy the `.jar` from `build/libs`.
|
||||
Any contribution is welcome, be that using the mod, reporting bugs or contributing code. If you want to get started
|
||||
developing the mod, [check out the instructions here](CONTRIBUTING.md#developing).
|
||||
|
||||
## Community
|
||||
If you need help getting started with CC: Tweaked, want to show off your latest project, or just want to chat about
|
||||
ComputerCraft we have a [forum](https://forums.computercraft.cc/) and [Discord guild](https://discord.gg/H2UyJXe)!
|
||||
There's also a fairly populated, albeit quiet [IRC channel](http://webchat.esper.net/?channels=#computercraft), if
|
||||
that's more your cup of tea.
|
||||
ComputerCraft we have a [forum](https://forums.computercraft.cc/) and [Discord guild](https://discord.computercraft.cc)!
|
||||
There's also a fairly populated, albeit quiet [IRC channel](http://webchat.esper.net/?channels=computercraft), if that's
|
||||
more your cup of tea.
|
||||
|
||||
I'd generally recommend you don't contact me directly (email, DM, etc...) unless absolutely necessary (i.e. in order to
|
||||
report exploits). You'll get a far quicker response if you ask the whole community!
|
||||
|
29
build.gradle
29
build.gradle
@@ -18,6 +18,7 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id "checkstyle"
|
||||
id "jacoco"
|
||||
id "com.github.hierynomus.license" version "0.15.0"
|
||||
id "com.matthewprenger.cursegradle" version "1.3.0"
|
||||
id "com.github.breadmoirai.github-release" version "2.2.4"
|
||||
@@ -43,10 +44,6 @@ minecraft {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name "JEI"
|
||||
url "https://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
maven {
|
||||
name "SquidDev"
|
||||
url "https://squiddev.cc/maven"
|
||||
@@ -55,14 +52,6 @@ repositories {
|
||||
name "Charset"
|
||||
artifactPattern "https://asie.pl/files/mods/Charset/LibOnly/[module]-[revision](-[classifier]).[ext]"
|
||||
}
|
||||
maven {
|
||||
name "Amadornes"
|
||||
url "https://maven.amadornes.com/"
|
||||
}
|
||||
maven {
|
||||
name "CraftTweaker"
|
||||
url "https://maven.blamejared.com/"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -81,7 +70,7 @@ dependencies {
|
||||
|
||||
runtime "mezz.jei:jei_1.12.2:4.15.0.269"
|
||||
|
||||
shade 'org.squiddev:Cobalt:0.5.0-SNAPSHOT'
|
||||
shade 'org.squiddev:Cobalt:0.5.5'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
|
||||
@@ -147,6 +136,9 @@ task proguard(type: ProGuardTask, dependsOn: jar) {
|
||||
// We want to avoid as much obfuscation as possible. We're only doing this to shrink code size.
|
||||
dontobfuscate; dontoptimize; keepattributes; keepparameternames
|
||||
|
||||
// Tell ProGuard to shut up
|
||||
dontwarn 'org.checkerframework.**'
|
||||
|
||||
// Proguard will remove directories by default, but that breaks JarMount.
|
||||
keepdirectories 'assets/computercraft/lua**'
|
||||
|
||||
@@ -255,11 +247,20 @@ test {
|
||||
}
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
reports {
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn jacocoTestReport
|
||||
|
||||
license {
|
||||
mapping("java", "SLASHSTAR_STYLE")
|
||||
strictCheck true
|
||||
|
||||
ext.year = Calendar.getInstance().get(Calendar.YEAR)
|
||||
ext.year = 2020
|
||||
}
|
||||
|
||||
[licenseMain, licenseFormatMain].forEach {
|
||||
|
11
doc/index.md
Normal file
11
doc/index.md
Normal file
@@ -0,0 +1,11 @@
|
||||
#  [](https://minecraft.curseforge.com/projects/cc-tweaked "Download CC: Tweaked on CurseForge")
|
||||
|
||||
CC: Tweaked is a fork of [ComputerCraft], adding programmable computers, turtles and more to Minecraft.
|
||||
|
||||
This website contains documentation for all Lua libraries and APIs from the latest version of CC: Tweaked. This
|
||||
documentation is still in development, so will most likely be incomplete. If you've found something you think is wrong,
|
||||
or would like to help out [please get in touch on GitHub][gh].
|
||||
|
||||
[bug]: https://github.com/SquidDev-CC/CC-Tweaked/issues/new/choose
|
||||
[computercraft]: https://github.com/dan200/ComputerCraft "ComputerCraft on GitHub"
|
||||
[gh]: https://github.com/SquidDev-CC/CC-Tweaked "CC:Tweaked on GitHub"
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
77
doc/stub/commands.lua
Normal file
77
doc/stub/commands.lua
Normal file
@@ -0,0 +1,77 @@
|
||||
--- Execute a specific command.
|
||||
--
|
||||
-- @tparam string command The command to execute.
|
||||
-- @treturn boolean Whether the command executed successfully.
|
||||
-- @treturn { string... } The output of this command, as a list of lines.
|
||||
-- @treturn number|nil The number of "affected" objects, or `nil` if the command
|
||||
-- failed. The definition of this varies from command to command.
|
||||
-- @usage Set the block above the command computer to stone.
|
||||
--
|
||||
-- commands.exec("setblock ~ ~1 ~ minecraft:stone")
|
||||
function exec(command) end
|
||||
|
||||
--- Asynchronously execute a command.
|
||||
--
|
||||
-- Unlike @{exec}, this will immediately return, instead of waiting for the
|
||||
-- command to execute. This allows you to run multiple commands at the same
|
||||
-- time.
|
||||
--
|
||||
-- When this command has finished executing, it will queue a `task_complete`
|
||||
-- event containing the result of executing this command (what @{exec} would
|
||||
-- return).
|
||||
--
|
||||
-- @tparam string command The command to execute.
|
||||
-- @treturn number The "task id". When this command has been executed, it will
|
||||
-- queue a `task_complete` event with a matching id.
|
||||
-- @usage Asynchronously sets the block above the computer to stone.
|
||||
--
|
||||
-- commands.execAsync("~ ~1 ~ minecraft:stone")
|
||||
-- @see parallel One may also use the parallel API to run multiple commands at
|
||||
-- once.
|
||||
function execAsync(commad) end
|
||||
|
||||
--- List all available commands which the computer has permission to execute.
|
||||
--
|
||||
-- @treturn { string... } A list of all available commands
|
||||
function list() end
|
||||
|
||||
--- Get the position of the current command computer.
|
||||
--
|
||||
-- @treturn number This computer's x position.
|
||||
-- @treturn number This computer's y position.
|
||||
-- @treturn number This computer's z position.
|
||||
-- @see gps.locate To get the position of a non-command computer.
|
||||
function getBlockPosition() end
|
||||
|
||||
--- Get some basic information about a block.
|
||||
--
|
||||
-- The returned table contains the current name, metadata and block state (as
|
||||
-- with @{turtle.inspect}). If there is a tile entity for that block, its NBT
|
||||
-- will also be returned.
|
||||
--
|
||||
-- @tparam number x The x position of the block to query.
|
||||
-- @tparam number y The y position of the block to query.
|
||||
-- @tparam number z The z position of the block to query.
|
||||
-- @treturn table The given block's information.
|
||||
-- @throws If the coordinates are not within the world, or are not currently
|
||||
-- loaded.
|
||||
function getBlockInfo(x, y, z) end
|
||||
|
||||
--- Get information about a range of blocks.
|
||||
--
|
||||
-- This returns the same information as @{getBlockInfo}, just for multiple
|
||||
-- blocks at once.
|
||||
--
|
||||
-- Blocks are traversed by ascending y level, followed by z and x - the returned
|
||||
-- table may be indexed using `x + z*width + y*depth*depth`.
|
||||
--
|
||||
-- @tparam number min_x The start x coordinate of the range to query.
|
||||
-- @tparam number min_y The start y coordinate of the range to query.
|
||||
-- @tparam number min_z The start z coordinate of the range to query.
|
||||
-- @tparam number max_x The end x coordinate of the range to query.
|
||||
-- @tparam number max_y The end y coordinate of the range to query.
|
||||
-- @tparam number max_z The end z coordinate of the range to query.
|
||||
-- @treturn { table... } A list of information about each block.
|
||||
-- @throws If the coordinates are not within the world.
|
||||
-- @throws If trying to get information about more than 4096 blocks.
|
||||
function getBlockInfos(min_x, min_y, min_z, max_x, max_y, max_z) end
|
84
doc/stub/fs.lua
Normal file
84
doc/stub/fs.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
--- The FS API allows you to manipulate files and the filesystem.
|
||||
--
|
||||
-- @module fs
|
||||
|
||||
function list(path) end
|
||||
function combine(base, child) end
|
||||
function getName(path) end
|
||||
function getSize(path) end
|
||||
function exists(path) end
|
||||
function isDir(path) end
|
||||
function isReadOnly(path) end
|
||||
function makeDir(path) end
|
||||
function move(from, to) end
|
||||
function copy(from, to) end
|
||||
function delete(path) end
|
||||
function open(path, mode) end
|
||||
function getDrive(path) end
|
||||
function getFreeSpace(path) end
|
||||
function find(pattern) end
|
||||
function getDir(path) end
|
||||
|
||||
--- Returns true if a path is mounted to the parent filesystem.
|
||||
--
|
||||
-- The root filesystem "/" is considered a mount, along with disk folders and
|
||||
-- the rom folder. Other programs (such as network shares) can exstend this to
|
||||
-- make other mount types by correctly assigning their return value for getDrive.
|
||||
--
|
||||
-- @tparam string path The path to check.
|
||||
-- @treturn boolean If the path is mounted, rather than a normal file/folder.
|
||||
-- @throws If the path does not exist.
|
||||
-- @see getDrive
|
||||
function isDriveRoot(path) end
|
||||
|
||||
--- Get the capacity of the drive at the given path.
|
||||
--
|
||||
-- This may be used in conjunction with @{getFreeSpace} to determine what
|
||||
-- percentage of this drive has been used.
|
||||
--
|
||||
-- @tparam string path The path of the drive to get.
|
||||
-- @treturn number This drive's capacity. This will be 0 for "read-only" drives,
|
||||
-- such as the ROM or treasure disks.
|
||||
function getCapacity(path) end
|
||||
|
||||
--- Get attributes about a specific file or folder.
|
||||
--
|
||||
-- The returned attributes table contains information about the size of the
|
||||
-- file, whether it is a directory, and when it was created and last modified.
|
||||
--
|
||||
-- The creation and modification times are given as the number of milliseconds
|
||||
-- since the UNIX epoch. This may be given to @{os.date} in order to convert it
|
||||
-- to more usable form.
|
||||
--
|
||||
-- @tparam string path The path to get attributes for.
|
||||
-- @treturn { size = number, isDir = boolean, created = number, modified = number }
|
||||
-- The resulting attributes.
|
||||
-- @throws If the path does not exist.
|
||||
-- @see getSize If you only care about the file's size.
|
||||
-- @see isDir If you only care whether a path is a directory or not.
|
||||
function attributes(path) end
|
||||
|
||||
-- Defined in bios.lua
|
||||
function complete(sPath, sLocation, bIncludeFiles, bIncludeDirs) end
|
||||
|
||||
--- A file handle which can be read from.
|
||||
--
|
||||
-- @type ReadHandle
|
||||
-- @see fs.open
|
||||
local ReadHandle = {}
|
||||
function ReadHandle.read(count) end
|
||||
function ReadHandle.readAll() end
|
||||
function ReadHandle.readLine(with_trailing) end
|
||||
function ReadHandle.seek(whence, offset) end
|
||||
function ReadHandle.close() end
|
||||
|
||||
--- A file handle which can be written to.
|
||||
--
|
||||
-- @type WriteHandle
|
||||
-- @see fs.open
|
||||
local WriteHandle = {}
|
||||
function WriteHandle.write(text) end
|
||||
function WriteHandle.writeLine(text) end
|
||||
function WriteHandle.flush(text) end
|
||||
function WriteHandle.seek(whence, offset) end
|
||||
function WriteHandle.close() end
|
229
doc/stub/http.lua
Normal file
229
doc/stub/http.lua
Normal file
@@ -0,0 +1,229 @@
|
||||
--- The http library allows communicating with web servers, sending and
|
||||
-- receiving data from them.
|
||||
--
|
||||
-- #### `http_check` event
|
||||
--
|
||||
-- @module http
|
||||
|
||||
--- Asynchronously make a HTTP request to the given url.
|
||||
--
|
||||
-- This returns immediately, a [`http_success`](#http-success-event) or
|
||||
-- [`http_failure`](#http-failure-event) will be queued once the request has
|
||||
-- completed.
|
||||
--
|
||||
-- @tparam string url The url to request
|
||||
-- @tparam[opt] string body An optional string containing the body of the
|
||||
-- request. If specified, a `POST` request will be made instead.
|
||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
|
||||
-- of this request.
|
||||
-- @tparam[opt] boolean binary Whether to make a binary HTTP request. If true,
|
||||
-- the body will not be UTF-8 encoded, and the received response will not be
|
||||
-- decoded.
|
||||
--
|
||||
-- @tparam[2] {
|
||||
-- url = string, body? = string, headers? = { [string] = string },
|
||||
-- binary? = boolean, method? = string, redirect? = boolean,
|
||||
-- } request Options for the request.
|
||||
--
|
||||
-- This table form is an expanded version of the previous syntax. All arguments
|
||||
-- from above are passed in as fields instead (for instance,
|
||||
-- `http.request("https://example.com")` becomes `http.request { url =
|
||||
-- "https://example.com" }`).
|
||||
--
|
||||
-- This table also accepts several additional options:
|
||||
--
|
||||
-- - `method`: Which HTTP method to use, for instance `"PATCH"` or `"DELETE"`.
|
||||
-- - `redirect`: Whether to follow HTTP redirects. Defaults to true.
|
||||
--
|
||||
-- @see http.get For a synchronous way to make GET requests.
|
||||
-- @see http.post For a synchronous way to make POST requests.
|
||||
function request(...) end
|
||||
|
||||
--- Make a HTTP GET request to the given url.
|
||||
--
|
||||
-- @tparam string url The url to request
|
||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
|
||||
-- of this request.
|
||||
-- @tparam[opt] boolean binary Whether to make a binary HTTP request. If true,
|
||||
-- the body will not be UTF-8 encoded, and the received response will not be
|
||||
-- decoded.
|
||||
--
|
||||
-- @tparam[2] {
|
||||
-- url = string, headers? = { [string] = string },
|
||||
-- binary? = boolean, method? = string, redirect? = boolean,
|
||||
-- } request Options for the request. See @{http.request} for details on how
|
||||
-- these options behave.
|
||||
--
|
||||
-- @treturn Response The resulting http response, which can be read from.
|
||||
-- @treturn[2] nil When the http request failed, such as in the event of a 404
|
||||
-- error or connection timeout.
|
||||
-- @treturn string A message detailing why the request failed.
|
||||
-- @treturn Response|nil The failing http response, if available.
|
||||
--
|
||||
-- @usage Make a request to [example.computercraft.cc](https://example.computercraft.cc),
|
||||
-- and print the returned page.
|
||||
-- ```lua
|
||||
-- local request = http.get("https://example.computercraft.cc")
|
||||
-- print(request.readAll())
|
||||
-- -- => HTTP is working!
|
||||
-- request.close()
|
||||
-- ```
|
||||
function get(...) end
|
||||
|
||||
--- Make a HTTP POST request to the given url.
|
||||
--
|
||||
-- @tparam string url The url to request
|
||||
-- @tparam string body The body of the POST request.
|
||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
|
||||
-- of this request.
|
||||
-- @tparam[opt] boolean binary Whether to make a binary HTTP request. If true,
|
||||
-- the body will not be UTF-8 encoded, and the received response will not be
|
||||
-- decoded.
|
||||
--
|
||||
-- @tparam[2] {
|
||||
-- url = string, body? = string, headers? = { [string] = string },
|
||||
-- binary? = boolean, method? = string, redirect? = boolean,
|
||||
-- } request Options for the request. See @{http.request} for details on how
|
||||
-- these options behave.
|
||||
--
|
||||
-- @treturn Response The resulting http response, which can be read from.
|
||||
-- @treturn[2] nil When the http request failed, such as in the event of a 404
|
||||
-- error or connection timeout.
|
||||
-- @treturn string A message detailing why the request failed.
|
||||
-- @treturn Response|nil The failing http response, if available.
|
||||
function post(...) end
|
||||
|
||||
--- A http response. This acts very much like a @{fs.ReadHandle|file}, though
|
||||
-- provides some http specific methods.
|
||||
--
|
||||
-- #### `http_success` event
|
||||
-- #### `http_failure` event
|
||||
--
|
||||
-- @type Response
|
||||
-- @see http.request On how to make a http request.
|
||||
local Response = {}
|
||||
|
||||
--- Returns the response code and response message returned by the server
|
||||
--
|
||||
-- @treturn number The response code (i.e. 200)
|
||||
-- @treturn string The response message (i.e. "OK")
|
||||
function Response.getResponseCode() end
|
||||
|
||||
--- Get a table containing the response's headers, in a format similar to that
|
||||
-- required by @{http.request}. If multiple headers are sent with the same
|
||||
-- name, they will be combined with a comma.
|
||||
--
|
||||
-- @treturn { [string]=string } The response's headers.
|
||||
-- Make a request to [example.computercraft.cc](https://example.computercraft.cc),
|
||||
-- and print the returned headers.
|
||||
-- ```lua
|
||||
-- local request = http.get("https://example.computercraft.cc")
|
||||
-- print(textutils.serialize(request.getResponseHeaders()))
|
||||
-- -- => {
|
||||
-- -- [ "Content-Type" ] = "text/plain; charset=utf8",
|
||||
-- -- [ "content-length" ] = 17,
|
||||
-- -- ...
|
||||
-- -- }
|
||||
-- request.close()
|
||||
-- ```
|
||||
function Response.getResponseHeaders() end
|
||||
|
||||
function Response.read(count) end
|
||||
function Response.readAll() end
|
||||
function Response.readLine(with_trailing) end
|
||||
function Response.seek(whence, offset) end
|
||||
function Response.close() end
|
||||
|
||||
--- Asynchronously determine whether a URL can be requested.
|
||||
--
|
||||
-- If this returns `true`, one should also listen for [`http_check`
|
||||
-- events](#http-check-event) which will container further information about
|
||||
-- whether the URL is allowed or not.
|
||||
--
|
||||
-- @tparam string url The URL to check.
|
||||
-- @treturn true When this url is not invalid. This does not imply that it is
|
||||
-- allowed - see the comment above.
|
||||
-- @treturn[2] false When this url is invalid.
|
||||
-- @treturn string A reason why this URL is not valid (for instance, if it is
|
||||
-- malformed, or blocked).
|
||||
--
|
||||
-- @see http.checkURL For a synchronous version.
|
||||
function checkURLAsync(url) end
|
||||
|
||||
--- Determine whether a URL can be requested.
|
||||
--
|
||||
-- If this returns `true`, one should also listen for [`http_check`
|
||||
-- events](#http-check-event) which will container further information about
|
||||
-- whether the URL is allowed or not.
|
||||
--
|
||||
-- @tparam string url The URL to check.
|
||||
-- @treturn true When this url is valid and can be requested via @{http.request}.
|
||||
-- @treturn[2] false When this url is invalid.
|
||||
-- @treturn string A reason why this URL is not valid (for instance, if it is
|
||||
-- malformed, or blocked).
|
||||
--
|
||||
-- @see http.checkURLAsync For an asynchronous version.
|
||||
--
|
||||
-- @usage
|
||||
-- ```lua
|
||||
-- print(http.checkURL("https://example.computercraft.cc/"))
|
||||
-- -- => true
|
||||
-- print(http.checkURL("http://localhost/"))
|
||||
-- -- => false Domain not permitted
|
||||
-- print(http.checkURL("not a url"))
|
||||
-- -- => false URL malformed
|
||||
-- ```
|
||||
function checkURL(url) end
|
||||
|
||||
--- Open a websocket.
|
||||
--
|
||||
-- @tparam string url The websocket url to connect to. This should have the
|
||||
-- `ws://` or `wss://` protocol.
|
||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
|
||||
-- of the initial websocket connection.
|
||||
--
|
||||
-- @treturn Websocket The websocket connection.
|
||||
-- @treturn[2] false If the websocket connection failed.
|
||||
-- @treturn string An error message describing why the connection failed.
|
||||
function websocket(url, headers) end
|
||||
|
||||
--- Asynchronously open a websocket.
|
||||
--
|
||||
-- This returns immediately, a [`websocket_success`](#websocket-success-event)
|
||||
-- or [`websocket_failure`](#websocket-failure-event) will be queued once the
|
||||
-- request has completed.
|
||||
--
|
||||
-- @tparam string url The websocket url to connect to. This should have the
|
||||
-- `ws://` or `wss://` protocol.
|
||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
|
||||
-- of the initial websocket connection.
|
||||
function websocketAsync(url, headers) end
|
||||
|
||||
--- A websocket, which can be used to send an receive messages with a web
|
||||
-- server.
|
||||
--
|
||||
-- @type Websocket
|
||||
-- @see http.websocket On how to open a websocket.
|
||||
local Websocket = {}
|
||||
|
||||
--- Send a websocket message to the connected server.
|
||||
--
|
||||
-- @tparam string message The message to send.
|
||||
-- @tparam[opt] boolean binary Whether this message should be treated as a
|
||||
-- binary string, rather than encoded text.
|
||||
-- @throws If the websocket has been closed.
|
||||
function Websocket.send(message, binary) end
|
||||
|
||||
--- Wait for a message from the server.
|
||||
--
|
||||
-- @tparam[opt] number timeout The number of seconds to wait if no message is
|
||||
-- received.
|
||||
-- @treturn[1] string The received message.
|
||||
-- @treturn boolean If this was a binary message.
|
||||
-- @treturn[2] nil If the websocket was closed while waiting, or if we timed out.
|
||||
-- @throws If the websocket has been closed.
|
||||
function Websocket.receive(timeout) end
|
||||
|
||||
--- Close this websocket. This will terminate the connection, meaning messages
|
||||
-- can no longer be sent or received along it.
|
||||
function Websocket.close() end
|
24
doc/stub/os.lua
Normal file
24
doc/stub/os.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
function queueEvent(event, ...) end
|
||||
function startTimer(delay) end
|
||||
function setAlarm(time) end
|
||||
function shutdown() end
|
||||
function reboot() end
|
||||
function getComputerID() end
|
||||
computerID = getComputerID
|
||||
function setComputerLabel(label) end
|
||||
function getComputerLabel() end
|
||||
computerLabel = getComputerLabel
|
||||
function clock() end
|
||||
function time(timezone) end
|
||||
function day(timezone) end
|
||||
function cancelTimer(id) end
|
||||
function cancelAlarm(id) end
|
||||
function epoch(timezone) end
|
||||
function date(format, time) end
|
||||
|
||||
-- Defined in bios.lua
|
||||
function loadAPI(path) end
|
||||
function pullEvent(filter) end
|
||||
function pullEventRaw(filter) end
|
||||
function version() end
|
||||
function run(env, path, ...) end
|
28
doc/stub/pocket.lua
Normal file
28
doc/stub/pocket.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
--[[-
|
||||
Control the current pocket computer, adding or removing upgrades.
|
||||
|
||||
This API is only available on pocket computers. As such, you may use its
|
||||
presence to determine what kind of computer you are using:
|
||||
|
||||
```lua
|
||||
if pocket then
|
||||
print("On a pocket computer")
|
||||
else
|
||||
print("On something else")
|
||||
end
|
||||
```
|
||||
]]
|
||||
|
||||
--- Search the player's inventory for another upgrade, replacing the existing
|
||||
-- one with that item if found.
|
||||
--
|
||||
-- This inventory search starts from the player's currently selected slot,
|
||||
-- allowing you to prioritise upgrades.
|
||||
--
|
||||
-- @throws If an upgrade cannot be found.
|
||||
function equipBack() end
|
||||
|
||||
--- Remove the pocket computer's current upgrade.
|
||||
--
|
||||
-- @throws If this pocket computer does not currently have an upgrade.
|
||||
function unequipBack() end
|
120
doc/stub/redstone.lua
Normal file
120
doc/stub/redstone.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
--[[- Interact with redstone attached to this computer.
|
||||
|
||||
The @{redstone} library exposes three "types" of redstone control:
|
||||
- Binary input/output (@{setOutput}/@{getInput}): These simply check if a
|
||||
redstone wire has any input or output. A signal strength of 1 and 15 are
|
||||
treated the same.
|
||||
- Analogue input/output (@{setAnalogueOutput}/@{getAnalogueInput}): These
|
||||
work with the actual signal strength of the redstone wired, from 0 to 15.
|
||||
- Bundled cables (@{setBundledOutput}/@{getBundledInput}): These interact with
|
||||
"bundled" cables, such as those from Project:Red. These allow you to send
|
||||
16 separate on/off signals. Each channel corresponds to a colour, with the
|
||||
first being @{colors.white} and the last @{colors.black}.
|
||||
|
||||
Whenever a redstone input changes, a `redstone` event will be fired. This may
|
||||
be used in or
|
||||
|
||||
This module may also be referred to as `rs`. For example, one may call
|
||||
`rs.getSides()` instead of @{redstone.getSides}.
|
||||
|
||||
@module redstone
|
||||
@usage Toggle the redstone signal above the computer every 0.5 seconds.
|
||||
|
||||
while true do
|
||||
redstone.setOutput("top", not redstone.getOutput("top"))
|
||||
sleep(0.5)
|
||||
end
|
||||
@usage Mimic a redstone comparator in [subtraction mode][comparator].
|
||||
|
||||
while true do
|
||||
local rear = rs.getAnalogueInput("back")
|
||||
local sides = math.max(rs.getAnalogueInput("left"), rs.getAnalogueInput("right"))
|
||||
rs.setAnalogueOutput("front", math.max(rear - sides, 0))
|
||||
|
||||
os.pullEvent("redstone") -- Wait for a change to inputs.
|
||||
end
|
||||
|
||||
[comparator]: https://minecraft.gamepedia.com/Redstone_Comparator#Subtract_signal_strength "Redstone Comparator on the Minecraft wiki."
|
||||
]]
|
||||
|
||||
--- Returns a table containing the six sides of the computer. Namely, "top",
|
||||
-- "bottom", "left", "right", "front" and "back".
|
||||
--
|
||||
-- @treturn { string... } A table of valid sides.
|
||||
function getSides() end
|
||||
|
||||
--- Turn the redstone signal of a specific side on or off.
|
||||
--
|
||||
-- @tparam string side The side to set.
|
||||
-- @tparam boolean on Whether the redstone signal should be on or off. When on,
|
||||
-- a signal strength of 15 is emitted.
|
||||
function setOutput(side, on) end
|
||||
|
||||
--- Get the current redstone output of a specific side.
|
||||
--
|
||||
-- @tparam string side The side to get.
|
||||
-- @treturn boolean Whether the redstone output is on or off.
|
||||
-- @see setOutput
|
||||
function getOutput(side) end
|
||||
|
||||
--- Get the current redstone input of a specific side.
|
||||
--
|
||||
-- @tparam string side The side to get.
|
||||
-- @treturn boolean Whether the redstone input is on or off.
|
||||
function getInput(side) end
|
||||
|
||||
--- Set the redstone signal strength for a specific side.
|
||||
--
|
||||
-- @tparam string side The side to set.
|
||||
-- @tparam number value The signal strength, between 0 and 15.
|
||||
-- @throws If `value` is not between 0 and 15.
|
||||
function setAnalogOutput(side, value) end
|
||||
setAnalogueOutput = setAnalogOutput
|
||||
|
||||
--- Get the redstone output signal strength for a specific side.
|
||||
--
|
||||
-- @tparam string side The side to get.
|
||||
-- @treturn number The output signal strength, between 0 and 15.
|
||||
-- @see setAnalogueOutput
|
||||
function getAnalogOutput(sid) end
|
||||
getAnalogueOutput = getAnalogOutput
|
||||
|
||||
--- Get the redstone input signal strength for a specific side.
|
||||
--
|
||||
-- @tparam string side The side to get.
|
||||
-- @treturn number The input signal strength, between 0 and 15.
|
||||
function getAnalogInput(side) end
|
||||
getAnalogueInput = getAnalogInput
|
||||
|
||||
--- Set the bundled cable output for a specific side.
|
||||
--
|
||||
-- @tparam string side The side to set.
|
||||
-- @tparam number The colour bitmask to set.
|
||||
-- @see colors.subtract For removing a colour from the bitmask.
|
||||
-- @see colors.combine For adding a colour to the bitmask.
|
||||
function setBundledOutput(side, output) end
|
||||
|
||||
--- Get the bundled cable output for a specific side.
|
||||
--
|
||||
-- @tparam string side The side to get.
|
||||
-- @treturn number The bundled cable's output.
|
||||
function getBundledOutput(side) end
|
||||
|
||||
--- Get the bundled cable input for a specific side.
|
||||
--
|
||||
-- @tparam string side The side to get.
|
||||
-- @treturn number The bundled cable's input.
|
||||
-- @see testBundledInput To determine if a specific colour is set.
|
||||
function getBundledInput(side) end
|
||||
|
||||
--- Determine if a specific combination of colours are on for the given side.
|
||||
--
|
||||
-- @tparam string side The side to test.
|
||||
-- @tparam number mask The mask to test.
|
||||
-- @see getBundledInput
|
||||
-- @see colors.combine For adding a colour to the bitmask.
|
||||
-- @usage Check if @{colors.white} and @{colors.black} are on for above the
|
||||
-- computer.
|
||||
--
|
||||
-- print(redstone.testBundledInput("top", colors.combine(colors.white, colors.black)))
|
||||
function testBundledInput(side, mask) end
|
52
doc/stub/term.lua
Normal file
52
doc/stub/term.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
function write(text) end
|
||||
function scroll(lines) end
|
||||
function setCursorPos(x, y) end
|
||||
function setCursorBlink(blink) end
|
||||
function getCursorPos() end
|
||||
function getSize() end
|
||||
function clear() end
|
||||
function clearLine() end
|
||||
function setTextColour(colour) end
|
||||
setTextColor = setTextColour
|
||||
function setBackgroundColour(colour) end
|
||||
setBackgroundColor = setBackgroundColour
|
||||
function isColour() end
|
||||
isColor = isColour
|
||||
function getTextColour() end
|
||||
getTextColor = getTextColor
|
||||
function getBackgroundColour() end
|
||||
getBackgroundColor = getBackgroundColour
|
||||
function blit(text, text_colours, background_colours) end
|
||||
function setPaletteColour(colour, ...) end
|
||||
setPaletteColor = setPaletteColour
|
||||
function getPaletteColour(colour, ...) end
|
||||
getPaletteColor = getPaletteColour
|
||||
function nativePaletteColour(colour) end
|
||||
nativePaletteColor = nativePaletteColour
|
||||
|
||||
--- @type Redirect
|
||||
local Redirect = {}
|
||||
|
||||
Redirect.write = write
|
||||
Redirect.scroll = scroll
|
||||
Redirect.setCursorPos = setCursorPos
|
||||
Redirect.setCursorBlink = setCursorBlink
|
||||
Redirect.getCursorPos = getCursorPos
|
||||
Redirect.getSize = getSize
|
||||
Redirect.clear = clear
|
||||
Redirect.clearLine = clearLine
|
||||
Redirect.setTextColour = setTextColour
|
||||
Redirect.setTextColor = setTextColor
|
||||
Redirect.setBackgroundColour = setBackgroundColour
|
||||
Redirect.setBackgroundColor = setBackgroundColor
|
||||
Redirect.isColour = isColour
|
||||
Redirect.isColor = isColor
|
||||
Redirect.getTextColour = getTextColour
|
||||
Redirect.getTextColor = getTextColor
|
||||
Redirect.getBackgroundColour = getBackgroundColour
|
||||
Redirect.getBackgroundColor = getBackgroundColor
|
||||
Redirect.blit = blit
|
||||
Redirect.setPaletteColour = setPaletteColour
|
||||
Redirect.setPaletteColor = setPaletteColor
|
||||
Redirect.getPaletteColour = getPaletteColour
|
||||
Redirect.getPaletteColor = getPaletteColor
|
230
doc/stub/turtle.lua
Normal file
230
doc/stub/turtle.lua
Normal file
@@ -0,0 +1,230 @@
|
||||
--- Move the turtle forward one block.
|
||||
-- @treturn boolean Whether the turtle could successfully move.
|
||||
-- @treturn string|nil The reason the turtle could not move.
|
||||
function forward() end
|
||||
|
||||
--- Move the turtle backwards one block.
|
||||
-- @treturn boolean Whether the turtle could successfully move.
|
||||
-- @treturn string|nil The reason the turtle could not move.
|
||||
function back() end
|
||||
|
||||
--- Move the turtle up one block.
|
||||
-- @treturn boolean Whether the turtle could successfully move.
|
||||
-- @treturn string|nil The reason the turtle could not move.
|
||||
function up() end
|
||||
|
||||
--- Move the turtle down one block.
|
||||
-- @treturn boolean Whether the turtle could successfully move.
|
||||
-- @treturn string|nil The reason the turtle could not move.
|
||||
function down() end
|
||||
|
||||
--- Rotate the turtle 90 degress to the left.
|
||||
function turnLeft() end
|
||||
|
||||
--- Rotate the turtle 90 degress to the right.
|
||||
function turnRight() end
|
||||
|
||||
--- Attempt to break the block in front of the turtle.
|
||||
--
|
||||
-- This requires a turtle tool capable of breaking the block. Diamond pickaxes
|
||||
-- (mining turtles) can break any vanilla block, but other tools (such as axes)
|
||||
-- are more limited.
|
||||
--
|
||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
|
||||
-- @treturn boolean Whether a block was broken.
|
||||
-- @treturn string|nil The reason no block was broken.
|
||||
function dig(side) end
|
||||
|
||||
--- Attempt to break the block above the turtle. See @{dig} for full details.
|
||||
--
|
||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
|
||||
-- @treturn boolean Whether a block was broken.
|
||||
-- @treturn string|nil The reason no block was broken.
|
||||
function digUp(side) end
|
||||
|
||||
--- Attempt to break the block below the turtle. See @{dig} for full details.
|
||||
--
|
||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
|
||||
-- @treturn boolean Whether a block was broken.
|
||||
-- @treturn string|nil The reason no block was broken.
|
||||
function digDown(side) end
|
||||
|
||||
--- Attack the entity in front of the turtle.
|
||||
--
|
||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
|
||||
-- @treturn boolean Whether an entity was attacked.
|
||||
-- @treturn string|nil The reason nothing was attacked.
|
||||
function attack(side) end
|
||||
|
||||
--- Attack the entity above the turtle.
|
||||
--
|
||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
|
||||
-- @treturn boolean Whether an entity was attacked.
|
||||
-- @treturn string|nil The reason nothing was attacked.
|
||||
function attackUp(side) end
|
||||
|
||||
--- Attack the entity below the turtle.
|
||||
--
|
||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
|
||||
-- @treturn boolean Whether an entity was attacked.
|
||||
-- @treturn string|nil The reason nothing was attacked.
|
||||
function attackDown(side) end
|
||||
|
||||
--- Place a block or item into the world in front of the turtle.
|
||||
--
|
||||
-- @treturn boolean Whether the block could be placed.
|
||||
-- @treturn string|nil The reason the block was not placed.
|
||||
function place() end
|
||||
|
||||
--- Place a block or item into the world above the turtle.
|
||||
--
|
||||
-- @treturn boolean Whether the block could be placed.
|
||||
-- @treturn string|nil The reason the block was not placed.
|
||||
function placeUp() end
|
||||
|
||||
--- Place a block or item into the world below the turtle.
|
||||
--
|
||||
-- @treturn boolean Whether the block could be placed.
|
||||
-- @treturn string|nil The reason the block was not placed.
|
||||
function placeDown() end
|
||||
|
||||
--- Drop the currently selected stack into the inventory in front of the turtle,
|
||||
-- or as an item into the world if there is no inventory.
|
||||
--
|
||||
-- @tparam[opt] number count The number of items to drop. If not given, the
|
||||
-- entire stack will be dropped.
|
||||
-- @treturn boolean Whether items were dropped.
|
||||
-- @treturn string|nil The reason the no items were dropped.
|
||||
-- @see select
|
||||
function drop(count) end
|
||||
|
||||
--- Drop the currently selected stack into the inventory above the turtle, or as
|
||||
-- an item into the world if there is no inventory.
|
||||
--
|
||||
-- @tparam[opt] number count The number of items to drop. If not given, the
|
||||
-- entire stack will be dropped.
|
||||
-- @treturn boolean Whether items were dropped.
|
||||
-- @treturn string|nil The reason the no items were dropped.
|
||||
-- @see select
|
||||
function dropUp(count) end
|
||||
|
||||
--- Drop the currently selected stack into the inventory below the turtle, or as
|
||||
-- an item into the world if there is no inventory.
|
||||
--
|
||||
-- @tparam[opt] number count The number of items to drop. If not given, the
|
||||
-- entire stack will be dropped.
|
||||
-- @treturn boolean Whether items were dropped.
|
||||
-- @treturn string|nil The reason the no items were dropped.
|
||||
-- @see select
|
||||
function dropDown(count) end
|
||||
|
||||
--- Suck an item from the inventory in front of the turtle, or from an item
|
||||
-- floating in the world.
|
||||
--
|
||||
-- This will pull items into the first acceptable slot, starting at the
|
||||
-- @{select|currently selected} one.
|
||||
--
|
||||
-- @tparam[opt] number count The number of items to suck. If not given, up to a
|
||||
-- stack of items will be picked up.
|
||||
-- @treturn boolean Whether items were picked up.
|
||||
-- @treturn string|nil The reason the no items were picked up.
|
||||
function suck(count) end
|
||||
|
||||
--- Suck an item from the inventory above the turtle, or from an item floating
|
||||
-- in the world.
|
||||
--
|
||||
-- @tparam[opt] number count The number of items to suck. If not given, up to a
|
||||
-- stack of items will be picked up.
|
||||
-- @treturn boolean Whether items were picked up.
|
||||
-- @treturn string|nil The reason the no items were picked up.
|
||||
function suckUp(count) end
|
||||
|
||||
--- Suck an item from the inventory below the turtle, or from an item floating
|
||||
-- in the world.
|
||||
--
|
||||
-- @tparam[opt] number count The number of items to suck. If not given, up to a
|
||||
-- stack of items will be picked up.
|
||||
-- @treturn boolean Whether items were picked up.
|
||||
-- @treturn string|nil The reason the no items were picked up.
|
||||
function suckDown(count) end
|
||||
|
||||
--- Check if there is a solid block in front of the turtle. In this case, solid
|
||||
-- refers to any non-air or liquid block.
|
||||
--
|
||||
-- @treturn boolean If there is a solid block in front.
|
||||
function detect() end
|
||||
|
||||
--- Check if there is a solid block above the turtle.
|
||||
--
|
||||
-- @treturn boolean If there is a solid block above.
|
||||
function detectUp() end
|
||||
|
||||
--- Check if there is a solid block below the turtle.
|
||||
--
|
||||
-- @treturn boolean If there is a solid block below.
|
||||
function detectDown() end
|
||||
|
||||
function compare() end
|
||||
function compareUp() end
|
||||
function compareDown() end
|
||||
|
||||
function inspect() end
|
||||
function inspectUp() end
|
||||
function inspectDown() end
|
||||
|
||||
|
||||
--- Change the currently selected slot.
|
||||
--
|
||||
-- The selected slot is determines what slot actions like @{drop} or
|
||||
-- @{getItemCount} act on.
|
||||
--
|
||||
-- @tparam number slot The slot to select.
|
||||
-- @see getSelectedSlot
|
||||
function select(slot) end
|
||||
|
||||
--- Get the currently selected slot.
|
||||
--
|
||||
-- @treturn number The current slot.
|
||||
-- @see select
|
||||
function getSelectedSlot() end
|
||||
|
||||
--- Get the number of items in the given slot.
|
||||
--
|
||||
-- @tparam[opt] number slot The slot we wish to check. Defaults to the @{turtle.select|selected slot}.
|
||||
-- @treturn number The number of items in this slot.
|
||||
function getItemCount(slot) end
|
||||
|
||||
--- Get the remaining number of items which may be stored in this stack.
|
||||
--
|
||||
-- For instance, if a slot contains 13 blocks of dirt, it has room for another 51.
|
||||
--
|
||||
-- @tparam[opt] number slot The slot we wish to check. Defaults to the @{turtle.select|selected slot}.
|
||||
-- @treturn number The space left in this slot.
|
||||
function getItemSpace(slot) end
|
||||
|
||||
|
||||
--- Get detailed information about the items in the given slot.
|
||||
--
|
||||
-- @tparam[opt] number slot The slot to get information about. Defaults to the @{turtle.select|selected slot}.
|
||||
-- @treturn nil|table Information about the given slot, or @{nil} if it is empty.
|
||||
-- @usage Print the current slot, assuming it contains 13 dirt.
|
||||
--
|
||||
-- print(textutils.serialize(turtle.getItemDetail()))
|
||||
-- -- => {
|
||||
-- -- name = "minecraft:dirt",
|
||||
-- -- damage = 0,
|
||||
-- -- count = 13,
|
||||
-- -- }
|
||||
function getItemDetail(slot) end
|
||||
|
||||
function getFuelLevel() end
|
||||
|
||||
function refuel(count) end
|
||||
function compareTo(slot) end
|
||||
function transferTo(slot, count) end
|
||||
|
||||
function getFuelLimit() end
|
||||
function equipLeft() end
|
||||
function equipRight() end
|
||||
|
||||
function craft(limit) end
|
186
doc/styles.css
Normal file
186
doc/styles.css
Normal file
@@ -0,0 +1,186 @@
|
||||
/* Basic reset on elements */
|
||||
h1, h2, h3, h4, p, table, div, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* Make the page a little more airy */
|
||||
body {
|
||||
margin: 20px auto;
|
||||
max-width: 1200px;
|
||||
padding: 0 10px;
|
||||
line-height: 1.6;
|
||||
color: #222;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
/* Try to use system default fonts. */
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans",
|
||||
"Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
}
|
||||
|
||||
code, pre, .parameter, .type, .definition-name, .reference-code {
|
||||
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
}
|
||||
|
||||
/* Some definitions of basic tags */
|
||||
code {
|
||||
color: #c7254e;
|
||||
background-color: #f9f2f4;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.9em 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
font-weight: lighter;
|
||||
border-bottom: solid 1px #aaa;
|
||||
}
|
||||
|
||||
h2, h3, h4 { margin: 1.4em 0 0.3em;}
|
||||
h2 { font-size: 1.25em; }
|
||||
h3 { font-size: 1.15em; font-weight: bold; }
|
||||
h4 { font-size: 1.06em; }
|
||||
|
||||
a, a:visited, a:active { font-weight: bold; color: #004080; text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
|
||||
blockquote { margin-left: 3em; }
|
||||
|
||||
/* Stop sublists from having initial vertical space */
|
||||
ul ul { margin-top: 0px; }
|
||||
ol ul { margin-top: 0px; }
|
||||
ol ol { margin-top: 0px; }
|
||||
ul ol { margin-top: 0px; }
|
||||
|
||||
/* Make the target distinct; helps when we're navigating to a function */
|
||||
a:target + * { background-color: #FFFF99; }
|
||||
|
||||
/* Allow linking to any subsection */
|
||||
a[name]::before { content: "#"; }
|
||||
|
||||
/* Layout */
|
||||
#main {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
min-height: calc(100vh - 100px);
|
||||
}
|
||||
|
||||
#main > nav {
|
||||
flex-basis: 30%;
|
||||
min-width: 150px;
|
||||
max-width: 250px;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
nav h1, nav ul { padding: 0em 10px; }
|
||||
|
||||
nav h2 {
|
||||
background-color:#e7e7e7;
|
||||
font-size: 1.1em;
|
||||
color:#000000;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#content {
|
||||
flex-shrink: 1;
|
||||
flex-basis: 80%;
|
||||
padding: 0px 10px;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: right;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
/* The definition lists at the top of each page */
|
||||
table.definition-list {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.definition-list td, table.definition-list th {
|
||||
border: 1px solid #cccccc;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
table.definition-list th {
|
||||
background-color: #f0f0f0;
|
||||
min-width: 200px;
|
||||
white-space: nowrap;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
table.definition-list td { width: 100%; }
|
||||
|
||||
dl.definition dt {
|
||||
border-top: 1px solid #ccc;
|
||||
padding-top: 1em;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
dl.definition dt .definition-name {
|
||||
padding: 0 0.1em;
|
||||
margin: 0 0.1em;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
|
||||
dl.definition dd {
|
||||
padding-bottom: 1em;
|
||||
margin: 10px 0 0 20px;
|
||||
}
|
||||
|
||||
dl.definition h3 {
|
||||
font-size: .95em;
|
||||
}
|
||||
|
||||
/* Links to source-code */
|
||||
.source-link { font-size: 0.8em; }
|
||||
.source-link::before { content: '[' }
|
||||
.source-link::after { content: ']' }
|
||||
a.source-link, a.source-link:visited, a.source-link:active { color: #505050; }
|
||||
|
||||
/* Method definitions */
|
||||
span.parameter:after { content:":"; padding-left: 0.3em; }
|
||||
.optional { text-decoration: underline dotted; }
|
||||
|
||||
/** Fancy colour display. */
|
||||
.colour-ref {
|
||||
display: inline-block;
|
||||
width: 0.8em;
|
||||
height: 0.8em;
|
||||
margin: 0.1em 0.1em 0.3em 0.1em; /* Terrrible hack to force vertical alignment. */
|
||||
border: solid 1px black;
|
||||
box-sizing: border-box;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* styles for prettification of source */
|
||||
.highlight .comment { color: #558817; }
|
||||
.highlight .constant { color: #a8660d; }
|
||||
.highlight .escape { color: #844631; }
|
||||
.highlight .keyword { color: #aa5050; font-weight: bold; }
|
||||
.highlight .library { color: #0e7c6b; }
|
||||
.highlight .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
|
||||
.highlight .string { color: #8080ff; }
|
||||
.highlight .literal-kw { color: #8080ff; }
|
||||
.highlight .number { color: #f8660d; }
|
||||
.highlight .operator { color: #2239a8; font-weight: bold; }
|
||||
.highlight .preprocessor, pre .prepro { color: #a33243; }
|
||||
.highlight .global { color: #800080; }
|
||||
.highlight .user-keyword { color: #800080; }
|
||||
.highlight .prompt { color: #558817; }
|
||||
.highlight .url { color: #272fc2; text-decoration: underline; }
|
@@ -1,5 +1,5 @@
|
||||
# Mod properties
|
||||
mod_version=1.86.0
|
||||
mod_version=1.89.2
|
||||
|
||||
# Minecraft properties
|
||||
mc_version=1.12.2
|
||||
|
@@ -1,28 +1,95 @@
|
||||
; -*- mode: Lisp;-*-
|
||||
|
||||
(sources
|
||||
/src/main/resources/assets/computercraft/lua/bios.lua
|
||||
/src/main/resources/assets/computercraft/lua/rom/
|
||||
/doc/stub/
|
||||
/src/main/resources/*/computercraft/lua/bios.lua
|
||||
/src/main/resources/*/computercraft/lua/rom/
|
||||
/src/test/resources/test-rom)
|
||||
|
||||
|
||||
(doc
|
||||
(title "CC: Tweaked")
|
||||
(index doc/index.md)
|
||||
(source-link https://github.com/SquidDev-CC/CC-Tweaked/blob/${commit}/${path}#L${line})
|
||||
|
||||
(library-path
|
||||
/doc/stub/
|
||||
|
||||
/src/main/resources/*/computercraft/lua/rom/apis
|
||||
/src/main/resources/*/computercraft/lua/rom/apis/command
|
||||
/src/main/resources/*/computercraft/lua/rom/apis/turtle
|
||||
|
||||
/src/main/resources/*/computercraft/lua/rom/modules/main
|
||||
/src/main/resources/*/computercraft/lua/rom/modules/command
|
||||
/src/main/resources/*/computercraft/lua/rom/modules/turtle))
|
||||
|
||||
(at /
|
||||
(linters
|
||||
syntax:string-index
|
||||
|
||||
;; It'd be nice to avoid this, but right now there's a lot of instances of
|
||||
;; it.
|
||||
-var:set-loop
|
||||
|
||||
;; It's useful to name arguments for documentation, so we allow this. It'd
|
||||
;; be good to find a compromise in the future, but this works for now.
|
||||
-var:unused-arg))
|
||||
-var:unused-arg)
|
||||
|
||||
(lint
|
||||
(bracket-spaces
|
||||
(call no-space)
|
||||
(function-args no-space)
|
||||
(parens no-space)
|
||||
(table space)
|
||||
(index no-space))
|
||||
|
||||
;; colours imports from colors, and we don't handle that right now.
|
||||
;; keys is entirely dynamic, so we skip it.
|
||||
(dynamic-modules colours keys)
|
||||
|
||||
(globals
|
||||
:max
|
||||
_CC_DEFAULT_SETTINGS
|
||||
_CC_DISABLE_LUA51_FEATURES
|
||||
;; Ideally we'd pick these up from bios.lua, but illuaminate currently
|
||||
;; isn't smart enough.
|
||||
sleep write printError read rs)))
|
||||
|
||||
;; We disable the unused global linter in bios.lua and the APIs. In the future
|
||||
;; hopefully we'll get illuaminate to handle this.
|
||||
(at
|
||||
(/src/main/resources/assets/computercraft/lua/bios.lua
|
||||
/src/main/resources/assets/computercraft/lua/rom/apis/)
|
||||
(/src/main/resources/*/computercraft/lua/bios.lua
|
||||
/src/main/resources/*/computercraft/lua/rom/apis/)
|
||||
(linters -var:unused-global)
|
||||
(lint
|
||||
(allow-toplevel-global true)))
|
||||
(lint (allow-toplevel-global true)))
|
||||
|
||||
;; These warnings are broken right now
|
||||
(at (bios.lua worm.lua) (linters -control:unreachable))
|
||||
;; Silence some variable warnings in documentation stubs.
|
||||
(at /doc/stub
|
||||
(linters -var:unused-global)
|
||||
(lint (allow-toplevel-global true)))
|
||||
|
||||
;; Suppress warnings for currently undocumented modules.
|
||||
(at
|
||||
(/doc/stub/fs.lua
|
||||
/doc/stub/http.lua
|
||||
/doc/stub/os.lua
|
||||
/doc/stub/term.lua
|
||||
/doc/stub/turtle.lua
|
||||
/src/main/resources/*/computercraft/lua/rom/apis/io.lua
|
||||
/src/main/resources/*/computercraft/lua/rom/apis/window.lua)
|
||||
|
||||
(linters -doc:undocumented -doc:undocumented-arg))
|
||||
|
||||
;; These currently rely on unknown references.
|
||||
(at
|
||||
(/src/main/resources/*/computercraft/lua/rom/apis/textutils.lua
|
||||
/src/main/resources/*/computercraft/lua/rom/modules/main/cc/completion.lua
|
||||
/src/main/resources/*/computercraft/lua/rom/modules/main/cc/shell/completion.lua
|
||||
/src/main/resources/*/computercraft/lua/rom/programs/shell.lua)
|
||||
(linters -doc:unresolved-reference))
|
||||
|
||||
(at /src/test/resources/test-rom
|
||||
(lint
|
||||
(globals
|
||||
:max sleep write
|
||||
cct_test describe expect howlci fail it pending stub)))
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
@@ -23,7 +22,6 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.event.TurtleAction;
|
||||
import dan200.computercraft.core.apis.AddressPredicate;
|
||||
import dan200.computercraft.core.apis.ApiFactories;
|
||||
import dan200.computercraft.core.apis.http.websocket.Websocket;
|
||||
import dan200.computercraft.core.computer.MainThread;
|
||||
import dan200.computercraft.core.filesystem.ComboMount;
|
||||
import dan200.computercraft.core.filesystem.FileMount;
|
||||
@@ -48,6 +46,7 @@ import dan200.computercraft.shared.peripheral.modem.wired.ItemCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockAdvancedModem;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.ItemAdvancedModem;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
|
||||
@@ -113,7 +112,8 @@ public class ComputerCraft
|
||||
public static boolean disable_lua51_features = false;
|
||||
public static String default_computer_settings = "";
|
||||
public static boolean debug_enable = true;
|
||||
public static boolean logPeripheralErrors = false;
|
||||
public static boolean logPeripheralErrors = true;
|
||||
public static boolean commandRequireCreative = true;
|
||||
|
||||
public static int computer_threads = 1;
|
||||
public static long maxMainGlobalTime = TimeUnit.MILLISECONDS.toNanos( 10 );
|
||||
@@ -129,7 +129,7 @@ public class ComputerCraft
|
||||
public static long httpMaxDownload = 16 * 1024 * 1024;
|
||||
public static long httpMaxUpload = 4 * 1024 * 1024;
|
||||
public static int httpMaxWebsockets = 4;
|
||||
public static int httpMaxWebsocketMessage = Websocket.MAX_MESSAGE_SIZE;
|
||||
public static int httpMaxWebsocketMessage = 128 * 1024;
|
||||
|
||||
public static boolean enableCommandBlock = false;
|
||||
public static int modem_range = 64;
|
||||
@@ -137,6 +137,8 @@ public class ComputerCraft
|
||||
public static int modem_rangeDuringStorm = 64;
|
||||
public static int modem_highAltitudeRangeDuringStorm = 384;
|
||||
public static int maxNotesPerTick = 8;
|
||||
public static MonitorRenderer monitorRenderer = MonitorRenderer.BEST;
|
||||
public static long monitorBandwidth = 1_000_000;
|
||||
|
||||
public static boolean turtlesNeedFuel = true;
|
||||
public static int turtleFuelLimit = 20000;
|
||||
@@ -536,7 +538,7 @@ public class ComputerCraft
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
if( zipFile != null ) IoUtil.closeQuietly( zipFile );
|
||||
IoUtil.closeQuietly( zipFile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
|
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.filesystem;
|
||||
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A simple version of {@link BasicFileAttributes}, which provides what information a {@link IMount} already exposes.
|
||||
*/
|
||||
final class FileAttributes implements BasicFileAttributes
|
||||
{
|
||||
private static final FileTime EPOCH = FileTime.from( Instant.EPOCH );
|
||||
|
||||
private final boolean isDirectory;
|
||||
private final long size;
|
||||
|
||||
FileAttributes( boolean isDirectory, long size )
|
||||
{
|
||||
this.isDirectory = isDirectory;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileTime lastModifiedTime()
|
||||
{
|
||||
return EPOCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileTime lastAccessTime()
|
||||
{
|
||||
return EPOCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileTime creationTime()
|
||||
{
|
||||
return EPOCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegularFile()
|
||||
{
|
||||
return !isDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectory()
|
||||
{
|
||||
return isDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSymbolicLink()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOther()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long size()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fileKey()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.filesystem;
|
||||
@@ -27,7 +27,7 @@ public class FileOperationException extends IOException
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public FileOperationException( String message )
|
||||
public FileOperationException( @Nonnull String message )
|
||||
{
|
||||
super( Objects.requireNonNull( message, "message cannot be null" ) );
|
||||
this.filename = null;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.filesystem;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.filesystem;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
@@ -15,6 +14,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -94,4 +94,18 @@ public interface IMount
|
||||
{
|
||||
return Channels.newChannel( openForRead( path ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes about the given file.
|
||||
*
|
||||
* @param path The path to query.
|
||||
* @return File attributes for the given file.
|
||||
* @throws IOException If the file does not exist, or attributes could not be fetched.
|
||||
*/
|
||||
@Nonnull
|
||||
default BasicFileAttributes getAttributes( @Nonnull String path ) throws IOException
|
||||
{
|
||||
if( !exists( path ) ) throw new FileOperationException( path, "No such file" );
|
||||
return new FileAttributes( isDirectory( path ), getSize( path ) );
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.filesystem;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
@@ -15,6 +14,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
/**
|
||||
* Represents a part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)}
|
||||
@@ -106,4 +106,16 @@ public interface IWritableMount extends IMount
|
||||
* @throws IOException If the remaining space could not be computed.
|
||||
*/
|
||||
long getRemainingSpace() throws IOException;
|
||||
|
||||
/**
|
||||
* Get the capacity of this mount. This should be equal to the size of all files/directories on this mount, minus
|
||||
* the {@link #getRemainingSpace()}.
|
||||
*
|
||||
* @return The capacity of this mount, in bytes.
|
||||
*/
|
||||
@Nonnull
|
||||
default OptionalLong getCapacity()
|
||||
{
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|FileSystem", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.filesystem;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IFileSystem;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Lua", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.media;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.media;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Media", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.media;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.network;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.network;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.network;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.network;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Network", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.network;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.network.wired;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.network.wired;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.network.wired;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.network.wired;
|
||||
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.network.wired;
|
||||
|
||||
import dan200.computercraft.api.network.IPacketSender;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Network|Wired", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.network.wired;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import dan200.computercraft.api.lua.ArgumentHelper;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Peripheral", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.permissions;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Permissions", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.permissions;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.redstone;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Redstone", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.redstone;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
/**
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
/**
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
/**
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
/**
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Turtle|Event", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner = "ComputerCraft", provides = "ComputerCraft|API|Turtle", apiVersion = "${version}" )
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.shared.command.text.ChatHelpers;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@@ -1,200 +1,327 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.client.FrameInfo;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class FixedWidthFontRenderer
|
||||
{
|
||||
private static final ResourceLocation FONT = new ResourceLocation( "computercraft", "textures/gui/term_font.png" );
|
||||
public static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/term_background.png" );
|
||||
|
||||
/**
|
||||
* Like {@link DefaultVertexFormats#POSITION_TEX_COLOR}, but flipped. This is backported from 1.15, hence the
|
||||
* custom format.
|
||||
*/
|
||||
public static final VertexFormat POSITION_COLOR_TEX = new VertexFormat();
|
||||
|
||||
static
|
||||
{
|
||||
POSITION_COLOR_TEX.addElement( DefaultVertexFormats.POSITION_3F );
|
||||
POSITION_COLOR_TEX.addElement( DefaultVertexFormats.COLOR_4UB );
|
||||
POSITION_COLOR_TEX.addElement( DefaultVertexFormats.TEX_2F );
|
||||
}
|
||||
|
||||
public static final int FONT_HEIGHT = 9;
|
||||
public static final int FONT_WIDTH = 6;
|
||||
public static final float WIDTH = 256.0f;
|
||||
|
||||
private static FixedWidthFontRenderer instance;
|
||||
|
||||
public static FixedWidthFontRenderer instance()
|
||||
{
|
||||
if( instance != null ) return instance;
|
||||
return instance = new FixedWidthFontRenderer();
|
||||
}
|
||||
|
||||
private final TextureManager m_textureManager;
|
||||
public static final float BACKGROUND_START = (WIDTH - 6.0f) / WIDTH;
|
||||
public static final float BACKGROUND_END = (WIDTH - 4.0f) / WIDTH;
|
||||
|
||||
private FixedWidthFontRenderer()
|
||||
{
|
||||
m_textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
}
|
||||
|
||||
private static void greyscaleify( double[] rgb )
|
||||
public static float toGreyscale( double[] rgb )
|
||||
{
|
||||
Arrays.fill( rgb, (rgb[0] + rgb[1] + rgb[2]) / 3.0f );
|
||||
return (float) ((rgb[0] + rgb[1] + rgb[2]) / 3);
|
||||
}
|
||||
|
||||
private void drawChar( BufferBuilder renderer, double x, double y, int index, int color, Palette p, boolean greyscale )
|
||||
public static int getColour( char c, Colour def )
|
||||
{
|
||||
return 15 - Terminal.getColour( c, def );
|
||||
}
|
||||
|
||||
private static void drawChar( BufferBuilder buffer, float x, float y, int index, float r, float g, float b )
|
||||
{
|
||||
// Short circuit to avoid the common case - the texture should be blank here after all.
|
||||
if( index == '\0' || index == ' ' ) return;
|
||||
|
||||
int column = index % 16;
|
||||
int row = index / 16;
|
||||
|
||||
double[] colour = p.getColour( 15 - color );
|
||||
if( greyscale )
|
||||
{
|
||||
greyscaleify( colour );
|
||||
}
|
||||
float r = (float) colour[0];
|
||||
float g = (float) colour[1];
|
||||
float b = (float) colour[2];
|
||||
|
||||
int xStart = 1 + column * (FONT_WIDTH + 2);
|
||||
int yStart = 1 + row * (FONT_HEIGHT + 2);
|
||||
|
||||
renderer.pos( x, y, 0.0 ).tex( xStart / 256.0, yStart / 256.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x, y + FONT_HEIGHT, 0.0 ).tex( xStart / 256.0, (yStart + FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x + FONT_WIDTH, y, 0.0 ).tex( (xStart + FONT_WIDTH) / 256.0, yStart / 256.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x + FONT_WIDTH, y, 0.0 ).tex( (xStart + FONT_WIDTH) / 256.0, yStart / 256.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x, y + FONT_HEIGHT, 0.0 ).tex( xStart / 256.0, (yStart + FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x + FONT_WIDTH, y + FONT_HEIGHT, 0.0 ).tex( (xStart + FONT_WIDTH) / 256.0, (yStart + FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( x, y, 0f ).color( r, g, b, 1.0f ).tex( xStart / WIDTH, yStart / WIDTH ).endVertex();
|
||||
buffer.pos( x, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).tex( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
||||
buffer.pos( x + FONT_WIDTH, y, 0f ).color( r, g, b, 1.0f ).tex( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ).endVertex();
|
||||
buffer.pos( x + FONT_WIDTH, y, 0f ).color( r, g, b, 1.0f ).tex( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ).endVertex();
|
||||
buffer.pos( x, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).tex( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
||||
buffer.pos( x + FONT_WIDTH, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).tex( (xStart + FONT_WIDTH) / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
||||
}
|
||||
|
||||
private void drawQuad( BufferBuilder renderer, double x, double y, int color, double width, Palette p, boolean greyscale )
|
||||
private static void drawQuad( BufferBuilder buffer, float x, float y, float width, float height, float r, float g, float b )
|
||||
{
|
||||
double[] colour = p.getColour( 15 - color );
|
||||
buffer.pos( x, y, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_START, BACKGROUND_START ).endVertex();
|
||||
buffer.pos( x, y + height, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_START, BACKGROUND_END ).endVertex();
|
||||
buffer.pos( x + width, y, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_END, BACKGROUND_START ).endVertex();
|
||||
buffer.pos( x + width, y, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_END, BACKGROUND_START ).endVertex();
|
||||
buffer.pos( x, y + height, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_START, BACKGROUND_END ).endVertex();
|
||||
buffer.pos( x + width, y + height, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_END, BACKGROUND_END ).endVertex();
|
||||
}
|
||||
|
||||
private static void drawQuad( BufferBuilder buffer, float x, float y, float width, float height, Palette palette, boolean greyscale, char colourIndex )
|
||||
{
|
||||
double[] colour = palette.getColour( getColour( colourIndex, Colour.Black ) );
|
||||
float r, g, b;
|
||||
if( greyscale )
|
||||
{
|
||||
greyscaleify( colour );
|
||||
r = g = b = toGreyscale( colour );
|
||||
}
|
||||
else
|
||||
{
|
||||
r = (float) colour[0];
|
||||
g = (float) colour[1];
|
||||
b = (float) colour[2];
|
||||
}
|
||||
float r = (float) colour[0];
|
||||
float g = (float) colour[1];
|
||||
float b = (float) colour[2];
|
||||
|
||||
renderer.pos( x, y, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x, y + FONT_HEIGHT, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x + width, y, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x + width, y, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x, y + FONT_HEIGHT, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
renderer.pos( x + width, y + FONT_HEIGHT, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
drawQuad( buffer, x, y, width, height, r, g, b );
|
||||
}
|
||||
|
||||
private boolean isGreyScale( int colour )
|
||||
private static void drawBackground(
|
||||
@Nonnull BufferBuilder renderer, float x, float y,
|
||||
@Nonnull TextBuffer backgroundColour, @Nonnull Palette palette, boolean greyscale,
|
||||
float leftMarginSize, float rightMarginSize, float height
|
||||
)
|
||||
{
|
||||
return colour == 0 || colour == 15 || colour == 7 || colour == 8;
|
||||
}
|
||||
if( leftMarginSize > 0 )
|
||||
{
|
||||
drawQuad( renderer, x - leftMarginSize, y, leftMarginSize, height, palette, greyscale, backgroundColour.charAt( 0 ) );
|
||||
}
|
||||
|
||||
public void drawStringBackgroundPart( int x, int y, TextBuffer backgroundColour, double leftMarginSize, double rightMarginSize, boolean greyScale, Palette p )
|
||||
{
|
||||
// Draw the quads
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR );
|
||||
if( leftMarginSize > 0.0 )
|
||||
if( rightMarginSize > 0 )
|
||||
{
|
||||
int colour1 = "0123456789abcdef".indexOf( backgroundColour.charAt( 0 ) );
|
||||
if( colour1 < 0 || (greyScale && !isGreyScale( colour1 )) )
|
||||
{
|
||||
colour1 = 15;
|
||||
}
|
||||
drawQuad( renderer, x - leftMarginSize, y, colour1, leftMarginSize, p, greyScale );
|
||||
}
|
||||
if( rightMarginSize > 0.0 )
|
||||
{
|
||||
int colour2 = "0123456789abcdef".indexOf( backgroundColour.charAt( backgroundColour.length() - 1 ) );
|
||||
if( colour2 < 0 || (greyScale && !isGreyScale( colour2 )) )
|
||||
{
|
||||
colour2 = 15;
|
||||
}
|
||||
drawQuad( renderer, x + backgroundColour.length() * FONT_WIDTH, y, colour2, rightMarginSize, p, greyScale );
|
||||
drawQuad( renderer, x + backgroundColour.length() * FONT_WIDTH, y, rightMarginSize, height, palette, greyscale, backgroundColour.charAt( backgroundColour.length() - 1 ) );
|
||||
}
|
||||
|
||||
// Batch together runs of identical background cells.
|
||||
int blockStart = 0;
|
||||
char blockColour = '\0';
|
||||
for( int i = 0; i < backgroundColour.length(); i++ )
|
||||
{
|
||||
int colour = "0123456789abcdef".indexOf( backgroundColour.charAt( i ) );
|
||||
if( colour < 0 || (greyScale && !isGreyScale( colour )) )
|
||||
char colourIndex = backgroundColour.charAt( i );
|
||||
if( colourIndex == blockColour ) continue;
|
||||
|
||||
if( blockColour != '\0' )
|
||||
{
|
||||
colour = 15;
|
||||
drawQuad( renderer, x + blockStart * FONT_WIDTH, y, FONT_WIDTH * (i - blockStart), height, palette, greyscale, blockColour );
|
||||
}
|
||||
drawQuad( renderer, x + i * FONT_WIDTH, y, colour, FONT_WIDTH, p, greyScale );
|
||||
|
||||
blockColour = colourIndex;
|
||||
blockStart = i;
|
||||
}
|
||||
|
||||
if( blockColour != '\0' )
|
||||
{
|
||||
drawQuad( renderer, x + blockStart * FONT_WIDTH, y, FONT_WIDTH * (backgroundColour.length() - blockStart), height, palette, greyscale, blockColour );
|
||||
}
|
||||
GlStateManager.disableTexture2D();
|
||||
tessellator.draw();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public void drawStringTextPart( int x, int y, TextBuffer s, TextBuffer textColour, boolean greyScale, Palette p )
|
||||
public static void drawString(
|
||||
@Nonnull BufferBuilder renderer, float x, float y,
|
||||
@Nonnull TextBuffer text, @Nonnull TextBuffer textColour, @Nullable TextBuffer backgroundColour,
|
||||
@Nonnull Palette palette, boolean greyscale, float leftMarginSize, float rightMarginSize
|
||||
)
|
||||
{
|
||||
// Draw the quads
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_TEX_COLOR );
|
||||
for( int i = 0; i < s.length(); i++ )
|
||||
if( backgroundColour != null )
|
||||
{
|
||||
// Switch colour
|
||||
int colour = "0123456789abcdef".indexOf( textColour.charAt( i ) );
|
||||
if( colour < 0 || (greyScale && !isGreyScale( colour )) )
|
||||
drawBackground( renderer, x, y, backgroundColour, palette, greyscale, leftMarginSize, rightMarginSize, FONT_HEIGHT );
|
||||
}
|
||||
|
||||
for( int i = 0; i < text.length(); i++ )
|
||||
{
|
||||
double[] colour = palette.getColour( getColour( textColour.charAt( i ), Colour.White ) );
|
||||
float r, g, b;
|
||||
if( greyscale )
|
||||
{
|
||||
colour = 0;
|
||||
r = g = b = toGreyscale( colour );
|
||||
}
|
||||
else
|
||||
{
|
||||
r = (float) colour[0];
|
||||
g = (float) colour[1];
|
||||
b = (float) colour[2];
|
||||
}
|
||||
|
||||
// Draw char
|
||||
int index = s.charAt( i );
|
||||
if( index < 0 || index > 255 )
|
||||
{
|
||||
index = '?';
|
||||
}
|
||||
drawChar( renderer, x + i * FONT_WIDTH, y, index, colour, p, greyScale );
|
||||
int index = text.charAt( i );
|
||||
if( index > 255 ) index = '?';
|
||||
drawChar( renderer, x + i * FONT_WIDTH, y, index, r, g, b );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void drawString(
|
||||
float x, float y, @Nonnull TextBuffer text, @Nonnull TextBuffer textColour, @Nullable TextBuffer backgroundColour,
|
||||
@Nonnull Palette palette, boolean greyscale, float leftMarginSize, float rightMarginSize
|
||||
)
|
||||
{
|
||||
bindFont();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
begin( buffer );
|
||||
drawString( buffer, x, y, text, textColour, backgroundColour, palette, greyscale, leftMarginSize, rightMarginSize );
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public void drawString( TextBuffer s, int x, int y, TextBuffer textColour, TextBuffer backgroundColour, double leftMarginSize, double rightMarginSize, boolean greyScale, Palette p )
|
||||
public static void drawTerminalWithoutCursor(
|
||||
@Nonnull BufferBuilder buffer, float x, float y,
|
||||
@Nonnull Terminal terminal, boolean greyscale,
|
||||
float topMarginSize, float bottomMarginSize, float leftMarginSize, float rightMarginSize
|
||||
)
|
||||
{
|
||||
// Draw background
|
||||
if( backgroundColour != null )
|
||||
Palette palette = terminal.getPalette();
|
||||
int height = terminal.getHeight();
|
||||
|
||||
// Top and bottom margins
|
||||
drawBackground(
|
||||
buffer, x, y - topMarginSize,
|
||||
terminal.getBackgroundColourLine( 0 ), palette, greyscale,
|
||||
leftMarginSize, rightMarginSize, topMarginSize
|
||||
);
|
||||
|
||||
drawBackground(
|
||||
buffer, x, y + height * FONT_HEIGHT,
|
||||
terminal.getBackgroundColourLine( height - 1 ), palette, greyscale,
|
||||
leftMarginSize, rightMarginSize, bottomMarginSize
|
||||
);
|
||||
|
||||
// The main text
|
||||
for( int i = 0; i < height; i++ )
|
||||
{
|
||||
// Bind the background texture
|
||||
m_textureManager.bindTexture( BACKGROUND );
|
||||
|
||||
// Draw the quads
|
||||
drawStringBackgroundPart( x, y, backgroundColour, leftMarginSize, rightMarginSize, greyScale, p );
|
||||
}
|
||||
|
||||
// Draw text
|
||||
if( s != null && textColour != null )
|
||||
{
|
||||
// Bind the font texture
|
||||
bindFont();
|
||||
|
||||
// Draw the quads
|
||||
drawStringTextPart( x, y, s, textColour, greyScale, p );
|
||||
drawString(
|
||||
buffer, x, y + FixedWidthFontRenderer.FONT_HEIGHT * i,
|
||||
terminal.getLine( i ), terminal.getTextColourLine( i ), terminal.getBackgroundColourLine( i ),
|
||||
palette, greyscale, leftMarginSize, rightMarginSize
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public int getStringWidth( String s )
|
||||
public static void drawCursor(
|
||||
@Nonnull BufferBuilder buffer, float x, float y,
|
||||
@Nonnull Terminal terminal, boolean greyscale
|
||||
)
|
||||
{
|
||||
if( s == null )
|
||||
Palette palette = terminal.getPalette();
|
||||
int width = terminal.getWidth();
|
||||
int height = terminal.getHeight();
|
||||
|
||||
int cursorX = terminal.getCursorX();
|
||||
int cursorY = terminal.getCursorY();
|
||||
if( terminal.getCursorBlink() && cursorX >= 0 && cursorX < width && cursorY >= 0 && cursorY < height && FrameInfo.getGlobalCursorBlink() )
|
||||
{
|
||||
return 0;
|
||||
double[] colour = palette.getColour( 15 - terminal.getTextColour() );
|
||||
float r, g, b;
|
||||
if( greyscale )
|
||||
{
|
||||
r = g = b = toGreyscale( colour );
|
||||
}
|
||||
else
|
||||
{
|
||||
r = (float) colour[0];
|
||||
g = (float) colour[1];
|
||||
b = (float) colour[2];
|
||||
}
|
||||
|
||||
drawChar( buffer, x + cursorX * FONT_WIDTH, y + cursorY * FONT_HEIGHT, '_', r, g, b );
|
||||
}
|
||||
return s.length() * FONT_WIDTH;
|
||||
}
|
||||
|
||||
public void bindFont()
|
||||
public static void drawTerminal(
|
||||
@Nonnull BufferBuilder buffer, float x, float y,
|
||||
@Nonnull Terminal terminal, boolean greyscale,
|
||||
float topMarginSize, float bottomMarginSize, float leftMarginSize, float rightMarginSize
|
||||
)
|
||||
{
|
||||
m_textureManager.bindTexture( FONT );
|
||||
drawTerminalWithoutCursor( buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
|
||||
drawCursor( buffer, x, y, terminal, greyscale );
|
||||
}
|
||||
|
||||
public static void drawTerminal(
|
||||
float x, float y, @Nonnull Terminal terminal, boolean greyscale,
|
||||
float topMarginSize, float bottomMarginSize, float leftMarginSize, float rightMarginSize
|
||||
)
|
||||
{
|
||||
bindFont();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
begin( buffer );
|
||||
drawTerminal( buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawEmptyTerminal( float x, float y, float width, float height )
|
||||
{
|
||||
bindFont();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
begin( buffer );
|
||||
|
||||
Colour colour = Colour.Black;
|
||||
drawQuad( buffer, x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawBlocker( @Nonnull BufferBuilder buffer, float x, float y, float width, float height )
|
||||
{
|
||||
Colour colour = Colour.Black;
|
||||
drawQuad( buffer, x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||
}
|
||||
|
||||
public static void drawBlocker( float x, float y, float width, float height )
|
||||
{
|
||||
bindFont();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
begin( buffer );
|
||||
drawBlocker( buffer, x, y, width, height );
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void bindFont()
|
||||
{
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( FONT );
|
||||
GlStateManager.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
|
||||
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void begin( BufferBuilder buffer )
|
||||
{
|
||||
buffer.begin( GL11.GL_TRIANGLES, POSITION_COLOR_TEX );
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@@ -1,30 +1,22 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
import dan200.computercraft.client.FrameInfo;
|
||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.computer.core.IComputerContainer;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.BACKGROUND;
|
||||
|
||||
public class WidgetTerminal extends Widget
|
||||
{
|
||||
private static final float TERMINATE_TIME = 0.5f;
|
||||
@@ -42,10 +34,10 @@ public class WidgetTerminal extends Widget
|
||||
private boolean m_focus = false;
|
||||
private boolean m_allowFocusLoss = true;
|
||||
|
||||
private int m_leftMargin;
|
||||
private int m_rightMargin;
|
||||
private int m_topMargin;
|
||||
private int m_bottomMargin;
|
||||
private final int leftMargin;
|
||||
private final int rightMargin;
|
||||
private final int topMargin;
|
||||
private final int bottomMargin;
|
||||
|
||||
private final ArrayList<Integer> m_keysDown = new ArrayList<>();
|
||||
|
||||
@@ -59,10 +51,10 @@ public class WidgetTerminal extends Widget
|
||||
|
||||
m_computer = computer;
|
||||
|
||||
m_leftMargin = leftMargin;
|
||||
m_rightMargin = rightMargin;
|
||||
m_topMargin = topMargin;
|
||||
m_bottomMargin = bottomMargin;
|
||||
this.leftMargin = leftMargin;
|
||||
this.rightMargin = rightMargin;
|
||||
this.topMargin = topMargin;
|
||||
this.bottomMargin = bottomMargin;
|
||||
}
|
||||
|
||||
public void setAllowFocusLoss( boolean allowFocusLoss )
|
||||
@@ -167,8 +159,8 @@ public class WidgetTerminal extends Widget
|
||||
Terminal term = computer.getTerminal();
|
||||
if( term != null )
|
||||
{
|
||||
int charX = (mouseX - (getXPosition() + m_leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int charY = (mouseY - (getYPosition() + m_topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
int charX = (mouseX - (getXPosition() + leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int charY = (mouseY - (getYPosition() + topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
|
||||
charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 );
|
||||
|
||||
@@ -224,8 +216,8 @@ public class WidgetTerminal extends Widget
|
||||
Terminal term = computer.getTerminal();
|
||||
if( term != null )
|
||||
{
|
||||
int charX = (mouseX - (getXPosition() + m_leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int charY = (mouseY - (getYPosition() + m_topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
int charX = (mouseX - (getXPosition() + leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int charY = (mouseY - (getYPosition() + topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
|
||||
charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 );
|
||||
|
||||
@@ -340,74 +332,14 @@ public class WidgetTerminal extends Widget
|
||||
Terminal terminal = computer != null ? computer.getTerminal() : null;
|
||||
if( terminal != null )
|
||||
{
|
||||
// Draw the terminal
|
||||
boolean greyscale = !computer.isColour();
|
||||
|
||||
Palette palette = terminal.getPalette();
|
||||
|
||||
// Get the data from the terminal first
|
||||
// Unfortunately we have to keep the lock for the whole of drawing, so the text doesn't change under us.
|
||||
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
|
||||
boolean tblink = m_focus && terminal.getCursorBlink() && FrameInfo.getGlobalCursorBlink();
|
||||
int tw = terminal.getWidth();
|
||||
int th = terminal.getHeight();
|
||||
int tx = terminal.getCursorX();
|
||||
int ty = terminal.getCursorY();
|
||||
|
||||
int x = startX + m_leftMargin;
|
||||
int y = startY + m_topMargin;
|
||||
|
||||
// Draw margins
|
||||
TextBuffer emptyLine = new TextBuffer( ' ', tw );
|
||||
if( m_topMargin > 0 )
|
||||
{
|
||||
fontRenderer.drawString( emptyLine, x, startY, terminal.getTextColourLine( 0 ), terminal.getBackgroundColourLine( 0 ), m_leftMargin, m_rightMargin, greyscale, palette );
|
||||
}
|
||||
if( m_bottomMargin > 0 )
|
||||
{
|
||||
fontRenderer.drawString( emptyLine, x, startY + 2 * m_bottomMargin + (th - 1) * FixedWidthFontRenderer.FONT_HEIGHT, terminal.getTextColourLine( th - 1 ), terminal.getBackgroundColourLine( th - 1 ), m_leftMargin, m_rightMargin, greyscale, palette );
|
||||
}
|
||||
|
||||
// Draw lines
|
||||
for( int line = 0; line < th; line++ )
|
||||
{
|
||||
TextBuffer text = terminal.getLine( line );
|
||||
TextBuffer colour = terminal.getTextColourLine( line );
|
||||
TextBuffer backgroundColour = terminal.getBackgroundColourLine( line );
|
||||
fontRenderer.drawString( text, x, y, colour, backgroundColour, m_leftMargin, m_rightMargin, greyscale, palette );
|
||||
y += FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
if( tblink && tx >= 0 && ty >= 0 && tx < tw && ty < th )
|
||||
{
|
||||
TextBuffer cursor = new TextBuffer( '_', 1 );
|
||||
TextBuffer cursorColour = new TextBuffer( "0123456789abcdef".charAt( terminal.getTextColour() ), 1 );
|
||||
|
||||
fontRenderer.drawString(
|
||||
cursor,
|
||||
x + FixedWidthFontRenderer.FONT_WIDTH * tx,
|
||||
startY + m_topMargin + FixedWidthFontRenderer.FONT_HEIGHT * ty,
|
||||
cursorColour, null,
|
||||
0, 0,
|
||||
greyscale,
|
||||
palette
|
||||
);
|
||||
}
|
||||
FixedWidthFontRenderer.drawTerminal(
|
||||
startX + topMargin, startY + bottomMargin,
|
||||
terminal, !computer.isColour(), topMargin, bottomMargin, leftMargin, rightMargin
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw a black background
|
||||
mc.getTextureManager().bindTexture( BACKGROUND );
|
||||
Colour black = Colour.Black;
|
||||
GlStateManager.color( black.getR(), black.getG(), black.getB(), 1.0f );
|
||||
try
|
||||
{
|
||||
drawTexturedModalRect( startX, startY, 0, 0, getWidth(), getHeight() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
FixedWidthFontRenderer.drawEmptyTerminal( startX, startY, getWidth(), getHeight() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.proxy;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user