mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-11-04 07:32:59 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			v1.12.2-1.
			...
			feature/ne
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					6ac1c0e944 | 
@@ -11,12 +11,5 @@ insert_final_newline = true
 | 
			
		||||
[*.md]
 | 
			
		||||
trim_trailing_whitespace = false
 | 
			
		||||
 | 
			
		||||
[*.sexp]
 | 
			
		||||
indent_size = 2
 | 
			
		||||
 | 
			
		||||
[*.yml]
 | 
			
		||||
indent_size = 2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[*.properties]
 | 
			
		||||
insert_final_newline = false
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							@@ -1,15 +1,16 @@
 | 
			
		||||
---
 | 
			
		||||
name: Bug report
 | 
			
		||||
about: Report some misbehaviour in the mod
 | 
			
		||||
labels: bug
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
<!--
 | 
			
		||||
## Before reporting
 | 
			
		||||
 - Search for the bug on the issue tracker. Make sure to look at closed issues too!
 | 
			
		||||
 - Search for the bug both here and [on the ComputerCraft issues page](https://github.com/dan200/ComputerCraft/issues?utf8=%E2%9C%93&q=is%3Aissue+)
 | 
			
		||||
 - If possible, try to reproduce on vanilla ComputerCraft. If it still occurs, [report on the ComputerCraft repo](https://github.com/dan200/ComputerCraft/issues/new) instead.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
## Useful information to include:
 | 
			
		||||
 - Minecraft version
 | 
			
		||||
 - CC: Tweaked version
 | 
			
		||||
 - Detailed reproduction steps: sometimes I can spot a bug pretty easily, but often it's much more obscure. The more information I have to help reproduce it, the quicker it'll get fixed.
 | 
			
		||||
 - Detailed reproduction steps!** Sometimes I can spot a bug pretty easily, but often it's much more obscure. Anything you can give which will help reproduce it means it'll get fixed quicker.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
								
							@@ -1,14 +1,15 @@
 | 
			
		||||
---
 | 
			
		||||
name: Feature request
 | 
			
		||||
about: Suggest an idea or improvement
 | 
			
		||||
labels: enhancement
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
<!--
 | 
			
		||||
## Before reporting
 | 
			
		||||
 - Search for the suggestion here. It's possible someone's suggested it before!
 | 
			
		||||
 - Search for the suggestion both here and [on the ComputerCraft issues page](https://github.com/dan200/ComputerCraft/issues?utf8=%E2%9C%93&q=is%3Aissue+). It's possible someone's suggested it before!
 | 
			
		||||
 - Unless something is specific to CC:Tweaked, try to [suggest them on the ComputerCraft repo](https://github.com/dan200/ComputerCraft/issues/new). There's a lot more people watching it, so it allows the wider community to contribute.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
## Useful information to include:
 | 
			
		||||
 - Explanation of how the feature/change should work.
 | 
			
		||||
 - Some rationale/use case for a feature. My general approach to designing new features is to ask yourself "what issue are we trying to solve" and _then_ "is this the best way to solve this issue?".
 | 
			
		||||
 - Explanation of how the feature/change chould work.
 | 
			
		||||
 - Some rationale/use case for a feature. I'd like to keep CC:T as minimal
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								.github/pull_request_template.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								.github/pull_request_template.md
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,9 @@
 | 
			
		||||
## A quick checklist
 | 
			
		||||
 - If there's a existing issue, please link to it. If not, provide fill out the same information you would in a normal issue - reproduction steps for bugs, rationale for use-case.
 | 
			
		||||
 - If you're working on CraftOS, try to write a few test cases so we can ensure everything continues to work in the future. Tests live in `src/test/resources/test-rom/spec` and can be run with `./gradlew check`.
 | 
			
		||||
<!--
 | 
			
		||||
Unless this feature is specific to CC:Tweaked, try to [target the original ComputerCraft repo](https://github.com/dan200/ComputerCraft/) instead. There's a lot more people watching it, so it allows the wider community to contribute.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
## Useful information to include:
 | 
			
		||||
 - Brief explanation of the changes you've made.
 | 
			
		||||
 - Rationale of why this change has been made/reasoning behind it.
 | 
			
		||||
 | 
			
		||||
The more information you can provide, the easier it is to review something now _and_ to see why a change was made, when the code needs updating in the future.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										50
									
								
								.github/workflows/main-ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										50
									
								
								.github/workflows/main-ci.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,50 +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: Cache gradle dependencies
 | 
			
		||||
      uses: actions/cache@v1
 | 
			
		||||
      with:
 | 
			
		||||
        path: ~/.gradle/caches
 | 
			
		||||
        key: ${{ runner.os }}-gradle-${{ hashFiles('gradle.properties') }}
 | 
			
		||||
        restore-keys: |
 | 
			
		||||
          ${{ runner.os }}-gradle-
 | 
			
		||||
 | 
			
		||||
    - name: Build with Gradle
 | 
			
		||||
      run: ./gradlew build --no-daemon
 | 
			
		||||
 | 
			
		||||
    - name: Upload Jar
 | 
			
		||||
      uses: actions/upload-artifact@v1
 | 
			
		||||
      with:
 | 
			
		||||
        name: CC-Tweaked
 | 
			
		||||
        path: build/libs
 | 
			
		||||
 | 
			
		||||
  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/linux-x86-64/illuaminate
 | 
			
		||||
        chmod +x bin/illuaminate
 | 
			
		||||
        bin/illuaminate lint
 | 
			
		||||
 | 
			
		||||
    - name: Check whitespace
 | 
			
		||||
      run: python3 tools/check-lines.py
 | 
			
		||||
							
								
								
									
										16
									
								
								.github/workflows/make-doc.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								.github/workflows/make-doc.sh
									
									
									
									
										vendored
									
									
								
							@@ -1,16 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
set -eu
 | 
			
		||||
 | 
			
		||||
DEST="${GITHUB_REF#refs/*/}"
 | 
			
		||||
echo "Uploading docs to https://tweaked.cc/$DEST"
 | 
			
		||||
 | 
			
		||||
# Setup ssh key
 | 
			
		||||
mkdir -p "$HOME/.ssh/"
 | 
			
		||||
echo "$SSH_KEY" > "$HOME/.ssh/key"
 | 
			
		||||
chmod 600 "$HOME/.ssh/key"
 | 
			
		||||
 | 
			
		||||
# And upload
 | 
			
		||||
rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \
 | 
			
		||||
      "$GITHUB_WORKSPACE/doc/" \
 | 
			
		||||
      "$SSH_USER@$SSH_HOST:/var/www/tweaked.cc/$DEST"
 | 
			
		||||
							
								
								
									
										29
									
								
								.github/workflows/make-doc.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								.github/workflows/make-doc.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,29 +0,0 @@
 | 
			
		||||
name: Build documentation
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
    branches: [ master ]
 | 
			
		||||
    tags:
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  make_doc:
 | 
			
		||||
    name: Build
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v1
 | 
			
		||||
 | 
			
		||||
    - name: Build documentation
 | 
			
		||||
      run: |
 | 
			
		||||
        test -d bin || mkdir bin
 | 
			
		||||
        test -f bin/illuaminate || wget -q -Obin/illuaminate https://squiddev.cc/illuaminate/linux-x86-64/illuaminate
 | 
			
		||||
        chmod +x bin/illuaminate
 | 
			
		||||
        bin/illuaminate doc-gen
 | 
			
		||||
 | 
			
		||||
    - name: Upload documentation
 | 
			
		||||
      run: .github/workflows/make-doc.sh 2> /dev/null
 | 
			
		||||
      env:
 | 
			
		||||
        SSH_KEY:  ${{ secrets.SSH_KEY  }}
 | 
			
		||||
        SSH_USER: ${{ secrets.SSH_USER }}
 | 
			
		||||
        SSH_HOST: ${{ secrets.SSH_HOST }}
 | 
			
		||||
        SSH_PORT: ${{ secrets.SSH_PORT }}
 | 
			
		||||
							
								
								
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -3,8 +3,6 @@
 | 
			
		||||
/logs
 | 
			
		||||
/build
 | 
			
		||||
/out
 | 
			
		||||
/doc/**/*.html
 | 
			
		||||
/doc/index.json
 | 
			
		||||
 | 
			
		||||
# Runtime directories
 | 
			
		||||
/run
 | 
			
		||||
@@ -17,9 +15,3 @@
 | 
			
		||||
.idea
 | 
			
		||||
.gradle
 | 
			
		||||
*.DS_Store
 | 
			
		||||
 | 
			
		||||
.classpath
 | 
			
		||||
.project
 | 
			
		||||
.settings/
 | 
			
		||||
bin/
 | 
			
		||||
*.launch
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
std = "max"
 | 
			
		||||
 | 
			
		||||
ignore = {
 | 
			
		||||
    -- Allow access to undefined globals or their fields. In the future we'll
 | 
			
		||||
    -- define all of CC's globals within this file
 | 
			
		||||
    '113', '143',
 | 
			
		||||
 | 
			
		||||
    -- FIXME: Ignore unused arguments and loop variables
 | 
			
		||||
    '212', '213',
 | 
			
		||||
 | 
			
		||||
    -- Disable line is too long for now. It would be possible to clean
 | 
			
		||||
    -- this up in the future.
 | 
			
		||||
    '631',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Only run the linter on ROM and bios for now, as the treasure disks
 | 
			
		||||
-- are largely unsupported.
 | 
			
		||||
include_files = {
 | 
			
		||||
    'src/main/resources/assets/computercraft/lua/rom',
 | 
			
		||||
    'src/main/resources/assets/computercraft/lua/bios.lua'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
files['src/main/resources/assets/computercraft/lua/bios.lua'] = {
 | 
			
		||||
    -- Allow declaring and mutating globals
 | 
			
		||||
    allow_defined_top = true,
 | 
			
		||||
    ignore = { '112', '121', '122', '131', '142' },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
files['src/main/resources/assets/computercraft/lua/rom/apis'] = {
 | 
			
		||||
    -- APIs may define globals on the top level. We'll ignore unused globals,
 | 
			
		||||
    -- as obviously they may be used outside that API.
 | 
			
		||||
    allow_defined_top = true,
 | 
			
		||||
    ignore = { '131' },
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
language: java
 | 
			
		||||
 | 
			
		||||
script: ./gradlew build --no-daemon
 | 
			
		||||
 | 
			
		||||
before_cache:
 | 
			
		||||
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
 | 
			
		||||
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
 | 
			
		||||
cache:
 | 
			
		||||
  directories:
 | 
			
		||||
    - $HOME/.gradle/caches/
 | 
			
		||||
    - $HOME/.gradle/wrapper/s
 | 
			
		||||
 | 
			
		||||
jdk:
 | 
			
		||||
    - oraclejdk8
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
# 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
 | 
			
		||||
@@ -1,6 +1,4 @@
 | 
			
		||||
MIT License
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2016 Nicolas Seriot
 | 
			
		||||
Copyright (c) 2007 LuaJ. All rights reserved.
 | 
			
		||||
 | 
			
		||||
Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
@@ -9,13 +7,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
furnished to do so, subject to the following conditions:
 | 
			
		||||
 | 
			
		||||
The above copyright notice and this permission notice shall be included in all
 | 
			
		||||
copies or substantial portions of the Software.
 | 
			
		||||
The above copyright notice and this permission notice shall be included in
 | 
			
		||||
all copies or substantial portions of the Software.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
SOFTWARE.
 | 
			
		||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
THE SOFTWARE.
 | 
			
		||||
							
								
								
									
										82
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										82
									
								
								README.md
									
									
									
									
									
								
							@@ -1,35 +1,35 @@
 | 
			
		||||
# 
 | 
			
		||||
[](https://github.com/SquidDev-CC/CC-Tweaked/actions "Current build status") [](https://minecraft.curseforge.com/projects/cc-tweaked "Download CC: Tweaked on CurseForge")
 | 
			
		||||
# 
 | 
			
		||||
[](https://travis-ci.org/SquidDev-CC/CC-Tweaked)
 | 
			
		||||
 | 
			
		||||
CC: Tweaked is a fork of [ComputerCraft](https://github.com/dan200/ComputerCraft), adding programmable computers,
 | 
			
		||||
turtles and more to Minecraft.
 | 
			
		||||
CC: Tweaked is a fork of ComputerCraft which aims to provide earlier access to the more experimental and in-development
 | 
			
		||||
features of the mod. For a more stable experience, I recommend checking out the
 | 
			
		||||
[original mod](https://github.com/dan200/ComputerCraft).
 | 
			
		||||
 | 
			
		||||
## What?
 | 
			
		||||
ComputerCraft has always held a fond place in my heart: it's the mod which really got me into Minecraft, and it's the
 | 
			
		||||
mod which has kept me playing it for many years. However, development of the original mod has slowed, as the original
 | 
			
		||||
developers have had less time to work on the mod, and moved onto other projects and commitments.
 | 
			
		||||
CC: Tweaked (or CC:T for short) does not aim to create a competing fork of ComputerCraft, nor am I planning to take it
 | 
			
		||||
in in a vastly different direction to the original mod. In fact, CC:T aims to be a nurturing ground for various
 | 
			
		||||
features, with a pull request against the original mod being the end goal.
 | 
			
		||||
 | 
			
		||||
CC: Tweaked (or CC:T for short) is an attempt to continue ComputerCraft's legacy. It's not intended to be a competitor
 | 
			
		||||
to CC, nor do I want to take it in a vastly different direction to the original mod. Instead, CC:T focuses on making the
 | 
			
		||||
ComputerCraft experience as _solid_ as possible, ironing out any wrinkles that may have developed over time.
 | 
			
		||||
CC:T also includes many pull requests from the community which have not yet been merged, offering a large number
 | 
			
		||||
of additional bug fixes and features over the original mod.
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
CC: Tweaked contains all the features of the latest version of ComputerCraft, as well as numerous fixes, performance
 | 
			
		||||
improvements and several nifty additions. I'd recommend checking out [the releases page](https://github.com/SquidDev-CC/CC-Tweaked/releases)
 | 
			
		||||
to see the full set of changes, but here's a couple of the more interesting additions:
 | 
			
		||||
CC: Tweaked contains all the features of the latest alpha, as well as numerous fixes, performance improvements and
 | 
			
		||||
several additional features. I'd recommend checking out [the releases page](https://github.com/SquidDev-CC/CC-Tweaked/releases)
 | 
			
		||||
to see the full changes, but here's a couple of the more interesting changes:
 | 
			
		||||
 | 
			
		||||
 - Improvements to the `http` library, including websockets, support for other HTTP methods (`PUT`, `DELETE`, etc...)
 | 
			
		||||
   and configurable limits on HTTP usage.
 | 
			
		||||
 - Full-block wired modems, allowing one to wrap non-solid peripherals (such as turtles, or chests if Plethora is
 | 
			
		||||
   installed).
 | 
			
		||||
 - Pocket computers can be held like maps, allowing you to view the screen without entering a GUI.
 | 
			
		||||
 - Printed pages and books can be placed in item frames and held like maps.
 | 
			
		||||
 - Several profiling and administration tools for server owners, via the `/computercraft` command. This allows operators
 | 
			
		||||
   to track which computers are hogging resources, turn on and shutdown multiple computers at once and interact with
 | 
			
		||||
 - Replace LuaJ with Cobalt.
 | 
			
		||||
 - Allow running multiple computers at the same time.
 | 
			
		||||
 - Websocket support in the HTTP library.
 | 
			
		||||
 - Wired modems and cables act more like multiparts.
 | 
			
		||||
 - Add map-like rendering for pocket computers and printed pages/books.
 | 
			
		||||
 - Adds the `/computercraft` command, offering various diagnostic tools for server owners. This allows operators to
 | 
			
		||||
   track which computers are hogging resources, turn on and shutdown multiple computers at once and interact with
 | 
			
		||||
   computers remotely.
 | 
			
		||||
 - Closer emulation of standard Lua, adding the `debug` and `io` libraries. This also enables seeking within binary
 | 
			
		||||
   files, meaning you don't need to read large files into memory.
 | 
			
		||||
 - Allow running multiple computers on multiple threads, reducing latency on worlds with many computers.
 | 
			
		||||
 - Add full-block wired modems, allowing one to wrap non-solid peripherals (such as turtles, or chests if Plethora is
 | 
			
		||||
   installed).
 | 
			
		||||
 - Extended binary file handles. They support file seeking, and reading new lines, allowing full (and accurate)
 | 
			
		||||
   emulation of the standard Lua `io` library.
 | 
			
		||||
 | 
			
		||||
## Relation to CCTweaks?
 | 
			
		||||
This mod has nothing to do with CCTweaks, though there is no denying the name is a throwback to it. That being said,
 | 
			
		||||
@@ -37,33 +37,13 @@ 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. If you want to get started
 | 
			
		||||
developing the mod, [check out the instructions here](CONTRIBUTING.md#developing).
 | 
			
		||||
Any contribution is welcome, be that using the mod, reporting bugs or contributing code. If you do wish to contribute
 | 
			
		||||
code, do consider submitting it to the ComputerCraft repository first.
 | 
			
		||||
 | 
			
		||||
## 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.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.
 | 
			
		||||
That being said, in order to start helping develop CC:T, you'll need to follow these steps:
 | 
			
		||||
 | 
			
		||||
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!
 | 
			
		||||
 - **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).
 | 
			
		||||
 | 
			
		||||
## Using
 | 
			
		||||
If you want to depend on CC: Tweaked, we have a maven repo. However, you should be wary that some functionality is only
 | 
			
		||||
exposed by CC:T's API and not vanilla ComputerCraft. If you wish to support all variations of ComputerCraft, I recommend
 | 
			
		||||
using [cc.crzd.me's maven](https://cc.crzd.me/maven/) instead.
 | 
			
		||||
 | 
			
		||||
```groovy
 | 
			
		||||
dependencies {
 | 
			
		||||
  maven { url 'https://squiddev.cc/maven/' }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
  implementation "org.squiddev:cc-tweaked-${mc_version}:${cct_version}"
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
You should also be careful to only use classes within the `dan200.computercraft.api` package. Non-API classes are
 | 
			
		||||
subject to change at any point. If you depend on functionality outside the API, file an issue, and we can look into
 | 
			
		||||
exposing more features.
 | 
			
		||||
If you want to run CC:T in a normal Minecraft instance, run `./gradlew build` and copy the `.jar` from `build/libs`.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										309
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										309
									
								
								build.gradle
									
									
									
									
									
								
							@@ -5,22 +5,17 @@ buildscript {
 | 
			
		||||
        jcenter()
 | 
			
		||||
        maven {
 | 
			
		||||
            name = "forge"
 | 
			
		||||
            url = "https://files.minecraftforge.net/maven"
 | 
			
		||||
            url = "http://files.minecraftforge.net/maven"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    dependencies {
 | 
			
		||||
        classpath 'com.google.code.gson:gson:2.8.1'
 | 
			
		||||
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
 | 
			
		||||
        classpath 'net.sf.proguard:proguard-gradle:6.1.0beta1'
 | 
			
		||||
        classpath 'org.ajoberstar.grgit:grgit-gradle:3.0.0'
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
plugins {
 | 
			
		||||
    id "checkstyle"
 | 
			
		||||
    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"
 | 
			
		||||
    id 'com.matthewprenger.cursegradle' version '1.0.10'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
apply plugin: 'net.minecraftforge.gradle.forge'
 | 
			
		||||
@@ -28,37 +23,35 @@ apply plugin: 'org.ajoberstar.grgit'
 | 
			
		||||
apply plugin: 'maven-publish'
 | 
			
		||||
apply plugin: 'maven'
 | 
			
		||||
 | 
			
		||||
version = mod_version
 | 
			
		||||
 | 
			
		||||
version = "1.80pr1.14"
 | 
			
		||||
group = "org.squiddev"
 | 
			
		||||
archivesBaseName = "cc-tweaked-${mc_version}"
 | 
			
		||||
archivesBaseName = "cc-tweaked"
 | 
			
		||||
 | 
			
		||||
minecraft {
 | 
			
		||||
    version = "${mc_version}-${forge_version}"
 | 
			
		||||
    version = "1.12.2-14.23.4.2749"
 | 
			
		||||
    runDir = "run"
 | 
			
		||||
    replace '${version}', mod_version
 | 
			
		||||
    replace '${version}', project.version
 | 
			
		||||
 | 
			
		||||
    mappings = mappings_version
 | 
			
		||||
    makeObfSourceJar = false
 | 
			
		||||
    // the mappings can be changed at any time, and must be in the following format.
 | 
			
		||||
    // snapshot_YYYYMMDD   snapshot are built nightly.
 | 
			
		||||
    // stable_#            stables are built at the discretion of the MCP team.
 | 
			
		||||
    // Use non-default mappings at your own risk. they may not allways work.
 | 
			
		||||
    // simply re-run your setup task after changing the mappings to update your workspace.
 | 
			
		||||
    mappings = "snapshot_20180724"
 | 
			
		||||
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    maven {
 | 
			
		||||
        name "SquidDev"
 | 
			
		||||
        url "https://squiddev.cc/maven"
 | 
			
		||||
    }
 | 
			
		||||
    ivy {
 | 
			
		||||
        name "Charset"
 | 
			
		||||
        artifactPattern "https://asie.pl/files/mods/Charset/LibOnly/[module]-[revision](-[classifier]).[ext]"
 | 
			
		||||
        name = "JEI"
 | 
			
		||||
        url  = "http://dvs1.progwml6.com/files/maven"
 | 
			
		||||
    }
 | 
			
		||||
    maven {
 | 
			
		||||
        name "Amadornes"
 | 
			
		||||
        url "https://maven.amadornes.com/"
 | 
			
		||||
    }
 | 
			
		||||
    maven {
 | 
			
		||||
        name "CraftTweaker"
 | 
			
		||||
        url "https://maven.blamejared.com/"
 | 
			
		||||
        name = "squiddev"
 | 
			
		||||
        url = "https://squiddev.cc/maven"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ivy { artifactPattern "https://asie.pl/files/mods/Charset/LibOnly/[module]-[revision](-[classifier]).[ext]" }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
configurations {
 | 
			
		||||
@@ -68,25 +61,18 @@ configurations {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
    checkstyle "com.puppycrawl.tools:checkstyle:8.25"
 | 
			
		||||
 | 
			
		||||
    deobfProvided "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.554"
 | 
			
		||||
    deobfProvided "MCMultiPart2:MCMultiPart:2.5.3"
 | 
			
		||||
    deobfProvided "mezz.jei:jei_1.12.2:4.15.0.269:api"
 | 
			
		||||
    deobfProvided "mezz.jei:jei_1.12.2:4.8.5.159:api"
 | 
			
		||||
    deobfProvided "pl.asie:Charset-Lib:0.5.4.6"
 | 
			
		||||
 | 
			
		||||
    runtime "mezz.jei:jei_1.12.2:4.15.0.269"
 | 
			
		||||
    runtime "mezz.jei:jei_1.12.2:4.8.5.159"
 | 
			
		||||
 | 
			
		||||
    shade 'org.squiddev:Cobalt:0.5.1-SNAPSHOT'
 | 
			
		||||
    shade 'org.squiddev:Cobalt:0.5.0-SNAPSHOT'
 | 
			
		||||
 | 
			
		||||
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
 | 
			
		||||
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
 | 
			
		||||
    testCompile 'junit:junit:4.11'
 | 
			
		||||
 | 
			
		||||
    deployerJars "org.apache.maven.wagon:wagon-ssh:3.0.0"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Compile tasks
 | 
			
		||||
 | 
			
		||||
javadoc {
 | 
			
		||||
    include "dan200/computercraft/api/**/*.java"
 | 
			
		||||
}
 | 
			
		||||
@@ -98,76 +84,20 @@ jar {
 | 
			
		||||
        attributes('FMLAT': 'computercraft_at.cfg')
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    from (sourceSets.main.allSource) {
 | 
			
		||||
    into("docs", { from (javadoc.destinationDir) })
 | 
			
		||||
 | 
			
		||||
    into("api", { from (sourceSets.main.allSource) {
 | 
			
		||||
        include "dan200/computercraft/api/**/*.java"
 | 
			
		||||
    }
 | 
			
		||||
    }})
 | 
			
		||||
 | 
			
		||||
    from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[compileJava, compileTestJava].forEach {
 | 
			
		||||
    it.configure {
 | 
			
		||||
        options.compilerArgs << "-Xlint" << "-Xlint:-processing" << "-Werror"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.nio.charset.StandardCharsets
 | 
			
		||||
import java.nio.file.*
 | 
			
		||||
import java.util.zip.*
 | 
			
		||||
 | 
			
		||||
import com.google.gson.GsonBuilder
 | 
			
		||||
import com.google.gson.JsonElement
 | 
			
		||||
import com.hierynomus.gradle.license.tasks.LicenseCheck
 | 
			
		||||
import com.hierynomus.gradle.license.tasks.LicenseFormat
 | 
			
		||||
import org.ajoberstar.grgit.Grgit
 | 
			
		||||
import proguard.gradle.ProGuardTask
 | 
			
		||||
 | 
			
		||||
task proguard(type: ProGuardTask, dependsOn: jar) {
 | 
			
		||||
    description "Removes unused shadowed classes from the jar"
 | 
			
		||||
    group "compact"
 | 
			
		||||
 | 
			
		||||
    injars jar.archivePath
 | 
			
		||||
    outjars "${jar.archivePath.absolutePath.replace(".jar", "")}-min.jar"
 | 
			
		||||
 | 
			
		||||
    // Add the main runtime jar and all non-shadowed dependencies
 | 
			
		||||
    libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
 | 
			
		||||
    libraryjars "${System.getProperty('java.home')}/lib/jce.jar"
 | 
			
		||||
    doFirst {
 | 
			
		||||
        sourceSets.main.compileClasspath
 | 
			
		||||
            .filter { !it.name.contains("Cobalt") }
 | 
			
		||||
            .each { libraryjars it }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // We want to avoid as much obfuscation as possible. We're only doing this to shrink code size.
 | 
			
		||||
    dontobfuscate; dontoptimize; keepattributes; keepparameternames
 | 
			
		||||
 | 
			
		||||
    // Proguard will remove directories by default, but that breaks JarMount.
 | 
			
		||||
    keepdirectories 'assets/computercraft/lua**'
 | 
			
		||||
 | 
			
		||||
    // Preserve ComputerCraft classes - we only want to strip shadowed files.
 | 
			
		||||
    keep 'class dan200.computercraft.** { *; }'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
task proguardMove(dependsOn: proguard) {
 | 
			
		||||
    description "Replace the original jar with the minified version"
 | 
			
		||||
    group "compact"
 | 
			
		||||
 | 
			
		||||
    doLast {
 | 
			
		||||
        Files.move(
 | 
			
		||||
            file("${jar.archivePath.absolutePath.replace(".jar", "")}-min.jar").toPath(),
 | 
			
		||||
            file(jar.archivePath).toPath(),
 | 
			
		||||
            StandardCopyOption.REPLACE_EXISTING
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
reobfJar.dependsOn proguardMove
 | 
			
		||||
 | 
			
		||||
processResources {
 | 
			
		||||
    inputs.property "version", mod_version
 | 
			
		||||
    inputs.property "mcversion", mc_version
 | 
			
		||||
    inputs.property "version", project.version
 | 
			
		||||
    inputs.property "mcversion", project.minecraft.version
 | 
			
		||||
 | 
			
		||||
    def hash = 'none'
 | 
			
		||||
    Set<String> contributors = []
 | 
			
		||||
@@ -188,9 +118,9 @@ processResources {
 | 
			
		||||
        include 'mcmod.info'
 | 
			
		||||
        include 'assets/computercraft/lua/rom/help/credits.txt'
 | 
			
		||||
 | 
			
		||||
        expand 'version': mod_version,
 | 
			
		||||
               'mcversion': mc_version,
 | 
			
		||||
               'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
 | 
			
		||||
        expand 'version':project.version,
 | 
			
		||||
               'mcversion':project.minecraft.version,
 | 
			
		||||
               'gitcontributors':contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    from(sourceSets.main.resources.srcDirs) {
 | 
			
		||||
@@ -199,149 +129,13 @@ processResources {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
task compressJson(dependsOn: extractAnnotationsJar) {
 | 
			
		||||
    group "compact"
 | 
			
		||||
    description "Minifies all JSON files, stripping whitespace"
 | 
			
		||||
 | 
			
		||||
    def jarPath = file(jar.archivePath)
 | 
			
		||||
 | 
			
		||||
    def tempPath = File.createTempFile("input", ".jar", temporaryDir)
 | 
			
		||||
    tempPath.deleteOnExit()
 | 
			
		||||
 | 
			
		||||
    def gson = new GsonBuilder().create()
 | 
			
		||||
 | 
			
		||||
    doLast {
 | 
			
		||||
        // Copy over all files in the current jar to the new one, running json files from GSON. As pretty printing
 | 
			
		||||
        // is turned off, they should be minified.
 | 
			
		||||
        new ZipFile(jarPath).withCloseable { inJar ->
 | 
			
		||||
            tempPath.getParentFile().mkdirs()
 | 
			
		||||
            new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(tempPath))).withCloseable { outJar ->
 | 
			
		||||
                inJar.entries().each { entry ->
 | 
			
		||||
                    if(entry.directory) {
 | 
			
		||||
                        outJar.putNextEntry(entry)
 | 
			
		||||
                    } else if(!entry.name.endsWith(".json")) {
 | 
			
		||||
                        outJar.putNextEntry(entry)
 | 
			
		||||
                        inJar.getInputStream(entry).withCloseable { outJar << it }
 | 
			
		||||
                    } else {
 | 
			
		||||
                        ZipEntry newEntry = new ZipEntry(entry.name)
 | 
			
		||||
                        newEntry.setTime(entry.time)
 | 
			
		||||
                        outJar.putNextEntry(newEntry)
 | 
			
		||||
 | 
			
		||||
                        def element = inJar.getInputStream(entry).withCloseable { gson.fromJson(it.newReader("UTF8"), JsonElement.class) }
 | 
			
		||||
                        outJar.write(gson.toJson(element).getBytes(StandardCharsets.UTF_8))
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // And replace the original jar again
 | 
			
		||||
        Files.move(tempPath.toPath(), jarPath.toPath(), StandardCopyOption.REPLACE_EXISTING)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
assemble.dependsOn compressJson
 | 
			
		||||
 | 
			
		||||
// Check tasks
 | 
			
		||||
 | 
			
		||||
test {
 | 
			
		||||
    useJUnitPlatform()
 | 
			
		||||
    testLogging {
 | 
			
		||||
        events "skipped", "failed"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
license {
 | 
			
		||||
    mapping("java", "SLASHSTAR_STYLE")
 | 
			
		||||
    strictCheck true
 | 
			
		||||
 | 
			
		||||
    ext.year = Calendar.getInstance().get(Calendar.YEAR)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[licenseMain, licenseFormatMain].forEach {
 | 
			
		||||
    it.configure {
 | 
			
		||||
        include("**/*.java")
 | 
			
		||||
        exclude("dan200/computercraft/api/**")
 | 
			
		||||
        header rootProject.file('config/license/main.txt')
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[licenseTest, licenseFormatTest].forEach {
 | 
			
		||||
    it.configure {
 | 
			
		||||
        include("**/*.java")
 | 
			
		||||
        header rootProject.file('config/license/main.txt')
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gradle.projectsEvaluated {
 | 
			
		||||
    tasks.withType(LicenseFormat) {
 | 
			
		||||
        outputs.upToDateWhen { false }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
task licenseAPI(type: LicenseCheck);
 | 
			
		||||
task licenseFormatAPI(type: LicenseFormat);
 | 
			
		||||
[licenseAPI, licenseFormatAPI].forEach {
 | 
			
		||||
    it.configure {
 | 
			
		||||
        source = sourceSets.main.java
 | 
			
		||||
        include("dan200/computercraft/api/**")
 | 
			
		||||
        header rootProject.file('config/license/api.txt')
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Upload tasks
 | 
			
		||||
 | 
			
		||||
task checkRelease {
 | 
			
		||||
    group "upload"
 | 
			
		||||
    description "Verifies that everything is ready for a release"
 | 
			
		||||
 | 
			
		||||
    inputs.property "version", mod_version
 | 
			
		||||
    inputs.file("src/main/resources/assets/computercraft/lua/rom/help/changelog.txt")
 | 
			
		||||
    inputs.file("src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt")
 | 
			
		||||
 | 
			
		||||
    doLast {
 | 
			
		||||
        def ok = true
 | 
			
		||||
 | 
			
		||||
        // Check we're targetting the current version
 | 
			
		||||
        def whatsnew = new File("src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt").readLines()
 | 
			
		||||
        if (whatsnew[0] != "New features in CC: Tweaked $mod_version") {
 | 
			
		||||
            ok = false
 | 
			
		||||
            project.logger.error("Expected `whatsnew.txt' to target $mod_version.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Check "read more" exists and trim it
 | 
			
		||||
        def idx = whatsnew.findIndexOf { it == 'Type "help changelog" to see the full version history.' }
 | 
			
		||||
        if (idx == -1) {
 | 
			
		||||
            ok = false
 | 
			
		||||
            project.logger.error("Must mention the changelog in whatsnew.txt")
 | 
			
		||||
        } else {
 | 
			
		||||
            whatsnew = whatsnew.getAt(0 ..< idx)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Check whatsnew and changelog match.
 | 
			
		||||
        def versionChangelog = "# " + whatsnew.join("\n")
 | 
			
		||||
        def changelog = new File("src/main/resources/assets/computercraft/lua/rom/help/changelog.txt").getText()
 | 
			
		||||
        if (!changelog.startsWith(versionChangelog)) {
 | 
			
		||||
            ok = false
 | 
			
		||||
            project.logger.error("whatsnew and changelog are not in sync")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!ok) throw new IllegalStateException("Could not check release")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
check.dependsOn checkRelease
 | 
			
		||||
 | 
			
		||||
curseforge {
 | 
			
		||||
    apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
 | 
			
		||||
    project {
 | 
			
		||||
        id = '282001'
 | 
			
		||||
        releaseType = 'release'
 | 
			
		||||
        changelog = "Release notes can be found on the GitHub repository (https://github.com/SquidDev-CC/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
 | 
			
		||||
 | 
			
		||||
        relations {
 | 
			
		||||
            incompatible "computercraft"
 | 
			
		||||
        }
 | 
			
		||||
        releaseType = 'beta'
 | 
			
		||||
        changelog = "Release notes can be found on the GitHub repository (https://github.com/SquidDev-CC/CC-Tweaked/releases/tag/v${project.version})."
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -369,22 +163,22 @@ uploadArchives {
 | 
			
		||||
                pom.project {
 | 
			
		||||
                    name 'CC: Tweaked'
 | 
			
		||||
                    packaging 'jar'
 | 
			
		||||
                    description 'CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles and more to Minecraft.'
 | 
			
		||||
                    description 'A fork of ComputerCraft which aims to provide earlier access to the more experimental and in-development features of the mod.'
 | 
			
		||||
                    url 'https://github.com/SquidDev-CC/CC-Tweaked'
 | 
			
		||||
 | 
			
		||||
                    scm {
 | 
			
		||||
                        url 'https://github.com/SquidDev-CC/CC-Tweaked.git'
 | 
			
		||||
                        url 'https://github.com/dan200/ComputerCraft.git'
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    issueManagement {
 | 
			
		||||
                        system 'github'
 | 
			
		||||
                        url 'https://github.com/SquidDev-CC/CC-Tweaked/issues'
 | 
			
		||||
                        url 'https://github.com/dan200/ComputerCraft/issues'
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    licenses {
 | 
			
		||||
                        license {
 | 
			
		||||
                            name 'ComputerCraft Public License, Version 1.0'
 | 
			
		||||
                            url 'https://github.com/SquidDev-CC/CC-Tweaked/blob/master/LICENSE'
 | 
			
		||||
                            url 'https://github.com/dan200/ComputerCraft/blob/master/LICENSE'
 | 
			
		||||
                            distribution 'repo'
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
@@ -398,31 +192,10 @@ uploadArchives {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
githubRelease {
 | 
			
		||||
    token project.hasProperty('githubApiKey') ? project.githubApiKey : ''
 | 
			
		||||
    owner 'SquidDev-CC'
 | 
			
		||||
    repo 'CC-Tweaked'
 | 
			
		||||
    try {
 | 
			
		||||
        targetCommitish = Grgit.open(dir: '.').branch.current().name
 | 
			
		||||
    } catch(Exception ignored) { }
 | 
			
		||||
 | 
			
		||||
    tagName "v${mc_version}-${mod_version}"
 | 
			
		||||
    releaseName "[${mc_version}] ${mod_version}"
 | 
			
		||||
    body {
 | 
			
		||||
        "## " + new File("src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt")
 | 
			
		||||
            .readLines()
 | 
			
		||||
            .takeWhile { it != 'Type "help changelog" to see the full version history.' }
 | 
			
		||||
            .join("\n").trim()
 | 
			
		||||
gradle.projectsEvaluated {
 | 
			
		||||
    tasks.withType(JavaCompile) {
 | 
			
		||||
        options.compilerArgs << "-Xlint"
 | 
			
		||||
    }
 | 
			
		||||
    prerelease false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
def uploadTasks = ["uploadArchives", "curseforge", "githubRelease"]
 | 
			
		||||
uploadTasks.forEach { tasks.getByName(it).dependsOn checkRelease }
 | 
			
		||||
 | 
			
		||||
task uploadAll(dependsOn: uploadTasks) {
 | 
			
		||||
    group "upload"
 | 
			
		||||
    description "Uploads to all repositories (Maven, Curse, GitHub release)"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
runClient.outputs.upToDateWhen { false }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,169 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE module PUBLIC
 | 
			
		||||
    "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
 | 
			
		||||
    "https://checkstyle.org/dtds/configuration_1_3.dtd">
 | 
			
		||||
<module name="Checker">
 | 
			
		||||
    <property name="tabWidth" value="4"/>
 | 
			
		||||
    <property name="charset" value="UTF-8" />
 | 
			
		||||
 | 
			
		||||
    <module name="SuppressionFilter">
 | 
			
		||||
        <property name="file" value="config/checkstyle/suppressions.xml" />
 | 
			
		||||
    </module>
 | 
			
		||||
 | 
			
		||||
    <module name="TreeWalker">
 | 
			
		||||
        <!-- Annotations -->
 | 
			
		||||
        <module name="AnnotationLocation" />
 | 
			
		||||
        <module name="AnnotationUseStyle" />
 | 
			
		||||
        <module name="MissingDeprecated" />
 | 
			
		||||
        <module name="MissingOverride" />
 | 
			
		||||
 | 
			
		||||
        <!-- Blocks -->
 | 
			
		||||
        <module name="EmptyBlock" />
 | 
			
		||||
        <module name="EmptyCatchBlock">
 | 
			
		||||
            <property name="exceptionVariableName" value="ignored" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="LeftCurly">
 | 
			
		||||
            <property name="option" value="nl" />
 | 
			
		||||
            <!-- The defaults, minus lambdas. -->
 | 
			
		||||
            <property name="tokens" value="ANNOTATION_DEF,CLASS_DEF,CTOR_DEF,ENUM_CONSTANT_DEF,ENUM_DEF,INTERFACE_DEF,LITERAL_CASE,LITERAL_CATCH,LITERAL_DEFAULT,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,METHOD_DEF,OBJBLOCK,STATIC_INIT" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="NeedBraces">
 | 
			
		||||
            <property name="allowSingleLineStatement" value="true"/>
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="RightCurly">
 | 
			
		||||
            <property name="option" value="alone" />
 | 
			
		||||
        </module>
 | 
			
		||||
 | 
			
		||||
        <!-- Class design. As if we've ever followed good practice here. -->
 | 
			
		||||
        <module name="FinalClass" />
 | 
			
		||||
        <module name="InterfaceIsType" />
 | 
			
		||||
        <module name="MutableException" />
 | 
			
		||||
        <module name="OneTopLevelClass" />
 | 
			
		||||
 | 
			
		||||
        <!-- Coding -->
 | 
			
		||||
        <module name="ArrayTrailingComma" />
 | 
			
		||||
        <module name="EqualsHashCode" />
 | 
			
		||||
        <!-- FallThrough does not handle unreachable code well -->
 | 
			
		||||
        <module name="IllegalInstantiation" />
 | 
			
		||||
        <module name="IllegalThrows" />
 | 
			
		||||
        <module name="ModifiedControlVariable" />
 | 
			
		||||
        <module name="NoClone" />
 | 
			
		||||
        <module name="NoFinalizer" />
 | 
			
		||||
        <module name="OneStatementPerLine" />
 | 
			
		||||
        <module name="PackageDeclaration" />
 | 
			
		||||
        <module name="SimplifyBooleanExpression" />
 | 
			
		||||
        <module name="SimplifyBooleanReturn" />
 | 
			
		||||
        <module name="StringLiteralEquality" />
 | 
			
		||||
        <module name="UnnecessaryParentheses" />
 | 
			
		||||
        <module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
 | 
			
		||||
        <module name="UnnecessarySemicolonInTryWithResources" />
 | 
			
		||||
        <module name="UnnecessarySemicolonInEnumeration" />
 | 
			
		||||
 | 
			
		||||
        <!-- Imports -->
 | 
			
		||||
        <module name="CustomImportOrder" />
 | 
			
		||||
        <module name="IllegalImport" />
 | 
			
		||||
        <module name="RedundantImport" />
 | 
			
		||||
        <module name="UnusedImports" />
 | 
			
		||||
 | 
			
		||||
        <!-- Javadoc -->
 | 
			
		||||
        <!-- TODO: Missing* checks for the dan200.computercraft.api package? -->
 | 
			
		||||
        <module name="AtclauseOrder" />
 | 
			
		||||
        <module name="InvalidJavadocPosition" />
 | 
			
		||||
        <module name="JavadocBlockTagLocation" />
 | 
			
		||||
        <module name="JavadocMethod"/>
 | 
			
		||||
        <module name="JavadocType"/>
 | 
			
		||||
        <module name="JavadocStyle" />
 | 
			
		||||
        <module name="NonEmptyAtclauseDescription" />
 | 
			
		||||
        <module name="SingleLineJavadoc" />
 | 
			
		||||
        <module name="SummaryJavadocCheck"/>
 | 
			
		||||
 | 
			
		||||
        <!-- Misc -->
 | 
			
		||||
        <module name="ArrayTypeStyle" />
 | 
			
		||||
        <module name="CommentsIndentation" />
 | 
			
		||||
        <module name="Indentation" />
 | 
			
		||||
        <module name="OuterTypeFilename" />
 | 
			
		||||
 | 
			
		||||
        <!-- Modifiers -->
 | 
			
		||||
        <module name="ModifierOrder" />
 | 
			
		||||
        <module name="RedundantModifier" />
 | 
			
		||||
 | 
			
		||||
        <!-- Naming -->
 | 
			
		||||
        <module name="ClassTypeParameterName" />
 | 
			
		||||
        <module name="InterfaceTypeParameterName" />
 | 
			
		||||
        <module name="LambdaParameterName" />
 | 
			
		||||
        <module name="LocalFinalVariableName" />
 | 
			
		||||
        <module name="LocalVariableName" />
 | 
			
		||||
        <!-- Allow an optional m_ on private members -->
 | 
			
		||||
        <module name="MemberName">
 | 
			
		||||
            <property name="applyToPrivate" value="false" />
 | 
			
		||||
            <property name="applyToPackage" value="false" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="MemberName">
 | 
			
		||||
            <property name="format" value="^(m_)?[a-z][a-zA-Z0-9]*$" />
 | 
			
		||||
            <property name="applyToPrivate" value="true" />
 | 
			
		||||
            <property name="applyToPackage" value="true" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="MethodName" />
 | 
			
		||||
        <module name="MethodTypeParameterName" />
 | 
			
		||||
        <module name="PackageName">
 | 
			
		||||
            <property name="format" value="^dan200\.computercraf(\.[a-z][a-z0-9]*)*" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="ParameterName" />
 | 
			
		||||
        <module name="StaticVariableName">
 | 
			
		||||
            <property name="format" value="^[a-z][a-zA-Z0-9]*|CAPABILITY(_[A-Z]+)?$" />
 | 
			
		||||
            <property name="applyToPrivate" value="false" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="StaticVariableName">
 | 
			
		||||
            <property name="format" value="^(s_)?[a-z][a-zA-Z0-9]*|CAPABILITY(_[A-Z]+)?$" />
 | 
			
		||||
            <property name="applyToPrivate" value="true" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="TypeName" />
 | 
			
		||||
 | 
			
		||||
        <!-- Whitespace -->
 | 
			
		||||
        <module name="EmptyForInitializerPad"/>
 | 
			
		||||
        <module name="EmptyForIteratorPad">
 | 
			
		||||
            <property name="option" value="space"/>
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="GenericWhitespace" />
 | 
			
		||||
        <module name="MethodParamPad" />
 | 
			
		||||
        <module name="NoLineWrap" />
 | 
			
		||||
        <module name="NoWhitespaceAfter">
 | 
			
		||||
            <property name="tokens" value="AT,INC,DEC,UNARY_MINUS,UNARY_PLUS,BNOT,LNOT,DOT,ARRAY_DECLARATOR,INDEX_OP" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="NoWhitespaceBefore" />
 | 
			
		||||
        <!-- TODO: Decide on an OperatorWrap style. -->
 | 
			
		||||
        <module name="ParenPad">
 | 
			
		||||
            <property name="option" value="space" />
 | 
			
		||||
            <property name="tokens" value="ANNOTATION,ANNOTATION_FIELD_DEF,CTOR_CALL,CTOR_DEF,ENUM_CONSTANT_DEF,LITERAL_CATCH,LITERAL_DO,LITERAL_FOR,LITERAL_IF,LITERAL_NEW,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_WHILE,METHOD_CALL,METHOD_DEF,RESOURCE_SPECIFICATION,SUPER_CTOR_CALL,LAMBDA" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="ParenPad">
 | 
			
		||||
            <property name="option" value="nospace" />
 | 
			
		||||
            <property name="tokens" value="DOT,EXPR,QUESTION" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="SeparatorWrap">
 | 
			
		||||
            <property name="option" value="eol" />
 | 
			
		||||
            <property name="tokens" value="COMMA,SEMI,ELLIPSIS,ARRAY_DECLARATOR,RBRACK,METHOD_REF" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="SeparatorWrap">
 | 
			
		||||
            <property name="option" value="nl" />
 | 
			
		||||
            <property name="tokens" value="DOT,AT" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="SingleSpaceSeparator" />
 | 
			
		||||
        <module name="TypecastParenPad" />
 | 
			
		||||
        <module name="WhitespaceAfter">
 | 
			
		||||
            <property name="tokens" value="COMMA" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="WhitespaceAround">
 | 
			
		||||
            <property name="allowEmptyConstructors" value="true" />
 | 
			
		||||
            <property name="ignoreEnhancedForColon" value="false" />
 | 
			
		||||
            <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,DO_WHILE,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_RETURN,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND" />
 | 
			
		||||
        </module>
 | 
			
		||||
    </module>
 | 
			
		||||
 | 
			
		||||
    <module name="FileTabCharacter" />
 | 
			
		||||
    <module name="NewlineAtEndOfFile" />
 | 
			
		||||
    <module name="RegexpSingleline">
 | 
			
		||||
        <property name="format" value="\s+$"/>
 | 
			
		||||
        <property name="message" value="Trailing whitespace"/>
 | 
			
		||||
    </module>
 | 
			
		||||
</module>
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE suppressions PUBLIC
 | 
			
		||||
    "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
 | 
			
		||||
    "https://checkstyle.org/dtds/suppressions_1_2.dtd">
 | 
			
		||||
<suppressions>
 | 
			
		||||
    <!-- All the config options and method fields. -->
 | 
			
		||||
    <suppress checks="StaticVariableName" files=".*[\\/]ComputerCraft.java" />
 | 
			
		||||
    <suppress checks="StaticVariableName" files=".*[\\/]ComputerCraftAPI.java" />
 | 
			
		||||
 | 
			
		||||
    <!-- Do not check for missing package Javadoc. -->
 | 
			
		||||
    <suppress checks="JavadocStyle" files=".*[\\/]package-info.java" />
 | 
			
		||||
</suppressions>
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,3 +0,0 @@
 | 
			
		||||
This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
Copyright Daniel Ratcliffe, 2011-${year}. 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.
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
Copyright Daniel Ratcliffe, 2011-${year}. Do not distribute without permission.
 | 
			
		||||
Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
							
								
								
									
										11
									
								
								doc/index.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								doc/index.md
									
									
									
									
									
								
							@@ -1,11 +0,0 @@
 | 
			
		||||
#  [](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"
 | 
			
		||||
@@ -1,6 +0,0 @@
 | 
			
		||||
function exec(command) end
 | 
			
		||||
function execAsync(commad) end
 | 
			
		||||
function list() end
 | 
			
		||||
function getBlockPosition() end
 | 
			
		||||
function getBlockInfos(min_x, min_y, min_z, max_x, max_y, max_z) end
 | 
			
		||||
function getBlockInfo(x, y, z) end
 | 
			
		||||
@@ -1,42 +0,0 @@
 | 
			
		||||
---  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
 | 
			
		||||
 | 
			
		||||
--- 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
 | 
			
		||||
@@ -1,229 +0,0 @@
 | 
			
		||||
--- 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
 | 
			
		||||
@@ -1,17 +0,0 @@
 | 
			
		||||
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
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
function getSides() end
 | 
			
		||||
function setOutput(side, on) end
 | 
			
		||||
function getOutput(side) end
 | 
			
		||||
function getInput(side) end
 | 
			
		||||
function setBundledOutput(side, output) end
 | 
			
		||||
function getBundledOutput(side) end
 | 
			
		||||
function getBundledInput(side) end
 | 
			
		||||
function testBundledInput(side, mask) end
 | 
			
		||||
function setAnalogOutput(side, value) end
 | 
			
		||||
setAnalogueOutput = setAnalogOutput
 | 
			
		||||
function getAnalogOutput(sid) end
 | 
			
		||||
getAnalogueOutput = getAnalogOutput
 | 
			
		||||
function getAnalogInput(side) end
 | 
			
		||||
getAnalogueInput = getAnaloguInput
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
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
 | 
			
		||||
getBackgroundColour = getBackgroundColour
 | 
			
		||||
function blit(text, text_colours, background_colours) end
 | 
			
		||||
function setPaletteColour(colour, ...) end
 | 
			
		||||
setPaletteColour = setPaletteColour
 | 
			
		||||
function getPaletteColour(colour, ...) end
 | 
			
		||||
getPaletteColour = getPaletteColour
 | 
			
		||||
function nativePaletteColour(colour) end
 | 
			
		||||
nativePaletteColour = 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
 | 
			
		||||
@@ -1,230 +0,0 @@
 | 
			
		||||
--- 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
									
									
									
									
									
								
							
							
						
						
									
										186
									
								
								doc/styles.css
									
									
									
									
									
								
							@@ -1,186 +0,0 @@
 | 
			
		||||
/* 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,7 +0,0 @@
 | 
			
		||||
# Mod properties
 | 
			
		||||
mod_version=1.87.0
 | 
			
		||||
 | 
			
		||||
# Minecraft properties
 | 
			
		||||
mc_version=1.12.2
 | 
			
		||||
forge_version=14.23.4.2749
 | 
			
		||||
mappings_version=snapshot_20180724
 | 
			
		||||
							
								
								
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
 | 
			
		||||
distributionPath=wrapper/dists
 | 
			
		||||
zipStoreBase=GRADLE_USER_HOME
 | 
			
		||||
zipStorePath=wrapper/dists
 | 
			
		||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
 | 
			
		||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
 | 
			
		||||
 
 | 
			
		||||
@@ -1,84 +0,0 @@
 | 
			
		||||
; -*- mode: Lisp;-*-
 | 
			
		||||
 | 
			
		||||
(sources
 | 
			
		||||
  /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
 | 
			
		||||
 | 
			
		||||
    ;; Some APIS (keys, colour and os mainly) are incomplete right now.
 | 
			
		||||
    -var:unresolved-member)
 | 
			
		||||
  (lint
 | 
			
		||||
    (bracket-spaces
 | 
			
		||||
      (call no-space)
 | 
			
		||||
      (function-args no-space)
 | 
			
		||||
      (parens no-space)
 | 
			
		||||
      (table space)
 | 
			
		||||
      (index no-space))))
 | 
			
		||||
 | 
			
		||||
;; 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/*/computercraft/lua/bios.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/apis/)
 | 
			
		||||
  (linters -var:unused-global)
 | 
			
		||||
  (lint (allow-toplevel-global true)))
 | 
			
		||||
 | 
			
		||||
;; 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/commands.lua
 | 
			
		||||
   /doc/stub/fs.lua
 | 
			
		||||
   /doc/stub/http.lua
 | 
			
		||||
   /doc/stub/os.lua
 | 
			
		||||
   /doc/stub/redstone.lua
 | 
			
		||||
   /doc/stub/term.lua
 | 
			
		||||
   /doc/stub/turtle.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/apis/command/commands.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/apis/io.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/apis/window.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/modules/main/cc/shell/completion.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/advanced/multishell.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/programs/shell.lua)
 | 
			
		||||
  (linters -doc:unresolved-reference))
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB  | 
@@ -1 +1 @@
 | 
			
		||||
rootProject.name = "cc-tweaked-${mc_version}"
 | 
			
		||||
rootProject.name = 'cc-tweaked'
 | 
			
		||||
 
 | 
			
		||||
@@ -1,29 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * 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;
 | 
			
		||||
import net.minecraftforge.fml.common.network.NetworkCheckHandler;
 | 
			
		||||
import net.minecraftforge.fml.relauncher.Side;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A stub mod for CC: Tweaked. This doesn't have any functionality (everything of note is done in
 | 
			
		||||
 * {@link ComputerCraft}), but people may depend on this if they require CC: Tweaked functionality.
 | 
			
		||||
 */
 | 
			
		||||
@Mod(
 | 
			
		||||
    modid = "cctweaked", name = ComputerCraft.NAME, version = ComputerCraft.VERSION,
 | 
			
		||||
    acceptableRemoteVersions = "*"
 | 
			
		||||
)
 | 
			
		||||
public class CCTweaked
 | 
			
		||||
{
 | 
			
		||||
    @NetworkCheckHandler
 | 
			
		||||
    public boolean onNetworkConnect( Map<String, String> mods, Side side )
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.filesystem.IMount;
 | 
			
		||||
@@ -22,15 +23,19 @@ 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.computer.MainThread;
 | 
			
		||||
import dan200.computercraft.core.apis.http.websocket.Websocket;
 | 
			
		||||
import dan200.computercraft.core.filesystem.ComboMount;
 | 
			
		||||
import dan200.computercraft.core.filesystem.FileMount;
 | 
			
		||||
import dan200.computercraft.core.filesystem.JarMount;
 | 
			
		||||
import dan200.computercraft.core.terminal.Terminal;
 | 
			
		||||
import dan200.computercraft.core.tracking.Tracking;
 | 
			
		||||
import dan200.computercraft.shared.*;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.BlockCommandComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ClientComputerRegistry;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ServerComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ServerComputerRegistry;
 | 
			
		||||
import dan200.computercraft.shared.computer.items.ItemCommandComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.items.ItemComputer;
 | 
			
		||||
@@ -38,20 +43,24 @@ import dan200.computercraft.shared.media.items.ItemDiskExpanded;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemDiskLegacy;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemPrintout;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
 | 
			
		||||
import dan200.computercraft.shared.network.NetworkHandler;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.common.ItemPeripheral;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockWiredModemFull;
 | 
			
		||||
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.peripheral.printer.TilePrinter;
 | 
			
		||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
 | 
			
		||||
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
 | 
			
		||||
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
 | 
			
		||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
 | 
			
		||||
import dan200.computercraft.shared.proxy.ICCTurtleProxy;
 | 
			
		||||
import dan200.computercraft.shared.proxy.IComputerCraftProxy;
 | 
			
		||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtleAdvanced;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtleLegacy;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtleNormal;
 | 
			
		||||
@@ -67,11 +76,14 @@ import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.server.MinecraftServer;
 | 
			
		||||
import net.minecraft.tileentity.TileEntity;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.EnumHand;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.IBlockAccess;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.common.DimensionManager;
 | 
			
		||||
import net.minecraftforge.fml.common.*;
 | 
			
		||||
import net.minecraftforge.fml.common.FMLCommonHandler;
 | 
			
		||||
import net.minecraftforge.fml.common.Mod;
 | 
			
		||||
import net.minecraftforge.fml.common.SidedProxy;
 | 
			
		||||
import net.minecraftforge.fml.common.event.*;
 | 
			
		||||
import net.minecraftforge.fml.relauncher.Side;
 | 
			
		||||
import org.apache.logging.log4j.Logger;
 | 
			
		||||
@@ -80,21 +92,30 @@ import java.io.*;
 | 
			
		||||
import java.net.MalformedURLException;
 | 
			
		||||
import java.net.URISyntaxException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.concurrent.TimeUnit;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.EnumSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.zip.ZipEntry;
 | 
			
		||||
import java.util.zip.ZipFile;
 | 
			
		||||
 | 
			
		||||
@Mod(
 | 
			
		||||
    modid = ComputerCraft.MOD_ID, name = ComputerCraft.NAME, version = ComputerCraft.VERSION,
 | 
			
		||||
    modid = ComputerCraft.MOD_ID, name = "CC: Tweaked", version = "${version}",
 | 
			
		||||
    guiFactory = "dan200.computercraft.client.gui.GuiConfigCC$Factory",
 | 
			
		||||
    dependencies = "required:forge@[14.23.4.2746,)"
 | 
			
		||||
)
 | 
			
		||||
public class ComputerCraft
 | 
			
		||||
{
 | 
			
		||||
    public static final String MOD_ID = "computercraft";
 | 
			
		||||
    static final String VERSION = "${version}";
 | 
			
		||||
    static final String NAME = "CC: Tweaked";
 | 
			
		||||
 | 
			
		||||
    // GUI IDs
 | 
			
		||||
    public static final int diskDriveGUIID = 100;
 | 
			
		||||
    public static final int computerGUIID = 101;
 | 
			
		||||
    public static final int printerGUIID = 102;
 | 
			
		||||
    public static final int turtleGUIID = 103;
 | 
			
		||||
    // ComputerCraftEdu uses ID 104
 | 
			
		||||
    public static final int printoutGUIID = 105;
 | 
			
		||||
    public static final int pocketComputerGUIID = 106;
 | 
			
		||||
    public static final int viewComputerGUIID = 110;
 | 
			
		||||
 | 
			
		||||
    // Configuration options
 | 
			
		||||
    public static final String[] DEFAULT_HTTP_WHITELIST = new String[] { "*" };
 | 
			
		||||
@@ -112,11 +133,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 int computer_threads = 1;
 | 
			
		||||
    public static long maxMainGlobalTime = TimeUnit.MILLISECONDS.toNanos( 10 );
 | 
			
		||||
    public static long maxMainComputerTime = TimeUnit.MILLISECONDS.toNanos( 5 );
 | 
			
		||||
    public static boolean logPeripheralErrors = false;
 | 
			
		||||
 | 
			
		||||
    public static boolean http_enable = true;
 | 
			
		||||
    public static boolean http_websocket_enable = true;
 | 
			
		||||
@@ -128,7 +146,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 = 128 * 1024;
 | 
			
		||||
    public static int httpMaxWebsocketMessage = Websocket.MAX_MESSAGE_SIZE;
 | 
			
		||||
 | 
			
		||||
    public static boolean enableCommandBlock = false;
 | 
			
		||||
    public static int modem_range = 64;
 | 
			
		||||
@@ -136,7 +154,6 @@ 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 boolean turtlesNeedFuel = true;
 | 
			
		||||
    public static int turtleFuelLimit = 20000;
 | 
			
		||||
@@ -155,7 +172,7 @@ public class ComputerCraft
 | 
			
		||||
    public static final int terminalHeight_pocketComputer = 20;
 | 
			
		||||
 | 
			
		||||
    // Blocks and Items
 | 
			
		||||
    public static final class Blocks
 | 
			
		||||
    public static class Blocks
 | 
			
		||||
    {
 | 
			
		||||
        public static BlockComputer computer;
 | 
			
		||||
        public static BlockCommandComputer commandComputer;
 | 
			
		||||
@@ -170,7 +187,7 @@ public class ComputerCraft
 | 
			
		||||
        public static BlockWiredModemFull wiredModemFull;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static final class Items
 | 
			
		||||
    public static class Items
 | 
			
		||||
    {
 | 
			
		||||
        public static ItemComputer computer;
 | 
			
		||||
        public static ItemCommandComputer commandComputer;
 | 
			
		||||
@@ -193,7 +210,7 @@ public class ComputerCraft
 | 
			
		||||
        public static ItemBlock wiredModemFull;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static final class TurtleUpgrades
 | 
			
		||||
    public static class TurtleUpgrades
 | 
			
		||||
    {
 | 
			
		||||
        public static TurtleModem wirelessModem;
 | 
			
		||||
        public static TurtleModem advancedModem;
 | 
			
		||||
@@ -207,7 +224,7 @@ public class ComputerCraft
 | 
			
		||||
        public static TurtleHoe diamondHoe;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static final class PocketUpgrades
 | 
			
		||||
    public static class PocketUpgrades
 | 
			
		||||
    {
 | 
			
		||||
        public static PocketModem wirelessModem;
 | 
			
		||||
        public static PocketModem advancedModem;
 | 
			
		||||
@@ -218,7 +235,7 @@ public class ComputerCraft
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static final class Upgrades
 | 
			
		||||
    public static class Upgrades
 | 
			
		||||
    {
 | 
			
		||||
        public static TurtleModem advancedModem;
 | 
			
		||||
    }
 | 
			
		||||
@@ -237,14 +254,20 @@ public class ComputerCraft
 | 
			
		||||
    public static List<IPeripheralProvider> peripheralProviders = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    // Implementation
 | 
			
		||||
    @Mod.Instance( ComputerCraft.MOD_ID )
 | 
			
		||||
    @Mod.Instance( value = ComputerCraft.MOD_ID )
 | 
			
		||||
    public static ComputerCraft instance;
 | 
			
		||||
 | 
			
		||||
    @SidedProxy(
 | 
			
		||||
        clientSide = "dan200.computercraft.client.proxy.ComputerCraftProxyClient",
 | 
			
		||||
        serverSide = "dan200.computercraft.shared.proxy.ComputerCraftProxyCommon"
 | 
			
		||||
    )
 | 
			
		||||
    private static ComputerCraftProxyCommon proxy;
 | 
			
		||||
    private static IComputerCraftProxy proxy;
 | 
			
		||||
 | 
			
		||||
    @SidedProxy(
 | 
			
		||||
        clientSide = "dan200.computercraft.client.proxy.CCTurtleProxyClient",
 | 
			
		||||
        serverSide = "dan200.computercraft.shared.proxy.CCTurtleProxyCommon"
 | 
			
		||||
    )
 | 
			
		||||
    private static ICCTurtleProxy turtleProxy;
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void preInit( FMLPreInitializationEvent event )
 | 
			
		||||
@@ -254,19 +277,24 @@ public class ComputerCraft
 | 
			
		||||
        // Load config
 | 
			
		||||
        Config.load( event.getSuggestedConfigurationFile() );
 | 
			
		||||
 | 
			
		||||
        // Setup network
 | 
			
		||||
        NetworkHandler.setup();
 | 
			
		||||
 | 
			
		||||
        proxy.preInit();
 | 
			
		||||
        turtleProxy.preInit();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void init( FMLInitializationEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        proxy.init();
 | 
			
		||||
        turtleProxy.init();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void onServerStarting( FMLServerStartingEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        ComputerCraftProxyCommon.initServer( event.getServer() );
 | 
			
		||||
        proxy.initServer( event.getServer() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
@@ -276,7 +304,6 @@ public class ComputerCraft
 | 
			
		||||
        {
 | 
			
		||||
            ComputerCraft.serverComputerRegistry.reset();
 | 
			
		||||
            WirelessNetwork.resetNetworks();
 | 
			
		||||
            MainThread.reset();
 | 
			
		||||
            Tracking.reset();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -288,14 +315,65 @@ public class ComputerCraft
 | 
			
		||||
        {
 | 
			
		||||
            ComputerCraft.serverComputerRegistry.reset();
 | 
			
		||||
            WirelessNetwork.resetNetworks();
 | 
			
		||||
            MainThread.reset();
 | 
			
		||||
            Tracking.reset();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String getVersion()
 | 
			
		||||
    {
 | 
			
		||||
        return VERSION;
 | 
			
		||||
        return "${version}";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void openDiskDriveGUI( EntityPlayer player, TileDiskDrive drive )
 | 
			
		||||
    {
 | 
			
		||||
        BlockPos pos = drive.getPos();
 | 
			
		||||
        player.openGui( ComputerCraft.instance, ComputerCraft.diskDriveGUIID, player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void openComputerGUI( EntityPlayer player, TileComputer computer )
 | 
			
		||||
    {
 | 
			
		||||
        BlockPos pos = computer.getPos();
 | 
			
		||||
        player.openGui( ComputerCraft.instance, ComputerCraft.computerGUIID, player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void openPrinterGUI( EntityPlayer player, TilePrinter printer )
 | 
			
		||||
    {
 | 
			
		||||
        BlockPos pos = printer.getPos();
 | 
			
		||||
        player.openGui( ComputerCraft.instance, ComputerCraft.printerGUIID, player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void openTurtleGUI( EntityPlayer player, TileTurtle turtle )
 | 
			
		||||
    {
 | 
			
		||||
        BlockPos pos = turtle.getPos();
 | 
			
		||||
        player.openGui( instance, ComputerCraft.turtleGUIID, player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void openPrintoutGUI( EntityPlayer player, EnumHand hand )
 | 
			
		||||
    {
 | 
			
		||||
        player.openGui( ComputerCraft.instance, ComputerCraft.printoutGUIID, player.getEntityWorld(), hand.ordinal(), 0, 0 );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void openPocketComputerGUI( EntityPlayer player, EnumHand hand )
 | 
			
		||||
    {
 | 
			
		||||
        player.openGui( ComputerCraft.instance, ComputerCraft.pocketComputerGUIID, player.getEntityWorld(), hand.ordinal(), 0, 0 );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void openComputerGUI( EntityPlayer player, ServerComputer computer )
 | 
			
		||||
    {
 | 
			
		||||
        ComputerFamily family = computer.getFamily();
 | 
			
		||||
        int width = 0, height = 0;
 | 
			
		||||
        Terminal terminal = computer.getTerminal();
 | 
			
		||||
        if( terminal != null )
 | 
			
		||||
        {
 | 
			
		||||
            width = terminal.getWidth();
 | 
			
		||||
            height = terminal.getHeight();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Pack useful terminal information into the various coordinate bits.
 | 
			
		||||
        // These are extracted in ComputerCraftProxyCommon.getClientGuiElement
 | 
			
		||||
        player.openGui( ComputerCraft.instance, ComputerCraft.viewComputerGUIID, player.getEntityWorld(),
 | 
			
		||||
            computer.getInstanceID(), family.ordinal(), (width & 0xFFFF) << 16 | (height & 0xFFFF)
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static File getBaseDir()
 | 
			
		||||
@@ -308,6 +386,16 @@ public class ComputerCraft
 | 
			
		||||
        return new File( getBaseDir(), "resourcepacks" );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean canPlayerUseCommands( EntityPlayer player )
 | 
			
		||||
    {
 | 
			
		||||
        MinecraftServer server = player.getServer();
 | 
			
		||||
        if( server != null )
 | 
			
		||||
        {
 | 
			
		||||
            return server.getPlayerList().canSendCommands( player.getGameProfile() );
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerPermissionProvider( ITurtlePermissionProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
@@ -390,27 +478,6 @@ public class ComputerCraft
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void loadFromFile( List<IMount> mounts, File file, String path, boolean allowMissing )
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            if( file.isFile() )
 | 
			
		||||
            {
 | 
			
		||||
                mounts.add( new JarMount( file, path ) );
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                File subResource = new File( file, path );
 | 
			
		||||
                if( subResource.exists() ) mounts.add( new FileMount( subResource, 0 ) );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch( IOException | RuntimeException e )
 | 
			
		||||
        {
 | 
			
		||||
            if( allowMissing && e instanceof FileNotFoundException ) return;
 | 
			
		||||
            ComputerCraft.log.error( "Could not load mount '" + path + " 'from '" + file.getName() + "'", e );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IMount createResourceMount( Class<?> modClass, String domain, String subPath )
 | 
			
		||||
    {
 | 
			
		||||
@@ -430,26 +497,18 @@ public class ComputerCraft
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Mount from mod jars, preferring the specified one.
 | 
			
		||||
        // Mount from mod jar
 | 
			
		||||
        File modJar = getContainingJar( modClass );
 | 
			
		||||
        Set<File> otherMods = new HashSet<>();
 | 
			
		||||
        for( ModContainer container : Loader.instance().getActiveModList() )
 | 
			
		||||
        {
 | 
			
		||||
            File modFile = container.getSource();
 | 
			
		||||
            if( modFile != null && !modFile.equals( modJar ) && modFile.exists() )
 | 
			
		||||
            {
 | 
			
		||||
                otherMods.add( container.getSource() );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for( File file : otherMods )
 | 
			
		||||
        {
 | 
			
		||||
            loadFromFile( mounts, file, subPath, true );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if( modJar != null )
 | 
			
		||||
        {
 | 
			
		||||
            loadFromFile( mounts, modJar, subPath, false );
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                mounts.add( new JarMount( modJar, subPath ) );
 | 
			
		||||
            }
 | 
			
		||||
            catch( IOException | RuntimeException e )
 | 
			
		||||
            {
 | 
			
		||||
                ComputerCraft.log.error( "Could not load mount from mod jar", e );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Mount from resource packs
 | 
			
		||||
@@ -459,8 +518,25 @@ public class ComputerCraft
 | 
			
		||||
            String[] resourcePacks = resourcePackDir.list();
 | 
			
		||||
            for( String resourcePackName : resourcePacks )
 | 
			
		||||
            {
 | 
			
		||||
                File resourcePack = new File( resourcePackDir, resourcePackName );
 | 
			
		||||
                loadFromFile( mounts, resourcePack, subPath, true );
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    File resourcePack = new File( resourcePackDir, resourcePackName );
 | 
			
		||||
                    if( !resourcePack.isDirectory() )
 | 
			
		||||
                    {
 | 
			
		||||
                        // Mount a resource pack from a jar
 | 
			
		||||
                        mounts.add( new JarMount( resourcePack, subPath ) );
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        // Mount a resource pack from a folder
 | 
			
		||||
                        File subResource = new File( resourcePack, subPath );
 | 
			
		||||
                        if( subResource.exists() ) mounts.add( new FileMount( subResource, 0 ) );
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                catch( IOException | RuntimeException e )
 | 
			
		||||
                {
 | 
			
		||||
                    ComputerCraft.log.error( "Could not load resource pack '" + resourcePackName + "'", e );
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -566,7 +642,7 @@ public class ComputerCraft
 | 
			
		||||
    private static File getContainingJar( Class<?> modClass )
 | 
			
		||||
    {
 | 
			
		||||
        String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
 | 
			
		||||
        int bangIndex = path.indexOf( '!' );
 | 
			
		||||
        int bangIndex = path.indexOf( "!" );
 | 
			
		||||
        if( bangIndex >= 0 )
 | 
			
		||||
        {
 | 
			
		||||
            path = path.substring( 0, bangIndex );
 | 
			
		||||
@@ -597,7 +673,7 @@ public class ComputerCraft
 | 
			
		||||
    private static File getDebugCodeDir( Class<?> modClass )
 | 
			
		||||
    {
 | 
			
		||||
        String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
 | 
			
		||||
        int bangIndex = path.indexOf( '!' );
 | 
			
		||||
        int bangIndex = path.indexOf( "!" );
 | 
			
		||||
        return bangIndex >= 0 ? null : new File( new File( path ).getParentFile(), "../.." );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -654,12 +730,5 @@ public class ComputerCraft
 | 
			
		||||
    {
 | 
			
		||||
        return Peripherals.getPeripheral( world, pos, side );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static boolean canPlayerUseCommands( EntityPlayer player )
 | 
			
		||||
    {
 | 
			
		||||
        MinecraftServer server = player.getServer();
 | 
			
		||||
        return server != null && server.getPlayerList().canSendCommands( player.getGameProfile() );
 | 
			
		||||
    }
 | 
			
		||||
    //endregion
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -31,9 +32,8 @@ import java.lang.reflect.Method;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The static entry point to the ComputerCraft API.
 | 
			
		||||
 *
 | 
			
		||||
 * Members in this class must be called after mod_ComputerCraft has been initialised, but may be called before it is
 | 
			
		||||
 * fully loaded.
 | 
			
		||||
 * Members in this class must be called after mod_ComputerCraft has been initialised,
 | 
			
		||||
 * but may be called before it is fully loaded.
 | 
			
		||||
 */
 | 
			
		||||
public final class ComputerCraftAPI
 | 
			
		||||
{
 | 
			
		||||
@@ -173,8 +173,8 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * Registers a peripheral provider to convert blocks into {@link IPeripheral} implementations.
 | 
			
		||||
     *
 | 
			
		||||
     * @param provider The peripheral provider to register.
 | 
			
		||||
     * @see IPeripheral
 | 
			
		||||
     * @see IPeripheralProvider
 | 
			
		||||
     * @see dan200.computercraft.api.peripheral.IPeripheral
 | 
			
		||||
     * @see dan200.computercraft.api.peripheral.IPeripheralProvider
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerPeripheralProvider( @Nonnull IPeripheralProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
@@ -198,7 +198,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * this during the load() method of your mod.
 | 
			
		||||
     *
 | 
			
		||||
     * @param upgrade The turtle upgrade to register.
 | 
			
		||||
     * @see ITurtleUpgrade
 | 
			
		||||
     * @see dan200.computercraft.api.turtle.ITurtleUpgrade
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
 | 
			
		||||
    {
 | 
			
		||||
@@ -223,7 +223,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * Registers a bundled redstone provider to provide bundled redstone output for blocks.
 | 
			
		||||
     *
 | 
			
		||||
     * @param provider The bundled redstone provider to register.
 | 
			
		||||
     * @see IBundledRedstoneProvider
 | 
			
		||||
     * @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
@@ -249,7 +249,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * @param side  The side to extract the bundled redstone output from.
 | 
			
		||||
     * @return If there is a block capable of emitting bundled redstone at the location, it's signal (0-65535) will be returned.
 | 
			
		||||
     * If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
 | 
			
		||||
     * @see IBundledRedstoneProvider
 | 
			
		||||
     * @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
 | 
			
		||||
     */
 | 
			
		||||
    public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
 | 
			
		||||
    {
 | 
			
		||||
@@ -269,10 +269,10 @@ public final class ComputerCraftAPI
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Registers a media provider to provide {@link IMedia} implementations for Items.
 | 
			
		||||
     * Registers a media provider to provide {@link IMedia} implementations for Items
 | 
			
		||||
     *
 | 
			
		||||
     * @param provider The media provider to register.
 | 
			
		||||
     * @see IMediaProvider
 | 
			
		||||
     * @see dan200.computercraft.api.media.IMediaProvider
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerMediaProvider( @Nonnull IMediaProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
@@ -294,7 +294,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * Registers a permission provider to restrict where turtles can move or build.
 | 
			
		||||
     *
 | 
			
		||||
     * @param provider The turtle permission provider to register.
 | 
			
		||||
     * @see ITurtlePermissionProvider
 | 
			
		||||
     * @see dan200.computercraft.api.permissions.ITurtlePermissionProvider
 | 
			
		||||
     * @deprecated Prefer using {@link dan200.computercraft.api.turtle.event.TurtleBlockEvent} or the standard Forge events.
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
@@ -370,7 +370,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Construct a new wired node for a given wired element.
 | 
			
		||||
     * Construct a new wired node for a given wired element
 | 
			
		||||
     *
 | 
			
		||||
     * @param element The element to construct it for
 | 
			
		||||
     * @return The element's node
 | 
			
		||||
@@ -398,7 +398,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the wired network element for a block in world.
 | 
			
		||||
     * Get the wired network element for a block in world
 | 
			
		||||
     *
 | 
			
		||||
     * @param world The world the block exists in
 | 
			
		||||
     * @param pos   The position the block exists in
 | 
			
		||||
@@ -438,50 +438,50 @@ public final class ComputerCraftAPI
 | 
			
		||||
                computerCraft_getVersion = findCCMethod( "getVersion", new Class<?>[] {
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class<?>[] {
 | 
			
		||||
                    World.class, String.class,
 | 
			
		||||
                    World.class, String.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class<?>[] {
 | 
			
		||||
                    World.class, String.class, Long.TYPE,
 | 
			
		||||
                    World.class, String.class, Long.TYPE
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class<?>[] {
 | 
			
		||||
                    Class.class, String.class, String.class,
 | 
			
		||||
                    Class.class, String.class, String.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class<?>[] {
 | 
			
		||||
                    IPeripheralProvider.class,
 | 
			
		||||
                    IPeripheralProvider.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class<?>[] {
 | 
			
		||||
                    ITurtleUpgrade.class,
 | 
			
		||||
                    ITurtleUpgrade.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class<?>[] {
 | 
			
		||||
                    IBundledRedstoneProvider.class,
 | 
			
		||||
                    IBundledRedstoneProvider.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class<?>[] {
 | 
			
		||||
                    World.class, BlockPos.class, EnumFacing.class,
 | 
			
		||||
                    World.class, BlockPos.class, EnumFacing.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class<?>[] {
 | 
			
		||||
                    IMediaProvider.class,
 | 
			
		||||
                    IMediaProvider.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class<?>[] {
 | 
			
		||||
                    ITurtlePermissionProvider.class,
 | 
			
		||||
                    ITurtlePermissionProvider.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerPocketUpgrade = findCCMethod( "registerPocketUpgrade", new Class<?>[] {
 | 
			
		||||
                    IPocketUpgrade.class,
 | 
			
		||||
                    IPocketUpgrade.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_getWirelessNetwork = findCCMethod( "getWirelessNetwork", new Class<?>[] {
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerAPIFactory = findCCMethod( "registerAPIFactory", new Class<?>[] {
 | 
			
		||||
                    ILuaAPIFactory.class,
 | 
			
		||||
                    ILuaAPIFactory.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createWiredNodeForElement = findCCMethod( "createWiredNodeForElement", new Class<?>[] {
 | 
			
		||||
                    IWiredElement.class,
 | 
			
		||||
                    IWiredElement.class
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_getWiredElementAt = findCCMethod( "getWiredElementAt", new Class<?>[] {
 | 
			
		||||
                    IBlockAccess.class, BlockPos.class, EnumFacing.class,
 | 
			
		||||
                    IBlockAccess.class, BlockPos.class, EnumFacing.class
 | 
			
		||||
                } );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                System.err.println( "ComputerCraftAPI: ComputerCraft not found." );
 | 
			
		||||
                System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
@@ -498,7 +498,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
        }
 | 
			
		||||
        catch( NoSuchMethodException e )
 | 
			
		||||
        {
 | 
			
		||||
            System.err.println( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
 | 
			
		||||
            System.out.println( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,81 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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,41 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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 javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An {@link IOException} which occurred on a specific file.
 | 
			
		||||
 *
 | 
			
		||||
 * This may be thrown from a {@link IMount} or {@link IWritableMount} to give more information about a failure.
 | 
			
		||||
 */
 | 
			
		||||
public class FileOperationException extends IOException
 | 
			
		||||
{
 | 
			
		||||
    private static final long serialVersionUID = -8809108200853029849L;
 | 
			
		||||
 | 
			
		||||
    private final String filename;
 | 
			
		||||
 | 
			
		||||
    public FileOperationException( @Nullable String filename, @Nonnull String message )
 | 
			
		||||
    {
 | 
			
		||||
        super( Objects.requireNonNull( message, "message cannot be null" ) );
 | 
			
		||||
        this.filename = filename;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public FileOperationException( @Nonnull String message )
 | 
			
		||||
    {
 | 
			
		||||
        super( Objects.requireNonNull( message, "message cannot be null" ) );
 | 
			
		||||
        this.filename = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public String getFilename()
 | 
			
		||||
    {
 | 
			
		||||
        return filename;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -14,12 +15,11 @@ 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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Represents a read only part of a virtual filesystem that can be mounted onto a computer using
 | 
			
		||||
 * {@link IComputerAccess#mount(String, IMount)}.
 | 
			
		||||
 * {@link IComputerAccess#mount(String, IMount)}
 | 
			
		||||
 *
 | 
			
		||||
 * Ready made implementations of this interface can be created using
 | 
			
		||||
 * {@link ComputerCraftAPI#createSaveDirMount(World, String, long)} or
 | 
			
		||||
@@ -60,7 +60,7 @@ public interface IMount
 | 
			
		||||
    void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the size of a file with a given path, in bytes.
 | 
			
		||||
     * Returns the size of a file with a given path, in bytes
 | 
			
		||||
     *
 | 
			
		||||
     * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram".
 | 
			
		||||
     * @return The size of the file, in bytes.
 | 
			
		||||
@@ -90,22 +90,9 @@ public interface IMount
 | 
			
		||||
     * @throws IOException If the file does not exist, or could not be opened.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @SuppressWarnings( "deprecation" )
 | 
			
		||||
    default ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOException
 | 
			
		||||
    {
 | 
			
		||||
        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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -14,7 +15,6 @@ 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)}
 | 
			
		||||
@@ -67,6 +67,7 @@ public interface IWritableMount extends IMount
 | 
			
		||||
     * @throws IOException If the file could not be opened for writing.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @SuppressWarnings( "deprecation" )
 | 
			
		||||
    default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws IOException
 | 
			
		||||
    {
 | 
			
		||||
        return Channels.newChannel( openForWrite( path ) );
 | 
			
		||||
@@ -93,6 +94,7 @@ public interface IWritableMount extends IMount
 | 
			
		||||
     * @throws IOException If the file could not be opened for writing.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @SuppressWarnings( "deprecation" )
 | 
			
		||||
    default WritableByteChannel openChannelForAppend( @Nonnull String path ) throws IOException
 | 
			
		||||
    {
 | 
			
		||||
        return Channels.newChannel( openForAppend( path ) );
 | 
			
		||||
@@ -106,16 +108,4 @@ 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,334 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.lua;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.peripheral.IComputerAccess;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides methods for extracting values and validating Lua arguments, such as those provided to
 | 
			
		||||
 * {@link ILuaObject#callMethod(ILuaContext, int, Object[])} or
 | 
			
		||||
 * {@link IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])}.
 | 
			
		||||
 *
 | 
			
		||||
 * This provides two sets of functions: the {@code get*} methods, which require an argument to be valid, and
 | 
			
		||||
 * {@code opt*}, which accept a default value and return that if the argument was not present or was {@code null}.
 | 
			
		||||
 * If the argument is of the wrong type, a suitable error message will be thrown, with a similar format to Lua's own
 | 
			
		||||
 * error messages.
 | 
			
		||||
 *
 | 
			
		||||
 * <h2>Example usage:</h2>
 | 
			
		||||
 * <pre>
 | 
			
		||||
 * {@code
 | 
			
		||||
 * int slot = getInt( args, 0 );
 | 
			
		||||
 * int amount = optInt( args, 1, 64 );
 | 
			
		||||
 * }
 | 
			
		||||
 * </pre>
 | 
			
		||||
 */
 | 
			
		||||
public final class ArgumentHelper
 | 
			
		||||
{
 | 
			
		||||
    private ArgumentHelper()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a string representation of the given value's type.
 | 
			
		||||
     *
 | 
			
		||||
     * @param value The value whose type we are trying to compute.
 | 
			
		||||
     * @return A string representation of the given value's type, in a similar format to that provided by Lua's
 | 
			
		||||
     * {@code type} function.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static String getType( @Nullable Object value )
 | 
			
		||||
    {
 | 
			
		||||
        if( value == null ) return "nil";
 | 
			
		||||
        if( value instanceof String ) return "string";
 | 
			
		||||
        if( value instanceof Boolean ) return "boolean";
 | 
			
		||||
        if( value instanceof Number ) return "number";
 | 
			
		||||
        if( value instanceof Map ) return "table";
 | 
			
		||||
        return "userdata";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Construct a "bad argument" exception, from an expected type and the actual value provided.
 | 
			
		||||
     *
 | 
			
		||||
     * @param index    The argument number, starting from 0.
 | 
			
		||||
     * @param expected The expected type for this argument.
 | 
			
		||||
     * @param actual   The actual value provided for this argument.
 | 
			
		||||
     * @return The constructed exception, which should be thrown immediately.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static LuaException badArgumentOf( int index, @Nonnull String expected, @Nullable Object actual )
 | 
			
		||||
    {
 | 
			
		||||
        return badArgument( index, expected, getType( actual ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Construct a "bad argument" exception, from an expected and actual type.
 | 
			
		||||
     *
 | 
			
		||||
     * @param index    The argument number, starting from 0.
 | 
			
		||||
     * @param expected The expected type for this argument.
 | 
			
		||||
     * @param actual   The provided type for this argument.
 | 
			
		||||
     * @return The constructed exception, which should be thrown immediately.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static LuaException badArgument( int index, @Nonnull String expected, @Nonnull String actual )
 | 
			
		||||
    {
 | 
			
		||||
        return new LuaException( "bad argument #" + (index + 1) + " (" + expected + " expected, got " + actual + ")" );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a double.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @return The argument's value.
 | 
			
		||||
     * @throws LuaException If the value is not a number.
 | 
			
		||||
     * @see #getFiniteDouble(Object[], int) if you require this to be finite (i.e. not infinite or NaN).
 | 
			
		||||
     */
 | 
			
		||||
    public static double getDouble( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( index >= args.length ) throw badArgument( index, "number", "nil" );
 | 
			
		||||
        Object value = args[index];
 | 
			
		||||
        if( !(value instanceof Number) ) throw badArgumentOf( index, "number", value );
 | 
			
		||||
        return ((Number) value).doubleValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as an integer.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @return The argument's value.
 | 
			
		||||
     * @throws LuaException If the value is not an integer.
 | 
			
		||||
     */
 | 
			
		||||
    public static int getInt( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return (int) getLong( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a long.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @return The argument's value.
 | 
			
		||||
     * @throws LuaException If the value is not a long.
 | 
			
		||||
     */
 | 
			
		||||
    public static long getLong( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( index >= args.length ) throw badArgument( index, "number", "nil" );
 | 
			
		||||
        Object value = args[index];
 | 
			
		||||
        if( !(value instanceof Number) ) throw badArgumentOf( index, "number", value );
 | 
			
		||||
        return checkFinite( index, (Number) value ).longValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a finite number (not infinite or NaN).
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @return The argument's value.
 | 
			
		||||
     * @throws LuaException If the value is not finite.
 | 
			
		||||
     */
 | 
			
		||||
    public static double getFiniteDouble( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return checkFinite( index, getDouble( args, index ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a boolean.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @return The argument's value.
 | 
			
		||||
     * @throws LuaException If the value is not a boolean.
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean getBoolean( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( index >= args.length ) throw badArgument( index, "boolean", "nil" );
 | 
			
		||||
        Object value = args[index];
 | 
			
		||||
        if( !(value instanceof Boolean) ) throw badArgumentOf( index, "boolean", value );
 | 
			
		||||
        return (Boolean) value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a string.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @return The argument's value.
 | 
			
		||||
     * @throws LuaException If the value is not a string.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static String getString( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( index >= args.length ) throw badArgument( index, "string", "nil" );
 | 
			
		||||
        Object value = args[index];
 | 
			
		||||
        if( !(value instanceof String) ) throw badArgumentOf( index, "string", value );
 | 
			
		||||
        return (String) value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a table.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @return The argument's value.
 | 
			
		||||
     * @throws LuaException If the value is not a table.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static Map<?, ?> getTable( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( index >= args.length ) throw badArgument( index, "table", "nil" );
 | 
			
		||||
        Object value = args[index];
 | 
			
		||||
        if( !(value instanceof Map) ) throw badArgumentOf( index, "table", value );
 | 
			
		||||
        return (Map<?, ?>) value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a double.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @param def   The default value, if this argument is not given.
 | 
			
		||||
     * @return The argument's value, or {@code def} if none was provided.
 | 
			
		||||
     * @throws LuaException If the value is not a number.
 | 
			
		||||
     */
 | 
			
		||||
    public static double optDouble( @Nonnull Object[] args, int index, double def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        Object value = index < args.length ? args[index] : null;
 | 
			
		||||
        if( value == null ) return def;
 | 
			
		||||
        if( !(value instanceof Number) ) throw badArgumentOf( index, "number", value );
 | 
			
		||||
        return ((Number) value).doubleValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as an int.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @param def   The default value, if this argument is not given.
 | 
			
		||||
     * @return The argument's value, or {@code def} if none was provided.
 | 
			
		||||
     * @throws LuaException If the value is not a number.
 | 
			
		||||
     */
 | 
			
		||||
    public static int optInt( @Nonnull Object[] args, int index, int def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return (int) optLong( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a long.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @param def   The default value, if this argument is not given.
 | 
			
		||||
     * @return The argument's value, or {@code def} if none was provided.
 | 
			
		||||
     * @throws LuaException If the value is not a number.
 | 
			
		||||
     */
 | 
			
		||||
    public static long optLong( @Nonnull Object[] args, int index, long def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        Object value = index < args.length ? args[index] : null;
 | 
			
		||||
        if( value == null ) return def;
 | 
			
		||||
        if( !(value instanceof Number) ) throw badArgumentOf( index, "number", value );
 | 
			
		||||
        return checkFinite( index, (Number) value ).longValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a finite number (not infinite or NaN).
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @param def   The default value, if this argument is not given.
 | 
			
		||||
     * @return The argument's value, or {@code def} if none was provided.
 | 
			
		||||
     * @throws LuaException If the value is not finite.
 | 
			
		||||
     */
 | 
			
		||||
    public static double optFiniteDouble( @Nonnull Object[] args, int index, double def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return checkFinite( index, optDouble( args, index, def ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a boolean.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @param def   The default value, if this argument is not given.
 | 
			
		||||
     * @return The argument's value, or {@code def} if none was provided.
 | 
			
		||||
     * @throws LuaException If the value is not a boolean.
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean optBoolean( @Nonnull Object[] args, int index, boolean def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        Object value = index < args.length ? args[index] : null;
 | 
			
		||||
        if( value == null ) return def;
 | 
			
		||||
        if( !(value instanceof Boolean) ) throw badArgumentOf( index, "boolean", value );
 | 
			
		||||
        return (Boolean) value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a string.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @param def   The default value, if this argument is not given.
 | 
			
		||||
     * @return The argument's value, or {@code def} if none was provided.
 | 
			
		||||
     * @throws LuaException If the value is not a string.
 | 
			
		||||
     */
 | 
			
		||||
    public static String optString( @Nonnull Object[] args, int index, String def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        Object value = index < args.length ? args[index] : null;
 | 
			
		||||
        if( value == null ) return def;
 | 
			
		||||
        if( !(value instanceof String) ) throw badArgumentOf( index, "string", value );
 | 
			
		||||
        return (String) value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an argument as a table.
 | 
			
		||||
     *
 | 
			
		||||
     * @param args  The arguments to extract from.
 | 
			
		||||
     * @param index The index into the argument array to read from.
 | 
			
		||||
     * @param def   The default value, if this argument is not given.
 | 
			
		||||
     * @return The argument's value, or {@code def} if none was provided.
 | 
			
		||||
     * @throws LuaException If the value is not a table.
 | 
			
		||||
     */
 | 
			
		||||
    public static Map<?, ?> optTable( @Nonnull Object[] args, int index, Map<Object, Object> def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        Object value = index < args.length ? args[index] : null;
 | 
			
		||||
        if( value == null ) return def;
 | 
			
		||||
        if( !(value instanceof Map) ) throw badArgumentOf( index, "table", value );
 | 
			
		||||
        return (Map<?, ?>) value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static Number checkFinite( int index, Number value ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        checkFinite( index, value.doubleValue() );
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static double checkFinite( int index, double value ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( !Double.isFinite( value ) ) throw badArgument( index, "number", getNumericType( value ) );
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a more detailed representation of this number's type. If this is finite, it will just return "number",
 | 
			
		||||
     * otherwise it returns whether it is infinite or NaN.
 | 
			
		||||
     *
 | 
			
		||||
     * @param value The value to extract the type for.
 | 
			
		||||
     * @return This value's numeric type.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static String getNumericType( double value )
 | 
			
		||||
    {
 | 
			
		||||
        if( Double.isNaN( value ) ) return "nan";
 | 
			
		||||
        if( value == Double.POSITIVE_INFINITY ) return "inf";
 | 
			
		||||
        if( value == Double.NEGATIVE_INFINITY ) return "-inf";
 | 
			
		||||
        return "number";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -25,7 +26,7 @@ public interface IComputerSystem extends IComputerAccess
 | 
			
		||||
    IFileSystem getFileSystem();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the label for this computer.
 | 
			
		||||
     * Get the label for this computer
 | 
			
		||||
     *
 | 
			
		||||
     * @return This computer's label, or {@code null} if it is not set.
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -16,7 +17,6 @@ import javax.annotation.Nullable;
 | 
			
		||||
 * @see ILuaAPI
 | 
			
		||||
 * @see ComputerCraftAPI#registerAPIFactory(ILuaAPIFactory)
 | 
			
		||||
 */
 | 
			
		||||
@FunctionalInterface
 | 
			
		||||
public interface ILuaAPIFactory
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -31,12 +32,7 @@ public interface ILuaContext
 | 
			
		||||
     *                              intercepted, or the computer will leak memory and end up in a broken state.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    default Object[] pullEvent( @Nullable String filter ) throws LuaException, InterruptedException
 | 
			
		||||
    {
 | 
			
		||||
        Object[] results = pullEventRaw( filter );
 | 
			
		||||
        if( results.length >= 1 && results[0].equals( "terminate" ) ) throw new LuaException( "Terminated", 0 );
 | 
			
		||||
        return results;
 | 
			
		||||
    }
 | 
			
		||||
    Object[] pullEvent( @Nullable String filter ) throws LuaException, InterruptedException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The same as {@link #pullEvent(String)}, except "terminated" events are ignored. Only use this if you want to
 | 
			
		||||
@@ -51,10 +47,7 @@ public interface ILuaContext
 | 
			
		||||
     * @see #pullEvent(String)
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    default Object[] pullEventRaw( @Nullable String filter ) throws InterruptedException
 | 
			
		||||
    {
 | 
			
		||||
        return yield( new Object[] { filter } );
 | 
			
		||||
    }
 | 
			
		||||
    Object[] pullEventRaw( @Nullable String filter ) throws InterruptedException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,12 +1,12 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
import net.minecraft.item.Item;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.SoundEvent;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
@@ -16,9 +16,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Represents an item that can be placed in a disk drive and used by a Computer.
 | 
			
		||||
 *
 | 
			
		||||
 * Implement this interface on your {@link Item} class to allow it to be used in the drive. Alternatively, register
 | 
			
		||||
 * a {@link IMediaProvider}.
 | 
			
		||||
 * Implement this interface on your Item class to allow it to be used in the drive.
 | 
			
		||||
 */
 | 
			
		||||
public interface IMedia
 | 
			
		||||
{
 | 
			
		||||
@@ -45,7 +43,7 @@ public interface IMedia
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If this disk represents an item with audio (like a record), get the readable name of the audio track. ie:
 | 
			
		||||
     * "Jonathan Coulton - Still Alive"
 | 
			
		||||
     * "Jonathon Coulton - Still Alive"
 | 
			
		||||
     *
 | 
			
		||||
     * @param stack The {@link ItemStack} to modify.
 | 
			
		||||
     * @return The name, or null if this item does not represent an item with audio.
 | 
			
		||||
@@ -76,7 +74,7 @@ public interface IMedia
 | 
			
		||||
     * @param world The world in which the item and disk drive reside.
 | 
			
		||||
     * @return The mount, or null if this item does not represent an item with data. If the mount returned also
 | 
			
		||||
     * implements {@link dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable()
 | 
			
		||||
     * @see IMount
 | 
			
		||||
     * @see dan200.computercraft.api.filesystem.IMount
 | 
			
		||||
     * @see dan200.computercraft.api.filesystem.IWritableMount
 | 
			
		||||
     * @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
 | 
			
		||||
     * @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -22,7 +23,7 @@ public interface IMediaProvider
 | 
			
		||||
     * Produce an IMedia implementation from an ItemStack.
 | 
			
		||||
     *
 | 
			
		||||
     * @param stack The stack from which to extract the media information.
 | 
			
		||||
     * @return An {@link IMedia} implementation, or {@code null} if the item is not something you wish to handle
 | 
			
		||||
     * @return An IMedia implementation, or null if the item is not something you wish to handle
 | 
			
		||||
     * @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,15 +1,14 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
import dan200.computercraft.api.filesystem.IMount;
 | 
			
		||||
import dan200.computercraft.api.filesystem.IWritableMount;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaTask;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -147,7 +146,7 @@ public interface IComputerAccess
 | 
			
		||||
     *
 | 
			
		||||
     *                  You may supply {@code null} to indicate that no arguments are to be supplied.
 | 
			
		||||
     * @throws RuntimeException If the peripheral has been detached.
 | 
			
		||||
     * @see IPeripheral#callMethod
 | 
			
		||||
     * @see dan200.computercraft.api.peripheral.IPeripheral#callMethod
 | 
			
		||||
     */
 | 
			
		||||
    void queueEvent( @Nonnull String event, @Nullable Object[] arguments );
 | 
			
		||||
 | 
			
		||||
@@ -180,8 +179,8 @@ public interface IComputerAccess
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a reachable peripheral with the given attachment name. This is a equivalent to
 | 
			
		||||
     * {@link #getAvailablePeripherals()}{@code .get(name)}, though may be more efficient.
 | 
			
		||||
     * Get a reachable peripheral with the given attachement name. This is a equivalent to
 | 
			
		||||
     * {@link #getAvailablePeripherals()}{@code .get(name)}, though may be more performant.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name The peripheral's attached name
 | 
			
		||||
     * @return The reachable peripheral, or {@code null} if none can be found.
 | 
			
		||||
@@ -192,23 +191,4 @@ public interface IComputerAccess
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a {@link IWorkMonitor} for tasks your peripheral might execute on the main (server) thread.
 | 
			
		||||
     *
 | 
			
		||||
     * This should be used to ensure your peripheral integrates with ComputerCraft's monitoring and limiting of how much
 | 
			
		||||
     * server time each computer consumes. You should not need to use this if you use
 | 
			
		||||
     * {@link ILuaContext#issueMainThreadTask(ILuaTask)} - this is intended for mods with their own system for running
 | 
			
		||||
     * work on the main thread.
 | 
			
		||||
     *
 | 
			
		||||
     * Please note that the returned implementation is <em>not</em> thread-safe, and should only be used from the main
 | 
			
		||||
     * thread.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The work monitor for the main thread, or {@code null} if this computer does not have one.
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    default IWorkMonitor getMainThreadMonitor()
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
import dan200.computercraft.api.lua.LuaException;
 | 
			
		||||
 | 
			
		||||
@@ -41,8 +41,8 @@ public interface IPeripheral
 | 
			
		||||
     * This is called when a lua program on an attached computer calls {@code peripheral.call()} with
 | 
			
		||||
     * one of the methods exposed by {@link #getMethodNames()}.
 | 
			
		||||
     *
 | 
			
		||||
     * Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe when interacting
 | 
			
		||||
     * with Minecraft objects.
 | 
			
		||||
     * Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
 | 
			
		||||
     * when interacting with Minecraft objects.
 | 
			
		||||
     *
 | 
			
		||||
     * @param computer  The interface to the computer that is making the call. Remember that multiple
 | 
			
		||||
     *                  computers can be attached to a peripheral at once.
 | 
			
		||||
@@ -58,11 +58,9 @@ public interface IPeripheral
 | 
			
		||||
     *                  Lua values of type "table" will be represented by Object type Map.<br>
 | 
			
		||||
     *                  Lua values of any other type will be represented by a null object.<br>
 | 
			
		||||
     *                  This array will be empty if no arguments are passed.
 | 
			
		||||
     *
 | 
			
		||||
     *                  It is recommended you use {@link ArgumentHelper} in order to validate and process arguments.
 | 
			
		||||
     * @return An array of objects, representing values you wish to return to the lua program. Integers, Doubles, Floats,
 | 
			
		||||
     * Strings, Booleans, Maps, ILuaObject and null be converted to their corresponding lua type. All other types will
 | 
			
		||||
     * be converted to nil.
 | 
			
		||||
     * Strings, Booleans, Maps and ILuaObject and null be converted to their corresponding lua type. All other types
 | 
			
		||||
     * will be converted to nil.
 | 
			
		||||
     *
 | 
			
		||||
     * You may return null to indicate no values should be returned.
 | 
			
		||||
     * @throws LuaException         If you throw any exception from this function, a lua error will be raised with the
 | 
			
		||||
@@ -72,27 +70,25 @@ public interface IPeripheral
 | 
			
		||||
     *                              InterruptedException will be thrown. This exception must not be caught or
 | 
			
		||||
     *                              intercepted, or the computer will leak memory and end up in a broken state.
 | 
			
		||||
     * @see #getMethodNames
 | 
			
		||||
     * @see ArgumentHelper
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Is called when when a computer is attaching to the peripheral.
 | 
			
		||||
     * Is called when canAttachToSide has returned true, and a computer is attaching to the peripheral.
 | 
			
		||||
     *
 | 
			
		||||
     * This will occur when a peripheral is placed next to an active computer, when a computer is turned on next to a
 | 
			
		||||
     * peripheral, when a turtle travels into a square next to a peripheral, or when a wired modem adjacent to this
 | 
			
		||||
     * peripheral is does any of the above.
 | 
			
		||||
     * peripheral, or when a turtle travels into a square next to a peripheral.
 | 
			
		||||
     *
 | 
			
		||||
     * Between calls to attach and {@link #detach}, the attached computer can make method calls on the peripheral using
 | 
			
		||||
     * Between calls to attach() and detach(), the attached computer can make method calls on the peripheral using
 | 
			
		||||
     * {@code peripheral.call()}. This method can be used to keep track of which computers are attached to the
 | 
			
		||||
     * peripheral, or to take action when attachment occurs.
 | 
			
		||||
     *
 | 
			
		||||
     * Be aware that will be called from both the server thread and ComputerCraft Lua thread, and so must be thread-safe
 | 
			
		||||
     * and reentrant.
 | 
			
		||||
     * Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
 | 
			
		||||
     * when interacting with Minecraft objects.
 | 
			
		||||
     *
 | 
			
		||||
     * @param computer The interface to the computer that is being attached. Remember that multiple computers can be
 | 
			
		||||
     *                 attached to a peripheral at once.
 | 
			
		||||
     * @param computer The interface to the computer that is being attached. Remember that multiple
 | 
			
		||||
     *                 computers can be attached to a peripheral at once.
 | 
			
		||||
     * @see #detach
 | 
			
		||||
     */
 | 
			
		||||
    default void attach( @Nonnull IComputerAccess computer )
 | 
			
		||||
@@ -100,21 +96,19 @@ public interface IPeripheral
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when a computer is detaching from the peripheral.
 | 
			
		||||
     * Is called when a computer is detaching from the peripheral.
 | 
			
		||||
     *
 | 
			
		||||
     * This will occur when a computer shuts down, when the peripheral is removed while attached to computers, when a
 | 
			
		||||
     * turtle moves away from a block attached to a peripheral, or when a wired modem adjacent to this peripheral is
 | 
			
		||||
     * detached.
 | 
			
		||||
     * This will occur when a computer shuts down, when the peripheral is removed while attached to computers,
 | 
			
		||||
     * or when a turtle moves away from a square attached to a peripheral. This method can be used to keep track of
 | 
			
		||||
     * which computers are attached to the peripheral, or to take action when detachment
 | 
			
		||||
     * occurs.
 | 
			
		||||
     *
 | 
			
		||||
     * This method can be used to keep track of which computers are attached to the peripheral, or to take action when
 | 
			
		||||
     * detachment occurs.
 | 
			
		||||
     * Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
 | 
			
		||||
     * when interacting with Minecraft objects.
 | 
			
		||||
     *
 | 
			
		||||
     * Be aware that this will be called from both the server and ComputerCraft Lua thread, and must be thread-safe
 | 
			
		||||
     * and reentrant.
 | 
			
		||||
     *
 | 
			
		||||
     * @param computer The interface to the computer that is being detached. Remember that multiple computers can be
 | 
			
		||||
     *                 attached to a peripheral at once.
 | 
			
		||||
     * @see #attach
 | 
			
		||||
     * @param computer The interface to the computer that is being detached. Remember that multiple
 | 
			
		||||
     *                 computers can be attached to a peripheral at once.
 | 
			
		||||
     * @see #detach
 | 
			
		||||
     */
 | 
			
		||||
    default void detach( @Nonnull IComputerAccess computer )
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
@@ -16,8 +16,6 @@ import javax.annotation.Nullable;
 | 
			
		||||
/**
 | 
			
		||||
 * This interface is used to create peripheral implementations for blocks.
 | 
			
		||||
 *
 | 
			
		||||
 * If you have a {@link TileEntity} which acts as a peripheral, you may alternatively implement {@link IPeripheralTile}.
 | 
			
		||||
 *
 | 
			
		||||
 * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
 | 
			
		||||
 */
 | 
			
		||||
@FunctionalInterface
 | 
			
		||||
 
 | 
			
		||||
@@ -1,32 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.peripheral;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A {@link net.minecraft.tileentity.TileEntity} which may act as a peripheral.
 | 
			
		||||
 *
 | 
			
		||||
 * If you need more complex capabilities (such as handling TEs not belonging to your mod), you should use
 | 
			
		||||
 * {@link IPeripheralProvider}.
 | 
			
		||||
 */
 | 
			
		||||
public interface IPeripheralTile
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the peripheral on the given {@code side}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param side The side to get the peripheral from.
 | 
			
		||||
     * @return A peripheral, or {@code null} if there is not a peripheral here.
 | 
			
		||||
     * @see IPeripheralProvider#getPeripheral(World, BlockPos, EnumFacing)
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull EnumFacing side );
 | 
			
		||||
}
 | 
			
		||||
@@ -1,77 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.peripheral;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
import java.util.concurrent.TimeUnit;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Monitors "work" associated with a computer, keeping track of how much a computer has done, and ensuring every
 | 
			
		||||
 * computer receives a fair share of any processing time.
 | 
			
		||||
 *
 | 
			
		||||
 * This is primarily intended for work done by peripherals on the main thread (such as on a tile entity's tick), but
 | 
			
		||||
 * could be used for other purposes (such as complex computations done on another thread).
 | 
			
		||||
 *
 | 
			
		||||
 * Before running a task, one should call {@link #canWork()} to determine if the computer is currently allowed to
 | 
			
		||||
 * execute work. If that returns true, you should execute the task and use {@link #trackWork(long, TimeUnit)} to inform
 | 
			
		||||
 * the monitor how long that task took.
 | 
			
		||||
 *
 | 
			
		||||
 * Alternatively, use {@link #runWork(Runnable)} to run and keep track of work.
 | 
			
		||||
 *
 | 
			
		||||
 * @see IComputerAccess#getMainThreadMonitor()
 | 
			
		||||
 */
 | 
			
		||||
public interface IWorkMonitor
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * If the owning computer is currently allowed to execute work.
 | 
			
		||||
     *
 | 
			
		||||
     * @return If we can execute work right now.
 | 
			
		||||
     */
 | 
			
		||||
    boolean canWork();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If the owning computer is currently allowed to execute work, and has ample time to do so.
 | 
			
		||||
     *
 | 
			
		||||
     * This is effectively a more restrictive form of {@link #canWork()}. One should use that in order to determine if
 | 
			
		||||
     * you may do an initial piece of work, and shouldWork to determine if any additional task may be performed.
 | 
			
		||||
     *
 | 
			
		||||
     * @return If we should execute work right now.
 | 
			
		||||
     */
 | 
			
		||||
    boolean shouldWork();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Inform the monitor how long some piece of work took to execute.
 | 
			
		||||
     *
 | 
			
		||||
     * @param time The time some task took to run
 | 
			
		||||
     * @param unit The unit that {@code time} was measured in.
 | 
			
		||||
     */
 | 
			
		||||
    void trackWork( long time, @Nonnull TimeUnit unit );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Run a task if possible, and inform the monitor of how long it took.
 | 
			
		||||
     *
 | 
			
		||||
     * @param runnable The task to run.
 | 
			
		||||
     * @return If the task was actually run (namely, {@link #canWork()} returned {@code true}).
 | 
			
		||||
     */
 | 
			
		||||
    default boolean runWork( @Nonnull Runnable runnable )
 | 
			
		||||
    {
 | 
			
		||||
        Objects.requireNonNull( runnable, "runnable should not be null" );
 | 
			
		||||
        if( !canWork() ) return false;
 | 
			
		||||
 | 
			
		||||
        long start = System.nanoTime();
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            runnable.run();
 | 
			
		||||
        }
 | 
			
		||||
        finally
 | 
			
		||||
        {
 | 
			
		||||
            trackWork( System.nanoTime() - start, TimeUnit.NANOSECONDS );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -15,7 +16,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Wrapper class for pocket computers.
 | 
			
		||||
 * Wrapper class for pocket computers
 | 
			
		||||
 */
 | 
			
		||||
public interface IPocketAccess
 | 
			
		||||
{
 | 
			
		||||
@@ -23,22 +24,10 @@ public interface IPocketAccess
 | 
			
		||||
     * Gets the entity holding this item.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The holding entity. This may be {@code null}.
 | 
			
		||||
     * @deprecated Use {@link #getValidEntity()} where possible.
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    Entity getEntity();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the entity holding this item with additional safety checks.
 | 
			
		||||
     *
 | 
			
		||||
     * This must be called on the server thread.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The holding entity, or {@code null} if none exists.
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    Entity getValidEntity();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the colour of this pocket computer as a RGB number.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -18,7 +19,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
/**
 | 
			
		||||
 * Additional peripherals for pocket computers.
 | 
			
		||||
 *
 | 
			
		||||
 * This is similar to {@link ITurtleUpgrade}.
 | 
			
		||||
 * This is similar to {@link dan200.computercraft.api.turtle.ITurtleUpgrade}.
 | 
			
		||||
 */
 | 
			
		||||
public interface IPocketUpgrade
 | 
			
		||||
{
 | 
			
		||||
@@ -53,9 +54,6 @@ public interface IPocketUpgrade
 | 
			
		||||
     * pocket computer which holds this upgrade. This item stack is also used to determine the upgrade given by
 | 
			
		||||
     * {@code pocket.equip()}/{@code pocket.unequip()}.
 | 
			
		||||
     *
 | 
			
		||||
     * Ideally this should be constant over a session. It is recommended that you cache
 | 
			
		||||
     * the item too, in order to prevent constructing it every time the method is called.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The item stack used for crafting. This can be {@link ItemStack#EMPTY} if crafting is disabled.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -144,9 +145,7 @@ public interface ITurtleAccess
 | 
			
		||||
    GameProfile getOwningPlayer();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the inventory of this turtle.
 | 
			
		||||
     *
 | 
			
		||||
     * Note: this inventory should only be accessed and modified on the server thread.
 | 
			
		||||
     * Get the inventory of this turtle
 | 
			
		||||
     *
 | 
			
		||||
     * @return This turtle's inventory
 | 
			
		||||
     * @see #getItemHandler()
 | 
			
		||||
@@ -157,8 +156,6 @@ public interface ITurtleAccess
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the inventory of this turtle as an {@link IItemHandlerModifiable}.
 | 
			
		||||
     *
 | 
			
		||||
     * Note: this inventory should only be accessed and modified on the server thread.
 | 
			
		||||
     *
 | 
			
		||||
     * @return This turtle's inventory
 | 
			
		||||
     * @see #getInventory()
 | 
			
		||||
     * @see IItemHandlerModifiable
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -78,9 +79,6 @@ public interface ITurtleUpgrade
 | 
			
		||||
     * with to create a turtle which holds this upgrade. This item stack is also used
 | 
			
		||||
     * to determine the upgrade given by {@code turtle.equip()}
 | 
			
		||||
     *
 | 
			
		||||
     * Ideally this should be constant over a session. It is recommended that you cache
 | 
			
		||||
     * the item too, in order to prevent constructing it every time the method is called.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The item stack to craft with, or {@link ItemStack#EMPTY} if it cannot be crafted.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
@@ -108,8 +106,8 @@ public interface ITurtleUpgrade
 | 
			
		||||
     * Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called
 | 
			
		||||
     * by the turtle, and the tool is required to do some work.
 | 
			
		||||
     *
 | 
			
		||||
     * Conforming implementations should fire {@link BlockEvent.BreakEvent} and {@link TurtleBlockEvent.Dig} for
 | 
			
		||||
     * digging, {@link AttackEntityEvent} and {@link TurtleAttackEvent} for attacking.
 | 
			
		||||
     * Conforming implementations should fire {@link BlockEvent.BreakEvent} and {@link TurtleBlockEvent.Dig}for digging,
 | 
			
		||||
     * {@link AttackEntityEvent} and {@link TurtleAttackEvent} for attacking.
 | 
			
		||||
     *
 | 
			
		||||
     * @param turtle    Access to the turtle that the tool resides on.
 | 
			
		||||
     * @param side      Which side of the turtle (left or right) the tool resides on.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -11,12 +12,12 @@ package dan200.computercraft.api.turtle;
 | 
			
		||||
public enum TurtleSide
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * The turtle's left side (where the pickaxe usually is on a Wireless Mining Turtle).
 | 
			
		||||
     * The turtle's left side (where the pickaxe usually is on a Wireless Mining Turtle)
 | 
			
		||||
     */
 | 
			
		||||
    Left,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The turtle's right side (where the modem usually is on a Wireless Mining Turtle).
 | 
			
		||||
     * The turtle's right side (where the modem usually is on a Wireless Mining Turtle)
 | 
			
		||||
     */
 | 
			
		||||
    Right,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -17,12 +18,12 @@ import net.minecraft.util.EnumFacing;
 | 
			
		||||
public enum TurtleVerb
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * The turtle called {@code turtle.dig()}, {@code turtle.digUp()} or {@code turtle.digDown()}.
 | 
			
		||||
     * The turtle called {@code turtle.dig()}, {@code turtle.digUp()} or {@code turtle.digDown()}
 | 
			
		||||
     */
 | 
			
		||||
    Dig,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The turtle called {@code turtle.attack()}, {@code turtle.attackUp()} or {@code turtle.attackDown()}.
 | 
			
		||||
     * The turtle called {@code turtle.attack()}, {@code turtle.attackUp()} or {@code turtle.attackDown()}
 | 
			
		||||
     */
 | 
			
		||||
    Attack,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -70,7 +71,7 @@ public enum TurtleAction
 | 
			
		||||
    EQUIP,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Inspect a block in world.
 | 
			
		||||
     * Inspect a block in world
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleBlockEvent.Inspect
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -18,6 +19,7 @@ import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
import net.minecraftforge.event.world.BlockEvent;
 | 
			
		||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
@@ -35,6 +37,7 @@ import java.util.Objects;
 | 
			
		||||
 * Be aware that some events (such as {@link TurtleInventoryEvent}) do not necessarily interact
 | 
			
		||||
 * with a block, simply objects within that block space.
 | 
			
		||||
 */
 | 
			
		||||
@Cancelable
 | 
			
		||||
public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
{
 | 
			
		||||
    private final World world;
 | 
			
		||||
@@ -81,6 +84,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleAction#DIG
 | 
			
		||||
     */
 | 
			
		||||
    @Cancelable
 | 
			
		||||
    public static class Dig extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final IBlockState block;
 | 
			
		||||
@@ -111,7 +115,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Get the upgrade doing the digging.
 | 
			
		||||
         * Get the upgrade doing the digging
 | 
			
		||||
         *
 | 
			
		||||
         * @return The upgrade doing the digging.
 | 
			
		||||
         */
 | 
			
		||||
@@ -138,6 +142,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleAction#MOVE
 | 
			
		||||
     */
 | 
			
		||||
    @Cancelable
 | 
			
		||||
    public static class Move extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        public Move( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos )
 | 
			
		||||
@@ -151,6 +156,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleAction#PLACE
 | 
			
		||||
     */
 | 
			
		||||
    @Cancelable
 | 
			
		||||
    public static class Place extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final ItemStack stack;
 | 
			
		||||
@@ -182,6 +188,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleAction#INSPECT
 | 
			
		||||
     */
 | 
			
		||||
    @Cancelable
 | 
			
		||||
    public static class Inspect extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final IBlockState state;
 | 
			
		||||
@@ -222,7 +229,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
        /**
 | 
			
		||||
         * Add new information to the inspection result. Note this will override fields with the same name.
 | 
			
		||||
         *
 | 
			
		||||
         * @param newData The data to add. Note all values should be convertible to Lua (see
 | 
			
		||||
         * @param newData The data to add. Note all values should be convertable to Lua (see
 | 
			
		||||
         *                {@link dan200.computercraft.api.peripheral.IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])}).
 | 
			
		||||
         */
 | 
			
		||||
        public void addData( @Nonnull Map<String, ?> newData )
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,73 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.turtle.event;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IComputerAccess;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Fired when a turtle gathers data on an item in its inventory.
 | 
			
		||||
 *
 | 
			
		||||
 * You may prevent items being inspected, or add additional information to the result. Be aware that this is fired on
 | 
			
		||||
 * the computer thread, and so any operations on it must be thread safe.
 | 
			
		||||
 *
 | 
			
		||||
 * @see TurtleAction#INSPECT_ITEM
 | 
			
		||||
 */
 | 
			
		||||
public class TurtleInspectItemEvent extends TurtleActionEvent
 | 
			
		||||
{
 | 
			
		||||
    private final ItemStack stack;
 | 
			
		||||
    private final Map<String, Object> data;
 | 
			
		||||
 | 
			
		||||
    public TurtleInspectItemEvent( @Nonnull ITurtleAccess turtle, @Nonnull ItemStack stack, @Nonnull Map<String, Object> data )
 | 
			
		||||
    {
 | 
			
		||||
        super( turtle, TurtleAction.INSPECT_ITEM );
 | 
			
		||||
 | 
			
		||||
        Objects.requireNonNull( stack, "stack cannot be null" );
 | 
			
		||||
        Objects.requireNonNull( data, "data cannot be null" );
 | 
			
		||||
        this.stack = stack;
 | 
			
		||||
        this.data = data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The item which is currently being inspected.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The item stack which is being inspected. This should <b>not</b> be modified.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public ItemStack getStack()
 | 
			
		||||
    {
 | 
			
		||||
        return stack;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the "inspection data" from this item, which will be returned to the user.
 | 
			
		||||
     *
 | 
			
		||||
     * @return This items's inspection data.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public Map<String, Object> getData()
 | 
			
		||||
    {
 | 
			
		||||
        return data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add new information to the inspection result. Note this will override fields with the same name.
 | 
			
		||||
     *
 | 
			
		||||
     * @param newData The data to add. Note all values should be convertible to Lua (see
 | 
			
		||||
     *                {@link dan200.computercraft.api.peripheral.IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])}).
 | 
			
		||||
     */
 | 
			
		||||
    public void addData( @Nonnull Map<String, ?> newData )
 | 
			
		||||
    {
 | 
			
		||||
        Objects.requireNonNull( newData, "newData cannot be null" );
 | 
			
		||||
        data.putAll( newData );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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;
 | 
			
		||||
@@ -10,6 +11,7 @@ import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
 | 
			
		||||
import net.minecraftforge.items.IItemHandler;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -19,6 +21,7 @@ import java.util.Objects;
 | 
			
		||||
/**
 | 
			
		||||
 * Fired when a turtle attempts to interact with an inventory.
 | 
			
		||||
 */
 | 
			
		||||
@Cancelable
 | 
			
		||||
public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
{
 | 
			
		||||
    private final IItemHandler handler;
 | 
			
		||||
@@ -30,7 +33,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the inventory being interacted with.
 | 
			
		||||
     * Get the inventory being interacted with
 | 
			
		||||
     *
 | 
			
		||||
     * @return The inventory being interacted with, {@code null} if the item will be dropped to/sucked from the world.
 | 
			
		||||
     */
 | 
			
		||||
@@ -45,6 +48,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleAction#SUCK
 | 
			
		||||
     */
 | 
			
		||||
    @Cancelable
 | 
			
		||||
    public static class Suck extends TurtleInventoryEvent
 | 
			
		||||
    {
 | 
			
		||||
        public Suck( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable IItemHandler handler )
 | 
			
		||||
@@ -58,6 +62,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleAction#DROP
 | 
			
		||||
     */
 | 
			
		||||
    @Cancelable
 | 
			
		||||
    public static class Drop extends TurtleInventoryEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final ItemStack stack;
 | 
			
		||||
@@ -73,12 +78,13 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
        /**
 | 
			
		||||
         * The item which will be inserted into the inventory/dropped on the ground.
 | 
			
		||||
         *
 | 
			
		||||
         * @return The item stack which will be dropped. This should <b>not</b> be modified.
 | 
			
		||||
         * Note that this is a copy of the original stack, and so should not be modified, as that will have no effect.
 | 
			
		||||
         *
 | 
			
		||||
         * @return The item stack which will be dropped.
 | 
			
		||||
         */
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        public ItemStack getStack()
 | 
			
		||||
        {
 | 
			
		||||
            return stack;
 | 
			
		||||
            return stack.copy();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,90 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.turtle.event;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Fired when a turtle attempts to refuel from an item.
 | 
			
		||||
 *
 | 
			
		||||
 * One may use {@link #setCanceled(boolean, String)} to prevent refueling from this specific item. Additionally, you
 | 
			
		||||
 * may use {@link #setHandler(Handler)} to register a custom fuel provider.
 | 
			
		||||
 */
 | 
			
		||||
public class TurtleRefuelEvent extends TurtleActionEvent
 | 
			
		||||
{
 | 
			
		||||
    private final ItemStack stack;
 | 
			
		||||
    private Handler handler;
 | 
			
		||||
 | 
			
		||||
    public TurtleRefuelEvent( @Nonnull ITurtleAccess turtle, @Nonnull ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        super( turtle, TurtleAction.REFUEL );
 | 
			
		||||
 | 
			
		||||
        Objects.requireNonNull( turtle, "turtle cannot be null" );
 | 
			
		||||
        this.stack = stack;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the stack we are attempting to refuel from.
 | 
			
		||||
     *
 | 
			
		||||
     * Do not modify the returned stack - all modifications should be done within the {@link Handler}.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The stack to refuel from.
 | 
			
		||||
     */
 | 
			
		||||
    public ItemStack getStack()
 | 
			
		||||
    {
 | 
			
		||||
        return stack;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the refuel handler for this stack.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The refuel handler, or {@code null} if none has currently been set.
 | 
			
		||||
     * @see #setHandler(Handler)
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Handler getHandler()
 | 
			
		||||
    {
 | 
			
		||||
        return handler;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the refuel handler for this stack.
 | 
			
		||||
     *
 | 
			
		||||
     * You should call this if you can actually refuel from this item, and ideally only if there are no existing
 | 
			
		||||
     * handlers.
 | 
			
		||||
     *
 | 
			
		||||
     * @param handler The new refuel handler.
 | 
			
		||||
     * @see #getHandler()
 | 
			
		||||
     */
 | 
			
		||||
    public void setHandler( @Nullable Handler handler )
 | 
			
		||||
    {
 | 
			
		||||
        this.handler = handler;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Handles refuelling a turtle from a specific item.
 | 
			
		||||
     */
 | 
			
		||||
    @FunctionalInterface
 | 
			
		||||
    public interface Handler
 | 
			
		||||
    {
 | 
			
		||||
        /**
 | 
			
		||||
         * Refuel a turtle using an item.
 | 
			
		||||
         *
 | 
			
		||||
         * @param turtle The turtle to refuel.
 | 
			
		||||
         * @param stack  The stack to refuel with.
 | 
			
		||||
         * @param slot   The slot the stack resides within. This may be used to modify the inventory afterwards.
 | 
			
		||||
         * @param limit  The maximum number of refuel operations to perform. This will often correspond to the number of
 | 
			
		||||
         *               items to consume.
 | 
			
		||||
         * @return The amount of fuel gained.
 | 
			
		||||
         */
 | 
			
		||||
        int refuel( @Nonnull ITurtleAccess turtle, @Nonnull ItemStack stack, int slot, int limit );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. 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,14 +1,14 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.client.render.TurtleModelLoader;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemDiskLegacy;
 | 
			
		||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtleBase;
 | 
			
		||||
import dan200.computercraft.shared.util.Colour;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
@@ -38,9 +38,9 @@ import javax.annotation.Nonnull;
 | 
			
		||||
 * Registers textures and models for items.
 | 
			
		||||
 */
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Side.CLIENT )
 | 
			
		||||
public final class ClientRegistry
 | 
			
		||||
public class ClientRegistry
 | 
			
		||||
{
 | 
			
		||||
    private static final String[] EXTRA_MODELS = new String[] {
 | 
			
		||||
    private static final String[] EXTRA_MODELS = {
 | 
			
		||||
        "turtle_modem_off_left",
 | 
			
		||||
        "turtle_modem_on_left",
 | 
			
		||||
        "turtle_modem_off_right",
 | 
			
		||||
@@ -58,8 +58,6 @@ public final class ClientRegistry
 | 
			
		||||
        "turtle_elf_overlay",
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    private ClientRegistry() {}
 | 
			
		||||
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public static void registerModels( ModelRegistryEvent event )
 | 
			
		||||
    {
 | 
			
		||||
@@ -119,7 +117,7 @@ public final class ClientRegistry
 | 
			
		||||
    public static void onItemColours( ColorHandlerEvent.Item event )
 | 
			
		||||
    {
 | 
			
		||||
        event.getItemColors().registerItemColorHandler(
 | 
			
		||||
            ( stack, layer ) -> layer == 1 ? ((ItemDiskLegacy) stack.getItem()).getColour( stack ) : 0xFFFFFF,
 | 
			
		||||
            ( stack, layer ) -> layer == 0 ? 0xFFFFFF : ((ItemDiskLegacy) stack.getItem()).getColour( stack ),
 | 
			
		||||
            ComputerCraft.Items.disk, ComputerCraft.Items.diskExpanded
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
@@ -129,21 +127,32 @@ public final class ClientRegistry
 | 
			
		||||
                case 0:
 | 
			
		||||
                default:
 | 
			
		||||
                    return 0xFFFFFF;
 | 
			
		||||
                case 1: // Frame colour
 | 
			
		||||
                    return ComputerCraft.Items.pocketComputer.getColour( stack );
 | 
			
		||||
                case 2: // Light colour
 | 
			
		||||
                case 1:
 | 
			
		||||
                {
 | 
			
		||||
                    int light = ItemPocketComputer.getLightState( stack );
 | 
			
		||||
                    return light == -1 ? Colour.Black.getHex() : light;
 | 
			
		||||
                    // Frame colour
 | 
			
		||||
                    int colour = ComputerCraft.Items.pocketComputer.getColour( stack );
 | 
			
		||||
                    return colour == -1 ? 0xFFFFFF : colour;
 | 
			
		||||
                }
 | 
			
		||||
                case 2:
 | 
			
		||||
                {
 | 
			
		||||
                    // Light colour
 | 
			
		||||
                    int colour = ComputerCraft.Items.pocketComputer.getLightState( stack );
 | 
			
		||||
                    return colour == -1 ? Colour.Black.getHex() : colour;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }, ComputerCraft.Items.pocketComputer );
 | 
			
		||||
 | 
			
		||||
        // Setup turtle colours
 | 
			
		||||
        event.getItemColors().registerItemColorHandler(
 | 
			
		||||
            ( stack, tintIndex ) -> tintIndex == 0 ? ((ItemTurtleBase) stack.getItem()).getColour( stack ) : 0xFFFFFF,
 | 
			
		||||
            ComputerCraft.Blocks.turtle, ComputerCraft.Blocks.turtleExpanded, ComputerCraft.Blocks.turtleAdvanced
 | 
			
		||||
        );
 | 
			
		||||
        event.getItemColors().registerItemColorHandler( ( stack, tintIndex ) -> {
 | 
			
		||||
            if( tintIndex == 0 )
 | 
			
		||||
            {
 | 
			
		||||
                ItemTurtleBase turtle = (ItemTurtleBase) stack.getItem();
 | 
			
		||||
                int colour = turtle.getColour( stack );
 | 
			
		||||
                if( colour != -1 ) return colour;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return 0xFFFFFF;
 | 
			
		||||
        }, ComputerCraft.Blocks.turtle, ComputerCraft.Blocks.turtleExpanded, ComputerCraft.Blocks.turtleAdvanced );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void registerItemModel( Item item, int damage, String name )
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.shared.command.text.ChatHelpers;
 | 
			
		||||
@@ -12,14 +13,12 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.gui.FontRenderer;
 | 
			
		||||
import net.minecraft.client.gui.GuiNewChat;
 | 
			
		||||
import net.minecraft.client.gui.GuiUtilRenderComponents;
 | 
			
		||||
import net.minecraft.util.math.MathHelper;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextFormatting;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class ClientTableFormatter implements TableFormatter
 | 
			
		||||
{
 | 
			
		||||
@@ -27,7 +26,7 @@ public class ClientTableFormatter implements TableFormatter
 | 
			
		||||
 | 
			
		||||
    private static Int2IntOpenHashMap lastHeights = new Int2IntOpenHashMap();
 | 
			
		||||
 | 
			
		||||
    private static FontRenderer renderer()
 | 
			
		||||
    private FontRenderer renderer()
 | 
			
		||||
    {
 | 
			
		||||
        return Minecraft.getMinecraft().fontRenderer;
 | 
			
		||||
    }
 | 
			
		||||
@@ -63,13 +62,7 @@ public class ClientTableFormatter implements TableFormatter
 | 
			
		||||
    @Override
 | 
			
		||||
    public void writeLine( int id, ITextComponent component )
 | 
			
		||||
    {
 | 
			
		||||
        Minecraft mc = Minecraft.getMinecraft();
 | 
			
		||||
        GuiNewChat chat = mc.ingameGUI.getChatGUI();
 | 
			
		||||
 | 
			
		||||
        // Trim the text if it goes over the allowed length
 | 
			
		||||
        int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getChatScale() );
 | 
			
		||||
        List<ITextComponent> list = GuiUtilRenderComponents.splitText( component, maxWidth, mc.fontRenderer, false, false );
 | 
			
		||||
        if( !list.isEmpty() ) chat.printChatMessageWithOptionalDeletion( list.get( 0 ), id );
 | 
			
		||||
        Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion( component, id );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user