mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-11-03 23:22:59 +00:00 
			
		
		
		
	Compare commits
	
		
			160 Commits
		
	
	
		
			v1.14.2-1.
			...
			v1.12.2-1.
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					2a8efb3fd5 | ||
| 
						 | 
					c0f3ca81fb | ||
| 
						 | 
					014bf55cd4 | ||
| 
						 | 
					085ae2e74a | ||
| 
						 | 
					4ff33f165d | ||
| 
						 | 
					d929c02d2a | ||
| 
						 | 
					d50a08a549 | ||
| 
						 | 
					161a5b4707 | ||
| 
						 | 
					c6b6b4479c | ||
| 
						 | 
					96e7b60285 | ||
| 
						 | 
					086fccd997 | ||
| 
						 | 
					a4ae36b6b3 | ||
| 
						 | 
					ac075d9f53 | ||
| 
						 | 
					05d7be0362 | ||
| 
						 | 
					9a71dc1a26 | ||
| 
						 | 
					156023b154 | ||
| 
						 | 
					6b3773a862 | ||
| 
						 | 
					376d628cf0 | ||
| 
						 | 
					44062ebd52 | ||
| 
						 | 
					5739285fc2 | ||
| 
						 | 
					70b457ed18 | ||
| 
						 | 
					1547ecbeb3 | ||
| 
						 | 
					550ada2f9e | ||
| 
						 | 
					17b7727262 | ||
| 
						 | 
					4553e404b2 | ||
| 
						 | 
					a565a571f9 | ||
| 
						 | 
					fb64b6017b | ||
| 
						 | 
					ed4229ab70 | ||
| 
						 | 
					3fb906ef6c | ||
| 
						 | 
					e1663f3df0 | ||
| 
						 | 
					447c3ab125 | ||
| 
						 | 
					8fac68386e | ||
| 
						 | 
					ae7ef66dfa | ||
| 
						 | 
					9748679484 | ||
| 
						 | 
					da419b24e7 | ||
| 
						 | 
					7f57a977a1 | ||
| 
						 | 
					2f42a4e85b | ||
| 
						 | 
					f3de97d67f | ||
| 
						 | 
					544f276ff0 | ||
| 
						 | 
					463635a459 | ||
| 
						 | 
					3b7b845930 | ||
| 
						 | 
					1fc0214857 | ||
| 
						 | 
					11bf601db9 | ||
| 
						 | 
					7c1154ddfc | ||
| 
						 | 
					cea8be7efa | ||
| 
						 | 
					c5f918ad95 | ||
| 
						 | 
					b14c7842fc | ||
| 
						 | 
					eead8b5755 | ||
| 
						 | 
					10a27a7a25 | ||
| 
						 | 
					865fc239a0 | ||
| 
						 | 
					f9f94b8304 | ||
| 
						 | 
					cb8135a0d1 | ||
| 
						 | 
					ef4b0a5632 | ||
| 
						 | 
					6a6a87489c | ||
| 
						 | 
					062977336a | ||
| 
						 | 
					e52d98ad8b | ||
| 
						 | 
					ef8da8054f | ||
| 
						 | 
					1ccd687c00 | ||
| 
						 | 
					a8ce5a5b20 | ||
| 
						 | 
					68e6bc464b | ||
| 
						 | 
					68762fe84c | ||
| 
						 | 
					0ffd5fcf85 | ||
| 
						 | 
					239bd769df | ||
| 
						 | 
					79f42e35ce | ||
| 
						 | 
					be89fc25f9 | ||
| 
						 | 
					8eae02c037 | ||
| 
						 | 
					930fd59298 | ||
| 
						 | 
					bf13bac152 | ||
| 
						 | 
					0de5969ec1 | ||
| 
						 | 
					3f98b2785e | ||
| 
						 | 
					798868427e | ||
| 
						 | 
					c79f643ba7 | ||
| 
						 | 
					1db3a14c54 | ||
| 
						 | 
					8b1773dd60 | ||
| 
						 | 
					018ecfbaa0 | ||
| 
						 | 
					4c8fd4fc35 | ||
| 
						 | 
					35c1b10224 | ||
| 
						 | 
					c1c01bef7c | ||
| 
						 | 
					a48c3d0ba8 | ||
| 
						 | 
					93a9ebc4f6 | ||
| 
						 | 
					7cc2bd43c6 | ||
| 
						 | 
					393e628721 | ||
| 
						 | 
					0bcd28e58c | ||
| 
						 | 
					42f5389fb8 | ||
| 
						 | 
					041cfe91b4 | ||
| 
						 | 
					0dde859582 | ||
| 
						 | 
					e59c043fb6 | ||
| 
						 | 
					ae928c4397 | ||
| 
						 | 
					da41c65128 | ||
| 
						 | 
					4d18234714 | ||
| 
						 | 
					d254c6464b | ||
| 
						 | 
					3a5d50e572 | ||
| 
						 | 
					03b6d2f1ab | ||
| 
						 | 
					b0397ed3c5 | ||
| 
						 | 
					fa70ebcac2 | ||
| 
						 | 
					86e0330100 | ||
| 
						 | 
					0ae70fed13 | ||
| 
						 | 
					121802a683 | ||
| 
						 | 
					08cf55e55f | ||
| 
						 | 
					3c8c0d78ef | ||
| 
						 | 
					c4d18aa9ca | ||
| 
						 | 
					a8fadabaf1 | ||
| 
						 | 
					38f9a015ca | ||
| 
						 | 
					c311cdc6f5 | ||
| 
						 | 
					a93e0f3284 | ||
| 
						 | 
					14b3065ba4 | ||
| 
						 | 
					c802290437 | ||
| 
						 | 
					418420523a | ||
| 
						 | 
					813e91073d | ||
| 
						 | 
					7250f22ff6 | ||
| 
						 | 
					db31a53bba | ||
| 
						 | 
					3023f235a4 | ||
| 
						 | 
					79cd8b4da5 | ||
| 
						 | 
					8e4d311cd9 | ||
| 
						 | 
					9bd8c86a94 | ||
| 
						 | 
					cbc0c1d0b6 | ||
| 
						 | 
					49c37857d4 | ||
| 
						 | 
					a802f25dd6 | ||
| 
						 | 
					a80302c513 | ||
| 
						 | 
					1c46949da7 | ||
| 
						 | 
					46d78af068 | ||
| 
						 | 
					eb5cff1045 | ||
| 
						 | 
					35c7792aa2 | ||
| 
						 | 
					521688d630 | ||
| 
						 | 
					75e2845c01 | ||
| 
						 | 
					2f96283286 | ||
| 
						 | 
					cbe6e9b5f5 | ||
| 
						 | 
					2ab79cf474 | ||
| 
						 | 
					6ce34aba79 | ||
| 
						 | 
					5eeb320b60 | ||
| 
						 | 
					93310850d2 | ||
| 
						 | 
					a2880b12ca | ||
| 
						 | 
					303b57779a | ||
| 
						 | 
					6279816ecc | ||
| 
						 | 
					4ae77261fa | ||
| 
						 | 
					4b7d843b78 | ||
| 
						 | 
					1c28df65c3 | ||
| 
						 | 
					85b740f484 | ||
| 
						 | 
					f9929cb27d | ||
| 
						 | 
					bafab1ac07 | ||
| 
						 | 
					e05c262468 | ||
| 
						 | 
					7a3f7d3bba | ||
| 
						 | 
					95aa48c456 | ||
| 
						 | 
					904a168d5c | ||
| 
						 | 
					724441eddc | ||
| 
						 | 
					f68ab3edd1 | ||
| 
						 | 
					29dce26bf6 | ||
| 
						 | 
					717ab69093 | ||
| 
						 | 
					138a2cf08f | ||
| 
						 | 
					81daf82647 | ||
| 
						 | 
					f3798bfb63 | ||
| 
						 | 
					bc07dfad2e | ||
| 
						 | 
					309cbdb8be | ||
| 
						 | 
					a0e7c4a74c | ||
| 
						 | 
					7d428030df | ||
| 
						 | 
					00c395f689 | ||
| 
						 | 
					d8e1c73d26 | ||
| 
						 | 
					ffa4cc241b | ||
| 
						 | 
					6f1b740c8f | ||
| 
						 | 
					3406ba3ebf | 
@@ -11,5 +11,12 @@ insert_final_newline = true
 | 
			
		||||
[*.md]
 | 
			
		||||
trim_trailing_whitespace = false
 | 
			
		||||
 | 
			
		||||
[*.sexp]
 | 
			
		||||
indent_size = 2
 | 
			
		||||
 | 
			
		||||
[*.yml]
 | 
			
		||||
indent_size = 2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[*.properties]
 | 
			
		||||
insert_final_newline = false
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										53
									
								
								.github/workflows/main-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								.github/workflows/main-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
    - name: Upload Coverage
 | 
			
		||||
      run: bash <(curl -s https://codecov.io/bash)
 | 
			
		||||
 | 
			
		||||
  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
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								.github/workflows/make-doc.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
#!/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
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								.github/workflows/make-doc.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
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,6 +3,8 @@
 | 
			
		||||
/logs
 | 
			
		||||
/build
 | 
			
		||||
/out
 | 
			
		||||
/doc/**/*.html
 | 
			
		||||
/doc/index.json
 | 
			
		||||
 | 
			
		||||
# Runtime directories
 | 
			
		||||
/run
 | 
			
		||||
@@ -15,3 +17,9 @@
 | 
			
		||||
.idea
 | 
			
		||||
.gradle
 | 
			
		||||
*.DS_Store
 | 
			
		||||
 | 
			
		||||
.classpath
 | 
			
		||||
.project
 | 
			
		||||
.settings/
 | 
			
		||||
bin/
 | 
			
		||||
*.launch
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								.luacheckrc
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								.luacheckrc
									
									
									
									
									
								
							@@ -1,34 +0,0 @@
 | 
			
		||||
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
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								.travis.yml
									
									
									
									
									
								
							@@ -1,14 +0,0 @@
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										36
									
								
								CONTRIBUTING.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								CONTRIBUTING.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
# Contributing to CC: Tweaked
 | 
			
		||||
As with many open source projects, CC: Tweaked thrives on contributions from other people! This document (hopefully)
 | 
			
		||||
provides an introduction as to how to get started in helping out.
 | 
			
		||||
 | 
			
		||||
If you've any other questions, [just ask the community][community] or [open an issue][new-issue].
 | 
			
		||||
 | 
			
		||||
## Reporting issues
 | 
			
		||||
If you have a bug, suggestion, or other feedback, the best thing to do is [file an issue][new-issue]. When doing so,
 | 
			
		||||
do use the issue templates - they provide a useful hint on what information to provide.
 | 
			
		||||
 | 
			
		||||
## Developing
 | 
			
		||||
In order to develop CC: Tweaked, you'll need to download the source code and then run it. This is a pretty simple
 | 
			
		||||
process.
 | 
			
		||||
 | 
			
		||||
 - **Clone the repository:** `git clone https://github.com/SquidDev-CC/CC-Tweaked.git && cd CC-Tweaked`
 | 
			
		||||
 - **Setup Forge:** `./gradlew setupDecompWorkspace`
 | 
			
		||||
 - **Run Minecraft:** `./gradlew runClient` (or run the `GradleStart` class from your IDE).
 | 
			
		||||
 | 
			
		||||
If you want to run CC:T in a normal Minecraft instance, run `./gradlew build` and copy the `.jar` from `build/libs`.
 | 
			
		||||
These commands may take a few minutes to run the first time, as the environment is set up, but should be much faster
 | 
			
		||||
afterwards.
 | 
			
		||||
 | 
			
		||||
### Code linters
 | 
			
		||||
CC: Tweaked uses a couple of "linters" on its source code, to enforce a consistent style across the project. While these
 | 
			
		||||
are run whenever you submit a PR, it's often useful to run this before committing.
 | 
			
		||||
 | 
			
		||||
 - **[Checkstyle]:** Checks Java code to ensure it is consistently formatted. This can be run with `./gradlew build` or
 | 
			
		||||
   `./gradle check`.
 | 
			
		||||
 - **[illuaminate]:** Checks Lua code for semantic and styleistic issues. See [the usage section][illuaminate-usage] for
 | 
			
		||||
   how to download and run it.
 | 
			
		||||
 | 
			
		||||
[new-issue]: https://github.com/SquidDev-CC/CC-Tweaked/issues/new/choose "Create a new issue"
 | 
			
		||||
[community]: README.md#Community "Get in touch with the community."
 | 
			
		||||
[checkstyle]: https://checkstyle.org/
 | 
			
		||||
[illuaminate]: https://github.com/SquidDev/illuaminate/
 | 
			
		||||
[illuaminate-usage]: https://github.com/SquidDev/illuaminate/blob/master/README.md#usage
 | 
			
		||||
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
# 
 | 
			
		||||
[](https://travis-ci.org/SquidDev-CC/CC-Tweaked "Current build status") [](https://minecraft.curseforge.com/projects/cc-tweaked "Download CC: Tweaked on CurseForge")
 | 
			
		||||
# 
 | 
			
		||||
[](https://github.com/SquidDev-CC/CC-Tweaked/actions "Current build status") [](https://minecraft.curseforge.com/projects/cc-tweaked "Download CC: Tweaked on CurseForge")
 | 
			
		||||
 | 
			
		||||
CC: Tweaked is a fork of [ComputerCraft](https://github.com/dan200/ComputerCraft), adding programmable computers,
 | 
			
		||||
turtles and more to Minecraft.
 | 
			
		||||
@@ -37,20 +37,14 @@ several features have been included, such as full block modems, the Cobalt runti
 | 
			
		||||
computers.
 | 
			
		||||
 | 
			
		||||
## Contributing
 | 
			
		||||
Any contribution is welcome, be that using the mod, reporting bugs or contributing code. In order to start helping
 | 
			
		||||
develop CC:T, you'll need to follow these steps:
 | 
			
		||||
 | 
			
		||||
 - **Clone the repository:** `git clone https://github.com/SquidDev-CC/CC-Tweaked.git && cd CC-Tweaked`
 | 
			
		||||
 - **Setup Forge:** `./gradlew setupDecompWorkspace`
 | 
			
		||||
 - **Test your changes:** `./gradlew runClient` (or run the `GradleStart` class from your IDE).
 | 
			
		||||
 | 
			
		||||
If you want to run CC:T in a normal Minecraft instance, run `./gradlew build` and copy the `.jar` from `build/libs`.
 | 
			
		||||
Any contribution is welcome, be that using the mod, reporting bugs or contributing code. If you want to get started
 | 
			
		||||
developing the mod, [check out the instructions here](CONTRIBUTING.md#developing).
 | 
			
		||||
 | 
			
		||||
## Community
 | 
			
		||||
If you need help getting started with CC: Tweaked, want to show off your latest project, or just want to chat about
 | 
			
		||||
ComputerCraft we have a [forum](https://forums.computercraft.cc/) and [Discord guild](https://discord.gg/H2UyJXe)!
 | 
			
		||||
There's also a fairly populated, albeit quiet [IRC channel](http://webchat.esper.net/?channels=#computercraft), if
 | 
			
		||||
that's more your cup of tea.
 | 
			
		||||
ComputerCraft we have a [forum](https://forums.computercraft.cc/) and [Discord guild](https://discord.computercraft.cc)!
 | 
			
		||||
There's also a fairly populated, albeit quiet [IRC channel](http://webchat.esper.net/?channels=computercraft), if that's
 | 
			
		||||
more your cup of tea.
 | 
			
		||||
 | 
			
		||||
I'd generally recommend you don't contact me directly (email, DM, etc...) unless absolutely necessary (i.e. in order to
 | 
			
		||||
report exploits). You'll get a far quicker response if you ask the whole community!
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										217
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										217
									
								
								build.gradle
									
									
									
									
									
								
							@@ -1,17 +1,30 @@
 | 
			
		||||
 | 
			
		||||
// For those who want the bleeding edge
 | 
			
		||||
buildscript {
 | 
			
		||||
    repositories {
 | 
			
		||||
        jcenter()
 | 
			
		||||
        maven {
 | 
			
		||||
            name = "forge"
 | 
			
		||||
            url = "https://files.minecraftforge.net/maven"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    dependencies {
 | 
			
		||||
        classpath 'com.google.code.gson:gson:2.8.1'
 | 
			
		||||
        classpath 'net.sf.proguard:proguard-gradle:6.1.0beta2'
 | 
			
		||||
        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 'fabric-loom' version '0.2.3-SNAPSHOT'
 | 
			
		||||
    id 'com.matthewprenger.cursegradle' version '1.2.0'
 | 
			
		||||
    id "checkstyle"
 | 
			
		||||
    id "jacoco"
 | 
			
		||||
    id "com.github.hierynomus.license" version "0.15.0"
 | 
			
		||||
    id "com.matthewprenger.cursegradle" version "1.3.0"
 | 
			
		||||
    id "com.github.breadmoirai.github-release" version "2.2.4"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
apply plugin: 'net.minecraftforge.gradle.forge'
 | 
			
		||||
apply plugin: 'org.ajoberstar.grgit'
 | 
			
		||||
apply plugin: 'maven-publish'
 | 
			
		||||
apply plugin: 'maven'
 | 
			
		||||
@@ -22,14 +35,15 @@ group = "org.squiddev"
 | 
			
		||||
archivesBaseName = "cc-tweaked-${mc_version}"
 | 
			
		||||
 | 
			
		||||
minecraft {
 | 
			
		||||
    version = "${mc_version}-${forge_version}"
 | 
			
		||||
    runDir = "run"
 | 
			
		||||
    replace '${version}', mod_version
 | 
			
		||||
 | 
			
		||||
    mappings = mappings_version
 | 
			
		||||
    makeObfSourceJar = false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    mavenCentral()
 | 
			
		||||
    maven {
 | 
			
		||||
        name "JEI"
 | 
			
		||||
        url  "http://dvs1.progwml6.com/files/maven"
 | 
			
		||||
    }
 | 
			
		||||
    maven {
 | 
			
		||||
        name "SquidDev"
 | 
			
		||||
        url "https://squiddev.cc/maven"
 | 
			
		||||
@@ -40,7 +54,11 @@ repositories {
 | 
			
		||||
    }
 | 
			
		||||
    maven {
 | 
			
		||||
        name "Amadornes"
 | 
			
		||||
        url "http://maven.amadornes.com/"
 | 
			
		||||
        url "https://maven.amadornes.com/"
 | 
			
		||||
    }
 | 
			
		||||
    maven {
 | 
			
		||||
        name "CraftTweaker"
 | 
			
		||||
        url "https://maven.blamejared.com/"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -51,29 +69,24 @@ configurations {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
    minecraft "com.mojang:minecraft:${mc_version}"
 | 
			
		||||
    mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}"
 | 
			
		||||
    modCompile "net.fabricmc:fabric-loader:0.4.8+build.153"
 | 
			
		||||
    modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0+build.175"
 | 
			
		||||
    checkstyle "com.puppycrawl.tools:checkstyle:8.25"
 | 
			
		||||
 | 
			
		||||
    implementation 'com.google.code.findbugs:jsr305:3.0.2'
 | 
			
		||||
    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 "pl.asie:Charset-Lib:0.5.4.6"
 | 
			
		||||
 | 
			
		||||
    shade 'org.squiddev:Cobalt:0.5.0-SNAPSHOT'
 | 
			
		||||
    shade 'javax.vecmath:vecmath:1.5.2'
 | 
			
		||||
    runtime "mezz.jei:jei_1.12.2:4.15.0.269"
 | 
			
		||||
 | 
			
		||||
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
 | 
			
		||||
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
 | 
			
		||||
    shade 'org.squiddev:Cobalt:0.5.1-SNAPSHOT'
 | 
			
		||||
 | 
			
		||||
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
 | 
			
		||||
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
 | 
			
		||||
 | 
			
		||||
    deployerJars "org.apache.maven.wagon:wagon-ssh:3.0.0"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sourceSets {
 | 
			
		||||
    main {
 | 
			
		||||
        java {
 | 
			
		||||
            exclude 'dan200/computercraft/shared/integration'
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
// Compile tasks
 | 
			
		||||
 | 
			
		||||
javadoc {
 | 
			
		||||
    include "dan200/computercraft/api/**/*.java"
 | 
			
		||||
@@ -83,13 +96,7 @@ jar {
 | 
			
		||||
    dependsOn javadoc
 | 
			
		||||
 | 
			
		||||
    manifest {
 | 
			
		||||
        attributes(["Specification-Title": "computercraft",
 | 
			
		||||
                    "Specification-Vendor": "SquidDev",
 | 
			
		||||
                    "Specification-Version": "25.0",
 | 
			
		||||
                    "Implementation-Title": "CC: Tweaked",
 | 
			
		||||
                    "Implementation-Version": "${mod_version}",
 | 
			
		||||
                    "Implementation-Vendor" :"SquidDev",
 | 
			
		||||
                    "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
 | 
			
		||||
        attributes('FMLAT': 'computercraft_at.cfg')
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    from (sourceSets.main.allSource) {
 | 
			
		||||
@@ -99,12 +106,22 @@ jar {
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
@@ -112,14 +129,12 @@ task proguard(type: ProGuardTask, dependsOn: jar) {
 | 
			
		||||
    description "Removes unused shadowed classes from the jar"
 | 
			
		||||
    group "compact"
 | 
			
		||||
 | 
			
		||||
    afterEvaluate {
 | 
			
		||||
        // Fabric changes the jar's classifier so we to do this after evaluating!
 | 
			
		||||
        injars jar.archivePath
 | 
			
		||||
        outjars "${jar.archivePath.absolutePath.replace(".jar", "")}-min.jar"
 | 
			
		||||
    }
 | 
			
		||||
    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") }
 | 
			
		||||
@@ -130,17 +145,10 @@ task proguard(type: ProGuardTask, dependsOn: jar) {
 | 
			
		||||
    dontobfuscate; dontoptimize; keepattributes; keepparameternames
 | 
			
		||||
 | 
			
		||||
    // Proguard will remove directories by default, but that breaks JarMount.
 | 
			
		||||
    keepdirectories 'data/computercraft/lua**'
 | 
			
		||||
    keepdirectories 'assets/computercraft/lua**'
 | 
			
		||||
 | 
			
		||||
    // Preserve ComputerCraft classes - we only want to strip shadowed files.
 | 
			
		||||
    keep 'class dan200.computercraft.** { *; }'
 | 
			
		||||
 | 
			
		||||
    // Preserve the constructors in Cobalt library class, as we init them via reflection
 | 
			
		||||
    keepclassmembers 'class org.squiddev.cobalt.lib.** { <init>(...); }'
 | 
			
		||||
 | 
			
		||||
    // LWJGL and Apache bundle Java 9 versions, which is great, but rather breaks Proguard
 | 
			
		||||
    dontwarn 'module-info'
 | 
			
		||||
    dontwarn 'org.apache.**,org.lwjgl.**,javax.crypto.SecretKey'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
task proguardMove(dependsOn: proguard) {
 | 
			
		||||
@@ -156,7 +164,7 @@ task proguardMove(dependsOn: proguard) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
remapJar.dependsOn proguardMove
 | 
			
		||||
reobfJar.dependsOn proguardMove
 | 
			
		||||
 | 
			
		||||
processResources {
 | 
			
		||||
    inputs.property "version", mod_version
 | 
			
		||||
@@ -178,8 +186,8 @@ processResources {
 | 
			
		||||
    inputs.property "commithash", hash
 | 
			
		||||
 | 
			
		||||
    from(sourceSets.main.resources.srcDirs) {
 | 
			
		||||
        include 'fabric.mod.json'
 | 
			
		||||
        include 'data/computercraft/lua/rom/help/credits.txt'
 | 
			
		||||
        include 'mcmod.info'
 | 
			
		||||
        include 'assets/computercraft/lua/rom/help/credits.txt'
 | 
			
		||||
 | 
			
		||||
        expand 'version': mod_version,
 | 
			
		||||
               'mcversion': mc_version,
 | 
			
		||||
@@ -187,12 +195,12 @@ processResources {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    from(sourceSets.main.resources.srcDirs) {
 | 
			
		||||
        exclude 'fabric.mod.json'
 | 
			
		||||
        exclude 'data/computercraft/lua/rom/help/credits.txt'
 | 
			
		||||
        exclude 'mcmod.info'
 | 
			
		||||
        exclude 'assets/computercraft/lua/rom/help/credits.txt'
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
task compressJson(dependsOn: remapJar) {
 | 
			
		||||
task compressJson(dependsOn: extractAnnotationsJar) {
 | 
			
		||||
    group "compact"
 | 
			
		||||
    description "Minifies all JSON files, stripping whitespace"
 | 
			
		||||
 | 
			
		||||
@@ -207,6 +215,7 @@ task compressJson(dependsOn: remapJar) {
 | 
			
		||||
        // 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) {
 | 
			
		||||
@@ -234,19 +243,78 @@ task compressJson(dependsOn: remapJar) {
 | 
			
		||||
 | 
			
		||||
assemble.dependsOn compressJson
 | 
			
		||||
 | 
			
		||||
// Check tasks
 | 
			
		||||
 | 
			
		||||
test {
 | 
			
		||||
    useJUnitPlatform()
 | 
			
		||||
    testLogging {
 | 
			
		||||
        events "skipped", "failed"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
jacocoTestReport {
 | 
			
		||||
    reports {
 | 
			
		||||
        xml.enabled true
 | 
			
		||||
        html.enabled true
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check.dependsOn jacocoTestReport
 | 
			
		||||
 | 
			
		||||
license {
 | 
			
		||||
    mapping("java", "SLASHSTAR_STYLE")
 | 
			
		||||
    strictCheck true
 | 
			
		||||
 | 
			
		||||
    ext.year = Calendar.getInstance().get(Calendar.YEAR)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[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/data/computercraft/lua/rom/help/changelog.txt")
 | 
			
		||||
    inputs.file("src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt")
 | 
			
		||||
    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/data/computercraft/lua/rom/help/whatsnew.txt").readLines()
 | 
			
		||||
        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.")
 | 
			
		||||
@@ -263,7 +331,7 @@ task checkRelease {
 | 
			
		||||
 | 
			
		||||
        // Check whatsnew and changelog match.
 | 
			
		||||
        def versionChangelog = "# " + whatsnew.join("\n")
 | 
			
		||||
        def changelog = new File("src/main/resources/data/computercraft/lua/rom/help/changelog.txt").getText()
 | 
			
		||||
        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")
 | 
			
		||||
@@ -272,28 +340,18 @@ task checkRelease {
 | 
			
		||||
        if (!ok) throw new IllegalStateException("Could not check release")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check.dependsOn checkRelease
 | 
			
		||||
 | 
			
		||||
curseforge {
 | 
			
		||||
    apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
 | 
			
		||||
    project {
 | 
			
		||||
        id = '282001'
 | 
			
		||||
        addGameVersion '1.14.2'
 | 
			
		||||
        releaseType = 'beta'
 | 
			
		||||
        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"
 | 
			
		||||
            requiredDependency "fabric"
 | 
			
		||||
        }
 | 
			
		||||
        afterEvaluate {
 | 
			
		||||
            mainArtifact(remapJar.output)
 | 
			
		||||
            uploadTask.dependsOn(remapJar)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    options {
 | 
			
		||||
        forgeGradleIntegration = false
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -301,7 +359,7 @@ publishing {
 | 
			
		||||
    publications {
 | 
			
		||||
        mavenJava(MavenPublication) {
 | 
			
		||||
            from components.java
 | 
			
		||||
            // artifact sourceJar
 | 
			
		||||
            artifact sourceJar
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -354,12 +412,14 @@ githubRelease {
 | 
			
		||||
    token project.hasProperty('githubApiKey') ? project.githubApiKey : ''
 | 
			
		||||
    owner 'SquidDev-CC'
 | 
			
		||||
    repo 'CC-Tweaked'
 | 
			
		||||
    targetCommitish { Grgit.open(dir: '.').branch.current().name }
 | 
			
		||||
    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/data/computercraft/lua/rom/help/whatsnew.txt")
 | 
			
		||||
        "## " + 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()
 | 
			
		||||
@@ -370,21 +430,10 @@ githubRelease {
 | 
			
		||||
def uploadTasks = ["uploadArchives", "curseforge", "githubRelease"]
 | 
			
		||||
uploadTasks.forEach { tasks.getByName(it).dependsOn checkRelease }
 | 
			
		||||
 | 
			
		||||
task uploadAll(dependsOn: [remapJar] + uploadTasks) {
 | 
			
		||||
task uploadAll(dependsOn: uploadTasks) {
 | 
			
		||||
    group "upload"
 | 
			
		||||
    description "Uploads to all repositories (Maven, Curse, GitHub release)"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test {
 | 
			
		||||
    useJUnitPlatform()
 | 
			
		||||
    testLogging {
 | 
			
		||||
        events "passed", "skipped", "failed"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gradle.projectsEvaluated {
 | 
			
		||||
    tasks.withType(JavaCompile) {
 | 
			
		||||
        options.compilerArgs << "-Xlint" << "-Xlint:-processing" // Causes Forge build to fail << "-Werror"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
runClient.outputs.upToDateWhen { false }
 | 
			
		||||
runServer.outputs.upToDateWhen { false }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										169
									
								
								config/checkstyle/checkstyle.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										169
									
								
								config/checkstyle/checkstyle.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,169 @@
 | 
			
		||||
<?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>
 | 
			
		||||
							
								
								
									
										12
									
								
								config/checkstyle/suppressions.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								config/checkstyle/suppressions.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
<?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>
 | 
			
		||||
							
								
								
									
										3
									
								
								config/license/api.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								config/license/api.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
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.
 | 
			
		||||
							
								
								
									
										3
									
								
								config/license/main.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								config/license/main.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
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
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								doc/index.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
#  [](https://minecraft.curseforge.com/projects/cc-tweaked "Download CC: Tweaked on CurseForge")
 | 
			
		||||
 | 
			
		||||
CC: Tweaked is a fork of [ComputerCraft], adding programmable computers, turtles and more to Minecraft.
 | 
			
		||||
 | 
			
		||||
This website contains documentation for all Lua libraries and APIs from the latest version of CC: Tweaked. This
 | 
			
		||||
documentation is still in development, so will most likely be incomplete. If you've found something you think is wrong,
 | 
			
		||||
or would like to help out [please get in touch on GitHub][gh].
 | 
			
		||||
 | 
			
		||||
[bug]: https://github.com/SquidDev-CC/CC-Tweaked/issues/new/choose
 | 
			
		||||
[computercraft]: https://github.com/dan200/ComputerCraft "ComputerCraft on GitHub"
 | 
			
		||||
[gh]: https://github.com/SquidDev-CC/CC-Tweaked "CC:Tweaked on GitHub"
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB  | 
							
								
								
									
										77
									
								
								doc/stub/commands.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								doc/stub/commands.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
--- Execute a specific command.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string command The command to execute.
 | 
			
		||||
-- @treturn boolean Whether the command executed successfully.
 | 
			
		||||
-- @treturn { string... } The output of this command, as a list of lines.
 | 
			
		||||
-- @treturn number|nil The number of "affected" objects, or `nil` if the command
 | 
			
		||||
-- failed. The definition of this varies from command to command.
 | 
			
		||||
-- @usage Set the block above the command computer to stone.
 | 
			
		||||
--
 | 
			
		||||
--     commands.exec("setblock ~ ~1 ~ minecraft:stone")
 | 
			
		||||
function exec(command) end
 | 
			
		||||
 | 
			
		||||
--- Asynchronously execute a command.
 | 
			
		||||
--
 | 
			
		||||
-- Unlike @{exec}, this will immediately return, instead of waiting for the
 | 
			
		||||
-- command to execute. This allows you to run multiple commands at the same
 | 
			
		||||
-- time.
 | 
			
		||||
--
 | 
			
		||||
-- When this command has finished executing, it will queue a `task_complete`
 | 
			
		||||
-- event containing the result of executing this command (what @{exec} would
 | 
			
		||||
-- return).
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string command The command to execute.
 | 
			
		||||
-- @treturn number The "task id". When this command has been executed, it will
 | 
			
		||||
-- queue a `task_complete` event with a matching id.
 | 
			
		||||
-- @usage Asynchronously sets the block above the computer to stone.
 | 
			
		||||
--
 | 
			
		||||
--     commands.execAsync("~ ~1 ~ minecraft:stone")
 | 
			
		||||
-- @see parallel One may also use the parallel API to run multiple commands at
 | 
			
		||||
-- once.
 | 
			
		||||
function execAsync(commad) end
 | 
			
		||||
 | 
			
		||||
--- List all available commands which the computer has permission to execute.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn { string... } A list of all available commands
 | 
			
		||||
function list() end
 | 
			
		||||
 | 
			
		||||
--- Get the position of the current command computer.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn number This computer's x position.
 | 
			
		||||
-- @treturn number This computer's y position.
 | 
			
		||||
-- @treturn number This computer's z position.
 | 
			
		||||
-- @see gps.locate To get the position of a non-command computer.
 | 
			
		||||
function getBlockPosition() end
 | 
			
		||||
 | 
			
		||||
--- Get some basic information about a block.
 | 
			
		||||
--
 | 
			
		||||
-- The returned table contains the current name, metadata and block state (as
 | 
			
		||||
-- with @{turtle.inspect}). If there is a tile entity for that block, its NBT
 | 
			
		||||
-- will also be returned.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam number x The x position of the block to query.
 | 
			
		||||
-- @tparam number y The y position of the block to query.
 | 
			
		||||
-- @tparam number z The z position of the block to query.
 | 
			
		||||
-- @treturn table The given block's information.
 | 
			
		||||
-- @throws If the coordinates are not within the world, or are not currently
 | 
			
		||||
-- loaded.
 | 
			
		||||
function getBlockInfo(x, y, z) end
 | 
			
		||||
 | 
			
		||||
--- Get information about a range of blocks.
 | 
			
		||||
--
 | 
			
		||||
-- This returns the same information as @{getBlockInfo}, just for multiple
 | 
			
		||||
-- blocks at once.
 | 
			
		||||
--
 | 
			
		||||
-- Blocks are traversed by ascending y level, followed by z and x - the returned
 | 
			
		||||
-- table may be indexed using `x + z*width + y*depth*depth`.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam number min_x The start x coordinate of the range to query.
 | 
			
		||||
-- @tparam number min_y The start y coordinate of the range to query.
 | 
			
		||||
-- @tparam number min_z The start z coordinate of the range to query.
 | 
			
		||||
-- @tparam number max_x The end x coordinate of the range to query.
 | 
			
		||||
-- @tparam number max_y The end y coordinate of the range to query.
 | 
			
		||||
-- @tparam number max_z The end z coordinate of the range to query.
 | 
			
		||||
-- @treturn { table... } A list of information about each block.
 | 
			
		||||
-- @throws If the coordinates are not within the world.
 | 
			
		||||
-- @throws If trying to get information about more than 4096 blocks.
 | 
			
		||||
function getBlockInfos(min_x, min_y, min_z, max_x, max_y, max_z) end
 | 
			
		||||
							
								
								
									
										84
									
								
								doc/stub/fs.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								doc/stub/fs.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,84 @@
 | 
			
		||||
---  The FS API allows you to manipulate files and the filesystem.
 | 
			
		||||
--
 | 
			
		||||
-- @module fs
 | 
			
		||||
 | 
			
		||||
function list(path) end
 | 
			
		||||
function combine(base, child) end
 | 
			
		||||
function getName(path) end
 | 
			
		||||
function getSize(path) end
 | 
			
		||||
function exists(path) end
 | 
			
		||||
function isDir(path) end
 | 
			
		||||
function isReadOnly(path) end
 | 
			
		||||
function makeDir(path) end
 | 
			
		||||
function move(from, to) end
 | 
			
		||||
function copy(from, to) end
 | 
			
		||||
function delete(path) end
 | 
			
		||||
function open(path, mode) end
 | 
			
		||||
function getDrive(path) end
 | 
			
		||||
function getFreeSpace(path) end
 | 
			
		||||
function find(pattern) end
 | 
			
		||||
function getDir(path) end
 | 
			
		||||
 | 
			
		||||
--- Returns true if a path is mounted to the parent filesystem.
 | 
			
		||||
--
 | 
			
		||||
-- The root filesystem "/" is considered a mount, along with disk folders and
 | 
			
		||||
-- the rom folder. Other programs (such as network shares) can exstend this to
 | 
			
		||||
-- make other mount types by correctly assigning their return value for getDrive.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string path The path to check.
 | 
			
		||||
-- @treturn boolean If the path is mounted, rather than a normal file/folder.
 | 
			
		||||
-- @throws If the path does not exist.
 | 
			
		||||
-- @see getDrive
 | 
			
		||||
function isDriveRoot(path) end
 | 
			
		||||
 | 
			
		||||
--- Get the capacity of the drive at the given path.
 | 
			
		||||
--
 | 
			
		||||
-- This may be used in conjunction with @{getFreeSpace} to determine what
 | 
			
		||||
-- percentage of this drive has been used.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string path The path of the drive to get.
 | 
			
		||||
-- @treturn number This drive's capacity. This will be 0 for "read-only" drives,
 | 
			
		||||
-- such as the ROM or treasure disks.
 | 
			
		||||
function getCapacity(path) end
 | 
			
		||||
 | 
			
		||||
--- Get attributes about a specific file or folder.
 | 
			
		||||
--
 | 
			
		||||
-- The returned attributes table contains information about the size of the
 | 
			
		||||
-- file, whether it is a directory, and when it was created and last modified.
 | 
			
		||||
--
 | 
			
		||||
-- The creation and modification times are given as the number of milliseconds
 | 
			
		||||
-- since the UNIX epoch. This may be given to @{os.date} in order to convert it
 | 
			
		||||
-- to more usable form.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string path The path to get attributes for.
 | 
			
		||||
-- @treturn { size = number, isDir = boolean, created = number, modified = number }
 | 
			
		||||
-- The resulting attributes.
 | 
			
		||||
-- @throws If the path does not exist.
 | 
			
		||||
-- @see getSize If you only care about the file's size.
 | 
			
		||||
-- @see isDir If you only care whether a path is a directory or not.
 | 
			
		||||
function attributes(path) end
 | 
			
		||||
 | 
			
		||||
-- Defined in bios.lua
 | 
			
		||||
function complete(sPath, sLocation, bIncludeFiles, bIncludeDirs) end
 | 
			
		||||
 | 
			
		||||
--- A file handle which can be read from.
 | 
			
		||||
--
 | 
			
		||||
-- @type ReadHandle
 | 
			
		||||
-- @see fs.open
 | 
			
		||||
local ReadHandle = {}
 | 
			
		||||
function ReadHandle.read(count) end
 | 
			
		||||
function ReadHandle.readAll() end
 | 
			
		||||
function ReadHandle.readLine(with_trailing) end
 | 
			
		||||
function ReadHandle.seek(whence, offset) end
 | 
			
		||||
function ReadHandle.close() end
 | 
			
		||||
 | 
			
		||||
--- A file handle which can be written to.
 | 
			
		||||
--
 | 
			
		||||
-- @type WriteHandle
 | 
			
		||||
-- @see fs.open
 | 
			
		||||
local WriteHandle = {}
 | 
			
		||||
function WriteHandle.write(text) end
 | 
			
		||||
function WriteHandle.writeLine(text) end
 | 
			
		||||
function WriteHandle.flush(text) end
 | 
			
		||||
function WriteHandle.seek(whence, offset) end
 | 
			
		||||
function WriteHandle.close() end
 | 
			
		||||
							
								
								
									
										229
									
								
								doc/stub/http.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										229
									
								
								doc/stub/http.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,229 @@
 | 
			
		||||
--- The http library allows communicating with web servers, sending and
 | 
			
		||||
-- receiving data from them.
 | 
			
		||||
--
 | 
			
		||||
-- #### `http_check` event
 | 
			
		||||
--
 | 
			
		||||
-- @module http
 | 
			
		||||
 | 
			
		||||
--- Asynchronously make a HTTP request to the given url.
 | 
			
		||||
--
 | 
			
		||||
-- This returns immediately, a [`http_success`](#http-success-event) or
 | 
			
		||||
-- [`http_failure`](#http-failure-event) will be queued once the request has
 | 
			
		||||
-- completed.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam      string url   The url to request
 | 
			
		||||
-- @tparam[opt] string body  An optional string containing the body of the
 | 
			
		||||
-- request. If specified, a `POST` request will be made instead.
 | 
			
		||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
 | 
			
		||||
-- of this request.
 | 
			
		||||
-- @tparam[opt] boolean binary Whether to make a binary HTTP request. If true,
 | 
			
		||||
-- the body will not be UTF-8 encoded, and the received response will not be
 | 
			
		||||
-- decoded.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[2] {
 | 
			
		||||
--   url = string, body? = string, headers? = { [string] = string },
 | 
			
		||||
--   binary? = boolean, method? = string, redirect? = boolean,
 | 
			
		||||
-- } request Options for the request.
 | 
			
		||||
--
 | 
			
		||||
-- This table form is an expanded version of the previous syntax. All arguments
 | 
			
		||||
-- from above are passed in as fields instead (for instance,
 | 
			
		||||
-- `http.request("https://example.com")` becomes `http.request { url =
 | 
			
		||||
-- "https://example.com" }`).
 | 
			
		||||
--
 | 
			
		||||
-- This table also accepts several additional options:
 | 
			
		||||
--
 | 
			
		||||
--  - `method`: Which HTTP method to use, for instance `"PATCH"` or `"DELETE"`.
 | 
			
		||||
--  - `redirect`: Whether to follow HTTP redirects. Defaults to true.
 | 
			
		||||
--
 | 
			
		||||
-- @see http.get  For a synchronous way to make GET requests.
 | 
			
		||||
-- @see http.post For a synchronous way to make POST requests.
 | 
			
		||||
function request(...) end
 | 
			
		||||
 | 
			
		||||
--- Make a HTTP GET request to the given url.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string url   The url to request
 | 
			
		||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
 | 
			
		||||
-- of this request.
 | 
			
		||||
-- @tparam[opt] boolean binary Whether to make a binary HTTP request. If true,
 | 
			
		||||
-- the body will not be UTF-8 encoded, and the received response will not be
 | 
			
		||||
-- decoded.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[2] {
 | 
			
		||||
--   url = string, headers? = { [string] = string },
 | 
			
		||||
--   binary? = boolean, method? = string, redirect? = boolean,
 | 
			
		||||
-- } request Options for the request. See @{http.request} for details on how
 | 
			
		||||
-- these options behave.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn Response The resulting http response, which can be read from.
 | 
			
		||||
-- @treturn[2] nil When the http request failed, such as in the event of a 404
 | 
			
		||||
-- error or connection timeout.
 | 
			
		||||
-- @treturn string A message detailing why the request failed.
 | 
			
		||||
-- @treturn Response|nil The failing http response, if available.
 | 
			
		||||
--
 | 
			
		||||
-- @usage Make a request to [example.computercraft.cc](https://example.computercraft.cc),
 | 
			
		||||
-- and print the returned page.
 | 
			
		||||
-- ```lua
 | 
			
		||||
-- local request = http.get("https://example.computercraft.cc")
 | 
			
		||||
-- print(request.readAll())
 | 
			
		||||
-- -- => HTTP is working!
 | 
			
		||||
-- request.close()
 | 
			
		||||
-- ```
 | 
			
		||||
function get(...) end
 | 
			
		||||
 | 
			
		||||
--- Make a HTTP POST request to the given url.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string url   The url to request
 | 
			
		||||
-- @tparam string body  The body of the POST request.
 | 
			
		||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
 | 
			
		||||
-- of this request.
 | 
			
		||||
-- @tparam[opt] boolean binary Whether to make a binary HTTP request. If true,
 | 
			
		||||
-- the body will not be UTF-8 encoded, and the received response will not be
 | 
			
		||||
-- decoded.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[2] {
 | 
			
		||||
--   url = string, body? = string, headers? = { [string] = string },
 | 
			
		||||
--   binary? = boolean, method? = string, redirect? = boolean,
 | 
			
		||||
-- } request Options for the request. See @{http.request} for details on how
 | 
			
		||||
-- these options behave.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn Response The resulting http response, which can be read from.
 | 
			
		||||
-- @treturn[2] nil When the http request failed, such as in the event of a 404
 | 
			
		||||
-- error or connection timeout.
 | 
			
		||||
-- @treturn string A message detailing why the request failed.
 | 
			
		||||
-- @treturn Response|nil The failing http response, if available.
 | 
			
		||||
function post(...) end
 | 
			
		||||
 | 
			
		||||
--- A http response. This acts very much like a @{fs.ReadHandle|file}, though
 | 
			
		||||
-- provides some http specific methods.
 | 
			
		||||
--
 | 
			
		||||
-- #### `http_success` event
 | 
			
		||||
-- #### `http_failure` event
 | 
			
		||||
--
 | 
			
		||||
-- @type Response
 | 
			
		||||
-- @see http.request On how to make a http request.
 | 
			
		||||
local Response = {}
 | 
			
		||||
 | 
			
		||||
--- Returns the response code and response message returned by the server
 | 
			
		||||
--
 | 
			
		||||
-- @treturn number The response code (i.e. 200)
 | 
			
		||||
-- @treturn string The response message (i.e. "OK")
 | 
			
		||||
function Response.getResponseCode() end
 | 
			
		||||
 | 
			
		||||
--- Get a table containing the response's headers, in a format similar to that
 | 
			
		||||
-- required by @{http.request}. If multiple headers are sent with the same
 | 
			
		||||
-- name, they will be combined with a comma.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn { [string]=string } The response's headers.
 | 
			
		||||
-- Make a request to [example.computercraft.cc](https://example.computercraft.cc),
 | 
			
		||||
-- and print the returned headers.
 | 
			
		||||
-- ```lua
 | 
			
		||||
-- local request = http.get("https://example.computercraft.cc")
 | 
			
		||||
-- print(textutils.serialize(request.getResponseHeaders()))
 | 
			
		||||
-- -- => {
 | 
			
		||||
-- --   [ "Content-Type" ] = "text/plain; charset=utf8",
 | 
			
		||||
-- --   [ "content-length" ] = 17,
 | 
			
		||||
-- --   ...
 | 
			
		||||
-- -- }
 | 
			
		||||
-- request.close()
 | 
			
		||||
-- ```
 | 
			
		||||
function Response.getResponseHeaders() end
 | 
			
		||||
 | 
			
		||||
function Response.read(count) end
 | 
			
		||||
function Response.readAll() end
 | 
			
		||||
function Response.readLine(with_trailing) end
 | 
			
		||||
function Response.seek(whence, offset) end
 | 
			
		||||
function Response.close() end
 | 
			
		||||
 | 
			
		||||
--- Asynchronously determine whether a URL can be requested.
 | 
			
		||||
--
 | 
			
		||||
-- If this returns `true`, one should also listen for [`http_check`
 | 
			
		||||
-- events](#http-check-event) which will container further information about
 | 
			
		||||
-- whether the URL is allowed or not.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string url The URL to check.
 | 
			
		||||
-- @treturn true When this url is not invalid. This does not imply that it is
 | 
			
		||||
-- allowed - see the comment above.
 | 
			
		||||
-- @treturn[2] false When this url is invalid.
 | 
			
		||||
-- @treturn string A reason why this URL is not valid (for instance, if it is
 | 
			
		||||
-- malformed, or blocked).
 | 
			
		||||
--
 | 
			
		||||
-- @see http.checkURL For a synchronous version.
 | 
			
		||||
function checkURLAsync(url) end
 | 
			
		||||
 | 
			
		||||
--- Determine whether a URL can be requested.
 | 
			
		||||
--
 | 
			
		||||
-- If this returns `true`, one should also listen for [`http_check`
 | 
			
		||||
-- events](#http-check-event) which will container further information about
 | 
			
		||||
-- whether the URL is allowed or not.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string url The URL to check.
 | 
			
		||||
-- @treturn true When this url is valid and can be requested via @{http.request}.
 | 
			
		||||
-- @treturn[2] false When this url is invalid.
 | 
			
		||||
-- @treturn string A reason why this URL is not valid (for instance, if it is
 | 
			
		||||
-- malformed, or blocked).
 | 
			
		||||
--
 | 
			
		||||
-- @see http.checkURLAsync For an asynchronous version.
 | 
			
		||||
--
 | 
			
		||||
-- @usage
 | 
			
		||||
-- ```lua
 | 
			
		||||
-- print(http.checkURL("https://example.computercraft.cc/"))
 | 
			
		||||
-- -- => true
 | 
			
		||||
-- print(http.checkURL("http://localhost/"))
 | 
			
		||||
-- -- => false Domain not permitted
 | 
			
		||||
-- print(http.checkURL("not a url"))
 | 
			
		||||
-- -- => false URL malformed
 | 
			
		||||
-- ```
 | 
			
		||||
function checkURL(url) end
 | 
			
		||||
 | 
			
		||||
--- Open a websocket.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string url The websocket url to connect to. This should have the
 | 
			
		||||
-- `ws://` or `wss://` protocol.
 | 
			
		||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
 | 
			
		||||
-- of the initial websocket connection.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn Websocket The websocket connection.
 | 
			
		||||
-- @treturn[2] false If the websocket connection failed.
 | 
			
		||||
-- @treturn string An error message describing why the connection failed.
 | 
			
		||||
function websocket(url, headers) end
 | 
			
		||||
 | 
			
		||||
--- Asynchronously open a websocket.
 | 
			
		||||
--
 | 
			
		||||
-- This returns immediately, a [`websocket_success`](#websocket-success-event)
 | 
			
		||||
-- or [`websocket_failure`](#websocket-failure-event) will be queued once the
 | 
			
		||||
-- request has completed.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string url The websocket url to connect to. This should have the
 | 
			
		||||
-- `ws://` or `wss://` protocol.
 | 
			
		||||
-- @tparam[opt] { [string] = string } headers Additional headers to send as part
 | 
			
		||||
-- of the initial websocket connection.
 | 
			
		||||
function websocketAsync(url, headers) end
 | 
			
		||||
 | 
			
		||||
--- A websocket, which can be used to send an receive messages with a web
 | 
			
		||||
-- server.
 | 
			
		||||
--
 | 
			
		||||
-- @type Websocket
 | 
			
		||||
-- @see http.websocket On how to open a websocket.
 | 
			
		||||
local Websocket = {}
 | 
			
		||||
 | 
			
		||||
--- Send a websocket message to the connected server.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string message The message to send.
 | 
			
		||||
-- @tparam[opt] boolean binary Whether this message should be treated as a
 | 
			
		||||
-- binary string, rather than encoded text.
 | 
			
		||||
-- @throws If the websocket has been closed.
 | 
			
		||||
function Websocket.send(message, binary) end
 | 
			
		||||
 | 
			
		||||
--- Wait for a message from the server.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number timeout The number of seconds to wait if no message is
 | 
			
		||||
-- received.
 | 
			
		||||
-- @treturn[1] string The received message.
 | 
			
		||||
-- @treturn boolean If this was a binary message.
 | 
			
		||||
-- @treturn[2] nil If the websocket was closed while waiting, or if we timed out.
 | 
			
		||||
-- @throws If the websocket has been closed.
 | 
			
		||||
function Websocket.receive(timeout) end
 | 
			
		||||
 | 
			
		||||
--- Close this websocket. This will terminate the connection, meaning messages
 | 
			
		||||
-- can no longer be sent or received along it.
 | 
			
		||||
function Websocket.close() end
 | 
			
		||||
							
								
								
									
										24
									
								
								doc/stub/os.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								doc/stub/os.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
function queueEvent(event, ...) end
 | 
			
		||||
function startTimer(delay) end
 | 
			
		||||
function setAlarm(time) end
 | 
			
		||||
function shutdown() end
 | 
			
		||||
function reboot() end
 | 
			
		||||
function getComputerID() end
 | 
			
		||||
computerID = getComputerID
 | 
			
		||||
function setComputerLabel(label) end
 | 
			
		||||
function getComputerLabel() end
 | 
			
		||||
computerLabel = getComputerLabel
 | 
			
		||||
function clock() end
 | 
			
		||||
function time(timezone) end
 | 
			
		||||
function day(timezone) end
 | 
			
		||||
function cancelTimer(id) end
 | 
			
		||||
function cancelAlarm(id) end
 | 
			
		||||
function epoch(timezone) end
 | 
			
		||||
function date(format, time) end
 | 
			
		||||
 | 
			
		||||
-- Defined in bios.lua
 | 
			
		||||
function loadAPI(path) end
 | 
			
		||||
function pullEvent(filter) end
 | 
			
		||||
function pullEventRaw(filter) end
 | 
			
		||||
function version() end
 | 
			
		||||
function run(env, path, ...) end
 | 
			
		||||
							
								
								
									
										28
									
								
								doc/stub/pocket.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								doc/stub/pocket.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
--[[-
 | 
			
		||||
Control the current pocket computer, adding or removing upgrades.
 | 
			
		||||
 | 
			
		||||
This API is only available on pocket computers. As such, you may use its
 | 
			
		||||
presence to determine what kind of computer you are using:
 | 
			
		||||
 | 
			
		||||
```lua
 | 
			
		||||
if pocket then
 | 
			
		||||
  print("On a pocket computer")
 | 
			
		||||
else
 | 
			
		||||
  print("On something else")
 | 
			
		||||
end
 | 
			
		||||
```
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
--- Search the player's inventory for another upgrade, replacing the existing
 | 
			
		||||
-- one with that item if found.
 | 
			
		||||
--
 | 
			
		||||
-- This inventory search starts from the player's currently selected slot,
 | 
			
		||||
-- allowing you to prioritise upgrades.
 | 
			
		||||
--
 | 
			
		||||
-- @throws If an upgrade cannot be found.
 | 
			
		||||
function equipBack() end
 | 
			
		||||
 | 
			
		||||
--- Remove the pocket computer's current upgrade.
 | 
			
		||||
--
 | 
			
		||||
-- @throws If this pocket computer does not currently have an upgrade.
 | 
			
		||||
function unequipBack() end
 | 
			
		||||
							
								
								
									
										120
									
								
								doc/stub/redstone.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								doc/stub/redstone.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,120 @@
 | 
			
		||||
--[[- Interact with redstone attached to this computer.
 | 
			
		||||
 | 
			
		||||
The @{redstone} library exposes three "types" of redstone control:
 | 
			
		||||
 - Binary input/output (@{setOutput}/@{getInput}): These simply check if a
 | 
			
		||||
   redstone wire has any input or output. A signal strength of 1 and 15 are
 | 
			
		||||
   treated the same.
 | 
			
		||||
 - Analogue input/output (@{setAnalogueOutput}/@{getAnalogueInput}): These
 | 
			
		||||
   work with the actual signal strength of the redstone wired, from 0 to 15.
 | 
			
		||||
 - Bundled cables (@{setBundledOutput}/@{getBundledInput}): These interact with
 | 
			
		||||
   "bundled" cables, such as those from Project:Red. These allow you to send
 | 
			
		||||
   16 separate on/off signals. Each channel corresponds to a colour, with the
 | 
			
		||||
   first being @{colors.white} and the last @{colors.black}.
 | 
			
		||||
 | 
			
		||||
Whenever a redstone input changes, a `redstone` event will be fired. This may
 | 
			
		||||
be used in or
 | 
			
		||||
 | 
			
		||||
This module may also be referred to as `rs`. For example, one may call
 | 
			
		||||
`rs.getSides()` instead of @{redstone.getSides}.
 | 
			
		||||
 | 
			
		||||
@module redstone
 | 
			
		||||
@usage Toggle the redstone signal above the computer every 0.5 seconds.
 | 
			
		||||
 | 
			
		||||
    while true do
 | 
			
		||||
        redstone.setOutput("top", not redstone.getOutput("top"))
 | 
			
		||||
        sleep(0.5)
 | 
			
		||||
    end
 | 
			
		||||
@usage Mimic a redstone comparator in [subtraction mode][comparator].
 | 
			
		||||
 | 
			
		||||
    while true do
 | 
			
		||||
      local rear = rs.getAnalogueInput("back")
 | 
			
		||||
      local sides = math.max(rs.getAnalogueInput("left"), rs.getAnalogueInput("right"))
 | 
			
		||||
      rs.setAnalogueOutput("front", math.max(rear - sides, 0))
 | 
			
		||||
 | 
			
		||||
      os.pullEvent("redstone") -- Wait for a change to inputs.
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
[comparator]: https://minecraft.gamepedia.com/Redstone_Comparator#Subtract_signal_strength "Redstone Comparator on the Minecraft wiki."
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
--- Returns a table containing the six sides of the computer. Namely, "top",
 | 
			
		||||
-- "bottom", "left", "right", "front" and "back".
 | 
			
		||||
--
 | 
			
		||||
-- @treturn { string... } A table of valid sides.
 | 
			
		||||
function getSides() end
 | 
			
		||||
 | 
			
		||||
--- Turn the redstone signal of a specific side on or off.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to set.
 | 
			
		||||
-- @tparam boolean on Whether the redstone signal should be on or off. When on,
 | 
			
		||||
-- a signal strength of 15 is emitted.
 | 
			
		||||
function setOutput(side, on) end
 | 
			
		||||
 | 
			
		||||
--- Get the current redstone output of a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to get.
 | 
			
		||||
-- @treturn boolean Whether the redstone output is on or off.
 | 
			
		||||
-- @see setOutput
 | 
			
		||||
function getOutput(side) end
 | 
			
		||||
 | 
			
		||||
--- Get the current redstone input of a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to get.
 | 
			
		||||
-- @treturn boolean Whether the redstone input is on or off.
 | 
			
		||||
function getInput(side) end
 | 
			
		||||
 | 
			
		||||
--- Set the redstone signal strength for a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to set.
 | 
			
		||||
-- @tparam number value The signal strength, between 0 and 15.
 | 
			
		||||
-- @throws If `value` is not between 0 and 15.
 | 
			
		||||
function setAnalogOutput(side, value) end
 | 
			
		||||
setAnalogueOutput = setAnalogOutput
 | 
			
		||||
 | 
			
		||||
--- Get the redstone output signal strength for a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to get.
 | 
			
		||||
-- @treturn number The output signal strength, between 0 and 15.
 | 
			
		||||
-- @see setAnalogueOutput
 | 
			
		||||
function getAnalogOutput(sid) end
 | 
			
		||||
getAnalogueOutput = getAnalogOutput
 | 
			
		||||
 | 
			
		||||
--- Get the redstone input signal strength for a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to get.
 | 
			
		||||
-- @treturn number The input signal strength, between 0 and 15.
 | 
			
		||||
function getAnalogInput(side) end
 | 
			
		||||
getAnalogueInput = getAnalogInput
 | 
			
		||||
 | 
			
		||||
--- Set the bundled cable output for a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to set.
 | 
			
		||||
-- @tparam number The colour bitmask to set.
 | 
			
		||||
-- @see colors.subtract For removing a colour from the bitmask.
 | 
			
		||||
-- @see colors.combine For adding a colour to the bitmask.
 | 
			
		||||
function setBundledOutput(side, output) end
 | 
			
		||||
 | 
			
		||||
--- Get the bundled cable output for a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to get.
 | 
			
		||||
-- @treturn number The bundled cable's output.
 | 
			
		||||
function getBundledOutput(side) end
 | 
			
		||||
 | 
			
		||||
--- Get the bundled cable input for a specific side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to get.
 | 
			
		||||
-- @treturn number The bundled cable's input.
 | 
			
		||||
-- @see testBundledInput To determine if a specific colour is set.
 | 
			
		||||
function getBundledInput(side) end
 | 
			
		||||
 | 
			
		||||
--- Determine if a specific combination of colours are on for the given side.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam string side The side to test.
 | 
			
		||||
-- @tparam number mask The mask to test.
 | 
			
		||||
-- @see getBundledInput
 | 
			
		||||
-- @see colors.combine For adding a colour to the bitmask.
 | 
			
		||||
-- @usage Check if @{colors.white} and @{colors.black} are on for above the
 | 
			
		||||
-- computer.
 | 
			
		||||
--
 | 
			
		||||
--     print(redstone.testBundledInput("top", colors.combine(colors.white, colors.black)))
 | 
			
		||||
function testBundledInput(side, mask) end
 | 
			
		||||
							
								
								
									
										52
									
								
								doc/stub/term.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								doc/stub/term.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
function write(text) end
 | 
			
		||||
function scroll(lines) end
 | 
			
		||||
function setCursorPos(x, y) end
 | 
			
		||||
function setCursorBlink(blink) end
 | 
			
		||||
function getCursorPos() end
 | 
			
		||||
function getSize() end
 | 
			
		||||
function clear() end
 | 
			
		||||
function clearLine() end
 | 
			
		||||
function setTextColour(colour) end
 | 
			
		||||
setTextColor = setTextColour
 | 
			
		||||
function setBackgroundColour(colour) end
 | 
			
		||||
setBackgroundColor = setBackgroundColour
 | 
			
		||||
function isColour() end
 | 
			
		||||
isColor = isColour
 | 
			
		||||
function getTextColour() end
 | 
			
		||||
getTextColor = getTextColor
 | 
			
		||||
function getBackgroundColour() end
 | 
			
		||||
getBackgroundColor = getBackgroundColour
 | 
			
		||||
function blit(text, text_colours, background_colours) end
 | 
			
		||||
function setPaletteColour(colour, ...) end
 | 
			
		||||
setPaletteColor = setPaletteColour
 | 
			
		||||
function getPaletteColour(colour, ...) end
 | 
			
		||||
getPaletteColor = getPaletteColour
 | 
			
		||||
function nativePaletteColour(colour) end
 | 
			
		||||
nativePaletteColor = nativePaletteColour
 | 
			
		||||
 | 
			
		||||
--- @type Redirect
 | 
			
		||||
local Redirect = {}
 | 
			
		||||
 | 
			
		||||
Redirect.write = write
 | 
			
		||||
Redirect.scroll = scroll
 | 
			
		||||
Redirect.setCursorPos = setCursorPos
 | 
			
		||||
Redirect.setCursorBlink = setCursorBlink
 | 
			
		||||
Redirect.getCursorPos = getCursorPos
 | 
			
		||||
Redirect.getSize = getSize
 | 
			
		||||
Redirect.clear = clear
 | 
			
		||||
Redirect.clearLine = clearLine
 | 
			
		||||
Redirect.setTextColour = setTextColour
 | 
			
		||||
Redirect.setTextColor = setTextColor
 | 
			
		||||
Redirect.setBackgroundColour = setBackgroundColour
 | 
			
		||||
Redirect.setBackgroundColor = setBackgroundColor
 | 
			
		||||
Redirect.isColour = isColour
 | 
			
		||||
Redirect.isColor = isColor
 | 
			
		||||
Redirect.getTextColour = getTextColour
 | 
			
		||||
Redirect.getTextColor = getTextColor
 | 
			
		||||
Redirect.getBackgroundColour = getBackgroundColour
 | 
			
		||||
Redirect.getBackgroundColor = getBackgroundColor
 | 
			
		||||
Redirect.blit = blit
 | 
			
		||||
Redirect.setPaletteColour = setPaletteColour
 | 
			
		||||
Redirect.setPaletteColor = setPaletteColor
 | 
			
		||||
Redirect.getPaletteColour = getPaletteColour
 | 
			
		||||
Redirect.getPaletteColor = getPaletteColor
 | 
			
		||||
							
								
								
									
										230
									
								
								doc/stub/turtle.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										230
									
								
								doc/stub/turtle.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,230 @@
 | 
			
		||||
--- Move the turtle forward one block.
 | 
			
		||||
-- @treturn boolean Whether the turtle could successfully move.
 | 
			
		||||
-- @treturn string|nil The reason the turtle could not move.
 | 
			
		||||
function forward() end
 | 
			
		||||
 | 
			
		||||
--- Move the turtle backwards one block.
 | 
			
		||||
-- @treturn boolean Whether the turtle could successfully move.
 | 
			
		||||
-- @treturn string|nil The reason the turtle could not move.
 | 
			
		||||
function back() end
 | 
			
		||||
 | 
			
		||||
--- Move the turtle up one block.
 | 
			
		||||
-- @treturn boolean Whether the turtle could successfully move.
 | 
			
		||||
-- @treturn string|nil The reason the turtle could not move.
 | 
			
		||||
function up() end
 | 
			
		||||
 | 
			
		||||
--- Move the turtle down one block.
 | 
			
		||||
-- @treturn boolean Whether the turtle could successfully move.
 | 
			
		||||
-- @treturn string|nil The reason the turtle could not move.
 | 
			
		||||
function down() end
 | 
			
		||||
 | 
			
		||||
--- Rotate the turtle 90 degress to the left.
 | 
			
		||||
function turnLeft() end
 | 
			
		||||
 | 
			
		||||
--- Rotate the turtle 90 degress to the right.
 | 
			
		||||
function turnRight() end
 | 
			
		||||
 | 
			
		||||
--- Attempt to break the block in front of the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- This requires a turtle tool capable of breaking the block. Diamond pickaxes
 | 
			
		||||
-- (mining turtles) can break any vanilla block, but other tools (such as axes)
 | 
			
		||||
-- are more limited.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
 | 
			
		||||
-- @treturn boolean Whether a block was broken.
 | 
			
		||||
-- @treturn string|nil The reason no block was broken.
 | 
			
		||||
function dig(side) end
 | 
			
		||||
 | 
			
		||||
--- Attempt to break the block above the turtle. See @{dig} for full details.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
 | 
			
		||||
-- @treturn boolean Whether a block was broken.
 | 
			
		||||
-- @treturn string|nil The reason no block was broken.
 | 
			
		||||
function digUp(side) end
 | 
			
		||||
 | 
			
		||||
--- Attempt to break the block below the turtle. See @{dig} for full details.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
 | 
			
		||||
-- @treturn boolean Whether a block was broken.
 | 
			
		||||
-- @treturn string|nil The reason no block was broken.
 | 
			
		||||
function digDown(side) end
 | 
			
		||||
 | 
			
		||||
--- Attack the entity in front of the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
 | 
			
		||||
-- @treturn boolean Whether an entity was attacked.
 | 
			
		||||
-- @treturn string|nil The reason nothing was attacked.
 | 
			
		||||
function attack(side) end
 | 
			
		||||
 | 
			
		||||
--- Attack the entity above the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
 | 
			
		||||
-- @treturn boolean Whether an entity was attacked.
 | 
			
		||||
-- @treturn string|nil The reason nothing was attacked.
 | 
			
		||||
function attackUp(side) end
 | 
			
		||||
 | 
			
		||||
--- Attack the entity below the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] "left"|"right" side The specific tool to use.
 | 
			
		||||
-- @treturn boolean Whether an entity was attacked.
 | 
			
		||||
-- @treturn string|nil The reason nothing was attacked.
 | 
			
		||||
function attackDown(side) end
 | 
			
		||||
 | 
			
		||||
--- Place a block or item into the world in front of the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn boolean Whether the block could be placed.
 | 
			
		||||
-- @treturn string|nil The reason the block was not placed.
 | 
			
		||||
function place() end
 | 
			
		||||
 | 
			
		||||
--- Place a block or item into the world above the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn boolean Whether the block could be placed.
 | 
			
		||||
-- @treturn string|nil The reason the block was not placed.
 | 
			
		||||
function placeUp() end
 | 
			
		||||
 | 
			
		||||
--- Place a block or item into the world below the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn boolean Whether the block could be placed.
 | 
			
		||||
-- @treturn string|nil The reason the block was not placed.
 | 
			
		||||
function placeDown() end
 | 
			
		||||
 | 
			
		||||
--- Drop the currently selected stack into the inventory in front of the turtle,
 | 
			
		||||
-- or as an item into the world if there is no inventory.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number count The number of items to drop. If not given, the
 | 
			
		||||
-- entire stack will be dropped.
 | 
			
		||||
-- @treturn boolean Whether items were dropped.
 | 
			
		||||
-- @treturn string|nil The reason the no items were dropped.
 | 
			
		||||
-- @see select
 | 
			
		||||
function drop(count) end
 | 
			
		||||
 | 
			
		||||
--- Drop the currently selected stack into the inventory above the turtle, or as
 | 
			
		||||
-- an item into the world if there is no inventory.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number count The number of items to drop. If not given, the
 | 
			
		||||
-- entire stack will be dropped.
 | 
			
		||||
-- @treturn boolean Whether items were dropped.
 | 
			
		||||
-- @treturn string|nil The reason the no items were dropped.
 | 
			
		||||
-- @see select
 | 
			
		||||
function dropUp(count) end
 | 
			
		||||
 | 
			
		||||
--- Drop the currently selected stack into the inventory below the turtle, or as
 | 
			
		||||
-- an item into the world if there is no inventory.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number count The number of items to drop. If not given, the
 | 
			
		||||
-- entire stack will be dropped.
 | 
			
		||||
-- @treturn boolean Whether items were dropped.
 | 
			
		||||
-- @treturn string|nil The reason the no items were dropped.
 | 
			
		||||
-- @see select
 | 
			
		||||
function dropDown(count) end
 | 
			
		||||
 | 
			
		||||
--- Suck an item from the inventory in front of the turtle, or from an item
 | 
			
		||||
-- floating in the world.
 | 
			
		||||
--
 | 
			
		||||
-- This will pull items into the first acceptable slot, starting at the
 | 
			
		||||
-- @{select|currently selected} one.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number count The number of items to suck. If not given, up to a
 | 
			
		||||
-- stack of items will be picked up.
 | 
			
		||||
-- @treturn boolean Whether items were picked up.
 | 
			
		||||
-- @treturn string|nil The reason the no items were picked up.
 | 
			
		||||
function suck(count) end
 | 
			
		||||
 | 
			
		||||
--- Suck an item from the inventory above the turtle, or from an item floating
 | 
			
		||||
-- in the world.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number count The number of items to suck. If not given, up to a
 | 
			
		||||
-- stack of items will be picked up.
 | 
			
		||||
-- @treturn boolean Whether items were picked up.
 | 
			
		||||
-- @treturn string|nil The reason the no items were picked up.
 | 
			
		||||
function suckUp(count) end
 | 
			
		||||
 | 
			
		||||
--- Suck an item from the inventory below the turtle, or from an item floating
 | 
			
		||||
-- in the world.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number count The number of items to suck. If not given, up to a
 | 
			
		||||
-- stack of items will be picked up.
 | 
			
		||||
-- @treturn boolean Whether items were picked up.
 | 
			
		||||
-- @treturn string|nil The reason the no items were picked up.
 | 
			
		||||
function suckDown(count) end
 | 
			
		||||
 | 
			
		||||
--- Check if there is a solid block in front of the turtle. In this case, solid
 | 
			
		||||
-- refers to any non-air or liquid block.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn boolean If there is a solid block in front.
 | 
			
		||||
function detect() end
 | 
			
		||||
 | 
			
		||||
--- Check if there is a solid block above the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn boolean If there is a solid block above.
 | 
			
		||||
function detectUp() end
 | 
			
		||||
 | 
			
		||||
--- Check if there is a solid block below the turtle.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn boolean If there is a solid block below.
 | 
			
		||||
function detectDown() end
 | 
			
		||||
 | 
			
		||||
function compare() end
 | 
			
		||||
function compareUp() end
 | 
			
		||||
function compareDown() end
 | 
			
		||||
 | 
			
		||||
function inspect() end
 | 
			
		||||
function inspectUp() end
 | 
			
		||||
function inspectDown() end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--- Change the currently selected slot.
 | 
			
		||||
--
 | 
			
		||||
-- The selected slot is determines what slot actions like @{drop} or
 | 
			
		||||
-- @{getItemCount} act on.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam number slot The slot to select.
 | 
			
		||||
-- @see getSelectedSlot
 | 
			
		||||
function select(slot) end
 | 
			
		||||
 | 
			
		||||
--- Get the currently selected slot.
 | 
			
		||||
--
 | 
			
		||||
-- @treturn number The current slot.
 | 
			
		||||
-- @see select
 | 
			
		||||
function getSelectedSlot() end
 | 
			
		||||
 | 
			
		||||
--- Get the number of items in the given slot.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number slot The slot we wish to check. Defaults to the @{turtle.select|selected slot}.
 | 
			
		||||
-- @treturn number The number of items in this slot.
 | 
			
		||||
function getItemCount(slot) end
 | 
			
		||||
 | 
			
		||||
--- Get the remaining number of items which may be stored in this stack.
 | 
			
		||||
--
 | 
			
		||||
-- For instance, if a slot contains 13 blocks of dirt, it has room for another 51.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number slot The slot we wish to check. Defaults to the @{turtle.select|selected slot}.
 | 
			
		||||
-- @treturn number The space left in this slot.
 | 
			
		||||
function getItemSpace(slot) end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--- Get detailed information about the items in the given slot.
 | 
			
		||||
--
 | 
			
		||||
-- @tparam[opt] number slot The slot to get information about. Defaults to the @{turtle.select|selected slot}.
 | 
			
		||||
-- @treturn nil|table Information about the given slot, or @{nil} if it is empty.
 | 
			
		||||
-- @usage Print the current slot, assuming it contains 13 dirt.
 | 
			
		||||
--
 | 
			
		||||
--     print(textutils.serialize(turtle.getItemDetail()))
 | 
			
		||||
--     -- => {
 | 
			
		||||
--     --    name = "minecraft:dirt",
 | 
			
		||||
--     --    damage = 0,
 | 
			
		||||
--     --    count = 13,
 | 
			
		||||
--     -- }
 | 
			
		||||
function getItemDetail(slot) end
 | 
			
		||||
 | 
			
		||||
function getFuelLevel() end
 | 
			
		||||
 | 
			
		||||
function refuel(count) end
 | 
			
		||||
function compareTo(slot) end
 | 
			
		||||
function transferTo(slot, count) end
 | 
			
		||||
 | 
			
		||||
function getFuelLimit() end
 | 
			
		||||
function equipLeft() end
 | 
			
		||||
function equipRight() end
 | 
			
		||||
 | 
			
		||||
function craft(limit) end
 | 
			
		||||
							
								
								
									
										186
									
								
								doc/styles.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										186
									
								
								doc/styles.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,186 @@
 | 
			
		||||
/* Basic reset on elements */
 | 
			
		||||
h1, h2, h3, h4, p, table, div, body {
 | 
			
		||||
    margin: 0;
 | 
			
		||||
    padding: 0;
 | 
			
		||||
    border: 0;
 | 
			
		||||
    font-size: 100%;
 | 
			
		||||
    font: inherit;
 | 
			
		||||
    vertical-align: baseline;
 | 
			
		||||
}
 | 
			
		||||
/* Make the page a little more airy */
 | 
			
		||||
body {
 | 
			
		||||
    margin: 20px auto;
 | 
			
		||||
    max-width: 1200px;
 | 
			
		||||
    padding: 0 10px;
 | 
			
		||||
    line-height: 1.6;
 | 
			
		||||
    color: #222;
 | 
			
		||||
    background: #fff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Try to use system default fonts. */
 | 
			
		||||
body {
 | 
			
		||||
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans",
 | 
			
		||||
                 "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
code, pre, .parameter, .type, .definition-name, .reference-code {
 | 
			
		||||
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Some definitions of basic tags */
 | 
			
		||||
code {
 | 
			
		||||
    color: #c7254e;
 | 
			
		||||
    background-color: #f9f2f4;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
p {
 | 
			
		||||
    margin: 0.9em 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
h1 {
 | 
			
		||||
    font-size: 1.5em;
 | 
			
		||||
    font-weight: lighter;
 | 
			
		||||
    border-bottom: solid 1px #aaa;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
h2, h3, h4 { margin: 1.4em 0 0.3em;}
 | 
			
		||||
h2 { font-size: 1.25em; }
 | 
			
		||||
h3 { font-size: 1.15em; font-weight: bold; }
 | 
			
		||||
h4 { font-size: 1.06em; }
 | 
			
		||||
 | 
			
		||||
a, a:visited, a:active { font-weight: bold; color: #004080; text-decoration: none; }
 | 
			
		||||
a:hover { text-decoration: underline; }
 | 
			
		||||
 | 
			
		||||
blockquote { margin-left: 3em; }
 | 
			
		||||
 | 
			
		||||
/* Stop sublists from having initial vertical space */
 | 
			
		||||
ul ul { margin-top: 0px; }
 | 
			
		||||
ol ul { margin-top: 0px; }
 | 
			
		||||
ol ol { margin-top: 0px; }
 | 
			
		||||
ul ol { margin-top: 0px; }
 | 
			
		||||
 | 
			
		||||
/* Make the target distinct; helps when we're navigating to a function */
 | 
			
		||||
a:target + * { background-color: #FFFF99; }
 | 
			
		||||
 | 
			
		||||
/* Allow linking to any subsection */
 | 
			
		||||
a[name]::before { content: "#"; }
 | 
			
		||||
 | 
			
		||||
/* Layout */
 | 
			
		||||
#main {
 | 
			
		||||
    display: flex;
 | 
			
		||||
    flex-wrap: nowrap;
 | 
			
		||||
    justify-content: space-between;
 | 
			
		||||
    min-height: calc(100vh - 100px);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#main > nav {
 | 
			
		||||
    flex-basis: 30%;
 | 
			
		||||
    min-width: 150px;
 | 
			
		||||
    max-width: 250px;
 | 
			
		||||
    background-color: #f0f0f0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nav h1, nav ul { padding: 0em 10px; }
 | 
			
		||||
 | 
			
		||||
nav h2 {
 | 
			
		||||
    background-color:#e7e7e7;
 | 
			
		||||
    font-size: 1.1em;
 | 
			
		||||
    color:#000000;
 | 
			
		||||
    padding: 5px 10px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nav ul {
 | 
			
		||||
    list-style-type: none;
 | 
			
		||||
    margin: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#content {
 | 
			
		||||
    flex-shrink: 1;
 | 
			
		||||
    flex-basis: 80%;
 | 
			
		||||
    padding: 0px 10px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
footer {
 | 
			
		||||
    text-align: right;
 | 
			
		||||
    font-size: 0.8em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* The definition lists at the top of each page */
 | 
			
		||||
table.definition-list {
 | 
			
		||||
    border-collapse: collapse;
 | 
			
		||||
    width: 100%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.definition-list td, table.definition-list th {
 | 
			
		||||
    border: 1px solid #cccccc;
 | 
			
		||||
    padding: 5px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.definition-list th {
 | 
			
		||||
    background-color: #f0f0f0;
 | 
			
		||||
    min-width: 200px;
 | 
			
		||||
    white-space: nowrap;
 | 
			
		||||
    text-align: right;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.definition-list td { width: 100%; }
 | 
			
		||||
 | 
			
		||||
dl.definition dt {
 | 
			
		||||
    border-top: 1px solid #ccc;
 | 
			
		||||
    padding-top: 1em;
 | 
			
		||||
    display: flex;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dl.definition dt .definition-name {
 | 
			
		||||
    padding: 0 0.1em;
 | 
			
		||||
    margin: 0 0.1em;
 | 
			
		||||
    flex-grow: 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
dl.definition dd {
 | 
			
		||||
    padding-bottom: 1em;
 | 
			
		||||
    margin: 10px 0 0 20px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dl.definition h3 {
 | 
			
		||||
    font-size: .95em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Links to source-code */
 | 
			
		||||
.source-link { font-size: 0.8em; }
 | 
			
		||||
.source-link::before { content: '[' }
 | 
			
		||||
.source-link::after  { content: ']' }
 | 
			
		||||
a.source-link, a.source-link:visited, a.source-link:active { color: #505050; }
 | 
			
		||||
 | 
			
		||||
/* Method definitions */
 | 
			
		||||
span.parameter:after { content:":"; padding-left: 0.3em; }
 | 
			
		||||
.optional { text-decoration: underline dotted; }
 | 
			
		||||
 | 
			
		||||
/** Fancy colour display. */
 | 
			
		||||
.colour-ref {
 | 
			
		||||
    display: inline-block;
 | 
			
		||||
    width: 0.8em;
 | 
			
		||||
    height: 0.8em;
 | 
			
		||||
    margin: 0.1em 0.1em 0.3em 0.1em; /* Terrrible hack to force vertical alignment. */
 | 
			
		||||
    border: solid 1px black;
 | 
			
		||||
    box-sizing: border-box;
 | 
			
		||||
    vertical-align: middle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* styles for prettification of source */
 | 
			
		||||
.highlight .comment { color: #558817; }
 | 
			
		||||
.highlight .constant { color: #a8660d; }
 | 
			
		||||
.highlight .escape { color: #844631; }
 | 
			
		||||
.highlight .keyword { color: #aa5050; font-weight: bold; }
 | 
			
		||||
.highlight .library { color: #0e7c6b; }
 | 
			
		||||
.highlight .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
 | 
			
		||||
.highlight .string { color: #8080ff; }
 | 
			
		||||
.highlight .literal-kw { color: #8080ff; }
 | 
			
		||||
.highlight .number { color: #f8660d; }
 | 
			
		||||
.highlight .operator { color: #2239a8; font-weight: bold; }
 | 
			
		||||
.highlight .preprocessor, pre .prepro { color: #a33243; }
 | 
			
		||||
.highlight .global { color: #800080; }
 | 
			
		||||
.highlight .user-keyword { color: #800080; }
 | 
			
		||||
.highlight .prompt { color: #558817; }
 | 
			
		||||
.highlight .url { color: #272fc2; text-decoration: underline; }
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
# Mod properties
 | 
			
		||||
mod_version=1.83.1
 | 
			
		||||
mod_version=1.89.1
 | 
			
		||||
 | 
			
		||||
# Minecraft properties
 | 
			
		||||
mc_version=1.14.2
 | 
			
		||||
mappings_version=2
 | 
			
		||||
mc_version=1.12.2
 | 
			
		||||
forge_version=14.23.4.2749
 | 
			
		||||
mappings_version=snapshot_20180724
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								gradle/wrapper/gradle-wrapper.jar
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gradle/wrapper/gradle-wrapper.jar
									
									
									
									
										vendored
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
distributionBase=GRADLE_USER_HOME
 | 
			
		||||
distributionPath=wrapper/dists
 | 
			
		||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
 | 
			
		||||
zipStoreBase=GRADLE_USER_HOME
 | 
			
		||||
zipStorePath=wrapper/dists
 | 
			
		||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										95
									
								
								illuaminate.sexp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								illuaminate.sexp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,95 @@
 | 
			
		||||
; -*- 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)
 | 
			
		||||
 | 
			
		||||
  (lint
 | 
			
		||||
    (bracket-spaces
 | 
			
		||||
      (call no-space)
 | 
			
		||||
      (function-args no-space)
 | 
			
		||||
      (parens no-space)
 | 
			
		||||
      (table space)
 | 
			
		||||
      (index no-space))
 | 
			
		||||
 | 
			
		||||
    ;; colours imports from colors, and we don't handle that right now.
 | 
			
		||||
    ;; keys is entirely dynamic, so we skip it.
 | 
			
		||||
    (dynamic-modules colours keys)
 | 
			
		||||
 | 
			
		||||
    (globals
 | 
			
		||||
      :max
 | 
			
		||||
      _CC_DEFAULT_SETTINGS
 | 
			
		||||
      _CC_DISABLE_LUA51_FEATURES
 | 
			
		||||
      ;; Ideally we'd pick these up from bios.lua, but illuaminate currently
 | 
			
		||||
      ;; isn't smart enough.
 | 
			
		||||
      sleep write printError read rs)))
 | 
			
		||||
 | 
			
		||||
;; We disable the unused global linter in bios.lua and the APIs. In the future
 | 
			
		||||
;; hopefully we'll get illuaminate to handle this.
 | 
			
		||||
(at
 | 
			
		||||
  (/src/main/resources/*/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/fs.lua
 | 
			
		||||
   /doc/stub/http.lua
 | 
			
		||||
   /doc/stub/os.lua
 | 
			
		||||
   /doc/stub/term.lua
 | 
			
		||||
   /doc/stub/turtle.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/apis/io.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/apis/window.lua)
 | 
			
		||||
 | 
			
		||||
  (linters -doc:undocumented -doc:undocumented-arg))
 | 
			
		||||
 | 
			
		||||
;; These currently rely on unknown references.
 | 
			
		||||
(at
 | 
			
		||||
  (/src/main/resources/*/computercraft/lua/rom/apis/textutils.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/modules/main/cc/completion.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/modules/main/cc/shell/completion.lua
 | 
			
		||||
   /src/main/resources/*/computercraft/lua/rom/programs/shell.lua)
 | 
			
		||||
  (linters -doc:unresolved-reference))
 | 
			
		||||
 | 
			
		||||
(at /src/test/resources/test-rom
 | 
			
		||||
  (lint
 | 
			
		||||
    (globals
 | 
			
		||||
      :max sleep write
 | 
			
		||||
      cct_test describe expect howlci fail it pending stub)))
 | 
			
		||||
@@ -1,12 +1 @@
 | 
			
		||||
pluginManagement {
 | 
			
		||||
    repositories {
 | 
			
		||||
        jcenter()
 | 
			
		||||
        maven {
 | 
			
		||||
            name = 'Fabric'
 | 
			
		||||
            url = 'https://maven.fabricmc.net/'
 | 
			
		||||
        }
 | 
			
		||||
        gradlePluginPortal()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
rootProject.name = "cc-tweaked-${mc_version}-fabric"
 | 
			
		||||
rootProject.name = "cc-tweaked-${mc_version}"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								src/main/java/dan200/computercraft/CCTweaked.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/main/java/dan200/computercraft/CCTweaked.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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,57 +1,100 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.filesystem.IMount;
 | 
			
		||||
import dan200.computercraft.api.filesystem.IWritableMount;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaAPIFactory;
 | 
			
		||||
import dan200.computercraft.api.media.IMedia;
 | 
			
		||||
import dan200.computercraft.api.media.IMediaProvider;
 | 
			
		||||
import dan200.computercraft.api.network.IPacketNetwork;
 | 
			
		||||
import dan200.computercraft.api.network.wired.IWiredElement;
 | 
			
		||||
import dan200.computercraft.api.network.wired.IWiredNode;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
 | 
			
		||||
import dan200.computercraft.api.permissions.ITurtlePermissionProvider;
 | 
			
		||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
 | 
			
		||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import dan200.computercraft.api.turtle.event.TurtleAction;
 | 
			
		||||
import dan200.computercraft.client.proxy.ComputerCraftProxyClient;
 | 
			
		||||
import dan200.computercraft.core.apis.AddressPredicate;
 | 
			
		||||
import dan200.computercraft.core.apis.http.websocket.Websocket;
 | 
			
		||||
import dan200.computercraft.core.filesystem.ResourceMount;
 | 
			
		||||
import dan200.computercraft.core.apis.ApiFactories;
 | 
			
		||||
import dan200.computercraft.core.computer.MainThread;
 | 
			
		||||
import dan200.computercraft.core.filesystem.ComboMount;
 | 
			
		||||
import dan200.computercraft.core.filesystem.FileMount;
 | 
			
		||||
import dan200.computercraft.core.filesystem.JarMount;
 | 
			
		||||
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.core.ClientComputerRegistry;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ServerComputerRegistry;
 | 
			
		||||
import dan200.computercraft.shared.computer.items.ItemCommandComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.items.ItemComputer;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemDisk;
 | 
			
		||||
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.peripheral.diskdrive.BlockDiskDrive;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.common.ItemPeripheral;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockWiredModemFull;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.ItemBlockCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockWirelessModem;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.monitor.BlockMonitor;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.printer.BlockPrinter;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.speaker.BlockSpeaker;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.ItemCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockAdvancedModem;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wireless.ItemAdvancedModem;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
 | 
			
		||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
 | 
			
		||||
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
 | 
			
		||||
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
 | 
			
		||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
 | 
			
		||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtleAdvanced;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtleLegacy;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtleNormal;
 | 
			
		||||
import dan200.computercraft.shared.turtle.upgrades.*;
 | 
			
		||||
import net.fabricmc.api.EnvType;
 | 
			
		||||
import net.fabricmc.api.ModInitializer;
 | 
			
		||||
import net.fabricmc.loader.api.FabricLoader;
 | 
			
		||||
import net.minecraft.resource.ReloadableResourceManager;
 | 
			
		||||
import net.minecraft.util.Identifier;
 | 
			
		||||
import org.apache.logging.log4j.LogManager;
 | 
			
		||||
import dan200.computercraft.shared.util.CreativeTabMain;
 | 
			
		||||
import dan200.computercraft.shared.util.IDAssigner;
 | 
			
		||||
import dan200.computercraft.shared.util.IoUtil;
 | 
			
		||||
import dan200.computercraft.shared.wired.CapabilityWiredElement;
 | 
			
		||||
import dan200.computercraft.shared.wired.WiredNode;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.item.ItemBlock;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.server.MinecraftServer;
 | 
			
		||||
import net.minecraft.tileentity.TileEntity;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
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.event.*;
 | 
			
		||||
import net.minecraftforge.fml.relauncher.Side;
 | 
			
		||||
import org.apache.logging.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.util.EnumSet;
 | 
			
		||||
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.zip.ZipEntry;
 | 
			
		||||
import java.util.zip.ZipFile;
 | 
			
		||||
 | 
			
		||||
public final class ComputerCraft implements ModInitializer
 | 
			
		||||
@Mod(
 | 
			
		||||
    modid = ComputerCraft.MOD_ID, name = ComputerCraft.NAME, version = ComputerCraft.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";
 | 
			
		||||
 | 
			
		||||
    public static final int DATAFIXER_VERSION = 0;
 | 
			
		||||
    static final String VERSION = "${version}";
 | 
			
		||||
    static final String NAME = "CC: Tweaked";
 | 
			
		||||
 | 
			
		||||
    // Configuration options
 | 
			
		||||
    public static final String[] DEFAULT_HTTP_WHITELIST = new String[] { "*" };
 | 
			
		||||
@@ -69,7 +112,8 @@ public final class ComputerCraft implements ModInitializer
 | 
			
		||||
    public static boolean disable_lua51_features = false;
 | 
			
		||||
    public static String default_computer_settings = "";
 | 
			
		||||
    public static boolean debug_enable = true;
 | 
			
		||||
    public static boolean logPeripheralErrors = false;
 | 
			
		||||
    public static boolean logPeripheralErrors = true;
 | 
			
		||||
    public static boolean commandRequireCreative = true;
 | 
			
		||||
 | 
			
		||||
    public static int computer_threads = 1;
 | 
			
		||||
    public static long maxMainGlobalTime = TimeUnit.MILLISECONDS.toNanos( 10 );
 | 
			
		||||
@@ -85,7 +129,7 @@ public final class ComputerCraft implements ModInitializer
 | 
			
		||||
    public static long httpMaxDownload = 16 * 1024 * 1024;
 | 
			
		||||
    public static long httpMaxUpload = 4 * 1024 * 1024;
 | 
			
		||||
    public static int httpMaxWebsockets = 4;
 | 
			
		||||
    public static int httpMaxWebsocketMessage = Websocket.MAX_MESSAGE_SIZE;
 | 
			
		||||
    public static int httpMaxWebsocketMessage = 128 * 1024;
 | 
			
		||||
 | 
			
		||||
    public static boolean enableCommandBlock = false;
 | 
			
		||||
    public static int modem_range = 64;
 | 
			
		||||
@@ -93,6 +137,8 @@ public final class ComputerCraft implements ModInitializer
 | 
			
		||||
    public static int modem_rangeDuringStorm = 64;
 | 
			
		||||
    public static int modem_highAltitudeRangeDuringStorm = 384;
 | 
			
		||||
    public static int maxNotesPerTick = 8;
 | 
			
		||||
    public static MonitorRenderer monitorRenderer = MonitorRenderer.BEST;
 | 
			
		||||
    public static long monitorBandwidth = 1_000_000;
 | 
			
		||||
 | 
			
		||||
    public static boolean turtlesNeedFuel = true;
 | 
			
		||||
    public static int turtleFuelLimit = 20000;
 | 
			
		||||
@@ -113,54 +159,46 @@ public final class ComputerCraft implements ModInitializer
 | 
			
		||||
    // Blocks and Items
 | 
			
		||||
    public static final class Blocks
 | 
			
		||||
    {
 | 
			
		||||
        public static BlockComputer computerNormal;
 | 
			
		||||
        public static BlockComputer computerAdvanced;
 | 
			
		||||
        public static BlockComputer computerCommand;
 | 
			
		||||
        public static BlockComputer computer;
 | 
			
		||||
        public static BlockCommandComputer commandComputer;
 | 
			
		||||
 | 
			
		||||
        public static BlockTurtle turtleNormal;
 | 
			
		||||
        public static BlockTurtle turtle;
 | 
			
		||||
        public static BlockTurtle turtleExpanded;
 | 
			
		||||
        public static BlockTurtle turtleAdvanced;
 | 
			
		||||
 | 
			
		||||
        public static BlockSpeaker speaker;
 | 
			
		||||
        public static BlockDiskDrive diskDrive;
 | 
			
		||||
        public static BlockPrinter printer;
 | 
			
		||||
 | 
			
		||||
        public static BlockMonitor monitorNormal;
 | 
			
		||||
        public static BlockMonitor monitorAdvanced;
 | 
			
		||||
 | 
			
		||||
        public static BlockWirelessModem wirelessModemNormal;
 | 
			
		||||
        public static BlockWirelessModem wirelessModemAdvanced;
 | 
			
		||||
 | 
			
		||||
        public static BlockWiredModemFull wiredModemFull;
 | 
			
		||||
        public static BlockPeripheral peripheral;
 | 
			
		||||
        public static BlockCable cable;
 | 
			
		||||
        public static BlockAdvancedModem advancedModem;
 | 
			
		||||
        public static BlockWiredModemFull wiredModemFull;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static final class Items
 | 
			
		||||
    {
 | 
			
		||||
        public static ItemComputer computerNormal;
 | 
			
		||||
        public static ItemComputer computerAdvanced;
 | 
			
		||||
        public static ItemComputer computerCommand;
 | 
			
		||||
        public static ItemComputer computer;
 | 
			
		||||
        public static ItemCommandComputer commandComputer;
 | 
			
		||||
 | 
			
		||||
        public static ItemPocketComputer pocketComputerNormal;
 | 
			
		||||
        public static ItemPocketComputer pocketComputerAdvanced;
 | 
			
		||||
        public static ItemTurtleLegacy turtle;
 | 
			
		||||
        public static ItemTurtleNormal turtleExpanded;
 | 
			
		||||
        public static ItemTurtleAdvanced turtleAdvanced;
 | 
			
		||||
 | 
			
		||||
        public static ItemTurtle turtleNormal;
 | 
			
		||||
        public static ItemTurtle turtleAdvanced;
 | 
			
		||||
        public static ItemPocketComputer pocketComputer;
 | 
			
		||||
 | 
			
		||||
        public static ItemDisk disk;
 | 
			
		||||
        public static ItemDiskLegacy disk;
 | 
			
		||||
        public static ItemDiskExpanded diskExpanded;
 | 
			
		||||
        public static ItemTreasureDisk treasureDisk;
 | 
			
		||||
 | 
			
		||||
        public static ItemPrintout printedPage;
 | 
			
		||||
        public static ItemPrintout printedPages;
 | 
			
		||||
        public static ItemPrintout printedBook;
 | 
			
		||||
        public static ItemPrintout printout;
 | 
			
		||||
 | 
			
		||||
        public static ItemBlockCable.Cable cable;
 | 
			
		||||
        public static ItemBlockCable.WiredModem wiredModem;
 | 
			
		||||
        public static ItemPeripheral peripheral;
 | 
			
		||||
        public static ItemAdvancedModem advancedModem;
 | 
			
		||||
        public static ItemCable cable;
 | 
			
		||||
        public static ItemBlock wiredModemFull;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static final class TurtleUpgrades
 | 
			
		||||
    {
 | 
			
		||||
        public static TurtleModem wirelessModemNormal;
 | 
			
		||||
        public static TurtleModem wirelessModemAdvanced;
 | 
			
		||||
        public static TurtleModem wirelessModem;
 | 
			
		||||
        public static TurtleModem advancedModem;
 | 
			
		||||
        public static TurtleSpeaker speaker;
 | 
			
		||||
 | 
			
		||||
        public static TurtleCraftingTable craftingTable;
 | 
			
		||||
@@ -173,58 +211,457 @@ public final class ComputerCraft implements ModInitializer
 | 
			
		||||
 | 
			
		||||
    public static final class PocketUpgrades
 | 
			
		||||
    {
 | 
			
		||||
        public static PocketModem wirelessModemNormal;
 | 
			
		||||
        public static PocketModem wirelessModemAdvanced;
 | 
			
		||||
        public static PocketModem wirelessModem;
 | 
			
		||||
        public static PocketModem advancedModem;
 | 
			
		||||
        public static PocketSpeaker speaker;
 | 
			
		||||
 | 
			
		||||
        @Deprecated
 | 
			
		||||
        public static PocketSpeaker pocketSpeaker;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static final class Upgrades
 | 
			
		||||
    {
 | 
			
		||||
        public static TurtleModem advancedModem;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Registries
 | 
			
		||||
    public static final ClientComputerRegistry clientComputerRegistry = new ClientComputerRegistry();
 | 
			
		||||
    public static final ServerComputerRegistry serverComputerRegistry = new ServerComputerRegistry();
 | 
			
		||||
 | 
			
		||||
    // Creative
 | 
			
		||||
    public static CreativeTabMain mainCreativeTab;
 | 
			
		||||
 | 
			
		||||
    // Logging
 | 
			
		||||
    public static final Logger log = LogManager.getLogger( MOD_ID );
 | 
			
		||||
    public static Logger log;
 | 
			
		||||
 | 
			
		||||
    // Peripheral providers. This is still here to ensure compatibility with Plethora and Computronics
 | 
			
		||||
    public static List<IPeripheralProvider> peripheralProviders = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    // Implementation
 | 
			
		||||
    @Mod.Instance( ComputerCraft.MOD_ID )
 | 
			
		||||
    public static ComputerCraft instance;
 | 
			
		||||
 | 
			
		||||
    public ComputerCraft()
 | 
			
		||||
    @SidedProxy(
 | 
			
		||||
        clientSide = "dan200.computercraft.client.proxy.ComputerCraftProxyClient",
 | 
			
		||||
        serverSide = "dan200.computercraft.shared.proxy.ComputerCraftProxyCommon"
 | 
			
		||||
    )
 | 
			
		||||
    private static ComputerCraftProxyCommon proxy;
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void preInit( FMLPreInitializationEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        instance = this;
 | 
			
		||||
        log = event.getModLog();
 | 
			
		||||
 | 
			
		||||
        // Load config
 | 
			
		||||
        Config.load( event.getSuggestedConfigurationFile() );
 | 
			
		||||
 | 
			
		||||
        proxy.preInit();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onInitialize()
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void init( FMLInitializationEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        ComputerCraftProxyCommon.setup();
 | 
			
		||||
        if( FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT )
 | 
			
		||||
        proxy.init();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void onServerStarting( FMLServerStartingEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        ComputerCraftProxyCommon.initServer( event.getServer() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void onServerStart( FMLServerStartedEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        if( FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER )
 | 
			
		||||
        {
 | 
			
		||||
            ComputerCraftProxyClient.setup();
 | 
			
		||||
            ComputerCraft.serverComputerRegistry.reset();
 | 
			
		||||
            WirelessNetwork.resetNetworks();
 | 
			
		||||
            MainThread.reset();
 | 
			
		||||
            Tracking.reset();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Mod.EventHandler
 | 
			
		||||
    public void onServerStopped( FMLServerStoppedEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        if( FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER )
 | 
			
		||||
        {
 | 
			
		||||
            ComputerCraft.serverComputerRegistry.reset();
 | 
			
		||||
            WirelessNetwork.resetNetworks();
 | 
			
		||||
            MainThread.reset();
 | 
			
		||||
            Tracking.reset();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String getVersion()
 | 
			
		||||
    {
 | 
			
		||||
        return "${version}";
 | 
			
		||||
        return VERSION;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static IMount createResourceMount( String domain, String subPath )
 | 
			
		||||
    private static File getBaseDir()
 | 
			
		||||
    {
 | 
			
		||||
        ReloadableResourceManager manager = ComputerCraftProxyCommon.getServer().getDataManager();
 | 
			
		||||
        ResourceMount mount = new ResourceMount( domain, subPath, manager );
 | 
			
		||||
        return mount.exists( "" ) ? mount : null;
 | 
			
		||||
        return FMLCommonHandler.instance().getMinecraftServerInstance().getDataDirectory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static InputStream getResourceFile( String domain, String subPath )
 | 
			
		||||
    private static File getResourcePackDir()
 | 
			
		||||
    {
 | 
			
		||||
        return new File( getBaseDir(), "resourcepacks" );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerPermissionProvider( ITurtlePermissionProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        TurtlePermissions.register( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerPocketUpgrade( IPocketUpgrade upgrade )
 | 
			
		||||
    {
 | 
			
		||||
        dan200.computercraft.shared.PocketUpgrades.register( upgrade );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerPeripheralProvider( IPeripheralProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        Peripherals.register( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerBundledRedstoneProvider( IBundledRedstoneProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        BundledRedstone.register( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerMediaProvider( IMediaProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        MediaProviders.register( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerAPIFactory( ILuaAPIFactory factory )
 | 
			
		||||
    {
 | 
			
		||||
        ApiFactories.register( factory );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IWiredNode createWiredNodeForElement( IWiredElement element )
 | 
			
		||||
    {
 | 
			
		||||
        return new WiredNode( element );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IWiredElement getWiredElementAt( IBlockAccess world, BlockPos pos, EnumFacing side )
 | 
			
		||||
    {
 | 
			
		||||
        TileEntity tile = world.getTileEntity( pos );
 | 
			
		||||
        return tile != null && tile.hasCapability( CapabilityWiredElement.CAPABILITY, side )
 | 
			
		||||
            ? tile.getCapability( CapabilityWiredElement.CAPABILITY, side )
 | 
			
		||||
            : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static int getDefaultBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
 | 
			
		||||
    {
 | 
			
		||||
        return BundledRedstone.getDefaultOutput( world, pos, side );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IPacketNetwork getWirelessNetwork()
 | 
			
		||||
    {
 | 
			
		||||
        return WirelessNetwork.getUniversal();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static int createUniqueNumberedSaveDir( World world, String parentSubPath )
 | 
			
		||||
    {
 | 
			
		||||
        return IDAssigner.getNextIDFromDirectory( parentSubPath );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IWritableMount createSaveDirMount( World world, String subPath, long capacity )
 | 
			
		||||
    {
 | 
			
		||||
        ReloadableResourceManager manager = ComputerCraftProxyCommon.getServer().getDataManager();
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            return manager.getResource( new Identifier( domain, subPath ) ).getInputStream();
 | 
			
		||||
            return new FileMount( new File( getWorldDir(), subPath ), capacity );
 | 
			
		||||
        }
 | 
			
		||||
        catch( IOException ignored )
 | 
			
		||||
        catch( Exception e )
 | 
			
		||||
        {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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 )
 | 
			
		||||
    {
 | 
			
		||||
        // Start building list of mounts
 | 
			
		||||
        List<IMount> mounts = new ArrayList<>();
 | 
			
		||||
        subPath = "assets/" + domain + "/" + subPath;
 | 
			
		||||
 | 
			
		||||
        // Mount from debug dir
 | 
			
		||||
        File codeDir = getDebugCodeDir( modClass );
 | 
			
		||||
        if( codeDir != null )
 | 
			
		||||
        {
 | 
			
		||||
            File subResource = new File( codeDir, subPath );
 | 
			
		||||
            if( subResource.exists() )
 | 
			
		||||
            {
 | 
			
		||||
                IMount resourcePackMount = new FileMount( subResource, 0 );
 | 
			
		||||
                mounts.add( resourcePackMount );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Mount from mod jars, preferring the specified one.
 | 
			
		||||
        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 );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Mount from resource packs
 | 
			
		||||
        File resourcePackDir = getResourcePackDir();
 | 
			
		||||
        if( resourcePackDir.exists() && resourcePackDir.isDirectory() )
 | 
			
		||||
        {
 | 
			
		||||
            String[] resourcePacks = resourcePackDir.list();
 | 
			
		||||
            for( String resourcePackName : resourcePacks )
 | 
			
		||||
            {
 | 
			
		||||
                File resourcePack = new File( resourcePackDir, resourcePackName );
 | 
			
		||||
                loadFromFile( mounts, resourcePack, subPath, true );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Return the combination of all the mounts found
 | 
			
		||||
        if( mounts.size() >= 2 )
 | 
			
		||||
        {
 | 
			
		||||
            IMount[] mountArray = new IMount[mounts.size()];
 | 
			
		||||
            mounts.toArray( mountArray );
 | 
			
		||||
            return new ComboMount( mountArray );
 | 
			
		||||
        }
 | 
			
		||||
        else if( mounts.size() == 1 )
 | 
			
		||||
        {
 | 
			
		||||
            return mounts.get( 0 );
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static InputStream getResourceFile( Class<?> modClass, String domain, String subPath )
 | 
			
		||||
    {
 | 
			
		||||
        // Start searching in possible locations
 | 
			
		||||
        subPath = "assets/" + domain + "/" + subPath;
 | 
			
		||||
 | 
			
		||||
        // Look in resource packs
 | 
			
		||||
        File resourcePackDir = getResourcePackDir();
 | 
			
		||||
        if( resourcePackDir.exists() && resourcePackDir.isDirectory() )
 | 
			
		||||
        {
 | 
			
		||||
            String[] resourcePacks = resourcePackDir.list();
 | 
			
		||||
            for( String resourcePackPath : resourcePacks )
 | 
			
		||||
            {
 | 
			
		||||
                File resourcePack = new File( resourcePackDir, resourcePackPath );
 | 
			
		||||
                if( resourcePack.isDirectory() )
 | 
			
		||||
                {
 | 
			
		||||
                    // Mount a resource pack from a folder
 | 
			
		||||
                    File subResource = new File( resourcePack, subPath );
 | 
			
		||||
                    if( subResource.exists() && subResource.isFile() )
 | 
			
		||||
                    {
 | 
			
		||||
                        try
 | 
			
		||||
                        {
 | 
			
		||||
                            return new FileInputStream( subResource );
 | 
			
		||||
                        }
 | 
			
		||||
                        catch( FileNotFoundException ignored )
 | 
			
		||||
                        {
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    ZipFile zipFile = null;
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        final ZipFile zip = zipFile = new ZipFile( resourcePack );
 | 
			
		||||
                        ZipEntry entry = zipFile.getEntry( subPath );
 | 
			
		||||
                        if( entry != null )
 | 
			
		||||
                        {
 | 
			
		||||
                            // Return a custom InputStream which will close the original zip when finished.
 | 
			
		||||
                            return new FilterInputStream( zipFile.getInputStream( entry ) )
 | 
			
		||||
                            {
 | 
			
		||||
                                @Override
 | 
			
		||||
                                public void close() throws IOException
 | 
			
		||||
                                {
 | 
			
		||||
                                    super.close();
 | 
			
		||||
                                    zip.close();
 | 
			
		||||
                                }
 | 
			
		||||
                            };
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            IoUtil.closeQuietly( zipFile );
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    catch( IOException e )
 | 
			
		||||
                    {
 | 
			
		||||
                        IoUtil.closeQuietly( zipFile );
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Look in debug dir
 | 
			
		||||
        File codeDir = getDebugCodeDir( modClass );
 | 
			
		||||
        if( codeDir != null )
 | 
			
		||||
        {
 | 
			
		||||
            File subResource = new File( codeDir, subPath );
 | 
			
		||||
            if( subResource.exists() && subResource.isFile() )
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    return new FileInputStream( subResource );
 | 
			
		||||
                }
 | 
			
		||||
                catch( FileNotFoundException ignored )
 | 
			
		||||
                {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Look in class loader
 | 
			
		||||
        return modClass.getClassLoader().getResourceAsStream( subPath );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static File getContainingJar( Class<?> modClass )
 | 
			
		||||
    {
 | 
			
		||||
        String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
 | 
			
		||||
        int bangIndex = path.indexOf( '!' );
 | 
			
		||||
        if( bangIndex >= 0 )
 | 
			
		||||
        {
 | 
			
		||||
            path = path.substring( 0, bangIndex );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        URL url;
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            url = new URL( path );
 | 
			
		||||
        }
 | 
			
		||||
        catch( MalformedURLException e1 )
 | 
			
		||||
        {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        File file;
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            file = new File( url.toURI() );
 | 
			
		||||
        }
 | 
			
		||||
        catch( URISyntaxException e )
 | 
			
		||||
        {
 | 
			
		||||
            file = new File( url.getPath() );
 | 
			
		||||
        }
 | 
			
		||||
        return file;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static File getDebugCodeDir( Class<?> modClass )
 | 
			
		||||
    {
 | 
			
		||||
        String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
 | 
			
		||||
        int bangIndex = path.indexOf( '!' );
 | 
			
		||||
        return bangIndex >= 0 ? null : new File( new File( path ).getParentFile(), "../.." );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerTurtleUpgrade( ITurtleUpgrade upgrade )
 | 
			
		||||
    {
 | 
			
		||||
        dan200.computercraft.shared.TurtleUpgrades.register( upgrade );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static File getWorldDir()
 | 
			
		||||
    {
 | 
			
		||||
        return DimensionManager.getCurrentSaveRootDirectory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //region Compatibility
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static File getWorldDir( World world )
 | 
			
		||||
    {
 | 
			
		||||
        return DimensionManager.getCurrentSaveRootDirectory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IMedia getMedia( ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        return MediaProviders.get( stack );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IPocketUpgrade getPocketUpgrade( ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        return dan200.computercraft.shared.PocketUpgrades.get( stack );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static ITurtleUpgrade getTurtleUpgrade( ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        return dan200.computercraft.shared.TurtleUpgrades.get( stack );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IPocketUpgrade getPocketUpgrade( String id )
 | 
			
		||||
    {
 | 
			
		||||
        return dan200.computercraft.shared.PocketUpgrades.get( id );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static ITurtleUpgrade getTurtleUpgrade( String id )
 | 
			
		||||
    {
 | 
			
		||||
        return dan200.computercraft.shared.TurtleUpgrades.get( id );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IPeripheral getPeripheralAt( World world, BlockPos pos, EnumFacing side )
 | 
			
		||||
    {
 | 
			
		||||
        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,150 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI.IComputerCraftAPI;
 | 
			
		||||
import dan200.computercraft.api.filesystem.IMount;
 | 
			
		||||
import dan200.computercraft.api.filesystem.IWritableMount;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaAPIFactory;
 | 
			
		||||
import dan200.computercraft.api.media.IMediaProvider;
 | 
			
		||||
import dan200.computercraft.api.network.IPacketNetwork;
 | 
			
		||||
import dan200.computercraft.api.network.wired.IWiredElement;
 | 
			
		||||
import dan200.computercraft.api.network.wired.IWiredNode;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
 | 
			
		||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
 | 
			
		||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import dan200.computercraft.core.apis.ApiFactories;
 | 
			
		||||
import dan200.computercraft.core.filesystem.FileMount;
 | 
			
		||||
import dan200.computercraft.shared.*;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.TileCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.TileWiredModemFull;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
 | 
			
		||||
import dan200.computercraft.shared.util.IDAssigner;
 | 
			
		||||
import dan200.computercraft.shared.wired.WiredNode;
 | 
			
		||||
import net.minecraft.block.entity.BlockEntity;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.world.BlockView;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
public final class ComputerCraftAPIImpl implements IComputerCraftAPI
 | 
			
		||||
{
 | 
			
		||||
    public static final ComputerCraftAPIImpl INSTANCE = new ComputerCraftAPIImpl();
 | 
			
		||||
 | 
			
		||||
    private ComputerCraftAPIImpl()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getInstalledVersion()
 | 
			
		||||
    {
 | 
			
		||||
        return "${version}";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
 | 
			
		||||
    {
 | 
			
		||||
        return IDAssigner.getNextId( world, parentSubPath );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            return new FileMount( new File( IDAssigner.getDir( world ), subPath ), capacity );
 | 
			
		||||
        }
 | 
			
		||||
        catch( Exception e )
 | 
			
		||||
        {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
 | 
			
		||||
    {
 | 
			
		||||
        return ComputerCraft.createResourceMount( domain, subPath );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void registerPeripheralProvider( @Nonnull IPeripheralProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        Peripherals.register( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
 | 
			
		||||
    {
 | 
			
		||||
        TurtleUpgrades.register( upgrade );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        BundledRedstone.register( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        return BundledRedstone.getDefaultOutput( world, pos, side );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void registerMediaProvider( @Nonnull IMediaProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        MediaProviders.register( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
 | 
			
		||||
    {
 | 
			
		||||
        PocketUpgrades.register( upgrade );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public IPacketNetwork getWirelessNetwork()
 | 
			
		||||
    {
 | 
			
		||||
        return WirelessNetwork.getUniversal();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void registerAPIFactory( @Nonnull ILuaAPIFactory factory )
 | 
			
		||||
    {
 | 
			
		||||
        ApiFactories.register( factory );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element )
 | 
			
		||||
    {
 | 
			
		||||
        return new WiredNode( element );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nullable
 | 
			
		||||
    @Override
 | 
			
		||||
    public IWiredElement getWiredElementAt( @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        BlockEntity tile = world.getBlockEntity( pos );
 | 
			
		||||
        if( tile instanceof TileCable )
 | 
			
		||||
        {
 | 
			
		||||
            return ((TileCable) tile).getElement( side );
 | 
			
		||||
        }
 | 
			
		||||
        else if( tile instanceof TileWiredModemFull )
 | 
			
		||||
        {
 | 
			
		||||
            return ((TileWiredModemFull) tile).getElement();
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,17 +1,16 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import dan200.computercraft.api.turtle.TurtleUpgradeType;
 | 
			
		||||
import net.minecraft.item.ItemConvertible;
 | 
			
		||||
import net.minecraft.block.Block;
 | 
			
		||||
import net.minecraft.item.Item;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.Identifier;
 | 
			
		||||
import net.minecraft.util.SystemUtil;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
@@ -22,41 +21,59 @@ import javax.annotation.Nonnull;
 | 
			
		||||
 */
 | 
			
		||||
public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
 | 
			
		||||
{
 | 
			
		||||
    private final Identifier id;
 | 
			
		||||
    private final ResourceLocation id;
 | 
			
		||||
    private final int legacyId;
 | 
			
		||||
    private final TurtleUpgradeType type;
 | 
			
		||||
    private final String adjective;
 | 
			
		||||
    private final ItemStack stack;
 | 
			
		||||
 | 
			
		||||
    protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemStack stack )
 | 
			
		||||
    protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.legacyId = legacyId;
 | 
			
		||||
        this.type = type;
 | 
			
		||||
        this.adjective = adjective;
 | 
			
		||||
        this.stack = stack;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemConvertible item )
 | 
			
		||||
    protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, Item item )
 | 
			
		||||
    {
 | 
			
		||||
        this( id, type, adjective, new ItemStack( item ) );
 | 
			
		||||
        this( id, legacyId, type, adjective, new ItemStack( item ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemStack stack )
 | 
			
		||||
    protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, Block block )
 | 
			
		||||
    {
 | 
			
		||||
        this( id, type, SystemUtil.createTranslationKey( "upgrade", id ) + ".adjective", stack );
 | 
			
		||||
        this( id, legacyId, type, adjective, new ItemStack( block ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemConvertible item )
 | 
			
		||||
    protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        this( id, type, new ItemStack( item ) );
 | 
			
		||||
        this( id, legacyId, type, "upgrade." + id + ".adjective", stack );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Item item )
 | 
			
		||||
    {
 | 
			
		||||
        this( id, legacyId, type, new ItemStack( item ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Block block )
 | 
			
		||||
    {
 | 
			
		||||
        this( id, legacyId, type, new ItemStack( block ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public final Identifier getUpgradeID()
 | 
			
		||||
    public final ResourceLocation getUpgradeID()
 | 
			
		||||
    {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public final int getLegacyUpgradeID()
 | 
			
		||||
    {
 | 
			
		||||
        return legacyId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public final String getUnlocalisedAdjective()
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.filesystem.IMount;
 | 
			
		||||
@@ -17,28 +16,49 @@ import dan200.computercraft.api.network.wired.IWiredNode;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IComputerAccess;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
 | 
			
		||||
import dan200.computercraft.api.permissions.ITurtlePermissionProvider;
 | 
			
		||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
 | 
			
		||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.world.BlockView;
 | 
			
		||||
import net.minecraft.world.IBlockAccess;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
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
 | 
			
		||||
{
 | 
			
		||||
    public static boolean isInstalled()
 | 
			
		||||
    {
 | 
			
		||||
        findCC();
 | 
			
		||||
        return computerCraft != null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static String getInstalledVersion()
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().getInstalledVersion();
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_getVersion != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (String) computerCraft_getVersion.invoke( null );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
@@ -62,7 +82,19 @@ public final class ComputerCraftAPI
 | 
			
		||||
     */
 | 
			
		||||
    public static int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().createUniqueNumberedSaveDir( world, parentSubPath );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_createUniqueNumberedSaveDir != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (Integer) computerCraft_createUniqueNumberedSaveDir.invoke( null, world, parentSubPath );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -86,54 +118,55 @@ public final class ComputerCraftAPI
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().createSaveDirMount( world, subPath, capacity );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_createSaveDirMount != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (IWritableMount) computerCraft_createSaveDirMount.invoke( null, world, subPath, capacity );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a file system mount to a resource folder, and returns it.
 | 
			
		||||
     *
 | 
			
		||||
     * Use in conjunction with {@link IComputerAccess#mount} or {@link IComputerAccess#mountWritable} to mount a
 | 
			
		||||
     * resource folder onto a computer's file system.
 | 
			
		||||
     * Use in conjunction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a resource folder
 | 
			
		||||
     * onto a computer's file system.
 | 
			
		||||
     *
 | 
			
		||||
     * The files in this mount will be a combination of files in all mod jar, and data packs that contain
 | 
			
		||||
     * The files in this mount will be a combination of files in the specified mod jar, and resource packs that contain
 | 
			
		||||
     * resources with the same domain and path.
 | 
			
		||||
     *
 | 
			
		||||
     * @param domain  The domain under which to look for resources. eg: "mymod".
 | 
			
		||||
     * @param subPath The subPath under which to look for resources. eg: "lua/myfiles".
 | 
			
		||||
     * @return The mount, or {@code null} if it could be created for some reason.
 | 
			
		||||
     * @param modClass A class in whose jar to look first for the resources to mount. Using your main mod class is recommended. eg: MyMod.class
 | 
			
		||||
     * @param domain   The domain under which to look for resources. eg: "mymod".
 | 
			
		||||
     * @param subPath  The domain under which to look for resources. eg: "mymod/lua/myfiles".
 | 
			
		||||
     * @return The mount, or {@code null} if it could be created for some reason. Use IComputerAccess.mount() or
 | 
			
		||||
     * IComputerAccess.mountWritable() to mount this on a Computers' file system.
 | 
			
		||||
     * @see IComputerAccess#mount(String, IMount)
 | 
			
		||||
     * @see IComputerAccess#mountWritable(String, IWritableMount)
 | 
			
		||||
     * @see IMount
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
 | 
			
		||||
    public static IMount createResourceMount( @Nonnull Class<?> modClass, @Nonnull String domain, @Nonnull String subPath )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().createResourceMount( domain, subPath );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a file system mount to a resource folder, and returns it.
 | 
			
		||||
     *
 | 
			
		||||
     * Use in conjunction with {@link IComputerAccess#mount} or {@link IComputerAccess#mountWritable} to mount a
 | 
			
		||||
     * resource folder onto a computer's file system.
 | 
			
		||||
     *
 | 
			
		||||
     * The files in this mount will be a combination of files in all mod jar, and data packs that contain
 | 
			
		||||
     * resources with the same domain and path.
 | 
			
		||||
     *
 | 
			
		||||
     * @param klass   The mod class to which the files belong.
 | 
			
		||||
     * @param domain  The domain under which to look for resources. eg: "mymod".
 | 
			
		||||
     * @param subPath The subPath under which to look for resources. eg: "lua/myfiles".
 | 
			
		||||
     * @return The mount, or {@code null} if it could be created for some reason.
 | 
			
		||||
     * @see IComputerAccess#mount(String, IMount)
 | 
			
		||||
     * @see IComputerAccess#mountWritable(String, IWritableMount)
 | 
			
		||||
     * @see IMount
 | 
			
		||||
     * @deprecated Use {@link #createResourceMount(String, String)} instead.
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static IMount createResourceMount( Class<?> klass, @Nonnull String domain, @Nonnull String subPath )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().createResourceMount( domain, subPath );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_createResourceMount != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (IMount) computerCraft_createResourceMount.invoke( null, modClass, domain, subPath );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -145,7 +178,18 @@ public final class ComputerCraftAPI
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerPeripheralProvider( @Nonnull IPeripheralProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        getInstance().registerPeripheralProvider( provider );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_registerPeripheralProvider != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                computerCraft_registerPeripheralProvider.invoke( null, provider );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -158,7 +202,21 @@ public final class ComputerCraftAPI
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
 | 
			
		||||
    {
 | 
			
		||||
        getInstance().registerTurtleUpgrade( upgrade );
 | 
			
		||||
        if( upgrade != null )
 | 
			
		||||
        {
 | 
			
		||||
            findCC();
 | 
			
		||||
            if( computerCraft_registerTurtleUpgrade != null )
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    computerCraft_registerTurtleUpgrade.invoke( null, upgrade );
 | 
			
		||||
                }
 | 
			
		||||
                catch( Exception e )
 | 
			
		||||
                {
 | 
			
		||||
                    // It failed
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -169,7 +227,18 @@ public final class ComputerCraftAPI
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        getInstance().registerBundledRedstoneProvider( provider );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_registerBundledRedstoneProvider != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                computerCraft_registerBundledRedstoneProvider.invoke( null, provider );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -182,25 +251,83 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
 | 
			
		||||
     * @see IBundledRedstoneProvider
 | 
			
		||||
     */
 | 
			
		||||
    public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().getBundledRedstoneOutput( world, pos, side );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_getDefaultBundledRedstoneOutput != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (Integer) computerCraft_getDefaultBundledRedstoneOutput.invoke( null, world, pos, side );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerMediaProvider( @Nonnull IMediaProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        getInstance().registerMediaProvider( provider );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_registerMediaProvider != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                computerCraft_registerMediaProvider.invoke( null, provider );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Registers a permission provider to restrict where turtles can move or build.
 | 
			
		||||
     *
 | 
			
		||||
     * @param provider The turtle permission provider to register.
 | 
			
		||||
     * @see ITurtlePermissionProvider
 | 
			
		||||
     * @deprecated Prefer using {@link dan200.computercraft.api.turtle.event.TurtleBlockEvent} or the standard Forge events.
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public static void registerPermissionProvider( @Nonnull ITurtlePermissionProvider provider )
 | 
			
		||||
    {
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_registerPermissionProvider != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                computerCraft_registerPermissionProvider.invoke( null, provider );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
 | 
			
		||||
    {
 | 
			
		||||
        getInstance().registerPocketUpgrade( upgrade );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_registerPocketUpgrade != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                computerCraft_registerPocketUpgrade.invoke( null, upgrade );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -210,16 +337,40 @@ public final class ComputerCraftAPI
 | 
			
		||||
     */
 | 
			
		||||
    public static IPacketNetwork getWirelessNetwork()
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().getWirelessNetwork();
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_getWirelessNetwork != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (IPacketNetwork) computerCraft_getWirelessNetwork.invoke( null );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void registerAPIFactory( @Nonnull ILuaAPIFactory factory )
 | 
			
		||||
    public static void registerAPIFactory( @Nonnull ILuaAPIFactory upgrade )
 | 
			
		||||
    {
 | 
			
		||||
        getInstance().registerAPIFactory( factory );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_registerAPIFactory != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                computerCraft_registerAPIFactory.invoke( null, upgrade );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                // It failed
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
@@ -228,11 +379,26 @@ public final class ComputerCraftAPI
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().createWiredNodeForElement( element );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_createWiredNodeForElement != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (IWiredNode) computerCraft_createWiredNodeForElement.invoke( null, element );
 | 
			
		||||
            }
 | 
			
		||||
            catch( ReflectiveOperationException e )
 | 
			
		||||
            {
 | 
			
		||||
                throw new IllegalStateException( "Error creating wired node", e );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw new IllegalStateException( "ComputerCraft cannot be found" );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
@@ -241,63 +407,117 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * @see IWiredElement#getNode()
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static IWiredElement getWiredElementAt( @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    public static IWiredElement getWiredElementAt( @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().getWiredElementAt( world, pos, side );
 | 
			
		||||
        findCC();
 | 
			
		||||
        if( computerCraft_getWiredElementAt != null )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return (IWiredElement) computerCraft_getWiredElementAt.invoke( null, world, pos, side );
 | 
			
		||||
            }
 | 
			
		||||
            catch( ReflectiveOperationException ignored )
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static IComputerCraftAPI instance;
 | 
			
		||||
    // The functions below here are private, and are used to interface with the non-API ComputerCraft classes.
 | 
			
		||||
    // Reflection is used here so you can develop your mod without decompiling ComputerCraft and including
 | 
			
		||||
    // it in your solution, and so your mod won't crash if ComputerCraft is installed.
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    private static IComputerCraftAPI getInstance()
 | 
			
		||||
    private static void findCC()
 | 
			
		||||
    {
 | 
			
		||||
        if( instance != null ) return instance;
 | 
			
		||||
        if( !ccSearched )
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
 | 
			
		||||
                computerCraft_getVersion = findCCMethod( "getVersion", new Class<?>[] {
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class<?>[] {
 | 
			
		||||
                    World.class, String.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class<?>[] {
 | 
			
		||||
                    World.class, String.class, Long.TYPE,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class<?>[] {
 | 
			
		||||
                    Class.class, String.class, String.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class<?>[] {
 | 
			
		||||
                    IPeripheralProvider.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class<?>[] {
 | 
			
		||||
                    ITurtleUpgrade.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class<?>[] {
 | 
			
		||||
                    IBundledRedstoneProvider.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class<?>[] {
 | 
			
		||||
                    World.class, BlockPos.class, EnumFacing.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class<?>[] {
 | 
			
		||||
                    IMediaProvider.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class<?>[] {
 | 
			
		||||
                    ITurtlePermissionProvider.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerPocketUpgrade = findCCMethod( "registerPocketUpgrade", new Class<?>[] {
 | 
			
		||||
                    IPocketUpgrade.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_getWirelessNetwork = findCCMethod( "getWirelessNetwork", new Class<?>[] {
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_registerAPIFactory = findCCMethod( "registerAPIFactory", new Class<?>[] {
 | 
			
		||||
                    ILuaAPIFactory.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_createWiredNodeForElement = findCCMethod( "createWiredNodeForElement", new Class<?>[] {
 | 
			
		||||
                    IWiredElement.class,
 | 
			
		||||
                } );
 | 
			
		||||
                computerCraft_getWiredElementAt = findCCMethod( "getWiredElementAt", new Class<?>[] {
 | 
			
		||||
                    IBlockAccess.class, BlockPos.class, EnumFacing.class,
 | 
			
		||||
                } );
 | 
			
		||||
            }
 | 
			
		||||
            catch( Exception e )
 | 
			
		||||
            {
 | 
			
		||||
                System.err.println( "ComputerCraftAPI: ComputerCraft not found." );
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                ccSearched = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static Method findCCMethod( String name, Class<?>[] args )
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            return instance = (IComputerCraftAPI) Class.forName( "dan200.computercraft.ComputerCraftAPIImpl" )
 | 
			
		||||
                .getField( "INSTANCE" ).get( null );
 | 
			
		||||
            return computerCraft != null ? computerCraft.getMethod( name, args ) : null;
 | 
			
		||||
        }
 | 
			
		||||
        catch( ReflectiveOperationException e )
 | 
			
		||||
        catch( NoSuchMethodException e )
 | 
			
		||||
        {
 | 
			
		||||
            throw new IllegalStateException( "Cannot find ComputerCraft API", e );
 | 
			
		||||
            System.err.println( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public interface IComputerCraftAPI
 | 
			
		||||
    {
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        String getInstalledVersion();
 | 
			
		||||
 | 
			
		||||
        int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath );
 | 
			
		||||
 | 
			
		||||
        @Nullable
 | 
			
		||||
        IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity );
 | 
			
		||||
 | 
			
		||||
        @Nullable
 | 
			
		||||
        IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath );
 | 
			
		||||
 | 
			
		||||
        void registerPeripheralProvider( @Nonnull IPeripheralProvider provider );
 | 
			
		||||
 | 
			
		||||
        void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade );
 | 
			
		||||
 | 
			
		||||
        void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider );
 | 
			
		||||
 | 
			
		||||
        int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
 | 
			
		||||
        void registerMediaProvider( @Nonnull IMediaProvider provider );
 | 
			
		||||
 | 
			
		||||
        void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade );
 | 
			
		||||
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        IPacketNetwork getWirelessNetwork();
 | 
			
		||||
 | 
			
		||||
        void registerAPIFactory( @Nonnull ILuaAPIFactory factory );
 | 
			
		||||
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element );
 | 
			
		||||
 | 
			
		||||
        @Nullable
 | 
			
		||||
        IWiredElement getWiredElementAt( @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
    }
 | 
			
		||||
    private static boolean ccSearched = false;
 | 
			
		||||
    private static Class<?> computerCraft = null;
 | 
			
		||||
    private static Method computerCraft_getVersion = null;
 | 
			
		||||
    private static Method computerCraft_createUniqueNumberedSaveDir = null;
 | 
			
		||||
    private static Method computerCraft_createSaveDirMount = null;
 | 
			
		||||
    private static Method computerCraft_createResourceMount = null;
 | 
			
		||||
    private static Method computerCraft_registerPeripheralProvider = null;
 | 
			
		||||
    private static Method computerCraft_registerTurtleUpgrade = null;
 | 
			
		||||
    private static Method computerCraft_registerBundledRedstoneProvider = null;
 | 
			
		||||
    private static Method computerCraft_getDefaultBundledRedstoneOutput = null;
 | 
			
		||||
    private static Method computerCraft_registerMediaProvider = null;
 | 
			
		||||
    private static Method computerCraft_registerPermissionProvider = null;
 | 
			
		||||
    private static Method computerCraft_registerPocketUpgrade = null;
 | 
			
		||||
    private static Method computerCraft_getWirelessNetwork = null;
 | 
			
		||||
    private static Method computerCraft_registerAPIFactory = null;
 | 
			
		||||
    private static Method computerCraft_createWiredNodeForElement = null;
 | 
			
		||||
    private static Method computerCraft_getWiredElementAt = null;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,81 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
package dan200.computercraft.api.filesystem;
 | 
			
		||||
 | 
			
		||||
import java.nio.file.attribute.BasicFileAttributes;
 | 
			
		||||
import java.nio.file.attribute.FileTime;
 | 
			
		||||
import java.time.Instant;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A simple version of {@link BasicFileAttributes}, which provides what information a {@link IMount} already exposes.
 | 
			
		||||
 */
 | 
			
		||||
final class FileAttributes implements BasicFileAttributes
 | 
			
		||||
{
 | 
			
		||||
    private static final FileTime EPOCH = FileTime.from( Instant.EPOCH );
 | 
			
		||||
 | 
			
		||||
    private final boolean isDirectory;
 | 
			
		||||
    private final long size;
 | 
			
		||||
 | 
			
		||||
    FileAttributes( boolean isDirectory, long size )
 | 
			
		||||
    {
 | 
			
		||||
        this.isDirectory = isDirectory;
 | 
			
		||||
        this.size = size;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public FileTime lastModifiedTime()
 | 
			
		||||
    {
 | 
			
		||||
        return EPOCH;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public FileTime lastAccessTime()
 | 
			
		||||
    {
 | 
			
		||||
        return EPOCH;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public FileTime creationTime()
 | 
			
		||||
    {
 | 
			
		||||
        return EPOCH;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isRegularFile()
 | 
			
		||||
    {
 | 
			
		||||
        return !isDirectory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isDirectory()
 | 
			
		||||
    {
 | 
			
		||||
        return isDirectory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isSymbolicLink()
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isOther()
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long size()
 | 
			
		||||
    {
 | 
			
		||||
        return size;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object fileKey()
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,41 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.filesystem;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.filesystem;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
@@ -15,11 +14,12 @@ 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,9 +90,22 @@ 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,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.filesystem;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
@@ -15,6 +14,7 @@ import java.io.IOException;
 | 
			
		||||
import java.io.OutputStream;
 | 
			
		||||
import java.nio.channels.Channels;
 | 
			
		||||
import java.nio.channels.WritableByteChannel;
 | 
			
		||||
import java.util.OptionalLong;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Represents a part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)}
 | 
			
		||||
@@ -67,7 +67,6 @@ 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 ) );
 | 
			
		||||
@@ -94,7 +93,6 @@ 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 ) );
 | 
			
		||||
@@ -108,4 +106,16 @@ public interface IWritableMount extends IMount
 | 
			
		||||
     * @throws IOException If the remaining space could not be computed.
 | 
			
		||||
     */
 | 
			
		||||
    long getRemainingSpace() throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the capacity of this mount. This should be equal to the size of all files/directories on this mount, minus
 | 
			
		||||
     * the {@link #getRemainingSpace()}.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The capacity of this mount, in bytes.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    default OptionalLong getCapacity()
 | 
			
		||||
    {
 | 
			
		||||
        return OptionalLong.empty();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
							
								
								
									
										334
									
								
								src/main/java/dan200/computercraft/api/lua/ArgumentHelper.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										334
									
								
								src/main/java/dan200/computercraft/api/lua/ArgumentHelper.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,334 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.lua;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.filesystem.IFileSystem;
 | 
			
		||||
@@ -26,7 +25,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,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.lua;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.lua;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.lua;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.lua;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.peripheral.IComputerAccess;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.lua;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.lua;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -1,15 +1,14 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.media;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.filesystem.IMount;
 | 
			
		||||
import net.minecraft.item.Item;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.sound.SoundEvent;
 | 
			
		||||
import net.minecraft.util.SoundEvent;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.media;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
package dan200.computercraft.api.network;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
package dan200.computercraft.api.network;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
package dan200.computercraft.api.network;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
package dan200.computercraft.api.network;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.network.wired;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.network.wired;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.network.wired;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.network.wired;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.network.IPacketNetwork;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.network.wired;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.network.IPacketSender;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
							
								
								
									
										9
									
								
								src/main/java/dan200/computercraft/api/package-info.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/main/java/dan200/computercraft/api/package-info.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.peripheral;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.peripheral;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.lua.ArgumentHelper;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
import dan200.computercraft.api.lua.LuaException;
 | 
			
		||||
 | 
			
		||||
@@ -58,9 +58,11 @@ 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 and ILuaObject and null be converted to their corresponding lua type. All other types
 | 
			
		||||
     * will be converted to nil.
 | 
			
		||||
     * Strings, Booleans, Maps, 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
 | 
			
		||||
@@ -70,6 +72,7 @@ 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;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,13 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.peripheral;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.block.entity.BlockEntity;
 | 
			
		||||
import net.minecraft.tileentity.TileEntity;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -17,8 +16,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
/**
 | 
			
		||||
 * This interface is used to create peripheral implementations for blocks.
 | 
			
		||||
 *
 | 
			
		||||
 * If you have a {@link BlockEntity} which acts as a peripheral, you may alternatively implement
 | 
			
		||||
 * {@link IPeripheralTile}.
 | 
			
		||||
 * If you have a {@link TileEntity} which acts as a peripheral, you may alternatively implement {@link IPeripheralTile}.
 | 
			
		||||
 *
 | 
			
		||||
 * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
 | 
			
		||||
 */
 | 
			
		||||
@@ -35,5 +33,5 @@ public interface IPeripheralProvider
 | 
			
		||||
     * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,19 +1,19 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
package dan200.computercraft.api.peripheral;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A {@link net.minecraft.block.entity.BlockEntity} which may act as a peripheral.
 | 
			
		||||
 * 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}.
 | 
			
		||||
@@ -25,8 +25,8 @@ public interface IPeripheralTile
 | 
			
		||||
     *
 | 
			
		||||
     * @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, Direction)
 | 
			
		||||
     * @see IPeripheralProvider#getPeripheral(World, BlockPos, EnumFacing)
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull Direction side );
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull EnumFacing side );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 * 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;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -0,0 +1,41 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.permissions;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This interface is used to restrict where turtles can move or build.
 | 
			
		||||
 *
 | 
			
		||||
 * Turtles will call these methods before attempting to perform an action, allowing them to be cancelled.
 | 
			
		||||
 *
 | 
			
		||||
 * @see dan200.computercraft.api.ComputerCraftAPI#registerPermissionProvider(ITurtlePermissionProvider)
 | 
			
		||||
 */
 | 
			
		||||
public interface ITurtlePermissionProvider
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine whether a block can be entered by a turtle.
 | 
			
		||||
     *
 | 
			
		||||
     * @param world The world the block exists in
 | 
			
		||||
     * @param pos   The location of the block.
 | 
			
		||||
     * @return Whether the turtle can move into this block.
 | 
			
		||||
     */
 | 
			
		||||
    boolean isBlockEnterable( @Nonnull World world, @Nonnull BlockPos pos );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine whether a block can be modified by a turtle.
 | 
			
		||||
     *
 | 
			
		||||
     * This includes breaking and placing blocks.
 | 
			
		||||
     *
 | 
			
		||||
     * @param world The world the block exists in
 | 
			
		||||
     * @param pos   The location of the block.
 | 
			
		||||
     * @return Whether the turtle can modify this block.
 | 
			
		||||
     */
 | 
			
		||||
    boolean isBlockEditable( @Nonnull World world, @Nonnull BlockPos pos );
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								src/main/java/dan200/computercraft/api/permissions/package-info.java
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								src/main/java/dan200/computercraft/api/permissions/package-info.java
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -1,15 +1,12 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 * 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.pocket;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.item.ItemConvertible;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.Identifier;
 | 
			
		||||
import net.minecraft.util.SystemUtil;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
@@ -20,30 +17,25 @@ import javax.annotation.Nonnull;
 | 
			
		||||
 */
 | 
			
		||||
public abstract class AbstractPocketUpgrade implements IPocketUpgrade
 | 
			
		||||
{
 | 
			
		||||
    private final Identifier id;
 | 
			
		||||
    private final ResourceLocation id;
 | 
			
		||||
    private final String adjective;
 | 
			
		||||
    private final ItemStack stack;
 | 
			
		||||
 | 
			
		||||
    protected AbstractPocketUpgrade( Identifier id, String adjective, ItemStack stack )
 | 
			
		||||
    protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.adjective = adjective;
 | 
			
		||||
        this.stack = stack;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected AbstractPocketUpgrade( Identifier identifier, String adjective, ItemConvertible item )
 | 
			
		||||
    protected AbstractPocketUpgrade( ResourceLocation id, ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        this( identifier, adjective, new ItemStack( item ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected AbstractPocketUpgrade( Identifier id, ItemConvertible item )
 | 
			
		||||
    {
 | 
			
		||||
        this( id, SystemUtil.createTranslationKey( "upgrade", id ) + ".adjective", new ItemStack( item ) );
 | 
			
		||||
        this( id, "upgrade." + id + ".adjective", stack );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public final Identifier getUpgradeID()
 | 
			
		||||
    public final ResourceLocation getUpgradeID()
 | 
			
		||||
    {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,34 +1,43 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.pocket;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import net.minecraft.entity.Entity;
 | 
			
		||||
import net.minecraft.nbt.CompoundTag;
 | 
			
		||||
import net.minecraft.util.Identifier;
 | 
			
		||||
import net.minecraft.nbt.NBTTagCompound;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Wrapper class for pocket computers
 | 
			
		||||
 * Wrapper class for pocket computers.
 | 
			
		||||
 */
 | 
			
		||||
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 getEntity();
 | 
			
		||||
    Entity getValidEntity();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the colour of this pocket computer as a RGB number.
 | 
			
		||||
@@ -75,7 +84,7 @@ public interface IPocketAccess
 | 
			
		||||
     * @see #updateUpgradeNBTData()
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    CompoundTag getUpgradeNBTData();
 | 
			
		||||
    NBTTagCompound getUpgradeNBTData();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Mark the upgrade-specific NBT as dirty.
 | 
			
		||||
@@ -95,5 +104,5 @@ public interface IPocketAccess
 | 
			
		||||
     * @return A collection of all upgrade names.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    Map<Identifier, IPeripheral> getUpgrades();
 | 
			
		||||
    Map<ResourceLocation, IPeripheral> getUpgrades();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,15 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.pocket;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.Identifier;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -36,7 +35,7 @@ public interface IPocketUpgrade
 | 
			
		||||
     * @see ComputerCraftAPI#registerPocketUpgrade(IPocketUpgrade)
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    Identifier getUpgradeID();
 | 
			
		||||
    ResourceLocation getUpgradeID();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return an unlocalised string to describe the type of pocket computer this upgrade provides.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,12 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.redstone;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -30,5 +29,5 @@ public interface IBundledRedstoneProvider
 | 
			
		||||
     * handle this block.
 | 
			
		||||
     * @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
 | 
			
		||||
     */
 | 
			
		||||
    int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
    int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -1,21 +1,21 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
import com.mojang.authlib.GameProfile;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
import dan200.computercraft.api.lua.LuaException;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import net.minecraft.inventory.Inventory;
 | 
			
		||||
import net.minecraft.nbt.CompoundTag;
 | 
			
		||||
import net.minecraft.inventory.IInventory;
 | 
			
		||||
import net.minecraft.nbt.NBTTagCompound;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.util.math.Vec3d;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.items.IItemHandlerModifiable;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
@@ -53,7 +53,8 @@ public interface ITurtleAccess
 | 
			
		||||
     * @param world The new world to move it to
 | 
			
		||||
     * @param pos   The new position to move it to.
 | 
			
		||||
     * @return Whether the movement was successful. It may fail if the block was not loaded or the block placement
 | 
			
		||||
     * was cancelled.
 | 
			
		||||
     * was cancelled. Note this will not check
 | 
			
		||||
     * {@link dan200.computercraft.api.permissions.ITurtlePermissionProvider#isBlockEnterable(World, BlockPos)}.
 | 
			
		||||
     * @throws UnsupportedOperationException When attempting to teleport on the client side.
 | 
			
		||||
     */
 | 
			
		||||
    boolean teleportTo( @Nonnull World world, @Nonnull BlockPos pos );
 | 
			
		||||
@@ -82,10 +83,10 @@ public interface ITurtleAccess
 | 
			
		||||
     * Returns the world direction the turtle is currently facing.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The world direction the turtle is currently facing.
 | 
			
		||||
     * @see #setDirection(Direction)
 | 
			
		||||
     * @see #setDirection(EnumFacing)
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    Direction getDirection();
 | 
			
		||||
    EnumFacing getDirection();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the direction the turtle is facing. Note that this will not play a rotation animation, you will also need to
 | 
			
		||||
@@ -94,7 +95,7 @@ public interface ITurtleAccess
 | 
			
		||||
     * @param dir The new direction to set. This should be on either the x or z axis (so north, south, east or west).
 | 
			
		||||
     * @see #getDirection()
 | 
			
		||||
     */
 | 
			
		||||
    void setDirection( @Nonnull Direction dir );
 | 
			
		||||
    void setDirection( @Nonnull EnumFacing dir );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the currently selected slot in the turtle's inventory.
 | 
			
		||||
@@ -143,12 +144,28 @@ public interface ITurtleAccess
 | 
			
		||||
    GameProfile getOwningPlayer();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the inventory of this turtle
 | 
			
		||||
     * Get the inventory of this turtle.
 | 
			
		||||
     *
 | 
			
		||||
     * Note: this inventory should only be accessed and modified on the server thread.
 | 
			
		||||
     *
 | 
			
		||||
     * @return This turtle's inventory
 | 
			
		||||
     * @see #getItemHandler()
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    Inventory getInventory();
 | 
			
		||||
    IInventory getInventory();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
     * @see net.minecraftforge.items.CapabilityItemHandler#ITEM_HANDLER_CAPABILITY
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    IItemHandlerModifiable getItemHandler();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine whether this turtle will require fuel when performing actions.
 | 
			
		||||
@@ -277,7 +294,7 @@ public interface ITurtleAccess
 | 
			
		||||
     * @see #updateUpgradeNBTData(TurtleSide)
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    CompoundTag getUpgradeNBTData( @Nullable TurtleSide side );
 | 
			
		||||
    NBTTagCompound getUpgradeNBTData( @Nullable TurtleSide side );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Mark the upgrade-specific data as dirty on a specific side. This is required for the data to be synced to the
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,22 +1,23 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import dan200.computercraft.api.turtle.event.TurtleAttackEvent;
 | 
			
		||||
import dan200.computercraft.api.turtle.event.TurtleBlockEvent;
 | 
			
		||||
import net.fabricmc.api.EnvType;
 | 
			
		||||
import net.fabricmc.api.Environment;
 | 
			
		||||
import net.minecraft.client.render.model.BakedModel;
 | 
			
		||||
import net.minecraft.client.util.ModelIdentifier;
 | 
			
		||||
import net.minecraft.client.renderer.block.model.IBakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.Identifier;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
 | 
			
		||||
import net.minecraftforge.event.world.BlockEvent;
 | 
			
		||||
import net.minecraftforge.fml.relauncher.Side;
 | 
			
		||||
import net.minecraftforge.fml.relauncher.SideOnly;
 | 
			
		||||
import org.apache.commons.lang3.tuple.Pair;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -40,7 +41,18 @@ public interface ITurtleUpgrade
 | 
			
		||||
     * @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade)
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    Identifier getUpgradeID();
 | 
			
		||||
    ResourceLocation getUpgradeID();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a numerical identifier representing this type of turtle upgrade,
 | 
			
		||||
     * for backwards compatibility with pre-1.76 worlds. If your upgrade was
 | 
			
		||||
     * not released for older ComputerCraft versions, you can return -1 here.
 | 
			
		||||
     * The turtle will fail registration if an already used positive ID is specified.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The legacy ID, or -1 if is needed.
 | 
			
		||||
     * @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade)
 | 
			
		||||
     */
 | 
			
		||||
    int getLegacyUpgradeID();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return an unlocalised string to describe this type of turtle in turtle item names.
 | 
			
		||||
@@ -96,8 +108,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 {@code BlockEvent.BreakEvent} and {@link TurtleBlockEvent.Dig}for digging,
 | 
			
		||||
     * {@code 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.
 | 
			
		||||
@@ -111,7 +123,7 @@ public interface ITurtleUpgrade
 | 
			
		||||
     * to be called.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    default TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull Direction direction )
 | 
			
		||||
    default TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction )
 | 
			
		||||
    {
 | 
			
		||||
        return TurtleCommandResult.failure();
 | 
			
		||||
    }
 | 
			
		||||
@@ -119,8 +131,8 @@ public interface ITurtleUpgrade
 | 
			
		||||
    /**
 | 
			
		||||
     * Called to obtain the model to be used when rendering a turtle peripheral.
 | 
			
		||||
     *
 | 
			
		||||
     * This can be obtained from {@link net.minecraft.client.render.item.ItemModels#getModel(ItemStack)},
 | 
			
		||||
     * {@link net.minecraft.client.render.model.BakedModelManager#getModel(ModelIdentifier)} or any other
 | 
			
		||||
     * This can be obtained from {@link net.minecraft.client.renderer.ItemModelMesher#getItemModel(ItemStack)},
 | 
			
		||||
     * {@link net.minecraft.client.renderer.block.model.ModelManager#getModel(ModelResourceLocation)} or any other
 | 
			
		||||
     * source.
 | 
			
		||||
     *
 | 
			
		||||
     * @param turtle Access to the turtle that the upgrade resides on. This will be null when getting item models!
 | 
			
		||||
@@ -129,8 +141,8 @@ public interface ITurtleUpgrade
 | 
			
		||||
     * a transformation of {@code null} has the same effect as the identify matrix.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Environment( EnvType.CLIENT )
 | 
			
		||||
    Pair<BakedModel, Matrix4f> getModel( @Nullable ITurtleAccess turtle, @Nonnull TurtleSide side );
 | 
			
		||||
    @SideOnly( Side.CLIENT )
 | 
			
		||||
    Pair<IBakedModel, Matrix4f> getModel( @Nullable ITurtleAccess turtle, @Nonnull TurtleSide side );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called once per tick for each turtle which has the upgrade equipped.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,11 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
@@ -15,7 +14,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
 * Used to indicate the result of executing a turtle command.
 | 
			
		||||
 *
 | 
			
		||||
 * @see ITurtleCommand#execute(ITurtleAccess)
 | 
			
		||||
 * @see ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)
 | 
			
		||||
 * @see ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, EnumFacing)
 | 
			
		||||
 */
 | 
			
		||||
public final class TurtleCommandResult
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -12,12 +11,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,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,29 +1,28 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An enum representing the different actions that an {@link ITurtleUpgrade} of type Tool may be called on to perform by
 | 
			
		||||
 * a turtle.
 | 
			
		||||
 *
 | 
			
		||||
 * @see ITurtleUpgrade#getType()
 | 
			
		||||
 * @see ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)
 | 
			
		||||
 * @see ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, 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,286 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
import com.mojang.authlib.GameProfile;
 | 
			
		||||
import io.netty.channel.ChannelHandlerContext;
 | 
			
		||||
import io.netty.util.concurrent.Future;
 | 
			
		||||
import io.netty.util.concurrent.GenericFutureListener;
 | 
			
		||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
 | 
			
		||||
import net.minecraft.block.entity.SignBlockEntity;
 | 
			
		||||
import net.minecraft.command.arguments.EntityAnchorArgumentType;
 | 
			
		||||
import net.minecraft.container.Container;
 | 
			
		||||
import net.minecraft.container.NameableContainerProvider;
 | 
			
		||||
import net.minecraft.entity.Entity;
 | 
			
		||||
import net.minecraft.entity.damage.DamageSource;
 | 
			
		||||
import net.minecraft.entity.effect.StatusEffectInstance;
 | 
			
		||||
import net.minecraft.entity.passive.HorseBaseEntity;
 | 
			
		||||
import net.minecraft.inventory.Inventory;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.network.ClientConnection;
 | 
			
		||||
import net.minecraft.network.NetworkSide;
 | 
			
		||||
import net.minecraft.network.NetworkState;
 | 
			
		||||
import net.minecraft.network.Packet;
 | 
			
		||||
import net.minecraft.network.chat.ChatMessageType;
 | 
			
		||||
import net.minecraft.network.chat.Component;
 | 
			
		||||
import net.minecraft.recipe.Recipe;
 | 
			
		||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
 | 
			
		||||
import net.minecraft.server.network.ServerPlayerEntity;
 | 
			
		||||
import net.minecraft.server.network.ServerPlayerInteractionManager;
 | 
			
		||||
import net.minecraft.server.network.packet.RequestCommandCompletionsC2SPacket;
 | 
			
		||||
import net.minecraft.server.network.packet.VehicleMoveC2SPacket;
 | 
			
		||||
import net.minecraft.server.world.ServerWorld;
 | 
			
		||||
import net.minecraft.sound.SoundCategory;
 | 
			
		||||
import net.minecraft.sound.SoundEvent;
 | 
			
		||||
import net.minecraft.util.DefaultedList;
 | 
			
		||||
import net.minecraft.util.Hand;
 | 
			
		||||
import net.minecraft.util.math.ChunkPos;
 | 
			
		||||
import net.minecraft.util.math.Vec3d;
 | 
			
		||||
import net.minecraft.village.TraderOfferList;
 | 
			
		||||
import net.minecraft.world.GameMode;
 | 
			
		||||
import net.minecraft.world.dimension.DimensionType;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import javax.crypto.SecretKey;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.OptionalInt;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A wrapper for {@link ServerPlayerEntity} which denotes a "fake" player.
 | 
			
		||||
 *
 | 
			
		||||
 * Please note that this does not implement any of the traditional fake player behaviour. It simply exists to prevent
 | 
			
		||||
 * me passing in normal players.
 | 
			
		||||
 */
 | 
			
		||||
public class FakePlayer extends ServerPlayerEntity
 | 
			
		||||
{
 | 
			
		||||
    public FakePlayer( ServerWorld world, GameProfile gameProfile )
 | 
			
		||||
    {
 | 
			
		||||
        super( world.getServer(), world, gameProfile, new ServerPlayerInteractionManager( world ) );
 | 
			
		||||
        networkHandler = new FakeNetHandler( this );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // region Direct networkHandler access
 | 
			
		||||
    @Override
 | 
			
		||||
    public void method_6000() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void method_6044() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void tick() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void method_14226() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onDeath( DamageSource damage ) { }
 | 
			
		||||
 | 
			
		||||
    @Nullable
 | 
			
		||||
    @Override
 | 
			
		||||
    public Entity changeDimension( DimensionType dimension )
 | 
			
		||||
    {
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void wakeUp( boolean resetTimer, boolean notify, boolean setSpawn ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean startRiding( Entity entity, boolean flag )
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void stopRiding() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void openEditSignScreen( SignBlockEntity tile ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public OptionalInt openContainer( @Nullable NameableContainerProvider container )
 | 
			
		||||
    {
 | 
			
		||||
        return OptionalInt.empty();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void sendTradeOffers( int id, TraderOfferList list, int level, int experience, boolean levelled ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void openHorseInventory( HorseBaseEntity horse, Inventory inventory ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void openEditBookScreen( ItemStack stack, Hand hand ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void openCommandBlockScreen( CommandBlockBlockEntity block ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onContainerSlotUpdate( Container container, int slot, ItemStack stack ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onContainerRegistered( Container container, DefaultedList<ItemStack> defaultedList ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onContainerPropertyUpdate( Container container, int key, int value ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void closeContainer() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void method_14241() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void addChatMessage( Component textComponent, boolean status ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void method_6040() { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void lookAt( EntityAnchorArgumentType.EntityAnchor anchor, Vec3d vec3d ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void method_14222( EntityAnchorArgumentType.EntityAnchor self, Entity entity, EntityAnchorArgumentType.EntityAnchor target ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void method_6020( StatusEffectInstance statusEffectInstance ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void method_6009( StatusEffectInstance statusEffectInstance, boolean particles ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void method_6129( StatusEffectInstance statusEffectInstance ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void requestTeleport( double x, double y, double z ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setGameMode( GameMode gameMode ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void sendChatMessage( Component textComponent, ChatMessageType chatMessageType ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getServerBrand()
 | 
			
		||||
    {
 | 
			
		||||
        return "[Fake Player]";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void method_14255( String url, String hash ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onStoppedTracking( Entity entity ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setCameraEntity( Entity entity ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void teleport( ServerWorld serverWorld, double x, double y, double z, float pitch, float yaw ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void sendInitialChunkPackets( ChunkPos chunkPos, Packet<?> packet, Packet<?> packet2 ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void sendUnloadChunkPacket( ChunkPos chunkPos ) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void playSound( SoundEvent soundEvent, SoundCategory soundCategory, float volume, float pitch ) { }
 | 
			
		||||
    // endregion
 | 
			
		||||
 | 
			
		||||
    // Indirect
 | 
			
		||||
    @Override
 | 
			
		||||
    public int lockRecipes( Collection<Recipe<?>> recipes )
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int unlockRecipes( Collection<Recipe<?>> recipes )
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    //
 | 
			
		||||
 | 
			
		||||
    private static class FakeNetHandler extends ServerPlayNetworkHandler
 | 
			
		||||
    {
 | 
			
		||||
        FakeNetHandler( ServerPlayerEntity player )
 | 
			
		||||
        {
 | 
			
		||||
            super( player.server, new FakeConnection(), player );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void disconnect( Component message ) { }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onRequestCommandCompletions( RequestCommandCompletionsC2SPacket packet ) { }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void sendPacket( Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> listener ) { }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onVehicleMove( VehicleMoveC2SPacket move ) { }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static class FakeConnection extends ClientConnection
 | 
			
		||||
    {
 | 
			
		||||
        FakeConnection()
 | 
			
		||||
        {
 | 
			
		||||
            super( NetworkSide.CLIENTBOUND );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void channelActive( ChannelHandlerContext active )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void setState( NetworkState state )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void disconnect( Component message )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void exceptionCaught( ChannelHandlerContext context, Throwable err )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        protected void method_10770( ChannelHandlerContext context, Packet<?> packet )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void tick()
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void setupEncryption( SecretKey key )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void disableAutoRead()
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void setMinCompressedSize( int size )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void send( Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> listener )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -71,7 +70,7 @@ public enum TurtleAction
 | 
			
		||||
    EQUIP,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Inspect a block in world
 | 
			
		||||
     * Inspect a block in world.
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleBlockEvent.Inspect
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,13 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
 | 
			
		||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
@@ -16,11 +16,11 @@ import java.util.Objects;
 | 
			
		||||
/**
 | 
			
		||||
 * An event fired when a turtle is performing a known action.
 | 
			
		||||
 */
 | 
			
		||||
@Cancelable
 | 
			
		||||
public class TurtleActionEvent extends TurtleEvent
 | 
			
		||||
{
 | 
			
		||||
    private final TurtleAction action;
 | 
			
		||||
    private String failureMessage;
 | 
			
		||||
    private boolean cancelled = false;
 | 
			
		||||
 | 
			
		||||
    public TurtleActionEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction action )
 | 
			
		||||
    {
 | 
			
		||||
@@ -44,6 +44,7 @@ public class TurtleActionEvent extends TurtleEvent
 | 
			
		||||
     * @see TurtleCommandResult#failure()
 | 
			
		||||
     * @deprecated Use {@link #setCanceled(boolean, String)} instead.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setCanceled( boolean cancel )
 | 
			
		||||
    {
 | 
			
		||||
@@ -61,7 +62,7 @@ public class TurtleActionEvent extends TurtleEvent
 | 
			
		||||
     */
 | 
			
		||||
    public void setCanceled( boolean cancel, @Nullable String failureMessage )
 | 
			
		||||
    {
 | 
			
		||||
        this.cancelled = true;
 | 
			
		||||
        super.setCanceled( cancel );
 | 
			
		||||
        this.failureMessage = cancel ? failureMessage : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -77,15 +78,4 @@ public class TurtleActionEvent extends TurtleEvent
 | 
			
		||||
    {
 | 
			
		||||
        return failureMessage;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine if this event is cancelled
 | 
			
		||||
     *
 | 
			
		||||
     * @return If this event is cancelled
 | 
			
		||||
     * @see #setCanceled(boolean, String)
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isCancelled()
 | 
			
		||||
    {
 | 
			
		||||
        return cancelled;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
@@ -11,7 +10,9 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import dan200.computercraft.api.turtle.TurtleSide;
 | 
			
		||||
import dan200.computercraft.api.turtle.TurtleVerb;
 | 
			
		||||
import net.minecraft.entity.Entity;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
@@ -19,11 +20,10 @@ import java.util.Objects;
 | 
			
		||||
/**
 | 
			
		||||
 * Fired when a turtle attempts to attack an entity.
 | 
			
		||||
 *
 | 
			
		||||
 * This must be fired by {@link ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)},
 | 
			
		||||
 * This must be fired by {@link ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, EnumFacing)},
 | 
			
		||||
 * as the base {@code turtle.attack()} command does not fire it.
 | 
			
		||||
 *
 | 
			
		||||
 * Note that such commands should also fire {@link net.fabricmc.fabric.api.event.player.AttackEntityCallback}, so you do
 | 
			
		||||
 * not need to listen to both.
 | 
			
		||||
 * Note that such commands should also fire {@link AttackEntityEvent}, so you do not need to listen to both.
 | 
			
		||||
 *
 | 
			
		||||
 * @see TurtleAction#ATTACK
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
@@ -12,11 +11,13 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import dan200.computercraft.api.turtle.TurtleSide;
 | 
			
		||||
import dan200.computercraft.api.turtle.TurtleVerb;
 | 
			
		||||
import net.minecraft.block.BlockState;
 | 
			
		||||
import net.minecraft.block.state.IBlockState;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Direction;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
import net.minecraftforge.event.world.BlockEvent;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
@@ -73,21 +74,20 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
    /**
 | 
			
		||||
     * Fired when a turtle attempts to dig a block.
 | 
			
		||||
     *
 | 
			
		||||
     * This must be fired by {@link ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)},
 | 
			
		||||
     * This must be fired by {@link ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, EnumFacing)},
 | 
			
		||||
     * as the base {@code turtle.dig()} command does not fire it.
 | 
			
		||||
     *
 | 
			
		||||
     * Note that such commands should also fire {@link net.fabricmc.fabric.api.event.player.AttackBlockCallback}, so you
 | 
			
		||||
     * do not need to listen to both.
 | 
			
		||||
     * Note that such commands should also fire {@link BlockEvent.BreakEvent}, so you do not need to listen to both.
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleAction#DIG
 | 
			
		||||
     */
 | 
			
		||||
    public static class Dig extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final BlockState block;
 | 
			
		||||
        private final IBlockState block;
 | 
			
		||||
        private final ITurtleUpgrade upgrade;
 | 
			
		||||
        private final TurtleSide side;
 | 
			
		||||
 | 
			
		||||
        public Dig( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState block, @Nonnull ITurtleUpgrade upgrade, @Nonnull TurtleSide side )
 | 
			
		||||
        public Dig( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState block, @Nonnull ITurtleUpgrade upgrade, @Nonnull TurtleSide side )
 | 
			
		||||
        {
 | 
			
		||||
            super( turtle, TurtleAction.DIG, player, world, pos );
 | 
			
		||||
 | 
			
		||||
@@ -105,13 +105,13 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
         * @return The block which is going to be broken.
 | 
			
		||||
         */
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        public BlockState getBlock()
 | 
			
		||||
        public IBlockState getBlock()
 | 
			
		||||
        {
 | 
			
		||||
            return block;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Get the upgrade doing the digging
 | 
			
		||||
         * Get the upgrade doing the digging.
 | 
			
		||||
         *
 | 
			
		||||
         * @return The upgrade doing the digging.
 | 
			
		||||
         */
 | 
			
		||||
@@ -184,10 +184,10 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
     */
 | 
			
		||||
    public static class Inspect extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final BlockState state;
 | 
			
		||||
        private final IBlockState state;
 | 
			
		||||
        private final Map<String, Object> data;
 | 
			
		||||
 | 
			
		||||
        public Inspect( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull Map<String, Object> data )
 | 
			
		||||
        public Inspect( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Map<String, Object> data )
 | 
			
		||||
        {
 | 
			
		||||
            super( turtle, TurtleAction.INSPECT, player, world, pos );
 | 
			
		||||
 | 
			
		||||
@@ -203,7 +203,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
         * @return The inspected block state.
 | 
			
		||||
         */
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        public BlockState getState()
 | 
			
		||||
        public IBlockState getState()
 | 
			
		||||
        {
 | 
			
		||||
            return state;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,12 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
import com.google.common.eventbus.EventBus;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
import net.minecraftforge.fml.common.eventhandler.Event;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
@@ -20,10 +19,8 @@ import java.util.Objects;
 | 
			
		||||
 *
 | 
			
		||||
 * @see TurtleActionEvent
 | 
			
		||||
 */
 | 
			
		||||
public abstract class TurtleEvent
 | 
			
		||||
public abstract class TurtleEvent extends Event
 | 
			
		||||
{
 | 
			
		||||
    public static final EventBus EVENT_BUS = new EventBus();
 | 
			
		||||
 | 
			
		||||
    private final ITurtleAccess turtle;
 | 
			
		||||
 | 
			
		||||
    protected TurtleEvent( @Nonnull ITurtleAccess turtle )
 | 
			
		||||
@@ -42,10 +39,4 @@ public abstract class TurtleEvent
 | 
			
		||||
    {
 | 
			
		||||
        return turtle;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean post( TurtleActionEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        EVENT_BUS.post( event );
 | 
			
		||||
        return event.isCancelled();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 * 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;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,16 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
import net.minecraft.inventory.Inventory;
 | 
			
		||||
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.items.IItemHandler;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
@@ -21,21 +21,21 @@ import java.util.Objects;
 | 
			
		||||
 */
 | 
			
		||||
public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
{
 | 
			
		||||
    private final Inventory handler;
 | 
			
		||||
    private final IItemHandler handler;
 | 
			
		||||
 | 
			
		||||
    protected TurtleInventoryEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction action, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Inventory handler )
 | 
			
		||||
    protected TurtleInventoryEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction action, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable IItemHandler handler )
 | 
			
		||||
    {
 | 
			
		||||
        super( turtle, action, player, world, pos );
 | 
			
		||||
        this.handler = handler;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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.
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Inventory getItemHandler()
 | 
			
		||||
    public IItemHandler getItemHandler()
 | 
			
		||||
    {
 | 
			
		||||
        return handler;
 | 
			
		||||
    }
 | 
			
		||||
@@ -47,7 +47,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
     */
 | 
			
		||||
    public static class Suck extends TurtleInventoryEvent
 | 
			
		||||
    {
 | 
			
		||||
        public Suck( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Inventory handler )
 | 
			
		||||
        public Suck( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable IItemHandler handler )
 | 
			
		||||
        {
 | 
			
		||||
            super( turtle, TurtleAction.SUCK, player, world, pos, handler );
 | 
			
		||||
        }
 | 
			
		||||
@@ -62,7 +62,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final ItemStack stack;
 | 
			
		||||
 | 
			
		||||
        public Drop( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Inventory handler, @Nonnull ItemStack stack )
 | 
			
		||||
        public Drop( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable IItemHandler handler, @Nonnull ItemStack stack )
 | 
			
		||||
        {
 | 
			
		||||
            super( turtle, TurtleAction.DROP, player, world, pos, handler );
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,12 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the public ComputerCraft API - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only.
 | 
			
		||||
 * For help using the API, and posting your mods, visit the forums at computercraft.info.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle.event;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleAccess;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of ComputerCraft - http://www.computercraft.info
 | 
			
		||||
 * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
 | 
			
		||||
 * Send enquiries to dratcliffe@gmail.com
 | 
			
		||||
 * 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;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
@@ -0,0 +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.
 | 
			
		||||
 * 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;
 | 
			
		||||
 | 
			
		||||
import net.minecraftforge.fml.common.API;
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user