mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-11-03 23:22:59 +00:00 
			
		
		
		
	Compare commits
	
		
			107 Commits
		
	
	
		
			mc-1.13.x
			...
			v1.14.4-1.
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					642351af1a | ||
| 
						 | 
					121802a683 | ||
| 
						 | 
					08cf55e55f | ||
| 
						 | 
					3c8c0d78ef | ||
| 
						 | 
					c4d18aa9ca | ||
| 
						 | 
					2d4a87adc9 | ||
| 
						 | 
					bedac71e3d | ||
| 
						 | 
					ee4e42e730 | ||
| 
						 | 
					0de75f05dd | ||
| 
						 | 
					be6dd21e54 | ||
| 
						 | 
					927ddb0bde | ||
| 
						 | 
					a8fadabaf1 | ||
| 
						 | 
					44d0f78c1b | ||
| 
						 | 
					38f9a015ca | ||
| 
						 | 
					c311cdc6f5 | ||
| 
						 | 
					a93e0f3284 | ||
| 
						 | 
					14b3065ba4 | ||
| 
						 | 
					3ea2d6a0a8 | ||
| 
						 | 
					c802290437 | ||
| 
						 | 
					f7781defe5 | ||
| 
						 | 
					418420523a | ||
| 
						 | 
					d342a1f368 | ||
| 
						 | 
					81f85361d5 | ||
| 
						 | 
					f1621b30ec | ||
| 
						 | 
					d4f6a594b6 | ||
| 
						 | 
					ff5ba5c131 | ||
| 
						 | 
					4243f30308 | ||
| 
						 | 
					813e91073d | ||
| 
						 | 
					7250f22ff6 | ||
| 
						 | 
					db31a53bba | ||
| 
						 | 
					3023f235a4 | ||
| 
						 | 
					79cd8b4da5 | ||
| 
						 | 
					8e4d311cd9 | ||
| 
						 | 
					9bd8c86a94 | ||
| 
						 | 
					cbc0c1d0b6 | ||
| 
						 | 
					49c37857d4 | ||
| 
						 | 
					b1139a4bf6 | ||
| 
						 | 
					7e8559278e | ||
| 
						 | 
					1e7f1c98fc | ||
| 
						 | 
					a802f25dd6 | ||
| 
						 | 
					f1d6d21d6d | ||
| 
						 | 
					a80302c513 | ||
| 
						 | 
					1c46949da7 | ||
| 
						 | 
					07a56454a0 | ||
| 
						 | 
					a0e72d02c8 | ||
| 
						 | 
					455a59ca85 | ||
| 
						 | 
					46d78af068 | ||
| 
						 | 
					08d22fd3df | ||
| 
						 | 
					e6c691a8f8 | ||
| 
						 | 
					4b0e5c445c | ||
| 
						 | 
					eb5cff1045 | ||
| 
						 | 
					35c7792aa2 | ||
| 
						 | 
					521688d630 | ||
| 
						 | 
					75e2845c01 | ||
| 
						 | 
					2f96283286 | ||
| 
						 | 
					cbe6e9b5f5 | ||
| 
						 | 
					2ab79cf474 | ||
| 
						 | 
					6ce34aba79 | ||
| 
						 | 
					5eeb320b60 | ||
| 
						 | 
					93310850d2 | ||
| 
						 | 
					a2880b12ca | ||
| 
						 | 
					cef2657048 | ||
| 
						 | 
					ccd85eb055 | ||
| 
						 | 
					303b57779a | ||
| 
						 | 
					6279816ecc | ||
| 
						 | 
					4ae77261fa | ||
| 
						 | 
					4b7d843b78 | ||
| 
						 | 
					1c28df65c3 | ||
| 
						 | 
					85b740f484 | ||
| 
						 | 
					f9929cb27d | ||
| 
						 | 
					bafab1ac07 | ||
| 
						 | 
					e05c262468 | ||
| 
						 | 
					acfb72246c | ||
| 
						 | 
					9d51c4c340 | ||
| 
						 | 
					18068effec | ||
| 
						 | 
					7a3f7d3bba | ||
| 
						 | 
					95aa48c456 | ||
| 
						 | 
					6ea8ca991b | ||
| 
						 | 
					f1e551b960 | ||
| 
						 | 
					772c54ec74 | ||
| 
						 | 
					13cb789c18 | ||
| 
						 | 
					42220c4268 | ||
| 
						 | 
					3052506e2e | ||
| 
						 | 
					0741daa7eb | ||
| 
						 | 
					b4aa554279 | ||
| 
						 | 
					8fe2abe0ae | ||
| 
						 | 
					5af789ae11 | ||
| 
						 | 
					904a168d5c | ||
| 
						 | 
					724441eddc | ||
| 
						 | 
					f68ab3edd1 | ||
| 
						 | 
					68542aca3a | ||
| 
						 | 
					594bc4203c | ||
| 
						 | 
					57318b022d | ||
| 
						 | 
					761159aa93 | ||
| 
						 | 
					29dce26bf6 | ||
| 
						 | 
					717ab69093 | ||
| 
						 | 
					138a2cf08f | ||
| 
						 | 
					81daf82647 | ||
| 
						 | 
					f3798bfb63 | ||
| 
						 | 
					bc07dfad2e | ||
| 
						 | 
					8dd1c2a6cc | ||
| 
						 | 
					d10b657a54 | ||
| 
						 | 
					f90da739eb | ||
| 
						 | 
					d9cadf64e8 | ||
| 
						 | 
					15d4a55cd8 | ||
| 
						 | 
					309cbdb8be | ||
| 
						 | 
					39a9ad0ce7 | 
							
								
								
									
										18
									
								
								.github/workflows/main-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								.github/workflows/main-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
name: Build
 | 
			
		||||
 | 
			
		||||
on: [push, pull_request]
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v1
 | 
			
		||||
 | 
			
		||||
    - name: Set up JDK 1.8
 | 
			
		||||
      uses: actions/setup-java@v1
 | 
			
		||||
      with:
 | 
			
		||||
        java-version: 1.8
 | 
			
		||||
 | 
			
		||||
    - name: Build with Gradle
 | 
			
		||||
      run: ./gradlew build --no-daemon
 | 
			
		||||
@@ -17,7 +17,8 @@ ignore = {
 | 
			
		||||
-- are largely unsupported.
 | 
			
		||||
include_files = {
 | 
			
		||||
    'src/main/resources/assets/computercraft/lua/rom',
 | 
			
		||||
    'src/main/resources/assets/computercraft/lua/bios.lua'
 | 
			
		||||
    'src/main/resources/assets/computercraft/lua/bios.lua',
 | 
			
		||||
    'src/test/resources/test-rom',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
files['src/main/resources/assets/computercraft/lua/bios.lua'] = {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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
 | 
			
		||||
@@ -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.
 | 
			
		||||
@@ -41,7 +41,7 @@ Any contribution is welcome, be that using the mod, reporting bugs or contributi
 | 
			
		||||
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`
 | 
			
		||||
 - **Setup Forge:** `./gradlew build`
 | 
			
		||||
 - **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`.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										80
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										80
									
								
								build.gradle
									
									
									
									
									
								
							@@ -4,12 +4,12 @@ buildscript {
 | 
			
		||||
        mavenCentral()
 | 
			
		||||
        maven {
 | 
			
		||||
            name = "forge"
 | 
			
		||||
            url = "http://files.minecraftforge.net/maven"
 | 
			
		||||
            url = "https://files.minecraftforge.net/maven"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    dependencies {
 | 
			
		||||
        classpath 'com.google.code.gson:gson:2.8.1'
 | 
			
		||||
        classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.117'
 | 
			
		||||
        classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.154'
 | 
			
		||||
        classpath 'net.sf.proguard:proguard-gradle:6.1.0beta2'
 | 
			
		||||
        classpath 'org.ajoberstar.grgit:grgit-gradle:3.0.0'
 | 
			
		||||
    }
 | 
			
		||||
@@ -67,7 +67,7 @@ minecraft {
 | 
			
		||||
repositories {
 | 
			
		||||
    maven {
 | 
			
		||||
        name "JEI"
 | 
			
		||||
        url  "http://dvs1.progwml6.com/files/maven"
 | 
			
		||||
        url "https://dvs1.progwml6.com/files/maven"
 | 
			
		||||
    }
 | 
			
		||||
    maven {
 | 
			
		||||
        name "SquidDev"
 | 
			
		||||
@@ -79,7 +79,7 @@ repositories {
 | 
			
		||||
    }
 | 
			
		||||
    maven {
 | 
			
		||||
        name "Amadornes"
 | 
			
		||||
        url "http://maven.amadornes.com/"
 | 
			
		||||
        url "https://maven.amadornes.com/"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -90,32 +90,25 @@ configurations {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
    checkstyle "com.puppycrawl.tools:checkstyle:8.21"
 | 
			
		||||
    checkstyle "com.puppycrawl.tools:checkstyle:8.25"
 | 
			
		||||
 | 
			
		||||
    minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
 | 
			
		||||
 | 
			
		||||
    compileOnly fg.deobf("mezz.jei:jei-1.13.2:5.0.0.20:api")
 | 
			
		||||
    compileOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.25:api")
 | 
			
		||||
    // deobfProvided "pl.asie:Charset-Lib:0.5.4.6"
 | 
			
		||||
    // deobfProvided "MCMultiPart2:MCMultiPart:2.5.3"
 | 
			
		||||
 | 
			
		||||
    runtimeOnly fg.deobf("mezz.jei:jei-1.13.2:5.0.0.20")
 | 
			
		||||
    runtimeOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.25")
 | 
			
		||||
 | 
			
		||||
    shade 'org.squiddev:Cobalt:0.5.0-SNAPSHOT'
 | 
			
		||||
 | 
			
		||||
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
 | 
			
		||||
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
 | 
			
		||||
    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/mcmp'
 | 
			
		||||
            exclude 'dan200/computercraft/shared/integration/charset'
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
// Compile tasks
 | 
			
		||||
 | 
			
		||||
javadoc {
 | 
			
		||||
    include "dan200/computercraft/api/**/*.java"
 | 
			
		||||
@@ -127,7 +120,7 @@ jar {
 | 
			
		||||
    manifest {
 | 
			
		||||
        attributes(["Specification-Title": "computercraft",
 | 
			
		||||
                    "Specification-Vendor": "SquidDev",
 | 
			
		||||
                    "Specification-Version": "25.0",
 | 
			
		||||
                    "Specification-Version": "1",
 | 
			
		||||
                    "Implementation-Title": "CC: Tweaked",
 | 
			
		||||
                    "Implementation-Version": "${mod_version}",
 | 
			
		||||
                    "Implementation-Vendor" :"SquidDev",
 | 
			
		||||
@@ -141,6 +134,14 @@ 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.*
 | 
			
		||||
@@ -276,7 +277,14 @@ task compressJson(dependsOn: jar) {
 | 
			
		||||
 | 
			
		||||
assemble.dependsOn compressJson
 | 
			
		||||
 | 
			
		||||
/* Check tasks */
 | 
			
		||||
// Check tasks
 | 
			
		||||
 | 
			
		||||
test {
 | 
			
		||||
    useJUnitPlatform()
 | 
			
		||||
    testLogging {
 | 
			
		||||
        events "skipped", "failed"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
license {
 | 
			
		||||
    mapping("java", "SLASHSTAR_STYLE")
 | 
			
		||||
@@ -300,6 +308,13 @@ license {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gradle.projectsEvaluated {
 | 
			
		||||
    tasks.withType(LicenseFormat) {
 | 
			
		||||
        outputs.upToDateWhen { false }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
task licenseAPI(type: LicenseCheck);
 | 
			
		||||
task licenseFormatAPI(type: LicenseFormat);
 | 
			
		||||
[licenseAPI, licenseFormatAPI].forEach {
 | 
			
		||||
@@ -310,7 +325,7 @@ task licenseFormatAPI(type: LicenseFormat);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Upload tasks */
 | 
			
		||||
// Upload tasks
 | 
			
		||||
 | 
			
		||||
task checkRelease {
 | 
			
		||||
    group "upload"
 | 
			
		||||
@@ -350,6 +365,7 @@ task checkRelease {
 | 
			
		||||
        if (!ok) throw new IllegalStateException("Could not check release")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
check.dependsOn checkRelease
 | 
			
		||||
 | 
			
		||||
curseforge {
 | 
			
		||||
    apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
 | 
			
		||||
@@ -421,7 +437,9 @@ 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}"
 | 
			
		||||
@@ -441,23 +459,3 @@ task uploadAll(dependsOn: uploadTasks) {
 | 
			
		||||
    group "upload"
 | 
			
		||||
    description "Uploads to all repositories (Maven, Curse, GitHub release)"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test {
 | 
			
		||||
    useJUnitPlatform()
 | 
			
		||||
    testLogging {
 | 
			
		||||
        events "passed", "skipped", "failed"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gradle.projectsEvaluated {
 | 
			
		||||
    reobfJar.dependsOn proguardMove
 | 
			
		||||
 | 
			
		||||
    tasks.withType(JavaCompile) {
 | 
			
		||||
        options.compilerArgs << "-Xlint" << "-Xlint:-processing" // Causes Forge build to fail << "-Werror"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tasks.withType(LicenseFormat) {
 | 
			
		||||
        outputs.upToDateWhen { false }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,9 +14,7 @@
 | 
			
		||||
        <!-- Annotations -->
 | 
			
		||||
        <module name="AnnotationLocation" />
 | 
			
		||||
        <module name="AnnotationUseStyle" />
 | 
			
		||||
        <module name="MissingDeprecated">
 | 
			
		||||
            <property name="skipNoJavadoc" value="true" />
 | 
			
		||||
        </module>
 | 
			
		||||
        <module name="MissingDeprecated" />
 | 
			
		||||
        <module name="MissingOverride" />
 | 
			
		||||
 | 
			
		||||
        <!-- Blocks -->
 | 
			
		||||
@@ -57,6 +55,9 @@
 | 
			
		||||
        <module name="SimplifyBooleanReturn" />
 | 
			
		||||
        <module name="StringLiteralEquality" />
 | 
			
		||||
        <module name="UnnecessaryParentheses" />
 | 
			
		||||
        <module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
 | 
			
		||||
        <module name="UnnecessarySemicolonInTryWithResources" />
 | 
			
		||||
        <module name="UnnecessarySemicolonInEnumeration" />
 | 
			
		||||
 | 
			
		||||
        <!-- Imports -->
 | 
			
		||||
        <module name="CustomImportOrder" />
 | 
			
		||||
@@ -65,10 +66,16 @@
 | 
			
		||||
        <module name="UnusedImports" />
 | 
			
		||||
 | 
			
		||||
        <!-- Javadoc -->
 | 
			
		||||
        <!-- TODO: Missing* checks for the dan200.computercraft.api package? -->
 | 
			
		||||
        <module name="AtclauseOrder" />
 | 
			
		||||
        <!-- TODO: Cleanup our documentation before enabling JavadocMethod, JavadocStyle, JavadocType and SummaryJavadoc. -->
 | 
			
		||||
        <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" />
 | 
			
		||||
@@ -149,11 +156,14 @@
 | 
			
		||||
        <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" />
 | 
			
		||||
            <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,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>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,10 @@
 | 
			
		||||
    "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
 | 
			
		||||
    "https://checkstyle.org/dtds/suppressions_1_2.dtd">
 | 
			
		||||
<suppressions>
 | 
			
		||||
    <!-- Has a public m_label field. We need to check if this is used in other projects before renaming it. -->
 | 
			
		||||
    <suppress checks="MemberName" files=".*[\\/]TileComputerBase.java"
 | 
			
		||||
        message="Name 'm_label' must match pattern .*" />
 | 
			
		||||
 | 
			
		||||
    <!-- 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>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
# Mod properties
 | 
			
		||||
mod_version=1.83.1
 | 
			
		||||
mod_version=1.85.1
 | 
			
		||||
 | 
			
		||||
# Minecraft properties
 | 
			
		||||
mc_version=1.13.2
 | 
			
		||||
forge_version=25.0.219
 | 
			
		||||
mappings_version=20190530-1.13.2
 | 
			
		||||
# Minecraft properties (update mods.toml when changing)
 | 
			
		||||
mc_version=1.14.4
 | 
			
		||||
forge_version=28.1.71
 | 
			
		||||
mappings_version=20191123-1.14.3
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ import dan200.computercraft.shared.util.IDAssigner;
 | 
			
		||||
import dan200.computercraft.shared.wired.CapabilityWiredElement;
 | 
			
		||||
import dan200.computercraft.shared.wired.WiredNode;
 | 
			
		||||
import net.minecraft.tileentity.TileEntity;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.IBlockReader;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
@@ -94,7 +94,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
 | 
			
		||||
    public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        return BundledRedstone.getDefaultOutput( world, pos, side );
 | 
			
		||||
    }
 | 
			
		||||
@@ -133,7 +133,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
 | 
			
		||||
    public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        TileEntity tile = world.getTileEntity( pos );
 | 
			
		||||
        return tile == null ? LazyOptional.empty() : tile.getCapability( CapabilityWiredElement.CAPABILITY, side );
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ 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 net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.IBlockReader;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
@@ -31,8 +31,9 @@ import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 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
 | 
			
		||||
{
 | 
			
		||||
@@ -183,13 +184,13 @@ 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 EnumFacing side )
 | 
			
		||||
    public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().getBundledRedstoneOutput( world, pos, side );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
@@ -220,7 +221,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Construct a new wired node for a given wired element
 | 
			
		||||
     * Construct a new wired node for a given wired element.
 | 
			
		||||
     *
 | 
			
		||||
     * @param element The element to construct it for
 | 
			
		||||
     * @return The element's node
 | 
			
		||||
@@ -233,7 +234,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the wired network element for a block in world
 | 
			
		||||
     * Get the wired network element for a block in world.
 | 
			
		||||
     *
 | 
			
		||||
     * @param world The world the block exists in
 | 
			
		||||
     * @param pos   The position the block exists in
 | 
			
		||||
@@ -242,7 +243,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
     * @see IWiredElement#getNode()
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
 | 
			
		||||
    public static LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        return getInstance().getWiredElementAt( world, pos, side );
 | 
			
		||||
    }
 | 
			
		||||
@@ -284,7 +285,7 @@ public final class ComputerCraftAPI
 | 
			
		||||
 | 
			
		||||
        void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider );
 | 
			
		||||
 | 
			
		||||
        int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
 | 
			
		||||
        int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
 | 
			
		||||
        void registerMediaProvider( @Nonnull IMediaProvider provider );
 | 
			
		||||
 | 
			
		||||
@@ -299,6 +300,6 @@ public final class ComputerCraftAPI
 | 
			
		||||
        IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element );
 | 
			
		||||
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
 | 
			
		||||
        LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ 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.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										335
									
								
								src/main/java/dan200/computercraft/api/lua/ArgumentHelper.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										335
									
								
								src/main/java/dan200/computercraft/api/lua/ArgumentHelper.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,335 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 * 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";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -26,7 +26,7 @@ public interface IComputerSystem extends IComputerAccess
 | 
			
		||||
    IFileSystem getFileSystem();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the label for this computer
 | 
			
		||||
     * Get the label for this computer.
 | 
			
		||||
     *
 | 
			
		||||
     * @return This computer's label, or {@code null} if it is not set.
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
 | 
			
		||||
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 +59,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 +73,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;
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@
 | 
			
		||||
package dan200.computercraft.api.peripheral;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.tileentity.TileEntity;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
@@ -34,5 +34,5 @@ public interface IPeripheralProvider
 | 
			
		||||
     * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
 */
 | 
			
		||||
package dan200.computercraft.api.peripheral;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
@@ -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, EnumFacing)
 | 
			
		||||
     * @see IPeripheralProvider#getPeripheral(World, BlockPos, Direction)
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull EnumFacing side );
 | 
			
		||||
    IPeripheral getPeripheral( @Nonnull Direction side );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ package dan200.computercraft.api.pocket;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import net.minecraft.entity.Entity;
 | 
			
		||||
import net.minecraft.nbt.NBTTagCompound;
 | 
			
		||||
import net.minecraft.nbt.CompoundNBT;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -16,7 +16,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Wrapper class for pocket computers
 | 
			
		||||
 * Wrapper class for pocket computers.
 | 
			
		||||
 */
 | 
			
		||||
public interface IPocketAccess
 | 
			
		||||
{
 | 
			
		||||
@@ -75,7 +75,7 @@ public interface IPocketAccess
 | 
			
		||||
     * @see #updateUpgradeNBTData()
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    NBTTagCompound getUpgradeNBTData();
 | 
			
		||||
    CompoundNBT getUpgradeNBTData();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Mark the upgrade-specific NBT as dirty.
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.redstone;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
@@ -30,5 +30,5 @@ public interface IBundledRedstoneProvider
 | 
			
		||||
     * handle this block.
 | 
			
		||||
     * @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
 | 
			
		||||
     */
 | 
			
		||||
    int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
 | 
			
		||||
    int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,8 +11,8 @@ import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
import dan200.computercraft.api.lua.LuaException;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import net.minecraft.inventory.IInventory;
 | 
			
		||||
import net.minecraft.nbt.NBTTagCompound;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.nbt.CompoundNBT;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.Vec3d;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
@@ -83,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(EnumFacing)
 | 
			
		||||
     * @see #setDirection(Direction)
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    EnumFacing getDirection();
 | 
			
		||||
    Direction getDirection();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the direction the turtle is facing. Note that this will not play a rotation animation, you will also need to
 | 
			
		||||
@@ -95,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 EnumFacing dir );
 | 
			
		||||
    void setDirection( @Nonnull Direction dir );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the currently selected slot in the turtle's inventory.
 | 
			
		||||
@@ -144,7 +144,9 @@ 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()
 | 
			
		||||
@@ -155,6 +157,8 @@ public interface ITurtleAccess
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the inventory of this turtle as an {@link IItemHandlerModifiable}.
 | 
			
		||||
     *
 | 
			
		||||
     * Note: this inventory should only be accessed and modified on the server thread.
 | 
			
		||||
     *
 | 
			
		||||
     * @return This turtle's inventory
 | 
			
		||||
     * @see #getInventory()
 | 
			
		||||
     * @see IItemHandlerModifiable
 | 
			
		||||
@@ -290,7 +294,7 @@ public interface ITurtleAccess
 | 
			
		||||
     * @see #updateUpgradeNBTData(TurtleSide)
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    NBTTagCompound getUpgradeNBTData( @Nullable TurtleSide side );
 | 
			
		||||
    CompoundNBT 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
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ import dan200.computercraft.api.turtle.event.TurtleBlockEvent;
 | 
			
		||||
import net.minecraft.client.renderer.model.IBakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
import net.minecraftforge.api.distmarker.OnlyIn;
 | 
			
		||||
@@ -98,8 +98,8 @@ public interface ITurtleUpgrade
 | 
			
		||||
     * Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called
 | 
			
		||||
     * by the turtle, and the tool is required to do some work.
 | 
			
		||||
     *
 | 
			
		||||
     * Conforming implementations should fire {@link BlockEvent.BreakEvent} and {@link TurtleBlockEvent.Dig}for digging,
 | 
			
		||||
     * {@link AttackEntityEvent} and {@link TurtleAttackEvent} for attacking.
 | 
			
		||||
     * Conforming implementations should fire {@link BlockEvent.BreakEvent} and {@link TurtleBlockEvent.Dig} for
 | 
			
		||||
     * digging, {@link AttackEntityEvent} and {@link TurtleAttackEvent} for attacking.
 | 
			
		||||
     *
 | 
			
		||||
     * @param turtle    Access to the turtle that the tool resides on.
 | 
			
		||||
     * @param side      Which side of the turtle (left or right) the tool resides on.
 | 
			
		||||
@@ -113,7 +113,7 @@ public interface ITurtleUpgrade
 | 
			
		||||
     * to be called.
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    default TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction )
 | 
			
		||||
    default TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull Direction direction )
 | 
			
		||||
    {
 | 
			
		||||
        return TurtleCommandResult.failure();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
@@ -15,7 +15,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, EnumFacing)
 | 
			
		||||
 * @see ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)
 | 
			
		||||
 */
 | 
			
		||||
public final class TurtleCommandResult
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -12,12 +12,12 @@ package dan200.computercraft.api.turtle;
 | 
			
		||||
public enum TurtleSide
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * The turtle's left side (where the pickaxe usually is on a Wireless Mining Turtle)
 | 
			
		||||
     * The turtle's left side (where the pickaxe usually is on a Wireless Mining Turtle).
 | 
			
		||||
     */
 | 
			
		||||
    Left,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The turtle's right side (where the modem usually is on a Wireless Mining Turtle)
 | 
			
		||||
     * The turtle's right side (where the modem usually is on a Wireless Mining Turtle).
 | 
			
		||||
     */
 | 
			
		||||
    Right,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,24 +6,24 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.api.turtle;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 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, EnumFacing)
 | 
			
		||||
 * @see ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)
 | 
			
		||||
 */
 | 
			
		||||
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,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ public enum TurtleAction
 | 
			
		||||
    EQUIP,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Inspect a block in world
 | 
			
		||||
     * Inspect a block in world.
 | 
			
		||||
     *
 | 
			
		||||
     * @see TurtleBlockEvent.Inspect
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ 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.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
 | 
			
		||||
 | 
			
		||||
@@ -21,7 +21,7 @@ import java.util.Objects;
 | 
			
		||||
/**
 | 
			
		||||
 * Fired when a turtle attempts to attack an entity.
 | 
			
		||||
 *
 | 
			
		||||
 * This must be fired by {@link ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, EnumFacing)},
 | 
			
		||||
 * This must be fired by {@link ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)},
 | 
			
		||||
 * as the base {@code turtle.attack()} command does not fire it.
 | 
			
		||||
 *
 | 
			
		||||
 * Note that such commands should also fire {@link AttackEntityEvent}, so you do not need to listen to both.
 | 
			
		||||
 
 | 
			
		||||
@@ -12,9 +12,9 @@ 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.state.IBlockState;
 | 
			
		||||
import net.minecraft.block.BlockState;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
@@ -75,7 +75,7 @@ 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, EnumFacing)},
 | 
			
		||||
     * This must be fired by {@link ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction)},
 | 
			
		||||
     * as the base {@code turtle.dig()} command does not fire it.
 | 
			
		||||
     *
 | 
			
		||||
     * Note that such commands should also fire {@link BlockEvent.BreakEvent}, so you do not need to listen to both.
 | 
			
		||||
@@ -84,11 +84,11 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
     */
 | 
			
		||||
    public static class Dig extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final IBlockState block;
 | 
			
		||||
        private final BlockState block;
 | 
			
		||||
        private final ITurtleUpgrade upgrade;
 | 
			
		||||
        private final 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 )
 | 
			
		||||
        public Dig( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState block, @Nonnull ITurtleUpgrade upgrade, @Nonnull TurtleSide side )
 | 
			
		||||
        {
 | 
			
		||||
            super( turtle, TurtleAction.DIG, player, world, pos );
 | 
			
		||||
 | 
			
		||||
@@ -106,13 +106,13 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
         * @return The block which is going to be broken.
 | 
			
		||||
         */
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        public IBlockState getBlock()
 | 
			
		||||
        public BlockState getBlock()
 | 
			
		||||
        {
 | 
			
		||||
            return block;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Get the upgrade doing the digging
 | 
			
		||||
         * Get the upgrade doing the digging.
 | 
			
		||||
         *
 | 
			
		||||
         * @return The upgrade doing the digging.
 | 
			
		||||
         */
 | 
			
		||||
@@ -185,10 +185,10 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
     */
 | 
			
		||||
    public static class Inspect extends TurtleBlockEvent
 | 
			
		||||
    {
 | 
			
		||||
        private final IBlockState state;
 | 
			
		||||
        private final BlockState state;
 | 
			
		||||
        private final 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 )
 | 
			
		||||
        public Inspect( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull Map<String, Object> data )
 | 
			
		||||
        {
 | 
			
		||||
            super( turtle, TurtleAction.INSPECT, player, world, pos );
 | 
			
		||||
 | 
			
		||||
@@ -204,7 +204,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
 | 
			
		||||
         * @return The inspected block state.
 | 
			
		||||
         */
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        public IBlockState getState()
 | 
			
		||||
        public BlockState getState()
 | 
			
		||||
        {
 | 
			
		||||
            return state;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the inventory being interacted with
 | 
			
		||||
     * Get the inventory being interacted with.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The inventory being interacted with, {@code null} if the item will be dropped to/sucked from the world.
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -16,15 +16,14 @@ import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.model.IBakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.model.IUnbakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
 | 
			
		||||
import net.minecraft.client.renderer.model.ModelRotation;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.resources.IResourceManager;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
import net.minecraftforge.client.event.ColorHandlerEvent;
 | 
			
		||||
import net.minecraftforge.client.event.ModelBakeEvent;
 | 
			
		||||
import net.minecraftforge.client.event.ModelRegistryEvent;
 | 
			
		||||
import net.minecraftforge.client.event.TextureStitchEvent;
 | 
			
		||||
import net.minecraftforge.client.model.BasicState;
 | 
			
		||||
import net.minecraftforge.client.model.ModelLoader;
 | 
			
		||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
 | 
			
		||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
 | 
			
		||||
@@ -36,7 +35,7 @@ import java.util.Map;
 | 
			
		||||
/**
 | 
			
		||||
 * Registers textures and models for items.
 | 
			
		||||
 */
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD )
 | 
			
		||||
public final class ClientRegistry
 | 
			
		||||
{
 | 
			
		||||
    private static final String[] EXTRA_MODELS = new String[] {
 | 
			
		||||
@@ -60,8 +59,8 @@ public final class ClientRegistry
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    private static final String[] EXTRA_TEXTURES = new String[] {
 | 
			
		||||
        // TODO: Gather these automatically from the model. I'm unable to get this working with Forge's current
 | 
			
		||||
        //  model loading code.
 | 
			
		||||
        // TODO: Gather these automatically from the model. Sadly the model loader isn't available
 | 
			
		||||
        //  when stitching textures.
 | 
			
		||||
        "block/turtle_colour",
 | 
			
		||||
        "block/turtle_elf_overlay",
 | 
			
		||||
        "block/turtle_crafty_face",
 | 
			
		||||
@@ -79,10 +78,11 @@ public final class ClientRegistry
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public static void onTextureStitchEvent( TextureStitchEvent.Pre event )
 | 
			
		||||
    {
 | 
			
		||||
        IResourceManager manager = Minecraft.getInstance().getResourceManager();
 | 
			
		||||
        if( event.getMap() != Minecraft.getInstance().getTextureMap() ) return;
 | 
			
		||||
 | 
			
		||||
        for( String extra : EXTRA_TEXTURES )
 | 
			
		||||
        {
 | 
			
		||||
            event.getMap().registerSprite( manager, new ResourceLocation( ComputerCraft.MOD_ID, extra ) );
 | 
			
		||||
            event.addSprite( new ResourceLocation( ComputerCraft.MOD_ID, extra ) );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -91,7 +91,7 @@ public final class ClientRegistry
 | 
			
		||||
    {
 | 
			
		||||
        // Load all extra models
 | 
			
		||||
        ModelLoader loader = event.getModelLoader();
 | 
			
		||||
        Map<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
 | 
			
		||||
        Map<ResourceLocation, IBakedModel> registry = event.getModelRegistry();
 | 
			
		||||
 | 
			
		||||
        for( String model : EXTRA_MODELS )
 | 
			
		||||
        {
 | 
			
		||||
@@ -160,9 +160,9 @@ public final class ClientRegistry
 | 
			
		||||
        model.getTextures( loader::getUnbakedModel, new HashSet<>() );
 | 
			
		||||
 | 
			
		||||
        return model.bake(
 | 
			
		||||
            loader::getUnbakedModel,
 | 
			
		||||
            loader,
 | 
			
		||||
            ModelLoader.defaultTextureGetter(),
 | 
			
		||||
            ModelRotation.X0_Y0, false, DefaultVertexFormats.BLOCK
 | 
			
		||||
            new BasicState( model.getDefaultState(), false ), DefaultVertexFormats.BLOCK
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,8 @@ import dan200.computercraft.shared.command.text.TableFormatter;
 | 
			
		||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.gui.FontRenderer;
 | 
			
		||||
import net.minecraft.client.gui.GuiNewChat;
 | 
			
		||||
import net.minecraft.client.gui.GuiUtilRenderComponents;
 | 
			
		||||
import net.minecraft.client.gui.NewChatGui;
 | 
			
		||||
import net.minecraft.client.gui.RenderComponentsUtil;
 | 
			
		||||
import net.minecraft.util.math.MathHelper;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextFormatting;
 | 
			
		||||
@@ -65,18 +65,18 @@ public class ClientTableFormatter implements TableFormatter
 | 
			
		||||
    public void writeLine( int id, ITextComponent component )
 | 
			
		||||
    {
 | 
			
		||||
        Minecraft mc = Minecraft.getInstance();
 | 
			
		||||
        GuiNewChat chat = mc.ingameGUI.getChatGUI();
 | 
			
		||||
        NewChatGui chat = mc.ingameGUI.getChatGUI();
 | 
			
		||||
 | 
			
		||||
        // Trim the text if it goes over the allowed length
 | 
			
		||||
        int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getScale() );
 | 
			
		||||
        List<ITextComponent> list = GuiUtilRenderComponents.splitText( component, maxWidth, mc.fontRenderer, false, false );
 | 
			
		||||
        List<ITextComponent> list = RenderComponentsUtil.splitText( component, maxWidth, mc.fontRenderer, false, false );
 | 
			
		||||
        if( !list.isEmpty() ) chat.printChatMessageWithOptionalDeletion( list.get( 0 ), id );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int display( TableBuilder table )
 | 
			
		||||
    {
 | 
			
		||||
        GuiNewChat chat = Minecraft.getInstance().ingameGUI.getChatGUI();
 | 
			
		||||
        NewChatGui chat = Minecraft.getInstance().ingameGUI.getChatGUI();
 | 
			
		||||
 | 
			
		||||
        int lastHeight = lastHeights.get( table.getId() );
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,9 @@ package dan200.computercraft.client;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
import net.minecraftforge.event.TickEvent;
 | 
			
		||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
 | 
			
		||||
import net.minecraftforge.fml.common.Mod;
 | 
			
		||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
 | 
			
		||||
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
 | 
			
		||||
public final class FrameInfo
 | 
			
		||||
 
 | 
			
		||||
@@ -6,11 +6,11 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.gui;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.core.terminal.TextBuffer;
 | 
			
		||||
import dan200.computercraft.shared.util.Palette;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.texture.TextureManager;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
@@ -129,9 +129,9 @@ public final class FixedWidthFontRenderer
 | 
			
		||||
            }
 | 
			
		||||
            drawQuad( renderer, x + i * FONT_WIDTH, y, colour, FONT_WIDTH, p, greyScale );
 | 
			
		||||
        }
 | 
			
		||||
        GlStateManager.disableTexture2D();
 | 
			
		||||
        GlStateManager.disableTexture();
 | 
			
		||||
        tessellator.draw();
 | 
			
		||||
        GlStateManager.enableTexture2D();
 | 
			
		||||
        GlStateManager.enableTexture();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void drawStringTextPart( int x, int y, TextBuffer s, TextBuffer textColour, boolean greyScale, Palette p )
 | 
			
		||||
@@ -195,6 +195,6 @@ public final class FixedWidthFontRenderer
 | 
			
		||||
    public void bindFont()
 | 
			
		||||
    {
 | 
			
		||||
        m_textureManager.bindTexture( FONT );
 | 
			
		||||
        GlStateManager.texParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
 | 
			
		||||
        GlStateManager.texParameter( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,19 +6,23 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.gui;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
 | 
			
		||||
import dan200.computercraft.client.gui.widgets.WidgetWrapper;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ClientComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
 | 
			
		||||
import net.minecraft.client.gui.inventory.GuiContainer;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.inventory.Container;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
 | 
			
		||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
 | 
			
		||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
 | 
			
		||||
import net.minecraft.entity.player.PlayerInventory;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import org.lwjgl.glfw.GLFW;
 | 
			
		||||
 | 
			
		||||
public class GuiComputer extends GuiContainer
 | 
			
		||||
public final class GuiComputer<T extends ContainerComputerBase> extends ContainerScreen<T>
 | 
			
		||||
{
 | 
			
		||||
    public static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_normal.png" );
 | 
			
		||||
    public static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_advanced.png" );
 | 
			
		||||
@@ -33,31 +37,47 @@ public class GuiComputer extends GuiContainer
 | 
			
		||||
    private WidgetTerminal terminal;
 | 
			
		||||
    private WidgetWrapper terminalWrapper;
 | 
			
		||||
 | 
			
		||||
    public GuiComputer( Container container, ComputerFamily family, ClientComputer computer, int termWidth, int termHeight )
 | 
			
		||||
    private GuiComputer(
 | 
			
		||||
        T container, PlayerInventory player, ITextComponent title, int termWidth, int termHeight
 | 
			
		||||
    )
 | 
			
		||||
    {
 | 
			
		||||
        super( container );
 | 
			
		||||
        m_family = family;
 | 
			
		||||
        m_computer = computer;
 | 
			
		||||
        super( container, player, title );
 | 
			
		||||
        m_family = container.getFamily();
 | 
			
		||||
        m_computer = (ClientComputer) container.getComputer();
 | 
			
		||||
        m_termWidth = termWidth;
 | 
			
		||||
        m_termHeight = termHeight;
 | 
			
		||||
        terminal = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GuiComputer( TileComputer computer )
 | 
			
		||||
    public static GuiComputer<ContainerComputer> create( ContainerComputer container, PlayerInventory inventory, ITextComponent component )
 | 
			
		||||
    {
 | 
			
		||||
        this(
 | 
			
		||||
            new ContainerComputer( computer ),
 | 
			
		||||
            computer.getFamily(),
 | 
			
		||||
            computer.createClientComputer(),
 | 
			
		||||
            ComputerCraft.terminalWidth_computer,
 | 
			
		||||
            ComputerCraft.terminalHeight_computer
 | 
			
		||||
        return new GuiComputer<>(
 | 
			
		||||
            container, inventory, component,
 | 
			
		||||
            ComputerCraft.terminalWidth_computer, ComputerCraft.terminalHeight_computer
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void initGui()
 | 
			
		||||
    public static GuiComputer<ContainerPocketComputer> createPocket( ContainerPocketComputer container, PlayerInventory inventory, ITextComponent component )
 | 
			
		||||
    {
 | 
			
		||||
        mc.keyboardListener.enableRepeatEvents( true );
 | 
			
		||||
        return new GuiComputer<>(
 | 
			
		||||
            container, inventory, component,
 | 
			
		||||
            ComputerCraft.terminalWidth_pocketComputer, ComputerCraft.terminalHeight_pocketComputer
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static GuiComputer<ContainerViewComputer> createView( ContainerViewComputer container, PlayerInventory inventory, ITextComponent component )
 | 
			
		||||
    {
 | 
			
		||||
        return new GuiComputer<>(
 | 
			
		||||
            container, inventory, component,
 | 
			
		||||
            container.getWidth(), container.getHeight()
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void init()
 | 
			
		||||
    {
 | 
			
		||||
        minecraft.keyboardListener.enableRepeatEvents( true );
 | 
			
		||||
 | 
			
		||||
        int termPxWidth = m_termWidth * FixedWidthFontRenderer.FONT_WIDTH;
 | 
			
		||||
        int termPxHeight = m_termHeight * FixedWidthFontRenderer.FONT_HEIGHT;
 | 
			
		||||
@@ -65,9 +85,9 @@ public class GuiComputer extends GuiContainer
 | 
			
		||||
        xSize = termPxWidth + 4 + 24;
 | 
			
		||||
        ySize = termPxHeight + 4 + 24;
 | 
			
		||||
 | 
			
		||||
        super.initGui();
 | 
			
		||||
        super.init();
 | 
			
		||||
 | 
			
		||||
        terminal = new WidgetTerminal( mc, () -> m_computer, m_termWidth, m_termHeight, 2, 2, 2, 2 );
 | 
			
		||||
        terminal = new WidgetTerminal( minecraft, () -> m_computer, m_termWidth, m_termHeight, 2, 2, 2, 2 );
 | 
			
		||||
        terminalWrapper = new WidgetWrapper( terminal, 2 + 12 + guiLeft, 2 + 12 + guiTop, termPxWidth, termPxHeight );
 | 
			
		||||
 | 
			
		||||
        children.add( terminalWrapper );
 | 
			
		||||
@@ -75,12 +95,12 @@ public class GuiComputer extends GuiContainer
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onGuiClosed()
 | 
			
		||||
    public void removed()
 | 
			
		||||
    {
 | 
			
		||||
        super.onGuiClosed();
 | 
			
		||||
        super.removed();
 | 
			
		||||
        children.remove( terminal );
 | 
			
		||||
        terminal = null;
 | 
			
		||||
        mc.keyboardListener.enableRepeatEvents( false );
 | 
			
		||||
        minecraft.keyboardListener.enableRepeatEvents( false );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -90,6 +110,18 @@ public class GuiComputer extends GuiContainer
 | 
			
		||||
        terminal.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean keyPressed( int key, int scancode, int modifiers )
 | 
			
		||||
    {
 | 
			
		||||
        // Forward the tab key to the terminal, rather than moving between controls.
 | 
			
		||||
        if( key == GLFW.GLFW_KEY_TAB && getFocused() != null && getFocused() == terminalWrapper )
 | 
			
		||||
        {
 | 
			
		||||
            return getFocused().keyPressed( key, scancode, modifiers );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return super.keyPressed( key, scancode, modifiers );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
 | 
			
		||||
    {
 | 
			
		||||
@@ -108,32 +140,32 @@ public class GuiComputer extends GuiContainer
 | 
			
		||||
        {
 | 
			
		||||
            case Normal:
 | 
			
		||||
            default:
 | 
			
		||||
                mc.getTextureManager().bindTexture( BACKGROUND_NORMAL );
 | 
			
		||||
                minecraft.getTextureManager().bindTexture( BACKGROUND_NORMAL );
 | 
			
		||||
                break;
 | 
			
		||||
            case Advanced:
 | 
			
		||||
                mc.getTextureManager().bindTexture( BACKGROUND_ADVANCED );
 | 
			
		||||
                minecraft.getTextureManager().bindTexture( BACKGROUND_ADVANCED );
 | 
			
		||||
                break;
 | 
			
		||||
            case Command:
 | 
			
		||||
                mc.getTextureManager().bindTexture( BACKGROUND_COMMAND );
 | 
			
		||||
                minecraft.getTextureManager().bindTexture( BACKGROUND_COMMAND );
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        drawTexturedModalRect( startX - 12, startY - 12, 12, 28, 12, 12 );
 | 
			
		||||
        drawTexturedModalRect( startX - 12, endY, 12, 40, 12, 12 );
 | 
			
		||||
        drawTexturedModalRect( endX, startY - 12, 24, 28, 12, 12 );
 | 
			
		||||
        drawTexturedModalRect( endX, endY, 24, 40, 12, 12 );
 | 
			
		||||
        blit( startX - 12, startY - 12, 12, 28, 12, 12 );
 | 
			
		||||
        blit( startX - 12, endY, 12, 40, 12, 12 );
 | 
			
		||||
        blit( endX, startY - 12, 24, 28, 12, 12 );
 | 
			
		||||
        blit( endX, endY, 24, 40, 12, 12 );
 | 
			
		||||
 | 
			
		||||
        drawTexturedModalRect( startX, startY - 12, 0, 0, endX - startX, 12 );
 | 
			
		||||
        drawTexturedModalRect( startX, endY, 0, 12, endX - startX, 12 );
 | 
			
		||||
        blit( startX, startY - 12, 0, 0, endX - startX, 12 );
 | 
			
		||||
        blit( startX, endY, 0, 12, endX - startX, 12 );
 | 
			
		||||
 | 
			
		||||
        drawTexturedModalRect( startX - 12, startY, 0, 28, 12, endY - startY );
 | 
			
		||||
        drawTexturedModalRect( endX, startY, 36, 28, 12, endY - startY );
 | 
			
		||||
        blit( startX - 12, startY, 0, 28, 12, endY - startY );
 | 
			
		||||
        blit( endX, startY, 36, 28, 12, endY - startY );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void render( int mouseX, int mouseY, float partialTicks )
 | 
			
		||||
    {
 | 
			
		||||
        drawDefaultBackground();
 | 
			
		||||
        renderBackground();
 | 
			
		||||
        super.render( mouseX, mouseY, partialTicks );
 | 
			
		||||
        renderHoveredToolTip( mouseX, mouseY );
 | 
			
		||||
    }
 | 
			
		||||
@@ -144,11 +176,4 @@ public class GuiComputer extends GuiContainer
 | 
			
		||||
        return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ))
 | 
			
		||||
            || super.mouseDragged( x, y, button, deltaX, deltaY );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean mouseReleased( double x, double y, int button )
 | 
			
		||||
    {
 | 
			
		||||
        return (getFocused() != null && getFocused().mouseReleased( x, y, button ))
 | 
			
		||||
            || super.mouseReleased( x, y, button );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,44 +6,42 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.gui;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
 | 
			
		||||
import net.minecraft.client.gui.inventory.GuiContainer;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.resources.I18n;
 | 
			
		||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
 | 
			
		||||
import net.minecraft.entity.player.PlayerInventory;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
 | 
			
		||||
public class GuiDiskDrive extends GuiContainer
 | 
			
		||||
public class GuiDiskDrive extends ContainerScreen<ContainerDiskDrive>
 | 
			
		||||
{
 | 
			
		||||
    private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/disk_drive.png" );
 | 
			
		||||
 | 
			
		||||
    private final ContainerDiskDrive m_container;
 | 
			
		||||
 | 
			
		||||
    public GuiDiskDrive( ContainerDiskDrive container )
 | 
			
		||||
    public GuiDiskDrive( ContainerDiskDrive container, PlayerInventory player, ITextComponent title )
 | 
			
		||||
    {
 | 
			
		||||
        super( container );
 | 
			
		||||
        m_container = container;
 | 
			
		||||
        super( container, player, title );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY )
 | 
			
		||||
    {
 | 
			
		||||
        String title = m_container.getDiskDrive().getDisplayName().getString();
 | 
			
		||||
        fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2.0f, 6, 0x404040 );
 | 
			
		||||
        fontRenderer.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 );
 | 
			
		||||
        String title = this.title.getFormattedText();
 | 
			
		||||
        font.drawString( title, (xSize - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
 | 
			
		||||
        font.drawString( title, 8, ySize - 96 + 2, 0x404040 );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
 | 
			
		||||
    {
 | 
			
		||||
        GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
 | 
			
		||||
        mc.getTextureManager().bindTexture( BACKGROUND );
 | 
			
		||||
        drawTexturedModalRect( guiLeft, guiTop, 0, 0, xSize, ySize );
 | 
			
		||||
        minecraft.getTextureManager().bindTexture( BACKGROUND );
 | 
			
		||||
        blit( guiLeft, guiTop, 0, 0, xSize, ySize );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void render( int mouseX, int mouseY, float partialTicks )
 | 
			
		||||
    {
 | 
			
		||||
        drawDefaultBackground();
 | 
			
		||||
        renderBackground();
 | 
			
		||||
        super.render( mouseX, mouseY, partialTicks );
 | 
			
		||||
        renderHoveredToolTip( mouseX, mouseY );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,34 +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.client.gui;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
 | 
			
		||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
 | 
			
		||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
 | 
			
		||||
import net.minecraft.item.Item;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
 | 
			
		||||
public class GuiPocketComputer extends GuiComputer
 | 
			
		||||
{
 | 
			
		||||
    public GuiPocketComputer( ContainerPocketComputer container )
 | 
			
		||||
    {
 | 
			
		||||
        super(
 | 
			
		||||
            container,
 | 
			
		||||
            getFamily( container.getStack() ),
 | 
			
		||||
            ItemPocketComputer.createClientComputer( container.getStack() ),
 | 
			
		||||
            ComputerCraft.terminalWidth_pocketComputer,
 | 
			
		||||
            ComputerCraft.terminalHeight_pocketComputer
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static ComputerFamily getFamily( ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        Item item = stack.getItem();
 | 
			
		||||
        return item instanceof ItemPocketComputer ? ((ItemPocketComputer) item).getFamily() : ComputerFamily.Normal;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -6,46 +6,45 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.gui;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
 | 
			
		||||
import net.minecraft.client.gui.inventory.GuiContainer;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
 | 
			
		||||
import net.minecraft.client.resources.I18n;
 | 
			
		||||
import net.minecraft.entity.player.PlayerInventory;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
 | 
			
		||||
public class GuiPrinter extends GuiContainer
 | 
			
		||||
public class GuiPrinter extends ContainerScreen<ContainerPrinter>
 | 
			
		||||
{
 | 
			
		||||
    private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/printer.png" );
 | 
			
		||||
 | 
			
		||||
    private final ContainerPrinter container;
 | 
			
		||||
 | 
			
		||||
    public GuiPrinter( ContainerPrinter container )
 | 
			
		||||
    public GuiPrinter( ContainerPrinter container, PlayerInventory player, ITextComponent title )
 | 
			
		||||
    {
 | 
			
		||||
        super( container );
 | 
			
		||||
        this.container = container;
 | 
			
		||||
        super( container, player, title );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY )
 | 
			
		||||
    {
 | 
			
		||||
        String title = container.getPrinter().getDisplayName().getString();
 | 
			
		||||
        fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2.0f, 6, 0x404040 );
 | 
			
		||||
        fontRenderer.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 );
 | 
			
		||||
        String title = getTitle().getFormattedText();
 | 
			
		||||
        font.drawString( title, (xSize - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
 | 
			
		||||
        font.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
 | 
			
		||||
    {
 | 
			
		||||
        GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
 | 
			
		||||
        mc.getTextureManager().bindTexture( BACKGROUND );
 | 
			
		||||
        drawTexturedModalRect( guiLeft, guiTop, 0, 0, xSize, ySize );
 | 
			
		||||
        minecraft.getTextureManager().bindTexture( BACKGROUND );
 | 
			
		||||
        blit( guiLeft, guiTop, 0, 0, xSize, ySize );
 | 
			
		||||
 | 
			
		||||
        if( container.isPrinting() ) drawTexturedModalRect( guiLeft + 34, guiTop + 21, 176, 0, 25, 45 );
 | 
			
		||||
        if( getContainer().isPrinting() ) blit( guiLeft + 34, guiTop + 21, 176, 0, 25, 45 );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void render( int mouseX, int mouseY, float partialTicks )
 | 
			
		||||
    {
 | 
			
		||||
        drawDefaultBackground();
 | 
			
		||||
        renderBackground();
 | 
			
		||||
        super.render( mouseX, mouseY, partialTicks );
 | 
			
		||||
        renderHoveredToolTip( mouseX, mouseY );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,16 +6,18 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.gui;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.core.terminal.TextBuffer;
 | 
			
		||||
import dan200.computercraft.shared.common.ContainerHeldItem;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemPrintout;
 | 
			
		||||
import net.minecraft.client.gui.inventory.GuiContainer;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
 | 
			
		||||
import net.minecraft.entity.player.PlayerInventory;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import org.lwjgl.glfw.GLFW;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.client.render.PrintoutRenderer.*;
 | 
			
		||||
 | 
			
		||||
public class GuiPrintout extends GuiContainer
 | 
			
		||||
public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
 | 
			
		||||
{
 | 
			
		||||
    private final boolean m_book;
 | 
			
		||||
    private final int m_pages;
 | 
			
		||||
@@ -23,9 +25,9 @@ public class GuiPrintout extends GuiContainer
 | 
			
		||||
    private final TextBuffer[] m_colours;
 | 
			
		||||
    private int m_page;
 | 
			
		||||
 | 
			
		||||
    public GuiPrintout( ContainerHeldItem container )
 | 
			
		||||
    public GuiPrintout( ContainerHeldItem container, PlayerInventory player, ITextComponent title )
 | 
			
		||||
    {
 | 
			
		||||
        super( container );
 | 
			
		||||
        super( container, player, title );
 | 
			
		||||
 | 
			
		||||
        ySize = Y_SIZE;
 | 
			
		||||
 | 
			
		||||
@@ -63,9 +65,9 @@ public class GuiPrintout extends GuiContainer
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean mouseScrolled( double delta )
 | 
			
		||||
    public boolean mouseScrolled( double x, double y, double delta )
 | 
			
		||||
    {
 | 
			
		||||
        if( super.mouseScrolled( delta ) ) return true;
 | 
			
		||||
        if( super.mouseScrolled( x, y, delta ) ) return true;
 | 
			
		||||
        if( delta < 0 )
 | 
			
		||||
        {
 | 
			
		||||
            // Scroll up goes to the next page
 | 
			
		||||
@@ -90,7 +92,7 @@ public class GuiPrintout extends GuiContainer
 | 
			
		||||
        GlStateManager.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
 | 
			
		||||
        GlStateManager.enableDepthTest();
 | 
			
		||||
 | 
			
		||||
        drawBorder( guiLeft, guiTop, zLevel, m_page, m_pages, m_book );
 | 
			
		||||
        drawBorder( guiLeft, guiTop, blitOffset, m_page, m_pages, m_book );
 | 
			
		||||
        drawText( guiLeft + X_TEXT_MARGIN, guiTop + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * m_page, m_text, m_colours );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -98,9 +100,9 @@ public class GuiPrintout extends GuiContainer
 | 
			
		||||
    public void render( int mouseX, int mouseY, float partialTicks )
 | 
			
		||||
    {
 | 
			
		||||
        // We must take the background further back in order to not overlap with our printed pages.
 | 
			
		||||
        zLevel--;
 | 
			
		||||
        drawDefaultBackground();
 | 
			
		||||
        zLevel++;
 | 
			
		||||
        blitOffset--;
 | 
			
		||||
        renderBackground();
 | 
			
		||||
        blitOffset++;
 | 
			
		||||
 | 
			
		||||
        super.render( mouseX, mouseY, partialTicks );
 | 
			
		||||
        renderHoveredToolTip( mouseX, mouseY );
 | 
			
		||||
 
 | 
			
		||||
@@ -6,18 +6,20 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.gui;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
 | 
			
		||||
import dan200.computercraft.client.gui.widgets.WidgetWrapper;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ClientComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
 | 
			
		||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
 | 
			
		||||
import net.minecraft.client.gui.inventory.GuiContainer;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
 | 
			
		||||
import net.minecraft.entity.player.PlayerInventory;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import org.lwjgl.glfw.GLFW;
 | 
			
		||||
 | 
			
		||||
public class GuiTurtle extends GuiContainer
 | 
			
		||||
public class GuiTurtle extends ContainerScreen<ContainerTurtle>
 | 
			
		||||
{
 | 
			
		||||
    private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( "computercraft", "textures/gui/turtle_normal.png" );
 | 
			
		||||
    private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( "computercraft", "textures/gui/turtle_advanced.png" );
 | 
			
		||||
@@ -30,29 +32,29 @@ public class GuiTurtle extends GuiContainer
 | 
			
		||||
    private WidgetTerminal terminal;
 | 
			
		||||
    private WidgetWrapper terminalWrapper;
 | 
			
		||||
 | 
			
		||||
    public GuiTurtle( TileTurtle turtle, ContainerTurtle container )
 | 
			
		||||
    public GuiTurtle( ContainerTurtle container, PlayerInventory player, ITextComponent title )
 | 
			
		||||
    {
 | 
			
		||||
        super( container );
 | 
			
		||||
        super( container, player, title );
 | 
			
		||||
 | 
			
		||||
        m_container = container;
 | 
			
		||||
        m_family = turtle.getFamily();
 | 
			
		||||
        m_computer = turtle.getClientComputer();
 | 
			
		||||
        m_family = container.getFamily();
 | 
			
		||||
        m_computer = (ClientComputer) container.getComputer();
 | 
			
		||||
 | 
			
		||||
        xSize = 254;
 | 
			
		||||
        ySize = 217;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void initGui()
 | 
			
		||||
    protected void init()
 | 
			
		||||
    {
 | 
			
		||||
        super.initGui();
 | 
			
		||||
        mc.keyboardListener.enableRepeatEvents( true );
 | 
			
		||||
        super.init();
 | 
			
		||||
        minecraft.keyboardListener.enableRepeatEvents( true );
 | 
			
		||||
 | 
			
		||||
        int termPxWidth = ComputerCraft.terminalWidth_turtle * FixedWidthFontRenderer.FONT_WIDTH;
 | 
			
		||||
        int termPxHeight = ComputerCraft.terminalHeight_turtle * FixedWidthFontRenderer.FONT_HEIGHT;
 | 
			
		||||
 | 
			
		||||
        terminal = new WidgetTerminal(
 | 
			
		||||
            mc, () -> m_computer,
 | 
			
		||||
            minecraft, () -> m_computer,
 | 
			
		||||
            ComputerCraft.terminalWidth_turtle,
 | 
			
		||||
            ComputerCraft.terminalHeight_turtle,
 | 
			
		||||
            2, 2, 2, 2
 | 
			
		||||
@@ -64,11 +66,12 @@ public class GuiTurtle extends GuiContainer
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onGuiClosed()
 | 
			
		||||
    public void removed()
 | 
			
		||||
    {
 | 
			
		||||
        super.removed();
 | 
			
		||||
        children.remove( terminal );
 | 
			
		||||
        terminal = null;
 | 
			
		||||
        mc.keyboardListener.enableRepeatEvents( false );
 | 
			
		||||
        minecraft.keyboardListener.enableRepeatEvents( false );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -78,6 +81,18 @@ public class GuiTurtle extends GuiContainer
 | 
			
		||||
        terminal.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean keyPressed( int key, int scancode, int modifiers )
 | 
			
		||||
    {
 | 
			
		||||
        // Forward the tab key to the terminal, rather than moving between controls.
 | 
			
		||||
        if( key == GLFW.GLFW_KEY_TAB && getFocused() != null && getFocused() == terminalWrapper )
 | 
			
		||||
        {
 | 
			
		||||
            return getFocused().keyPressed( key, scancode, modifiers );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return super.keyPressed( key, scancode, modifiers );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void drawSelectionSlot( boolean advanced )
 | 
			
		||||
    {
 | 
			
		||||
        // Draw selection slot
 | 
			
		||||
@@ -87,8 +102,8 @@ public class GuiTurtle extends GuiContainer
 | 
			
		||||
            GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
 | 
			
		||||
            int slotX = slot % 4;
 | 
			
		||||
            int slotY = slot / 4;
 | 
			
		||||
            mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
 | 
			
		||||
            drawTexturedModalRect( guiLeft + m_container.turtleInvStartX - 2 + slotX * 18, guiTop + m_container.playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24 );
 | 
			
		||||
            minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
 | 
			
		||||
            blit( guiLeft + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, guiTop + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, 0, 217, 24, 24 );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -101,8 +116,8 @@ public class GuiTurtle extends GuiContainer
 | 
			
		||||
 | 
			
		||||
        // Draw border/inventory
 | 
			
		||||
        GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
 | 
			
		||||
        mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
 | 
			
		||||
        drawTexturedModalRect( guiLeft, guiTop, 0, 0, xSize, ySize );
 | 
			
		||||
        minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
 | 
			
		||||
        blit( guiLeft, guiTop, 0, 0, xSize, ySize );
 | 
			
		||||
 | 
			
		||||
        drawSelectionSlot( advanced );
 | 
			
		||||
    }
 | 
			
		||||
@@ -110,8 +125,15 @@ public class GuiTurtle extends GuiContainer
 | 
			
		||||
    @Override
 | 
			
		||||
    public void render( int mouseX, int mouseY, float partialTicks )
 | 
			
		||||
    {
 | 
			
		||||
        drawDefaultBackground();
 | 
			
		||||
        renderBackground();
 | 
			
		||||
        super.render( mouseX, mouseY, partialTicks );
 | 
			
		||||
        renderHoveredToolTip( mouseX, mouseY );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY )
 | 
			
		||||
    {
 | 
			
		||||
        return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ))
 | 
			
		||||
            || super.mouseDragged( x, y, button, deltaX, deltaY );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.gui.widgets;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.client.FrameInfo;
 | 
			
		||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
 | 
			
		||||
import dan200.computercraft.core.terminal.Terminal;
 | 
			
		||||
@@ -17,7 +18,6 @@ import dan200.computercraft.shared.util.Palette;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.gui.IGuiEventListener;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.util.SharedConstants;
 | 
			
		||||
@@ -35,6 +35,8 @@ public class WidgetTerminal implements IGuiEventListener
 | 
			
		||||
 | 
			
		||||
    private final Minecraft client;
 | 
			
		||||
 | 
			
		||||
    private boolean focused;
 | 
			
		||||
 | 
			
		||||
    private final Supplier<ClientComputer> computer;
 | 
			
		||||
    private final int termWidth;
 | 
			
		||||
    private final int termHeight;
 | 
			
		||||
@@ -239,25 +241,35 @@ public class WidgetTerminal implements IGuiEventListener
 | 
			
		||||
            charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
 | 
			
		||||
            charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 );
 | 
			
		||||
 | 
			
		||||
            computer.mouseDrag( button + 1, charX + 1, charY + 1 );
 | 
			
		||||
 | 
			
		||||
            lastMouseX = charX;
 | 
			
		||||
            lastMouseY = charY;
 | 
			
		||||
            lastMouseButton = button;
 | 
			
		||||
            if( button == lastMouseButton && (charX != lastMouseX || charY != lastMouseY) )
 | 
			
		||||
            {
 | 
			
		||||
                computer.mouseDrag( button + 1, charX + 1, charY + 1 );
 | 
			
		||||
                lastMouseX = charX;
 | 
			
		||||
                lastMouseY = charY;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean mouseScrolled( double delta )
 | 
			
		||||
    public boolean mouseScrolled( double mouseX, double mouseY, double delta )
 | 
			
		||||
    {
 | 
			
		||||
        ClientComputer computer = this.computer.get();
 | 
			
		||||
        if( computer == null || !computer.isColour() ) return false;
 | 
			
		||||
        if( computer == null || !computer.isColour() || delta == 0 ) return false;
 | 
			
		||||
 | 
			
		||||
        if( lastMouseX >= 0 && lastMouseY >= 0 && delta != 0 )
 | 
			
		||||
        Terminal term = computer.getTerminal();
 | 
			
		||||
        if( term != null )
 | 
			
		||||
        {
 | 
			
		||||
            queueEvent( "mouse_scroll", delta < 0 ? 1 : -1, lastMouseX + 1, lastMouseY + 1 );
 | 
			
		||||
            int charX = (int) (mouseX / FixedWidthFontRenderer.FONT_WIDTH);
 | 
			
		||||
            int charY = (int) (mouseY / FixedWidthFontRenderer.FONT_HEIGHT);
 | 
			
		||||
            charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
 | 
			
		||||
            charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 );
 | 
			
		||||
 | 
			
		||||
            computer.mouseScroll( delta < 0 ? 1 : -1, charX + 1, charY + 1 );
 | 
			
		||||
 | 
			
		||||
            lastMouseX = charX;
 | 
			
		||||
            lastMouseY = charY;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -284,9 +296,9 @@ public class WidgetTerminal implements IGuiEventListener
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void focusChanged( boolean focused )
 | 
			
		||||
    public boolean changeFocus( boolean reversed )
 | 
			
		||||
    {
 | 
			
		||||
        if( !focused )
 | 
			
		||||
        if( focused )
 | 
			
		||||
        {
 | 
			
		||||
            // When blurring, we should make all keys go up
 | 
			
		||||
            for( int key = 0; key < keysDown.size(); key++ )
 | 
			
		||||
@@ -305,6 +317,8 @@ public class WidgetTerminal implements IGuiEventListener
 | 
			
		||||
 | 
			
		||||
            shutdownTimer = terminateTimer = rebootTimer = -1;
 | 
			
		||||
        }
 | 
			
		||||
        focused = !focused;
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void draw( int originX, int originY )
 | 
			
		||||
@@ -414,4 +428,10 @@ public class WidgetTerminal implements IGuiEventListener
 | 
			
		||||
        ClientComputer computer = this.computer.get();
 | 
			
		||||
        if( computer != null ) computer.queueEvent( event, args );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isMouseOver( double x, double y )
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,15 +26,9 @@ public class WidgetWrapper implements IGuiEventListener
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void focusChanged( boolean b )
 | 
			
		||||
    public boolean changeFocus( boolean b )
 | 
			
		||||
    {
 | 
			
		||||
        listener.focusChanged( b );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean canFocus()
 | 
			
		||||
    {
 | 
			
		||||
        return listener.canFocus();
 | 
			
		||||
        return listener.changeFocus( b );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -59,9 +53,9 @@ public class WidgetWrapper implements IGuiEventListener
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean mouseScrolled( double delta )
 | 
			
		||||
    public boolean mouseScrolled( double x, double y, double delta )
 | 
			
		||||
    {
 | 
			
		||||
        return listener.mouseScrolled( delta );
 | 
			
		||||
        return listener.mouseScrolled( x, y, delta );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -101,4 +95,11 @@ public class WidgetWrapper implements IGuiEventListener
 | 
			
		||||
    {
 | 
			
		||||
        return height;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isMouseOver( double x, double y )
 | 
			
		||||
    {
 | 
			
		||||
        double dx = x - this.x, dy = y - this.y;
 | 
			
		||||
        return dx >= 0 && dx < width && dy >= 0 && dy < height;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,29 +11,25 @@ import dan200.computercraft.client.gui.*;
 | 
			
		||||
import dan200.computercraft.client.render.TileEntityCableRenderer;
 | 
			
		||||
import dan200.computercraft.client.render.TileEntityMonitorRenderer;
 | 
			
		||||
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ClientComputer;
 | 
			
		||||
import dan200.computercraft.shared.common.ContainerHeldItem;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
 | 
			
		||||
import dan200.computercraft.shared.network.container.*;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.TileCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
 | 
			
		||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
 | 
			
		||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.gui.inventory.GuiContainer;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.client.gui.ScreenManager;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
import net.minecraftforge.event.world.WorldEvent;
 | 
			
		||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
 | 
			
		||||
import net.minecraftforge.fml.ExtensionPoint;
 | 
			
		||||
import net.minecraftforge.fml.ModLoadingContext;
 | 
			
		||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
 | 
			
		||||
import net.minecraftforge.fml.common.Mod;
 | 
			
		||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
 | 
			
		||||
 | 
			
		||||
import java.util.function.BiFunction;
 | 
			
		||||
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD )
 | 
			
		||||
public final class ComputerCraftProxyClient
 | 
			
		||||
{
 | 
			
		||||
@@ -50,35 +46,17 @@ public final class ComputerCraftProxyClient
 | 
			
		||||
 | 
			
		||||
    private static void registerContainers()
 | 
			
		||||
    {
 | 
			
		||||
        ContainerType.registerGui( TileEntityContainerType::computer, ( packet, player ) ->
 | 
			
		||||
            new GuiComputer( (TileComputer) packet.getTileEntity( player ) ) );
 | 
			
		||||
        ContainerType.registerGui( TileEntityContainerType::diskDrive, GuiDiskDrive::new );
 | 
			
		||||
        ContainerType.registerGui( TileEntityContainerType::printer, GuiPrinter::new );
 | 
			
		||||
        ContainerType.registerGui( TileEntityContainerType::turtle, ( packet, player ) -> {
 | 
			
		||||
            TileTurtle turtle = (TileTurtle) packet.getTileEntity( player );
 | 
			
		||||
            return new GuiTurtle( turtle, new ContainerTurtle( player.inventory, turtle.getAccess(), turtle.getClientComputer() ) );
 | 
			
		||||
        } );
 | 
			
		||||
        // My IDE doesn't think so, but we do actually need these generics.
 | 
			
		||||
 | 
			
		||||
        ContainerType.registerGui( PocketComputerContainerType::new, GuiPocketComputer::new );
 | 
			
		||||
        ContainerType.registerGui( PrintoutContainerType::new, GuiPrintout::new );
 | 
			
		||||
        ContainerType.registerGui( ViewComputerContainerType::new, ( packet, player ) -> {
 | 
			
		||||
            ClientComputer computer = ComputerCraft.clientComputerRegistry.get( packet.instanceId );
 | 
			
		||||
            if( computer == null )
 | 
			
		||||
            {
 | 
			
		||||
                ComputerCraft.clientComputerRegistry.add( packet.instanceId, computer = new ClientComputer( packet.instanceId ) );
 | 
			
		||||
            }
 | 
			
		||||
        ScreenManager.<ContainerComputer, GuiComputer<ContainerComputer>>registerFactory( ContainerComputer.TYPE, GuiComputer::create );
 | 
			
		||||
        ScreenManager.<ContainerPocketComputer, GuiComputer<ContainerPocketComputer>>registerFactory( ContainerPocketComputer.TYPE, GuiComputer::createPocket );
 | 
			
		||||
        ScreenManager.registerFactory( ContainerTurtle.TYPE, GuiTurtle::new );
 | 
			
		||||
 | 
			
		||||
            ContainerViewComputer container = new ContainerViewComputer( computer );
 | 
			
		||||
            return new GuiComputer( container, packet.family, computer, packet.width, packet.height );
 | 
			
		||||
        } );
 | 
			
		||||
        ScreenManager.registerFactory( ContainerPrinter.TYPE, GuiPrinter::new );
 | 
			
		||||
        ScreenManager.registerFactory( ContainerDiskDrive.TYPE, GuiDiskDrive::new );
 | 
			
		||||
        ScreenManager.registerFactory( ContainerHeldItem.PRINTOUT_TYPE, GuiPrintout::new );
 | 
			
		||||
 | 
			
		||||
        ModLoadingContext.get().registerExtensionPoint( ExtensionPoint.GUIFACTORY, () -> packet -> {
 | 
			
		||||
            ContainerType<?> type = ContainerType.factories.get( packet.getId() ).get();
 | 
			
		||||
            if( packet.getAdditionalData() != null ) type.fromBytes( packet.getAdditionalData() );
 | 
			
		||||
            @SuppressWarnings( "unchecked" )
 | 
			
		||||
            BiFunction<ContainerType<?>, EntityPlayer, GuiContainer> factory = (BiFunction<ContainerType<?>, EntityPlayer, GuiContainer>) ContainerType.guiFactories.get( packet.getId() );
 | 
			
		||||
            return factory.apply( type, Minecraft.getInstance().player );
 | 
			
		||||
        } );
 | 
			
		||||
        ScreenManager.<ContainerViewComputer, GuiComputer<ContainerViewComputer>>registerFactory( ContainerViewComputer.TYPE, GuiComputer::createView );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
 | 
			
		||||
 
 | 
			
		||||
@@ -6,17 +6,19 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.CableShapes;
 | 
			
		||||
import dan200.computercraft.shared.util.WorldUtil;
 | 
			
		||||
import net.minecraft.block.state.IBlockState;
 | 
			
		||||
import net.minecraft.block.BlockState;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.ActiveRenderInfo;
 | 
			
		||||
import net.minecraft.client.renderer.WorldRenderer;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.BlockRayTraceResult;
 | 
			
		||||
import net.minecraft.util.math.RayTraceResult;
 | 
			
		||||
import net.minecraft.util.math.Vec3d;
 | 
			
		||||
import net.minecraft.util.math.shapes.VoxelShape;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
@@ -36,17 +38,19 @@ public final class CableHighlightRenderer
 | 
			
		||||
     * Draw an outline for a specific part of a cable "Multipart".
 | 
			
		||||
     *
 | 
			
		||||
     * @param event The event to observe
 | 
			
		||||
     * @see WorldRenderer#drawSelectionBox(EntityPlayer, RayTraceResult, int, float)
 | 
			
		||||
     * @see WorldRenderer#drawSelectionBox(ActiveRenderInfo, RayTraceResult, int)
 | 
			
		||||
     */
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public static void drawHighlight( DrawBlockHighlightEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        if( event.getTarget().type != RayTraceResult.Type.BLOCK ) return;
 | 
			
		||||
        if( event.getTarget().getType() != RayTraceResult.Type.BLOCK ) return;
 | 
			
		||||
 | 
			
		||||
        BlockPos pos = event.getTarget().getBlockPos();
 | 
			
		||||
        World world = event.getPlayer().getEntityWorld();
 | 
			
		||||
        BlockRayTraceResult hit = (BlockRayTraceResult) event.getTarget();
 | 
			
		||||
        BlockPos pos = hit.getPos();
 | 
			
		||||
        World world = event.getInfo().getRenderViewEntity().getEntityWorld();
 | 
			
		||||
        ActiveRenderInfo info = event.getInfo();
 | 
			
		||||
 | 
			
		||||
        IBlockState state = world.getBlockState( pos );
 | 
			
		||||
        BlockState state = world.getBlockState( pos );
 | 
			
		||||
 | 
			
		||||
        // We only care about instances with both cable and modem.
 | 
			
		||||
        if( state.getBlock() != ComputerCraft.Blocks.cable || state.get( BlockCable.MODEM ).getFacing() == null || !state.get( BlockCable.CABLE ) )
 | 
			
		||||
@@ -56,33 +60,31 @@ public final class CableHighlightRenderer
 | 
			
		||||
 | 
			
		||||
        event.setCanceled( true );
 | 
			
		||||
 | 
			
		||||
        EntityPlayer player = event.getPlayer();
 | 
			
		||||
        Minecraft mc = Minecraft.getInstance();
 | 
			
		||||
        float partialTicks = event.getPartialTicks();
 | 
			
		||||
 | 
			
		||||
        GlStateManager.enableBlend();
 | 
			
		||||
        GlStateManager.blendFuncSeparate( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO );
 | 
			
		||||
        GlStateManager.lineWidth( Math.max( 2.5F, mc.mainWindow.getFramebufferWidth() / 1920.0F * 2.5F ) );
 | 
			
		||||
        GlStateManager.disableTexture2D();
 | 
			
		||||
        GlStateManager.disableTexture();
 | 
			
		||||
        GlStateManager.depthMask( false );
 | 
			
		||||
        GlStateManager.matrixMode( GL11.GL_PROJECTION );
 | 
			
		||||
        GlStateManager.pushMatrix();
 | 
			
		||||
        GlStateManager.scalef( 1.0F, 1.0F, 0.999F );
 | 
			
		||||
 | 
			
		||||
        double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
 | 
			
		||||
        double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
 | 
			
		||||
        double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
 | 
			
		||||
 | 
			
		||||
        VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), event.getTarget().hitVec.subtract( pos.getX(), pos.getY(), pos.getZ() ) )
 | 
			
		||||
        VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getHitVec().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
 | 
			
		||||
            ? CableShapes.getModemShape( state )
 | 
			
		||||
            : CableShapes.getCableShape( state );
 | 
			
		||||
 | 
			
		||||
        WorldRenderer.drawShape( shape, pos.getX() - x, pos.getY() - y, pos.getZ() - z, 0.0F, 0.0F, 0.0F, 0.4F );
 | 
			
		||||
        Vec3d cameraPos = info.getProjectedView();
 | 
			
		||||
        WorldRenderer.drawShape(
 | 
			
		||||
            shape, pos.getX() - cameraPos.getX(), pos.getY() - cameraPos.getY(), pos.getZ() - cameraPos.getZ(),
 | 
			
		||||
            0.0F, 0.0F, 0.0F, 0.4F
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        GlStateManager.popMatrix();
 | 
			
		||||
        GlStateManager.matrixMode( GL11.GL_MODELVIEW );
 | 
			
		||||
        GlStateManager.depthMask( true );
 | 
			
		||||
        GlStateManager.enableTexture2D();
 | 
			
		||||
        GlStateManager.enableTexture();
 | 
			
		||||
        GlStateManager.disableBlend();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,38 +6,38 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.FirstPersonRenderer;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.entity.player.PlayerEntity;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.EnumHand;
 | 
			
		||||
import net.minecraft.util.EnumHandSide;
 | 
			
		||||
import net.minecraft.util.Hand;
 | 
			
		||||
import net.minecraft.util.HandSide;
 | 
			
		||||
import net.minecraft.util.math.MathHelper;
 | 
			
		||||
 | 
			
		||||
public abstract class ItemMapLikeRenderer
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * The main rendering method for the item
 | 
			
		||||
     * The main rendering method for the item.
 | 
			
		||||
     *
 | 
			
		||||
     * @param stack The stack to render
 | 
			
		||||
     * @see FirstPersonRenderer#renderMapFirstPerson(ItemStack)
 | 
			
		||||
     */
 | 
			
		||||
    protected abstract void renderItem( ItemStack stack );
 | 
			
		||||
 | 
			
		||||
    protected void renderItemFirstPerson( EnumHand hand, float pitch, float equipProgress, float swingProgress, ItemStack stack )
 | 
			
		||||
    protected void renderItemFirstPerson( Hand hand, float pitch, float equipProgress, float swingProgress, ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        EntityPlayer player = Minecraft.getInstance().player;
 | 
			
		||||
        PlayerEntity player = Minecraft.getInstance().player;
 | 
			
		||||
 | 
			
		||||
        GlStateManager.pushMatrix();
 | 
			
		||||
        if( hand == EnumHand.MAIN_HAND && player.getHeldItemOffhand().isEmpty() )
 | 
			
		||||
        if( hand == Hand.MAIN_HAND && player.getHeldItemOffhand().isEmpty() )
 | 
			
		||||
        {
 | 
			
		||||
            renderItemFirstPersonCenter( pitch, equipProgress, swingProgress, stack );
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            renderItemFirstPersonSide(
 | 
			
		||||
                hand == EnumHand.MAIN_HAND ? player.getPrimaryHand() : player.getPrimaryHand().opposite(),
 | 
			
		||||
                hand == Hand.MAIN_HAND ? player.getPrimaryHand() : player.getPrimaryHand().opposite(),
 | 
			
		||||
                equipProgress, swingProgress, stack
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
@@ -51,12 +51,12 @@ public abstract class ItemMapLikeRenderer
 | 
			
		||||
     * @param equipProgress The equip progress of this item
 | 
			
		||||
     * @param swingProgress The swing progress of this item
 | 
			
		||||
     * @param stack         The stack to render
 | 
			
		||||
     * @see FirstPersonRenderer#renderMapFirstPersonSide(float, EnumHandSide, float, ItemStack)
 | 
			
		||||
     * @see FirstPersonRenderer#renderMapFirstPersonSide(float, HandSide, float, ItemStack)
 | 
			
		||||
     */
 | 
			
		||||
    private void renderItemFirstPersonSide( EnumHandSide side, float equipProgress, float swingProgress, ItemStack stack )
 | 
			
		||||
    private void renderItemFirstPersonSide( HandSide side, float equipProgress, float swingProgress, ItemStack stack )
 | 
			
		||||
    {
 | 
			
		||||
        Minecraft minecraft = Minecraft.getInstance();
 | 
			
		||||
        float offset = side == EnumHandSide.RIGHT ? 1f : -1f;
 | 
			
		||||
        float offset = side == HandSide.RIGHT ? 1f : -1f;
 | 
			
		||||
        GlStateManager.translatef( offset * 0.125f, -0.125f, 0f );
 | 
			
		||||
 | 
			
		||||
        // If the player is not invisible then render a single arm
 | 
			
		||||
@@ -87,7 +87,7 @@ public abstract class ItemMapLikeRenderer
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Render an item in the middle of the screen
 | 
			
		||||
     * Render an item in the middle of the screen.
 | 
			
		||||
     *
 | 
			
		||||
     * @param pitch         The pitch of the player
 | 
			
		||||
     * @param equipProgress The equip progress of this item
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.client.FrameInfo;
 | 
			
		||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
 | 
			
		||||
@@ -18,7 +19,6 @@ import dan200.computercraft.shared.util.Colour;
 | 
			
		||||
import dan200.computercraft.shared.util.Palette;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
@@ -32,7 +32,7 @@ import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*;
 | 
			
		||||
import static dan200.computercraft.client.gui.GuiComputer.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Emulates map rendering for pocket computers
 | 
			
		||||
 * Emulates map rendering for pocket computers.
 | 
			
		||||
 */
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
 | 
			
		||||
public final class ItemPocketRenderer extends ItemMapLikeRenderer
 | 
			
		||||
@@ -173,7 +173,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
 | 
			
		||||
    private static void renderLight( int colour, int width, int height )
 | 
			
		||||
    {
 | 
			
		||||
        GlStateManager.enableBlend();
 | 
			
		||||
        GlStateManager.disableTexture2D();
 | 
			
		||||
        GlStateManager.disableTexture();
 | 
			
		||||
 | 
			
		||||
        float r = ((colour >>> 16) & 0xFF) / 255.0f;
 | 
			
		||||
        float g = ((colour >>> 8) & 0xFF) / 255.0f;
 | 
			
		||||
@@ -188,7 +188,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
 | 
			
		||||
        buffer.pos( width - LIGHT_HEIGHT * 2, height + FRAME / 2.0f, 0.0D ).color( r, g, b, 1.0f ).endVertex();
 | 
			
		||||
 | 
			
		||||
        tessellator.draw();
 | 
			
		||||
        GlStateManager.enableTexture2D();
 | 
			
		||||
        GlStateManager.enableTexture();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void renderTerminal( Terminal terminal, boolean greyscale, int width, int height )
 | 
			
		||||
 
 | 
			
		||||
@@ -6,9 +6,9 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemPrintout;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
import net.minecraftforge.client.event.RenderItemInFrameEvent;
 | 
			
		||||
@@ -23,7 +23,7 @@ import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAG
 | 
			
		||||
import static dan200.computercraft.shared.media.items.ItemPrintout.LINE_MAX_LENGTH;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Emulates map and item-frame rendering for printouts
 | 
			
		||||
 * Emulates map and item-frame rendering for printouts.
 | 
			
		||||
 */
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
 | 
			
		||||
public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ package dan200.computercraft.client.render;
 | 
			
		||||
import net.minecraft.client.renderer.model.BakedQuad;
 | 
			
		||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.VertexFormat;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
 | 
			
		||||
import net.minecraftforge.client.model.pipeline.LightUtil;
 | 
			
		||||
import net.minecraftforge.client.model.pipeline.VertexTransformer;
 | 
			
		||||
@@ -102,7 +102,7 @@ public final class ModelTransformer
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void setQuadOrientation( @Nonnull EnumFacing orientation )
 | 
			
		||||
        public void setQuadOrientation( @Nonnull Direction orientation )
 | 
			
		||||
        {
 | 
			
		||||
            super.setQuadOrientation( orientation == null ? orientation : TRSRTransformation.rotate( positionMatrix, orientation ) );
 | 
			
		||||
        }
 | 
			
		||||
@@ -187,7 +187,7 @@ public final class ModelTransformer
 | 
			
		||||
        private final int[] vertexData;
 | 
			
		||||
        private int vertexIndex = 0, elementIndex = 0;
 | 
			
		||||
 | 
			
		||||
        private EnumFacing orientation;
 | 
			
		||||
        private Direction orientation;
 | 
			
		||||
        private int quadTint;
 | 
			
		||||
        private boolean diffuse;
 | 
			
		||||
        private TextureAtlasSprite texture;
 | 
			
		||||
@@ -212,7 +212,7 @@ public final class ModelTransformer
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void setQuadOrientation( @Nonnull EnumFacing orientation )
 | 
			
		||||
        public void setQuadOrientation( @Nonnull Direction orientation )
 | 
			
		||||
        {
 | 
			
		||||
            this.orientation = orientation;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,18 +6,19 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.tileentity.TileEntity;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.BlockRayTraceResult;
 | 
			
		||||
import net.minecraft.util.math.RayTraceResult;
 | 
			
		||||
import net.minecraft.util.math.Vec3d;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
 | 
			
		||||
@@ -27,7 +28,7 @@ import org.lwjgl.opengl.GL11;
 | 
			
		||||
 | 
			
		||||
import java.util.EnumSet;
 | 
			
		||||
 | 
			
		||||
import static net.minecraft.util.EnumFacing.*;
 | 
			
		||||
import static net.minecraft.util.Direction.*;
 | 
			
		||||
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
 | 
			
		||||
public final class MonitorHighlightRenderer
 | 
			
		||||
@@ -41,10 +42,13 @@ public final class MonitorHighlightRenderer
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public static void drawHighlight( DrawBlockHighlightEvent event )
 | 
			
		||||
    {
 | 
			
		||||
        if( event.getTarget().type != RayTraceResult.Type.BLOCK || event.getPlayer().isSneaking() ) return;
 | 
			
		||||
        if( event.getTarget().getType() != RayTraceResult.Type.BLOCK || event.getInfo().getRenderViewEntity().isSneaking() )
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        World world = event.getPlayer().getEntityWorld();
 | 
			
		||||
        BlockPos pos = event.getTarget().getBlockPos();
 | 
			
		||||
        World world = event.getInfo().getRenderViewEntity().getEntityWorld();
 | 
			
		||||
        BlockPos pos = ((BlockRayTraceResult) event.getTarget()).getPos();
 | 
			
		||||
 | 
			
		||||
        TileEntity tile = world.getTileEntity( pos );
 | 
			
		||||
        if( !(tile instanceof TileMonitor) ) return;
 | 
			
		||||
@@ -53,8 +57,8 @@ public final class MonitorHighlightRenderer
 | 
			
		||||
        event.setCanceled( true );
 | 
			
		||||
 | 
			
		||||
        // Determine which sides are part of the external faces of the monitor, and so which need to be rendered.
 | 
			
		||||
        EnumSet<EnumFacing> faces = EnumSet.allOf( EnumFacing.class );
 | 
			
		||||
        EnumFacing front = monitor.getFront();
 | 
			
		||||
        EnumSet<Direction> faces = EnumSet.allOf( Direction.class );
 | 
			
		||||
        Direction front = monitor.getFront();
 | 
			
		||||
        faces.remove( front );
 | 
			
		||||
        if( monitor.getXIndex() != 0 ) faces.remove( monitor.getRight().getOpposite() );
 | 
			
		||||
        if( monitor.getXIndex() != monitor.getWidth() - 1 ) faces.remove( monitor.getRight() );
 | 
			
		||||
@@ -64,16 +68,12 @@ public final class MonitorHighlightRenderer
 | 
			
		||||
        GlStateManager.enableBlend();
 | 
			
		||||
        GlStateManager.blendFuncSeparate( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO );
 | 
			
		||||
        GlStateManager.lineWidth( Math.max( 2.5F, (float) Minecraft.getInstance().mainWindow.getFramebufferWidth() / 1920.0F * 2.5F ) );
 | 
			
		||||
        GlStateManager.disableTexture2D();
 | 
			
		||||
        GlStateManager.disableTexture();
 | 
			
		||||
        GlStateManager.depthMask( false );
 | 
			
		||||
        GlStateManager.pushMatrix();
 | 
			
		||||
 | 
			
		||||
        EntityPlayer player = event.getPlayer();
 | 
			
		||||
        double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks();
 | 
			
		||||
        double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks();
 | 
			
		||||
        double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks();
 | 
			
		||||
 | 
			
		||||
        GlStateManager.translated( -x + pos.getX(), -y + pos.getY(), -z + pos.getZ() );
 | 
			
		||||
        Vec3d cameraPos = event.getInfo().getProjectedView();
 | 
			
		||||
        GlStateManager.translated( pos.getX() - cameraPos.getX(), pos.getY() - cameraPos.getY(), pos.getZ() - cameraPos.getZ() );
 | 
			
		||||
 | 
			
		||||
        Tessellator tessellator = Tessellator.getInstance();
 | 
			
		||||
        BufferBuilder buffer = tessellator.getBuffer();
 | 
			
		||||
@@ -97,11 +97,11 @@ public final class MonitorHighlightRenderer
 | 
			
		||||
 | 
			
		||||
        GlStateManager.popMatrix();
 | 
			
		||||
        GlStateManager.depthMask( true );
 | 
			
		||||
        GlStateManager.enableTexture2D();
 | 
			
		||||
        GlStateManager.enableTexture();
 | 
			
		||||
        GlStateManager.disableBlend();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void line( BufferBuilder buffer, int x, int y, int z, EnumFacing direction )
 | 
			
		||||
    private static void line( BufferBuilder buffer, int x, int y, int z, Direction direction )
 | 
			
		||||
    {
 | 
			
		||||
        double minX = x == 0 ? -EXPAND : 1 + EXPAND;
 | 
			
		||||
        double minY = y == 0 ? -EXPAND : 1 + EXPAND;
 | 
			
		||||
 
 | 
			
		||||
@@ -6,14 +6,14 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
 | 
			
		||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
 | 
			
		||||
import dan200.computercraft.core.terminal.TextBuffer;
 | 
			
		||||
import dan200.computercraft.shared.util.Palette;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager.DestFactor;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
@@ -28,32 +28,32 @@ public final class PrintoutRenderer
 | 
			
		||||
    private static final double BG_SIZE = 256.0;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Width of a page
 | 
			
		||||
     * Width of a page.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int X_SIZE = 172;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Height of a page
 | 
			
		||||
     * Height of a page.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int Y_SIZE = 209;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Padding between the left and right of a page and the text
 | 
			
		||||
     * Padding between the left and right of a page and the text.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int X_TEXT_MARGIN = 13;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Padding between the top and bottom of a page and the text
 | 
			
		||||
     * Padding between the top and bottom of a page and the text.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int Y_TEXT_MARGIN = 11;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Width of the extra page texture
 | 
			
		||||
     * Width of the extra page texture.
 | 
			
		||||
     */
 | 
			
		||||
    private static final int X_FOLD_SIZE = 12;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Size of the leather cover
 | 
			
		||||
     * Size of the leather cover.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int COVER_SIZE = 12;
 | 
			
		||||
 | 
			
		||||
@@ -76,7 +76,7 @@ public final class PrintoutRenderer
 | 
			
		||||
    {
 | 
			
		||||
        GlStateManager.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
 | 
			
		||||
        GlStateManager.enableBlend();
 | 
			
		||||
        GlStateManager.enableTexture2D();
 | 
			
		||||
        GlStateManager.enableTexture();
 | 
			
		||||
        GlStateManager.blendFuncSeparate( SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO );
 | 
			
		||||
 | 
			
		||||
        FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
 | 
			
		||||
@@ -91,7 +91,7 @@ public final class PrintoutRenderer
 | 
			
		||||
    {
 | 
			
		||||
        GlStateManager.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
 | 
			
		||||
        GlStateManager.enableBlend();
 | 
			
		||||
        GlStateManager.enableTexture2D();
 | 
			
		||||
        GlStateManager.enableTexture();
 | 
			
		||||
        GlStateManager.blendFuncSeparate( SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO );
 | 
			
		||||
 | 
			
		||||
        Minecraft.getInstance().getTextureManager().bindTexture( BG );
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.CableModemVariant;
 | 
			
		||||
@@ -13,10 +14,9 @@ import dan200.computercraft.shared.peripheral.modem.wired.CableShapes;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.TileCable;
 | 
			
		||||
import dan200.computercraft.shared.util.WorldUtil;
 | 
			
		||||
import net.minecraft.block.Block;
 | 
			
		||||
import net.minecraft.block.state.IBlockState;
 | 
			
		||||
import net.minecraft.block.BlockState;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.WorldRenderer;
 | 
			
		||||
import net.minecraft.client.renderer.model.IBakedModel;
 | 
			
		||||
@@ -24,11 +24,12 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
 | 
			
		||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.util.BlockRenderLayer;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.math.BlockRayTraceResult;
 | 
			
		||||
import net.minecraft.util.math.RayTraceResult;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.client.ForgeHooksClient;
 | 
			
		||||
import net.minecraftforge.client.MinecraftForgeClient;
 | 
			
		||||
import net.minecraftforge.client.model.data.EmptyModelData;
 | 
			
		||||
import org.lwjgl.opengl.GL11;
 | 
			
		||||
 | 
			
		||||
@@ -40,8 +41,17 @@ import java.util.Random;
 | 
			
		||||
 */
 | 
			
		||||
public class TileEntityCableRenderer extends TileEntityRenderer<TileCable>
 | 
			
		||||
{
 | 
			
		||||
    private static final ResourceLocation[] DESTROY_STAGES = new ResourceLocation[10];
 | 
			
		||||
    private static final Random random = new Random();
 | 
			
		||||
 | 
			
		||||
    static
 | 
			
		||||
    {
 | 
			
		||||
        for( int i = 0; i < DESTROY_STAGES.length; i++ )
 | 
			
		||||
        {
 | 
			
		||||
            DESTROY_STAGES[i] = new ResourceLocation( "block/destroy_stage_" + i );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void render( @Nonnull TileCable te, double x, double y, double z, float partialTicks, int destroyStage )
 | 
			
		||||
    {
 | 
			
		||||
@@ -52,16 +62,17 @@ public class TileEntityCableRenderer extends TileEntityRenderer<TileCable>
 | 
			
		||||
        Minecraft mc = Minecraft.getInstance();
 | 
			
		||||
 | 
			
		||||
        RayTraceResult hit = mc.objectMouseOver;
 | 
			
		||||
        if( hit == null || !hit.getBlockPos().equals( pos ) ) return;
 | 
			
		||||
 | 
			
		||||
        if( MinecraftForgeClient.getRenderPass() != 0 ) return;
 | 
			
		||||
        if( hit == null || hit.getType() != RayTraceResult.Type.BLOCK || !((BlockRayTraceResult) hit).getPos().equals( pos ) )
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        World world = te.getWorld();
 | 
			
		||||
        IBlockState state = world.getBlockState( pos );
 | 
			
		||||
        BlockState state = world.getBlockState( pos );
 | 
			
		||||
        Block block = state.getBlock();
 | 
			
		||||
        if( block != ComputerCraft.Blocks.cable ) return;
 | 
			
		||||
 | 
			
		||||
        state = WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.hitVec.subtract( pos.getX(), pos.getY(), pos.getZ() ) )
 | 
			
		||||
        state = WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getHitVec().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
 | 
			
		||||
            ? block.getDefaultState().with( BlockCable.MODEM, state.get( BlockCable.MODEM ) )
 | 
			
		||||
            : state.with( BlockCable.MODEM, CableModemVariant.None );
 | 
			
		||||
 | 
			
		||||
@@ -69,18 +80,19 @@ public class TileEntityCableRenderer extends TileEntityRenderer<TileCable>
 | 
			
		||||
 | 
			
		||||
        preRenderDamagedBlocks();
 | 
			
		||||
 | 
			
		||||
        ForgeHooksClient.setRenderLayer( block.getRenderLayer() );
 | 
			
		||||
 | 
			
		||||
        // See BlockRendererDispatcher#renderBlockDamage
 | 
			
		||||
        TextureAtlasSprite breakingTexture = mc.getTextureMap().getSprite( DESTROY_STAGES[destroyStage] );
 | 
			
		||||
 | 
			
		||||
        BufferBuilder buffer = Tessellator.getInstance().getBuffer();
 | 
			
		||||
        buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.BLOCK );
 | 
			
		||||
        buffer.setTranslation( x - pos.getX(), y - pos.getY(), z - pos.getZ() );
 | 
			
		||||
        buffer.noColor();
 | 
			
		||||
 | 
			
		||||
        ForgeHooksClient.setRenderLayer( block.getRenderLayer() );
 | 
			
		||||
 | 
			
		||||
        // See BlockRendererDispatcher#renderBlockDamage
 | 
			
		||||
        TextureAtlasSprite breakingTexture = mc.getTextureMap().getSprite( DESTROY_STAGES[destroyStage] );
 | 
			
		||||
        mc.getBlockRendererDispatcher().getBlockModelRenderer().renderModel(
 | 
			
		||||
            world,
 | 
			
		||||
            ForgeHooksClient.getDamageModel( model, breakingTexture, state, world, pos ),
 | 
			
		||||
            ForgeHooksClient.getDamageModel( model, breakingTexture, state, world, pos, 0 ),
 | 
			
		||||
            state, pos, buffer, true, random, state.getPositionRandom( pos ), EmptyModelData.INSTANCE
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
@@ -93,6 +105,8 @@ public class TileEntityCableRenderer extends TileEntityRenderer<TileCable>
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set up the state for rendering block-breaking progress.
 | 
			
		||||
     *
 | 
			
		||||
     * @see WorldRenderer#preRenderDamagedBlocks()
 | 
			
		||||
     */
 | 
			
		||||
    private void preRenderDamagedBlocks()
 | 
			
		||||
@@ -111,6 +125,8 @@ public class TileEntityCableRenderer extends TileEntityRenderer<TileCable>
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Tear down the state for rendering block-breaking progress.
 | 
			
		||||
     *
 | 
			
		||||
     * @see WorldRenderer#postRenderDamagedBlocks()
 | 
			
		||||
     */
 | 
			
		||||
    private void postRenderDamagedBlocks()
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,8 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GLX;
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.client.FrameInfo;
 | 
			
		||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
 | 
			
		||||
import dan200.computercraft.core.terminal.Terminal;
 | 
			
		||||
@@ -17,12 +19,10 @@ import dan200.computercraft.shared.util.DirectionUtil;
 | 
			
		||||
import dan200.computercraft.shared.util.Palette;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.OpenGlHelper;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import org.lwjgl.opengl.GL11;
 | 
			
		||||
 | 
			
		||||
@@ -64,8 +64,8 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
 | 
			
		||||
        posZ += originPos.getZ() - monitorPos.getZ();
 | 
			
		||||
 | 
			
		||||
        // Determine orientation
 | 
			
		||||
        EnumFacing dir = origin.getDirection();
 | 
			
		||||
        EnumFacing front = origin.getFront();
 | 
			
		||||
        Direction dir = origin.getDirection();
 | 
			
		||||
        Direction front = origin.getFront();
 | 
			
		||||
        float yaw = dir.getHorizontalAngle();
 | 
			
		||||
        float pitch = DirectionUtil.toPitchAngle( front );
 | 
			
		||||
 | 
			
		||||
@@ -94,7 +94,7 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
 | 
			
		||||
 | 
			
		||||
            // Draw the contents
 | 
			
		||||
            GlStateManager.depthMask( false );
 | 
			
		||||
            OpenGlHelper.glMultiTexCoord2f( OpenGlHelper.GL_TEXTURE1, 0xFFFF, 0xFFFF );
 | 
			
		||||
            GLX.glMultiTexCoord2f( GLX.GL_TEXTURE1, 0xFFFF, 0xFFFF );
 | 
			
		||||
            GlStateManager.disableLighting();
 | 
			
		||||
            mc.gameRenderer.disableLightmap();
 | 
			
		||||
            try
 | 
			
		||||
@@ -171,7 +171,7 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        GlStateManager.callList( originTerminal.renderDisplayLists[0] );
 | 
			
		||||
                        GlStateManager.resetColor();
 | 
			
		||||
                        GlStateManager.clearCurrentColor();
 | 
			
		||||
 | 
			
		||||
                        // Draw text
 | 
			
		||||
                        fontRenderer.bindFont();
 | 
			
		||||
@@ -199,7 +199,7 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        GlStateManager.callList( originTerminal.renderDisplayLists[1] );
 | 
			
		||||
                        GlStateManager.resetColor();
 | 
			
		||||
                        GlStateManager.clearCurrentColor();
 | 
			
		||||
 | 
			
		||||
                        // Draw cursor
 | 
			
		||||
                        fontRenderer.bindFont();
 | 
			
		||||
@@ -233,7 +233,7 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
 | 
			
		||||
                        if( FrameInfo.getGlobalCursorBlink() )
 | 
			
		||||
                        {
 | 
			
		||||
                            GlStateManager.callList( originTerminal.renderDisplayLists[2] );
 | 
			
		||||
                            GlStateManager.resetColor();
 | 
			
		||||
                            GlStateManager.clearCurrentColor();
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    finally
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.platform.GlStateManager;
 | 
			
		||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
 | 
			
		||||
import dan200.computercraft.api.turtle.TurtleSide;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
 | 
			
		||||
@@ -13,22 +14,23 @@ import dan200.computercraft.shared.turtle.blocks.TileTurtle;
 | 
			
		||||
import dan200.computercraft.shared.util.DirectionUtil;
 | 
			
		||||
import dan200.computercraft.shared.util.Holiday;
 | 
			
		||||
import dan200.computercraft.shared.util.HolidayUtil;
 | 
			
		||||
import net.minecraft.block.state.IBlockState;
 | 
			
		||||
import net.minecraft.block.BlockState;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.BufferBuilder;
 | 
			
		||||
import net.minecraft.client.renderer.GameRenderer;
 | 
			
		||||
import net.minecraft.client.renderer.GlStateManager;
 | 
			
		||||
import net.minecraft.client.renderer.Tessellator;
 | 
			
		||||
import net.minecraft.client.renderer.model.BakedQuad;
 | 
			
		||||
import net.minecraft.client.renderer.model.IBakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.model.ModelManager;
 | 
			
		||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
 | 
			
		||||
import net.minecraft.client.renderer.texture.TextureMap;
 | 
			
		||||
import net.minecraft.client.renderer.texture.AtlasTexture;
 | 
			
		||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.VertexFormat;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.util.math.BlockRayTraceResult;
 | 
			
		||||
import net.minecraft.util.math.RayTraceResult;
 | 
			
		||||
import net.minecraft.util.math.Vec3d;
 | 
			
		||||
import net.minecraftforge.client.ForgeHooksClient;
 | 
			
		||||
import net.minecraftforge.client.model.data.EmptyModelData;
 | 
			
		||||
@@ -85,13 +87,14 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
 | 
			
		||||
    {
 | 
			
		||||
        // Render the label
 | 
			
		||||
        String label = turtle.createProxy().getLabel();
 | 
			
		||||
        if( label != null && rendererDispatcher.cameraHitResult != null && turtle.getPos().equals( rendererDispatcher.cameraHitResult.getBlockPos() ) )
 | 
			
		||||
        RayTraceResult hit = rendererDispatcher.cameraHitResult;
 | 
			
		||||
        if( label != null && hit.getType() == RayTraceResult.Type.BLOCK && turtle.getPos().equals( ((BlockRayTraceResult) hit).getPos() ) )
 | 
			
		||||
        {
 | 
			
		||||
            setLightmapDisabled( true );
 | 
			
		||||
            GameRenderer.drawNameplate(
 | 
			
		||||
                getFontRenderer(), label,
 | 
			
		||||
                (float) posX + 0.5F, (float) posY + 1.2F, (float) posZ + 0.5F, 0,
 | 
			
		||||
                rendererDispatcher.entityYaw, rendererDispatcher.entityPitch, false, false
 | 
			
		||||
                rendererDispatcher.renderInfo.getYaw(), rendererDispatcher.renderInfo.getPitch(), false
 | 
			
		||||
            );
 | 
			
		||||
            setLightmapDisabled( false );
 | 
			
		||||
        }
 | 
			
		||||
@@ -99,7 +102,7 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
 | 
			
		||||
        GlStateManager.pushMatrix();
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            IBlockState state = turtle.getBlockState();
 | 
			
		||||
            BlockState state = turtle.getBlockState();
 | 
			
		||||
            // Setup the transform
 | 
			
		||||
            Vec3d offset = turtle.getRenderOffset( partialTicks );
 | 
			
		||||
            float yaw = turtle.getRenderYaw( partialTicks );
 | 
			
		||||
@@ -153,7 +156,7 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void renderUpgrade( IBlockState state, TileTurtle turtle, TurtleSide side, float f )
 | 
			
		||||
    private void renderUpgrade( BlockState state, TileTurtle turtle, TurtleSide side, float f )
 | 
			
		||||
    {
 | 
			
		||||
        ITurtleUpgrade upgrade = turtle.getUpgrade( side );
 | 
			
		||||
        if( upgrade != null )
 | 
			
		||||
@@ -186,20 +189,20 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void renderModel( IBlockState state, ModelResourceLocation modelLocation, int[] tints )
 | 
			
		||||
    private void renderModel( BlockState state, ModelResourceLocation modelLocation, int[] tints )
 | 
			
		||||
    {
 | 
			
		||||
        Minecraft mc = Minecraft.getInstance();
 | 
			
		||||
        ModelManager modelManager = mc.getItemRenderer().getItemModelMesher().getModelManager();
 | 
			
		||||
        renderModel( state, modelManager.getModel( modelLocation ), tints );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void renderModel( IBlockState state, IBakedModel model, int[] tints )
 | 
			
		||||
    private void renderModel( BlockState state, IBakedModel model, int[] tints )
 | 
			
		||||
    {
 | 
			
		||||
        Random random = new Random( 0 );
 | 
			
		||||
        Tessellator tessellator = Tessellator.getInstance();
 | 
			
		||||
        rendererDispatcher.textureManager.bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
 | 
			
		||||
        rendererDispatcher.textureManager.bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE );
 | 
			
		||||
        renderQuads( tessellator, model.getQuads( state, null, random, EmptyModelData.INSTANCE ), tints );
 | 
			
		||||
        for( EnumFacing facing : DirectionUtil.FACINGS )
 | 
			
		||||
        for( Direction facing : DirectionUtil.FACINGS )
 | 
			
		||||
        {
 | 
			
		||||
            renderQuads( tessellator, model.getQuads( state, facing, random, EmptyModelData.INSTANCE ), tints );
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -9,15 +9,15 @@ package dan200.computercraft.client.render;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import net.minecraft.client.renderer.model.IBakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.model.IUnbakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.model.ModelBakery;
 | 
			
		||||
import net.minecraft.client.renderer.texture.ISprite;
 | 
			
		||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
 | 
			
		||||
import net.minecraft.client.renderer.vertex.VertexFormat;
 | 
			
		||||
import net.minecraft.resources.IResourceManager;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraftforge.client.model.ICustomModelLoader;
 | 
			
		||||
import net.minecraftforge.common.model.IModelState;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
@@ -91,13 +91,13 @@ public final class TurtleModelLoader implements ICustomModelLoader
 | 
			
		||||
                .collect( Collectors.toSet() );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Nullable
 | 
			
		||||
        @Nonnull
 | 
			
		||||
        @Override
 | 
			
		||||
        public IBakedModel bake( @Nonnull Function<ResourceLocation, IUnbakedModel> modelGetter, @Nonnull Function<ResourceLocation, TextureAtlasSprite> spriteGetter, @Nonnull IModelState state, boolean uvlock, @Nonnull VertexFormat format )
 | 
			
		||||
        public IBakedModel bake( @Nonnull ModelBakery bakery, @Nonnull Function<ResourceLocation, TextureAtlasSprite> spriteGetter, @Nonnull ISprite sprite, @Nonnull VertexFormat format )
 | 
			
		||||
        {
 | 
			
		||||
            return new TurtleSmartItemModel(
 | 
			
		||||
                modelGetter.apply( family ).bake( modelGetter, spriteGetter, state, uvlock, format ),
 | 
			
		||||
                modelGetter.apply( COLOUR_TURTLE_MODEL ).bake( modelGetter, spriteGetter, state, uvlock, format )
 | 
			
		||||
                bakery.getBakedModel( family, sprite, spriteGetter, format ),
 | 
			
		||||
                bakery.getBakedModel( COLOUR_TURTLE_MODEL, sprite, spriteGetter, format )
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,12 +6,12 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.client.render;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.block.state.IBlockState;
 | 
			
		||||
import net.minecraft.block.BlockState;
 | 
			
		||||
import net.minecraft.client.renderer.model.BakedQuad;
 | 
			
		||||
import net.minecraft.client.renderer.model.IBakedModel;
 | 
			
		||||
import net.minecraft.client.renderer.model.ItemOverrideList;
 | 
			
		||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraftforge.client.model.data.EmptyModelData;
 | 
			
		||||
import net.minecraftforge.client.model.data.IModelData;
 | 
			
		||||
 | 
			
		||||
@@ -29,7 +29,7 @@ public class TurtleMultiModel implements IBakedModel
 | 
			
		||||
    private final IBakedModel m_rightUpgradeModel;
 | 
			
		||||
    private final Matrix4f m_rightUpgradeTransform;
 | 
			
		||||
    private List<BakedQuad> m_generalQuads = null;
 | 
			
		||||
    private Map<EnumFacing, List<BakedQuad>> m_faceQuads = new EnumMap<>( EnumFacing.class );
 | 
			
		||||
    private Map<Direction, List<BakedQuad>> m_faceQuads = new EnumMap<>( Direction.class );
 | 
			
		||||
 | 
			
		||||
    public TurtleMultiModel( IBakedModel baseModel, IBakedModel overlayModel, Matrix4f generalTransform, IBakedModel leftUpgradeModel, Matrix4f leftUpgradeTransform, IBakedModel rightUpgradeModel, Matrix4f rightUpgradeTransform )
 | 
			
		||||
    {
 | 
			
		||||
@@ -46,14 +46,14 @@ public class TurtleMultiModel implements IBakedModel
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, @Nonnull Random rand )
 | 
			
		||||
    public List<BakedQuad> getQuads( BlockState state, Direction side, @Nonnull Random rand )
 | 
			
		||||
    {
 | 
			
		||||
        return getQuads( state, side, rand, EmptyModelData.INSTANCE );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, @Nonnull Random rand, @Nonnull IModelData data )
 | 
			
		||||
    public List<BakedQuad> getQuads( BlockState state, Direction side, @Nonnull Random rand, @Nonnull IModelData data )
 | 
			
		||||
    {
 | 
			
		||||
        if( side != null )
 | 
			
		||||
        {
 | 
			
		||||
@@ -67,7 +67,7 @@ public class TurtleMultiModel implements IBakedModel
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private List<BakedQuad> buildQuads( IBlockState state, EnumFacing side, Random rand )
 | 
			
		||||
    private List<BakedQuad> buildQuads( BlockState state, Direction side, Random rand )
 | 
			
		||||
    {
 | 
			
		||||
        ArrayList<BakedQuad> quads = new ArrayList<>();
 | 
			
		||||
        ModelTransformer.transformQuadsTo( quads, m_baseModel.getQuads( state, side, rand, EmptyModelData.INSTANCE ), m_generalTransform );
 | 
			
		||||
@@ -119,6 +119,7 @@ public class TurtleMultiModel implements IBakedModel
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public TextureAtlasSprite getParticleTexture()
 | 
			
		||||
    {
 | 
			
		||||
        return m_baseModel.getParticleTexture();
 | 
			
		||||
 
 | 
			
		||||
@@ -12,13 +12,13 @@ import dan200.computercraft.api.turtle.TurtleSide;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtle;
 | 
			
		||||
import dan200.computercraft.shared.util.Holiday;
 | 
			
		||||
import dan200.computercraft.shared.util.HolidayUtil;
 | 
			
		||||
import net.minecraft.block.state.IBlockState;
 | 
			
		||||
import net.minecraft.block.BlockState;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.client.renderer.model.*;
 | 
			
		||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
 | 
			
		||||
import net.minecraft.entity.EntityLivingBase;
 | 
			
		||||
import net.minecraft.entity.LivingEntity;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraftforge.client.model.data.IModelData;
 | 
			
		||||
@@ -111,7 +111,7 @@ public class TurtleSmartItemModel implements IBakedModel
 | 
			
		||||
        {
 | 
			
		||||
            @Nonnull
 | 
			
		||||
            @Override
 | 
			
		||||
            public IBakedModel getModelWithOverrides( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity )
 | 
			
		||||
            public IBakedModel getModelWithOverrides( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable LivingEntity entity )
 | 
			
		||||
            {
 | 
			
		||||
                ItemTurtle turtle = (ItemTurtle) stack.getItem();
 | 
			
		||||
                int colour = turtle.getColour( stack );
 | 
			
		||||
@@ -169,7 +169,7 @@ public class TurtleSmartItemModel implements IBakedModel
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public List<BakedQuad> getQuads( IBlockState state, EnumFacing facing, @Nonnull Random rand )
 | 
			
		||||
    public List<BakedQuad> getQuads( BlockState state, Direction facing, @Nonnull Random rand )
 | 
			
		||||
    {
 | 
			
		||||
        return familyModel.getQuads( state, facing, rand );
 | 
			
		||||
    }
 | 
			
		||||
@@ -177,7 +177,7 @@ public class TurtleSmartItemModel implements IBakedModel
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public List<BakedQuad> getQuads( IBlockState state, EnumFacing facing, @Nonnull Random rand, @Nonnull IModelData data )
 | 
			
		||||
    public List<BakedQuad> getQuads( BlockState state, Direction facing, @Nonnull Random rand, @Nonnull IModelData data )
 | 
			
		||||
    {
 | 
			
		||||
        return familyModel.getQuads( state, facing, rand, data );
 | 
			
		||||
    }
 | 
			
		||||
@@ -202,6 +202,7 @@ public class TurtleSmartItemModel implements IBakedModel
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @Override
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public TextureAtlasSprite getParticleTexture()
 | 
			
		||||
    {
 | 
			
		||||
        return familyModel.getParticleTexture();
 | 
			
		||||
 
 | 
			
		||||
@@ -160,7 +160,7 @@ public class AddressPredicate
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine whether the given address matches a series of patterns
 | 
			
		||||
     * Determine whether the given address matches a series of patterns.
 | 
			
		||||
     *
 | 
			
		||||
     * @param address The address to check.
 | 
			
		||||
     * @return Whether it matches any of these patterns.
 | 
			
		||||
 
 | 
			
		||||
@@ -13,256 +13,106 @@ import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Various helpers for arguments
 | 
			
		||||
 * A stub for any mods which depended on this version of the argument helper.
 | 
			
		||||
 *
 | 
			
		||||
 * @deprecated Use {@link dan200.computercraft.api.lua.ArgumentHelper}.
 | 
			
		||||
 */
 | 
			
		||||
@Deprecated
 | 
			
		||||
public final class ArgumentHelper
 | 
			
		||||
{
 | 
			
		||||
    private ArgumentHelper()
 | 
			
		||||
    {
 | 
			
		||||
        throw new IllegalStateException( "Cannot instantiate singleton " + getClass().getName() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static String getType( @Nullable Object type )
 | 
			
		||||
    {
 | 
			
		||||
        if( type == null ) return "nil";
 | 
			
		||||
        if( type instanceof String ) return "string";
 | 
			
		||||
        if( type instanceof Boolean ) return "boolean";
 | 
			
		||||
        if( type instanceof Number ) return "number";
 | 
			
		||||
        if( type instanceof Map ) return "table";
 | 
			
		||||
 | 
			
		||||
        Class<?> klass = type.getClass();
 | 
			
		||||
        if( klass.isArray() )
 | 
			
		||||
        {
 | 
			
		||||
            StringBuilder name = new StringBuilder();
 | 
			
		||||
            while( klass.isArray() )
 | 
			
		||||
            {
 | 
			
		||||
                name.append( "[]" );
 | 
			
		||||
                klass = klass.getComponentType();
 | 
			
		||||
            }
 | 
			
		||||
            name.insert( 0, klass.getName() );
 | 
			
		||||
            return name.toString();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            return klass.getName();
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.getType( type );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static LuaException badArgument( int index, @Nonnull String expected, @Nullable Object actual )
 | 
			
		||||
    {
 | 
			
		||||
        return badArgument( index, expected, getType( actual ) );
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.badArgumentOf( index, expected, actual );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public static LuaException badArgument( int index, @Nonnull String expected, @Nonnull String actual )
 | 
			
		||||
    {
 | 
			
		||||
        return new LuaException( "bad argument #" + (index + 1) + " (" + expected + " expected, got " + actual + ")" );
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.badArgument( index, expected, actual );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static double getNumber( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( index >= args.length ) throw badArgument( index, "number", "nil" );
 | 
			
		||||
        Object value = args[index];
 | 
			
		||||
        if( value instanceof Number )
 | 
			
		||||
        {
 | 
			
		||||
            return ((Number) value).doubleValue();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "number", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.getDouble( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getInt( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return (int) getLong( args, index );
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.getInt( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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 )
 | 
			
		||||
        {
 | 
			
		||||
            return checkReal( index, (Number) value ).longValue();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "number", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.getLong( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static double getReal( @Nonnull Object[] args, int index ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return checkReal( index, getNumber( args, index ) );
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.getFiniteDouble( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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 )
 | 
			
		||||
        {
 | 
			
		||||
            return (Boolean) value;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "boolean", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.getBoolean( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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 )
 | 
			
		||||
        {
 | 
			
		||||
            return (String) value;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "string", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.getString( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings( "unchecked" )
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    @SuppressWarnings( "unchecked" )
 | 
			
		||||
    public static Map<Object, Object> 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 )
 | 
			
		||||
        {
 | 
			
		||||
            return (Map<Object, Object>) value;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "table", value );
 | 
			
		||||
        }
 | 
			
		||||
        return (Map<Object, Object>) dan200.computercraft.api.lua.ArgumentHelper.getTable( args, index );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static double optNumber( @Nonnull Object[] args, int index, double def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        Object value = index < args.length ? args[index] : null;
 | 
			
		||||
        if( value == null )
 | 
			
		||||
        {
 | 
			
		||||
            return def;
 | 
			
		||||
        }
 | 
			
		||||
        else if( value instanceof Number )
 | 
			
		||||
        {
 | 
			
		||||
            return ((Number) value).doubleValue();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "number", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.optDouble( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int optInt( @Nonnull Object[] args, int index, int def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return (int) optLong( args, index, def );
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.optInt( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
        }
 | 
			
		||||
        else if( value instanceof Number )
 | 
			
		||||
        {
 | 
			
		||||
            return checkReal( index, (Number) value ).longValue();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "number", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.optLong( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static double optReal( @Nonnull Object[] args, int index, double def ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        return checkReal( index, optNumber( args, index, def ) );
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.optFiniteDouble( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
        }
 | 
			
		||||
        else if( value instanceof Boolean )
 | 
			
		||||
        {
 | 
			
		||||
            return (Boolean) value;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "boolean", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.optBoolean( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
        }
 | 
			
		||||
        else if( value instanceof String )
 | 
			
		||||
        {
 | 
			
		||||
            return (String) value;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "string", value );
 | 
			
		||||
        }
 | 
			
		||||
        return dan200.computercraft.api.lua.ArgumentHelper.optString( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings( "unchecked" )
 | 
			
		||||
    public static Map<Object, Object> 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;
 | 
			
		||||
        }
 | 
			
		||||
        else if( value instanceof Map )
 | 
			
		||||
        {
 | 
			
		||||
            return (Map<Object, Object>) value;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "table", value );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static Number checkReal( int index, Number value ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        checkReal( index, value.doubleValue() );
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static double checkReal( int index, double value ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( Double.isNaN( value ) )
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "number", "nan" );
 | 
			
		||||
        }
 | 
			
		||||
        else if( value == Double.POSITIVE_INFINITY )
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "number", "inf" );
 | 
			
		||||
        }
 | 
			
		||||
        else if( value == Double.NEGATIVE_INFINITY )
 | 
			
		||||
        {
 | 
			
		||||
            throw badArgument( index, "number", "-inf" );
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            return value;
 | 
			
		||||
        }
 | 
			
		||||
        return (Map<Object, Object>) dan200.computercraft.api.lua.ArgumentHelper.optTable( args, index, def );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.function.Function;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.getString;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.getString;
 | 
			
		||||
 | 
			
		||||
public class FSAPI implements ILuaAPI
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ import java.util.Collections;
 | 
			
		||||
import java.util.Locale;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.*;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.*;
 | 
			
		||||
import static dan200.computercraft.core.apis.TableHelper.*;
 | 
			
		||||
 | 
			
		||||
public class HTTPAPI implements ILuaAPI
 | 
			
		||||
@@ -89,7 +89,7 @@ public class HTTPAPI implements ILuaAPI
 | 
			
		||||
            case 0: // request
 | 
			
		||||
            {
 | 
			
		||||
                String address, postString, requestMethod;
 | 
			
		||||
                Map<Object, Object> headerTable;
 | 
			
		||||
                Map<?, ?> headerTable;
 | 
			
		||||
                boolean binary, redirect;
 | 
			
		||||
 | 
			
		||||
                if( args.length >= 1 && args[0] instanceof Map )
 | 
			
		||||
@@ -172,7 +172,7 @@ public class HTTPAPI implements ILuaAPI
 | 
			
		||||
            case 2: // websocket
 | 
			
		||||
            {
 | 
			
		||||
                String address = getString( args, 0 );
 | 
			
		||||
                Map<Object, Object> headerTbl = optTable( args, 1, Collections.emptyMap() );
 | 
			
		||||
                Map<?, ?> headerTbl = optTable( args, 1, Collections.emptyMap() );
 | 
			
		||||
 | 
			
		||||
                if( !ComputerCraft.http_websocket_enable )
 | 
			
		||||
                {
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ import java.time.ZonedDateTime;
 | 
			
		||||
import java.time.format.DateTimeFormatterBuilder;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.*;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.*;
 | 
			
		||||
 | 
			
		||||
public class OSAPI implements ILuaAPI
 | 
			
		||||
{
 | 
			
		||||
@@ -229,7 +229,7 @@ public class OSAPI implements ILuaAPI
 | 
			
		||||
            case 1:
 | 
			
		||||
            {
 | 
			
		||||
                // startTimer
 | 
			
		||||
                double timer = getReal( args, 0 );
 | 
			
		||||
                double timer = getFiniteDouble( args, 0 );
 | 
			
		||||
                synchronized( m_timers )
 | 
			
		||||
                {
 | 
			
		||||
                    m_timers.put( m_nextTimerToken, new Timer( (int) Math.round( timer / 0.05 ) ) );
 | 
			
		||||
@@ -239,7 +239,7 @@ public class OSAPI implements ILuaAPI
 | 
			
		||||
            case 2:
 | 
			
		||||
            {
 | 
			
		||||
                // setAlarm
 | 
			
		||||
                double time = getReal( args, 0 );
 | 
			
		||||
                double time = getFiniteDouble( args, 0 );
 | 
			
		||||
                if( time < 0.0 || time >= 24.0 )
 | 
			
		||||
                {
 | 
			
		||||
                    throw new LuaException( "Number out of range" );
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ import java.util.Collections;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.getString;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.getString;
 | 
			
		||||
 | 
			
		||||
public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChangeListener
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.*;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.*;
 | 
			
		||||
 | 
			
		||||
public class RedstoneAPI implements ILuaAPI
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -6,14 +6,17 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.core.apis;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.api.lua.ArgumentHelper;
 | 
			
		||||
import dan200.computercraft.api.lua.LuaException;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.getNumericType;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Various helpers for tables
 | 
			
		||||
 * Various helpers for tables.
 | 
			
		||||
 */
 | 
			
		||||
public final class TableHelper
 | 
			
		||||
{
 | 
			
		||||
@@ -200,21 +203,7 @@ public final class TableHelper
 | 
			
		||||
 | 
			
		||||
    private static double checkReal( @Nonnull String key, double value ) throws LuaException
 | 
			
		||||
    {
 | 
			
		||||
        if( Double.isNaN( value ) )
 | 
			
		||||
        {
 | 
			
		||||
            throw badKey( key, "number", "nan" );
 | 
			
		||||
        }
 | 
			
		||||
        else if( value == Double.POSITIVE_INFINITY )
 | 
			
		||||
        {
 | 
			
		||||
            throw badKey( key, "number", "inf" );
 | 
			
		||||
        }
 | 
			
		||||
        else if( value == Double.NEGATIVE_INFINITY )
 | 
			
		||||
        {
 | 
			
		||||
            throw badKey( key, "number", "-inf" );
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            return value;
 | 
			
		||||
        }
 | 
			
		||||
        if( !Double.isFinite( value ) ) throw badKey( key, "number", getNumericType( value ) );
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ import org.apache.commons.lang3.ArrayUtils;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.*;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.*;
 | 
			
		||||
 | 
			
		||||
public class TermAPI implements ILuaAPI
 | 
			
		||||
{
 | 
			
		||||
@@ -242,9 +242,9 @@ public class TermAPI implements ILuaAPI
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    double r = getReal( args, 1 );
 | 
			
		||||
                    double g = getReal( args, 2 );
 | 
			
		||||
                    double b = getReal( args, 3 );
 | 
			
		||||
                    double r = getFiniteDouble( args, 1 );
 | 
			
		||||
                    double g = getFiniteDouble( args, 2 );
 | 
			
		||||
                    double b = getFiniteDouble( args, 3 );
 | 
			
		||||
                    setColour( m_terminal, colour, r, g, b );
 | 
			
		||||
                }
 | 
			
		||||
                return null;
 | 
			
		||||
 
 | 
			
		||||
@@ -21,8 +21,8 @@ import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.getInt;
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.optBoolean;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.getInt;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.optBoolean;
 | 
			
		||||
 | 
			
		||||
public class BinaryReadableHandle extends HandleGeneric
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -7,9 +7,9 @@
 | 
			
		||||
package dan200.computercraft.core.apis.handles;
 | 
			
		||||
 | 
			
		||||
import com.google.common.collect.ObjectArrays;
 | 
			
		||||
import dan200.computercraft.api.lua.ArgumentHelper;
 | 
			
		||||
import dan200.computercraft.api.lua.ILuaContext;
 | 
			
		||||
import dan200.computercraft.api.lua.LuaException;
 | 
			
		||||
import dan200.computercraft.core.apis.ArgumentHelper;
 | 
			
		||||
import dan200.computercraft.shared.util.StringUtil;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -73,7 +73,7 @@ public class BinaryWritableHandle extends HandleGeneric
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        throw ArgumentHelper.badArgument( 0, "string or number", args.length > 0 ? args[0] : null );
 | 
			
		||||
                        throw ArgumentHelper.badArgumentOf( 0, "string or number", args.length > 0 ? args[0] : null );
 | 
			
		||||
                    }
 | 
			
		||||
                    return null;
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,8 +20,8 @@ import java.nio.charset.CharsetDecoder;
 | 
			
		||||
import java.nio.charset.CodingErrorAction;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.optBoolean;
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.optInt;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.optBoolean;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.optInt;
 | 
			
		||||
 | 
			
		||||
public class EncodedReadableHandle extends HandleGeneric
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,8 @@ import java.io.IOException;
 | 
			
		||||
import java.nio.channels.Channel;
 | 
			
		||||
import java.nio.channels.SeekableByteChannel;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.optLong;
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.optString;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.optLong;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.optString;
 | 
			
		||||
 | 
			
		||||
public abstract class HandleGeneric implements ILuaObject
 | 
			
		||||
{
 | 
			
		||||
@@ -47,7 +47,7 @@ public abstract class HandleGeneric implements ILuaObject
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Shared implementation for various file handle types
 | 
			
		||||
     * Shared implementation for various file handle types.
 | 
			
		||||
     *
 | 
			
		||||
     * @param channel The channel to seek in
 | 
			
		||||
     * @param args    The Lua arguments to process, like Lua's {@code file:seek}.
 | 
			
		||||
 
 | 
			
		||||
@@ -99,7 +99,7 @@ public final class NetworkUtils
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks a host is allowed
 | 
			
		||||
     * Checks a host is allowed.
 | 
			
		||||
     *
 | 
			
		||||
     * @param host The domain to check against
 | 
			
		||||
     * @throws HTTPRequestException If the host is not permitted.
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,8 @@ import java.util.function.Consumer;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A holder for one or more resources, with a lifetime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param <T> The type of this resource. Should be the class extending from {@link Resource}.
 | 
			
		||||
 */
 | 
			
		||||
public abstract class Resource<T extends Resource<T>> implements Closeable
 | 
			
		||||
{
 | 
			
		||||
@@ -42,8 +44,9 @@ public abstract class Resource<T extends Resource<T>> implements Closeable
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks if this has been cancelled. If so, it'll clean up any
 | 
			
		||||
     * existing resources and cancel any pending futures.
 | 
			
		||||
     * Checks if this has been cancelled. If so, it'll clean up any existing resources and cancel any pending futures.
 | 
			
		||||
     *
 | 
			
		||||
     * @return Whether this resource has been closed.
 | 
			
		||||
     */
 | 
			
		||||
    public final boolean checkClosed()
 | 
			
		||||
    {
 | 
			
		||||
@@ -80,6 +83,7 @@ public abstract class Resource<T extends Resource<T>> implements Closeable
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a {@link WeakReference} which will close {@code this} when collected.
 | 
			
		||||
     *
 | 
			
		||||
     * @param <R>    The object we are wrapping in a reference.
 | 
			
		||||
     * @param object The object to reference to
 | 
			
		||||
     * @return The weak reference.
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,8 @@ import java.util.function.Supplier;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A collection of {@link Resource}s, with an upper bound on capacity.
 | 
			
		||||
 *
 | 
			
		||||
 * @param <T> The type of the resource this group manages.
 | 
			
		||||
 */
 | 
			
		||||
public class ResourceGroup<T extends Resource<T>>
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,8 @@ import java.util.function.Supplier;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A {@link ResourceGroup} which will queue items when the group at capacity.
 | 
			
		||||
 *
 | 
			
		||||
 * @param <T> The type of the resource this queue manages.
 | 
			
		||||
 */
 | 
			
		||||
public class ResourceQueue<T extends Resource<T>> extends ResourceGroup<T>
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Represents one or more
 | 
			
		||||
 * Represents an in-progress HTTP request.
 | 
			
		||||
 */
 | 
			
		||||
public class HttpRequest extends Resource<HttpRequest>
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -226,7 +226,11 @@ public final class HttpRequestHandler extends SimpleChannelInboundHandler<HttpOb
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine the redirect from this response
 | 
			
		||||
     * Determine the redirect from this response.
 | 
			
		||||
     *
 | 
			
		||||
     * @param status  The status of the HTTP response.
 | 
			
		||||
     * @param headers The headers of the HTTP response.
 | 
			
		||||
     * @return The URI to redirect to, or {@code null} if no redirect should occur.
 | 
			
		||||
     */
 | 
			
		||||
    private URI getRedirect( HttpResponseStatus status, HttpHeaders headers )
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
import java.io.Closeable;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
 | 
			
		||||
import static dan200.computercraft.core.apis.ArgumentHelper.optBoolean;
 | 
			
		||||
import static dan200.computercraft.api.lua.ArgumentHelper.optBoolean;
 | 
			
		||||
import static dan200.computercraft.core.apis.http.websocket.Websocket.CLOSE_EVENT;
 | 
			
		||||
import static dan200.computercraft.core.apis.http.websocket.Websocket.MESSAGE_EVENT;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -268,7 +268,7 @@ final class ComputerExecutor
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Queue an event if the computer is on
 | 
			
		||||
     * Queue an event if the computer is on.
 | 
			
		||||
     *
 | 
			
		||||
     * @param event The event's name
 | 
			
		||||
     * @param args  The event's arguments
 | 
			
		||||
 
 | 
			
		||||
@@ -6,11 +6,13 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.core.computer;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A side on a computer. Unlike {@link net.minecraft.util.EnumFacing}, this is relative to the direction the computer is
 | 
			
		||||
 * A side on a computer. Unlike {@link Direction}, this is relative to the direction the computer is
 | 
			
		||||
 * facing..
 | 
			
		||||
 */
 | 
			
		||||
public enum ComputerSide
 | 
			
		||||
 
 | 
			
		||||
@@ -50,7 +50,7 @@ import static dan200.computercraft.core.computer.TimeoutState.TIMEOUT;
 | 
			
		||||
public final class ComputerThread
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * How often the computer thread monitor should run, in milliseconds
 | 
			
		||||
     * How often the computer thread monitor should run, in milliseconds.
 | 
			
		||||
     *
 | 
			
		||||
     * @see Monitor
 | 
			
		||||
     */
 | 
			
		||||
@@ -83,7 +83,7 @@ public final class ComputerThread
 | 
			
		||||
    private static final Object threadLock = new Object();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Whether the computer thread system is currently running
 | 
			
		||||
     * Whether the computer thread system is currently running.
 | 
			
		||||
     */
 | 
			
		||||
    private static volatile boolean running = false;
 | 
			
		||||
 | 
			
		||||
@@ -105,7 +105,7 @@ public final class ComputerThread
 | 
			
		||||
    private static final Condition hasWork = computerLock.newCondition();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Active queues to execute
 | 
			
		||||
     * Active queues to execute.
 | 
			
		||||
     */
 | 
			
		||||
    private static final TreeSet<ComputerExecutor> computerQueue = new TreeSet<>( ( a, b ) -> {
 | 
			
		||||
        if( a == b ) return 0; // Should never happen, but let's be consistent here
 | 
			
		||||
@@ -126,7 +126,7 @@ public final class ComputerThread
 | 
			
		||||
    private ComputerThread() {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Start the computer thread
 | 
			
		||||
     * Start the computer thread.
 | 
			
		||||
     */
 | 
			
		||||
    static void start()
 | 
			
		||||
    {
 | 
			
		||||
@@ -194,7 +194,7 @@ public final class ComputerThread
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Mark a computer as having work, enqueuing it on the thread
 | 
			
		||||
     * Mark a computer as having work, enqueuing it on the thread.
 | 
			
		||||
     *
 | 
			
		||||
     * You must be holding {@link ComputerExecutor}'s {@code queueLock} when calling this method - it should only
 | 
			
		||||
     * be called from {@code enqueue}.
 | 
			
		||||
@@ -244,6 +244,8 @@ public final class ComputerThread
 | 
			
		||||
     * {@link #minimumVirtualRuntime} based on the current tasks.
 | 
			
		||||
     *
 | 
			
		||||
     * This is called before queueing tasks, to ensure that {@link #minimumVirtualRuntime} is up-to-date.
 | 
			
		||||
     *
 | 
			
		||||
     * @param current The machine which we updating runtimes from.
 | 
			
		||||
     */
 | 
			
		||||
    private static void updateRuntimes( @Nullable ComputerExecutor current )
 | 
			
		||||
    {
 | 
			
		||||
@@ -321,7 +323,7 @@ public final class ComputerThread
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The scaled period for a single task
 | 
			
		||||
     * The scaled period for a single task.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The scaled period for the task
 | 
			
		||||
     * @see #DEFAULT_LATENCY
 | 
			
		||||
@@ -336,7 +338,7 @@ public final class ComputerThread
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine if the thread has computers queued up
 | 
			
		||||
     * Determine if the thread has computers queued up.
 | 
			
		||||
     *
 | 
			
		||||
     * @return If we have work queued up.
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -36,12 +36,12 @@ import java.util.concurrent.TimeUnit;
 | 
			
		||||
public final class TimeoutState
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * The total time a task is allowed to run before aborting in nanoseconds
 | 
			
		||||
     * The total time a task is allowed to run before aborting in nanoseconds.
 | 
			
		||||
     */
 | 
			
		||||
    static final long TIMEOUT = TimeUnit.MILLISECONDS.toNanos( 7000 );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The time the task is allowed to run after each abort in nanoseconds
 | 
			
		||||
     * The time the task is allowed to run after each abort in nanoseconds.
 | 
			
		||||
     */
 | 
			
		||||
    static final long ABORT_TIMEOUT = TimeUnit.MILLISECONDS.toNanos( 1500 );
 | 
			
		||||
 | 
			
		||||
@@ -111,6 +111,8 @@ public final class TimeoutState
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If the machine should be passively aborted.
 | 
			
		||||
     *
 | 
			
		||||
     * @return {@code true} if we should throw a timeout error.
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isSoftAborted()
 | 
			
		||||
    {
 | 
			
		||||
@@ -118,7 +120,9 @@ public final class TimeoutState
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If the machine should be forcibly aborted.
 | 
			
		||||
     * Determine if the machine should be forcibly aborted.
 | 
			
		||||
     *
 | 
			
		||||
     * @return {@code true} if the machine should be forcibly shut down.
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isHardAborted()
 | 
			
		||||
    {
 | 
			
		||||
@@ -146,7 +150,7 @@ public final class TimeoutState
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Pauses the cumulative time, to be resumed by {@link #startTimer()}
 | 
			
		||||
     * Pauses the cumulative time, to be resumed by {@link #startTimer()}.
 | 
			
		||||
     *
 | 
			
		||||
     * @see #nanoCumulative()
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -170,7 +170,7 @@ public class ResourceMount implements IMount
 | 
			
		||||
                {
 | 
			
		||||
                    total += read;
 | 
			
		||||
                    read = s.read( TEMP_BUFFER );
 | 
			
		||||
                } while ( read > 0 );
 | 
			
		||||
                } while( read > 0 );
 | 
			
		||||
 | 
			
		||||
                return file.size = total;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ public final class MachineResult
 | 
			
		||||
    public static final MachineResult TIMEOUT = new MachineResult( true, false, TimeoutState.ABORT_MESSAGE );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * An error with no user-friendly error message
 | 
			
		||||
     * An error with no user-friendly error message.
 | 
			
		||||
     */
 | 
			
		||||
    public static final MachineResult GENERIC_ERROR = new MachineResult( true, false, null );
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@
 | 
			
		||||
package dan200.computercraft.core.terminal;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.shared.util.Palette;
 | 
			
		||||
import net.minecraft.nbt.NBTTagCompound;
 | 
			
		||||
import net.minecraft.nbt.CompoundNBT;
 | 
			
		||||
 | 
			
		||||
public class Terminal
 | 
			
		||||
{
 | 
			
		||||
@@ -314,6 +314,9 @@ public class Terminal
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine whether this terminal has changed.
 | 
			
		||||
     *
 | 
			
		||||
     * @return If this terminal is dirty.
 | 
			
		||||
     * @deprecated All {@code *Changed()} methods are deprecated: one should pass in a callback
 | 
			
		||||
     * instead.
 | 
			
		||||
     */
 | 
			
		||||
@@ -334,7 +337,7 @@ public class Terminal
 | 
			
		||||
        m_changed = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public synchronized NBTTagCompound writeToNBT( NBTTagCompound nbt )
 | 
			
		||||
    public synchronized CompoundNBT writeToNBT( CompoundNBT nbt )
 | 
			
		||||
    {
 | 
			
		||||
        nbt.putInt( "term_cursorX", m_cursorX );
 | 
			
		||||
        nbt.putInt( "term_cursorY", m_cursorY );
 | 
			
		||||
@@ -354,7 +357,7 @@ public class Terminal
 | 
			
		||||
        return nbt;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public synchronized void readFromNBT( NBTTagCompound nbt )
 | 
			
		||||
    public synchronized void readFromNBT( CompoundNBT nbt )
 | 
			
		||||
    {
 | 
			
		||||
        m_cursorX = nbt.getInt( "term_cursorX" );
 | 
			
		||||
        m_cursorY = nbt.getInt( "term_cursorY" );
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ package dan200.computercraft.shared;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
 | 
			
		||||
import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
@@ -30,12 +30,12 @@ public final class BundledRedstone
 | 
			
		||||
        providers.add( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getDefaultOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
 | 
			
		||||
    public static int getDefaultOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        return World.isValid( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static int getUnmaskedOutput( World world, BlockPos pos, EnumFacing side )
 | 
			
		||||
    private static int getUnmaskedOutput( World world, BlockPos pos, Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        if( !World.isValid( pos ) ) return -1;
 | 
			
		||||
 | 
			
		||||
@@ -60,7 +60,7 @@ public final class BundledRedstone
 | 
			
		||||
        return combinedSignal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getOutput( World world, BlockPos pos, EnumFacing side )
 | 
			
		||||
    public static int getOutput( World world, BlockPos pos, Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        int signal = getUnmaskedOutput( world, pos, side );
 | 
			
		||||
        return signal >= 0 ? signal : 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,8 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.shared;
 | 
			
		||||
 | 
			
		||||
import com.electronwill.nightconfig.core.CommentedConfig;
 | 
			
		||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
 | 
			
		||||
import com.google.common.base.CaseFormat;
 | 
			
		||||
import com.google.common.base.Converter;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
@@ -325,6 +327,10 @@ public final class Config
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public static void sync( ModConfig.ConfigReloading event )
 | 
			
		||||
    {
 | 
			
		||||
        // Ensure file configs are reloaded. Forge should probably do this, so worth checking in the future.
 | 
			
		||||
        CommentedConfig config = event.getConfig().getConfigData();
 | 
			
		||||
        if( config instanceof CommentedFileConfig ) ((CommentedFileConfig) config).load();
 | 
			
		||||
 | 
			
		||||
        sync();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ package dan200.computercraft.shared;
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheral;
 | 
			
		||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
 | 
			
		||||
import net.minecraft.util.EnumFacing;
 | 
			
		||||
import net.minecraft.util.Direction;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
 | 
			
		||||
@@ -30,12 +30,12 @@ public final class Peripherals
 | 
			
		||||
        providers.add( provider );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side )
 | 
			
		||||
    public static IPeripheral getPeripheral( World world, BlockPos pos, Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        return World.isValid( pos ) && !world.isRemote ? getPeripheralAt( world, pos, side ) : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static IPeripheral getPeripheralAt( World world, BlockPos pos, EnumFacing side )
 | 
			
		||||
    private static IPeripheral getPeripheralAt( World world, BlockPos pos, Direction side )
 | 
			
		||||
    {
 | 
			
		||||
        // Try the handlers in order:
 | 
			
		||||
        for( IPeripheralProvider peripheralProvider : providers )
 | 
			
		||||
 
 | 
			
		||||
@@ -8,15 +8,23 @@ package dan200.computercraft.shared;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.api.ComputerCraftAPI;
 | 
			
		||||
import dan200.computercraft.shared.common.ColourableRecipe;
 | 
			
		||||
import dan200.computercraft.shared.common.ContainerHeldItem;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.TileCommandComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.items.ItemComputer;
 | 
			
		||||
import dan200.computercraft.shared.computer.recipe.ComputerUpgradeRecipe;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemDisk;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemPrintout;
 | 
			
		||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
 | 
			
		||||
import dan200.computercraft.shared.media.recipes.DiskRecipe;
 | 
			
		||||
import dan200.computercraft.shared.media.recipes.PrintoutRecipe;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wired.*;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockWirelessModem;
 | 
			
		||||
@@ -24,25 +32,35 @@ import dan200.computercraft.shared.peripheral.modem.wireless.TileWirelessModem;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.monitor.BlockMonitor;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.printer.BlockPrinter;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.speaker.BlockSpeaker;
 | 
			
		||||
import dan200.computercraft.shared.peripheral.speaker.TileSpeaker;
 | 
			
		||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
 | 
			
		||||
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.pocket.recipes.PocketComputerUpgradeRecipe;
 | 
			
		||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
 | 
			
		||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.items.ItemTurtle;
 | 
			
		||||
import dan200.computercraft.shared.turtle.recipes.TurtleRecipe;
 | 
			
		||||
import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe;
 | 
			
		||||
import dan200.computercraft.shared.turtle.upgrades.*;
 | 
			
		||||
import dan200.computercraft.shared.util.CreativeTabMain;
 | 
			
		||||
import dan200.computercraft.shared.util.ImpostorRecipe;
 | 
			
		||||
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
 | 
			
		||||
import net.minecraft.block.Block;
 | 
			
		||||
import net.minecraft.block.material.Material;
 | 
			
		||||
import net.minecraft.entity.EntityType;
 | 
			
		||||
import net.minecraft.init.Items;
 | 
			
		||||
import net.minecraft.inventory.container.ContainerType;
 | 
			
		||||
import net.minecraft.item.BlockItem;
 | 
			
		||||
import net.minecraft.item.Item;
 | 
			
		||||
import net.minecraft.item.ItemBlock;
 | 
			
		||||
import net.minecraft.item.ItemGroup;
 | 
			
		||||
import net.minecraft.item.Items;
 | 
			
		||||
import net.minecraft.item.crafting.IRecipeSerializer;
 | 
			
		||||
import net.minecraft.tileentity.TileEntityType;
 | 
			
		||||
import net.minecraft.util.ResourceLocation;
 | 
			
		||||
import net.minecraftforge.event.RegistryEvent;
 | 
			
		||||
@@ -181,7 +199,7 @@ public final class Registry
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static <T extends ItemBlock> T setupItemBlock( T item )
 | 
			
		||||
    private static <T extends BlockItem> T setupItemBlock( T item )
 | 
			
		||||
    {
 | 
			
		||||
        item.setRegistryName( item.getBlock().getRegistryName() );
 | 
			
		||||
        return item;
 | 
			
		||||
@@ -247,14 +265,14 @@ public final class Registry
 | 
			
		||||
 | 
			
		||||
        // Peripherals
 | 
			
		||||
        registry.registerAll(
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.speaker, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.diskDrive, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.printer, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.monitorNormal, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.monitorAdvanced, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.wirelessModemNormal, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.wirelessModemAdvanced, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new ItemBlock( ComputerCraft.Blocks.wiredModemFull, defaultItem() ) )
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.speaker, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.diskDrive, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.printer, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.monitorNormal, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.monitorAdvanced, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.wirelessModemNormal, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.wirelessModemAdvanced, defaultItem() ) ),
 | 
			
		||||
            setupItemBlock( new BlockItem( ComputerCraft.Blocks.wiredModemFull, defaultItem() ) )
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        ComputerCraft.Items.cable = new ItemBlockCable.Cable( ComputerCraft.Blocks.cable, defaultItem() );
 | 
			
		||||
@@ -286,7 +304,7 @@ public final class Registry
 | 
			
		||||
        ComputerCraft.TurtleUpgrades.diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), Items.DIAMOND_SWORD );
 | 
			
		||||
        ComputerCraftAPI.registerTurtleUpgrade( ComputerCraft.TurtleUpgrades.diamondSword );
 | 
			
		||||
 | 
			
		||||
        ComputerCraft.TurtleUpgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), Items.DIAMOND_SHOVEL );
 | 
			
		||||
        ComputerCraft.TurtleUpgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), net.minecraft.item.Items.DIAMOND_SHOVEL );
 | 
			
		||||
        ComputerCraftAPI.registerTurtleUpgrade( ComputerCraft.TurtleUpgrades.diamondShovel );
 | 
			
		||||
 | 
			
		||||
        ComputerCraft.TurtleUpgrades.diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), Items.DIAMOND_PICKAXE );
 | 
			
		||||
@@ -311,4 +329,37 @@ public final class Registry
 | 
			
		||||
    {
 | 
			
		||||
        registry.getRegistry().register( TurtlePlayer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_player" ) ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public static void registerContainers( RegistryEvent.Register<ContainerType<?>> event )
 | 
			
		||||
    {
 | 
			
		||||
        event.getRegistry().registerAll(
 | 
			
		||||
            ContainerComputer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ),
 | 
			
		||||
            ContainerPocketComputer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer" ) ),
 | 
			
		||||
            ContainerTurtle.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ),
 | 
			
		||||
 | 
			
		||||
            ContainerDiskDrive.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk_drive" ) ),
 | 
			
		||||
            ContainerPrinter.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printer" ) ),
 | 
			
		||||
            ContainerHeldItem.PRINTOUT_TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ),
 | 
			
		||||
 | 
			
		||||
            ContainerViewComputer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "view_computer" ) )
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public static void regsterRecipeSerializers( RegistryEvent.Register<IRecipeSerializer<?>> event )
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        event.getRegistry().registerAll(
 | 
			
		||||
            ColourableRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "colour" ) ),
 | 
			
		||||
            ComputerUpgradeRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer_upgrade" ) ),
 | 
			
		||||
            PocketComputerUpgradeRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer_upgrade" ) ),
 | 
			
		||||
            DiskRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk" ) ),
 | 
			
		||||
            PrintoutRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ),
 | 
			
		||||
            TurtleRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ),
 | 
			
		||||
            TurtleUpgradeRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_upgrade" ) ),
 | 
			
		||||
            ImpostorShapelessRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shapeless" ) ),
 | 
			
		||||
            ImpostorRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shaped" ) )
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ package dan200.computercraft.shared;
 | 
			
		||||
 | 
			
		||||
import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import dan200.computercraft.api.turtle.event.TurtleActionEvent;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.entity.player.PlayerEntity;
 | 
			
		||||
import net.minecraft.server.MinecraftServer;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
@@ -18,13 +18,13 @@ import net.minecraftforge.fml.common.Mod;
 | 
			
		||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID )
 | 
			
		||||
public final class TurtlePermissions
 | 
			
		||||
{
 | 
			
		||||
    public static boolean isBlockEnterable( World world, BlockPos pos, EntityPlayer player )
 | 
			
		||||
    public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player )
 | 
			
		||||
    {
 | 
			
		||||
        MinecraftServer server = world.getServer();
 | 
			
		||||
        return server == null || world.isRemote || !server.isBlockProtected( world, pos, player );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean isBlockEditable( World world, BlockPos pos, EntityPlayer player )
 | 
			
		||||
    public static boolean isBlockEditable( World world, BlockPos pos, PlayerEntity player )
 | 
			
		||||
    {
 | 
			
		||||
        MinecraftServer server = world.getServer();
 | 
			
		||||
        return server == null || world.isRemote || !server.isBlockProtected( world, pos, player );
 | 
			
		||||
 
 | 
			
		||||
@@ -20,17 +20,22 @@ import dan200.computercraft.core.tracking.TrackingField;
 | 
			
		||||
import dan200.computercraft.shared.command.text.TableBuilder;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
 | 
			
		||||
import dan200.computercraft.shared.computer.core.ServerComputer;
 | 
			
		||||
import dan200.computercraft.shared.network.Containers;
 | 
			
		||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
 | 
			
		||||
import dan200.computercraft.shared.network.container.ViewComputerContainerData;
 | 
			
		||||
import net.minecraft.command.CommandSource;
 | 
			
		||||
import net.minecraft.entity.Entity;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
			
		||||
import net.minecraft.network.play.server.SPacketPlayerPosLook;
 | 
			
		||||
import net.minecraft.entity.player.PlayerEntity;
 | 
			
		||||
import net.minecraft.entity.player.PlayerInventory;
 | 
			
		||||
import net.minecraft.entity.player.ServerPlayerEntity;
 | 
			
		||||
import net.minecraft.inventory.container.Container;
 | 
			
		||||
import net.minecraft.inventory.container.INamedContainerProvider;
 | 
			
		||||
import net.minecraft.network.play.server.SPlayerPositionLookPacket;
 | 
			
		||||
import net.minecraft.util.math.BlockPos;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextComponentString;
 | 
			
		||||
import net.minecraft.util.text.StringTextComponent;
 | 
			
		||||
import net.minecraft.util.text.TranslationTextComponent;
 | 
			
		||||
import net.minecraft.world.World;
 | 
			
		||||
import net.minecraft.world.WorldServer;
 | 
			
		||||
import net.minecraft.world.server.ServerWorld;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
@@ -170,16 +175,21 @@ public final class CommandComputerCraft
 | 
			
		||||
                    if( world == null || pos == null ) throw TP_NOT_THERE.create();
 | 
			
		||||
 | 
			
		||||
                    Entity entity = context.getSource().assertIsEntity();
 | 
			
		||||
                    if( !(entity instanceof EntityPlayerMP) ) throw TP_NOT_PLAYER.create();
 | 
			
		||||
                    if( !(entity instanceof ServerPlayerEntity) ) throw TP_NOT_PLAYER.create();
 | 
			
		||||
 | 
			
		||||
                    EntityPlayerMP player = (EntityPlayerMP) entity;
 | 
			
		||||
                    ServerPlayerEntity player = (ServerPlayerEntity) entity;
 | 
			
		||||
                    if( player.getEntityWorld() == world )
 | 
			
		||||
                    {
 | 
			
		||||
                        player.connection.setPlayerLocation( pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0, EnumSet.noneOf( SPacketPlayerPosLook.EnumFlags.class ) );
 | 
			
		||||
                        player.connection.setPlayerLocation(
 | 
			
		||||
                            pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0,
 | 
			
		||||
                            EnumSet.noneOf( SPlayerPositionLookPacket.Flags.class )
 | 
			
		||||
                        );
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        player.teleport( (WorldServer) world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0 );
 | 
			
		||||
                        player.teleport( (ServerWorld) world,
 | 
			
		||||
                            pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0
 | 
			
		||||
                        );
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    return 1;
 | 
			
		||||
@@ -210,9 +220,24 @@ public final class CommandComputerCraft
 | 
			
		||||
                .requires( UserLevel.OP )
 | 
			
		||||
                .arg( "computer", oneComputer() )
 | 
			
		||||
                .executes( context -> {
 | 
			
		||||
                    EntityPlayerMP player = context.getSource().asPlayer();
 | 
			
		||||
                    ServerPlayerEntity player = context.getSource().asPlayer();
 | 
			
		||||
                    ServerComputer computer = getComputerArgument( context, "computer" );
 | 
			
		||||
                    Containers.openComputerGUI( player, computer );
 | 
			
		||||
                    new ViewComputerContainerData( computer ).open( player, new INamedContainerProvider()
 | 
			
		||||
                    {
 | 
			
		||||
                        @Nonnull
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public ITextComponent getDisplayName()
 | 
			
		||||
                        {
 | 
			
		||||
                            return new TranslationTextComponent( "gui.computercraft.view_computer" );
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        @Nonnull
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public Container createMenu( int id, @Nonnull PlayerInventory player, @Nonnull PlayerEntity entity )
 | 
			
		||||
                        {
 | 
			
		||||
                            return new ContainerViewComputer( id, computer );
 | 
			
		||||
                        }
 | 
			
		||||
                    } );
 | 
			
		||||
                    return 1;
 | 
			
		||||
                } ) )
 | 
			
		||||
 | 
			
		||||
@@ -259,7 +284,7 @@ public final class CommandComputerCraft
 | 
			
		||||
 | 
			
		||||
    private static ITextComponent linkComputer( CommandSource source, ServerComputer serverComputer, int computerId )
 | 
			
		||||
    {
 | 
			
		||||
        ITextComponent out = new TextComponentString( "" );
 | 
			
		||||
        ITextComponent out = new StringTextComponent( "" );
 | 
			
		||||
 | 
			
		||||
        // Append the computer instance
 | 
			
		||||
        if( serverComputer == null )
 | 
			
		||||
@@ -319,7 +344,7 @@ public final class CommandComputerCraft
 | 
			
		||||
    private static TrackingContext getTimingContext( CommandSource source )
 | 
			
		||||
    {
 | 
			
		||||
        Entity entity = source.getEntity();
 | 
			
		||||
        return entity instanceof EntityPlayer ? Tracking.getContext( entity.getUniqueID() ) : Tracking.getContext( SYSTEM_UUID );
 | 
			
		||||
        return entity instanceof PlayerEntity ? Tracking.getContext( entity.getUniqueID() ) : Tracking.getContext( SYSTEM_UUID );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static final List<TrackingField> DEFAULT_FIELDS = Arrays.asList( TrackingField.TASKS, TrackingField.TOTAL_TIME, TrackingField.AVERAGE_TIME, TrackingField.MAX_TIME );
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,8 @@ import dan200.computercraft.ComputerCraft;
 | 
			
		||||
import net.minecraft.client.Minecraft;
 | 
			
		||||
import net.minecraft.command.CommandSource;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextComponentString;
 | 
			
		||||
import net.minecraft.util.text.TextComponentTranslation;
 | 
			
		||||
import net.minecraft.util.text.StringTextComponent;
 | 
			
		||||
import net.minecraft.util.text.TranslationTextComponent;
 | 
			
		||||
import net.minecraft.util.text.event.ClickEvent;
 | 
			
		||||
import net.minecraft.util.text.event.HoverEvent;
 | 
			
		||||
import net.minecraftforge.api.distmarker.Dist;
 | 
			
		||||
@@ -58,10 +58,10 @@ public final class CommandCopy
 | 
			
		||||
 | 
			
		||||
    public static ITextComponent createCopyText( String text )
 | 
			
		||||
    {
 | 
			
		||||
        TextComponentString name = new TextComponentString( text );
 | 
			
		||||
        StringTextComponent name = new StringTextComponent( text );
 | 
			
		||||
        name.getStyle()
 | 
			
		||||
            .setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
 | 
			
		||||
            .setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TextComponentTranslation( "gui.computercraft.tooltip.copy" ) ) );
 | 
			
		||||
            .setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) );
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
 | 
			
		||||
import net.minecraft.command.CommandSource;
 | 
			
		||||
import net.minecraft.command.ISuggestionProvider;
 | 
			
		||||
import net.minecraft.entity.Entity;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
			
		||||
import net.minecraft.entity.player.ServerPlayerEntity;
 | 
			
		||||
import net.minecraftforge.common.util.FakePlayer;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
@@ -27,9 +27,9 @@ public final class CommandUtils
 | 
			
		||||
    public static boolean isPlayer( CommandSource output )
 | 
			
		||||
    {
 | 
			
		||||
        Entity sender = output.getEntity();
 | 
			
		||||
        return sender instanceof EntityPlayerMP
 | 
			
		||||
        return sender instanceof ServerPlayerEntity
 | 
			
		||||
            && !(sender instanceof FakePlayer)
 | 
			
		||||
            && ((EntityPlayerMP) sender).connection != null;
 | 
			
		||||
            && ((ServerPlayerEntity) sender).connection != null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings( "unchecked" )
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.command;
 | 
			
		||||
import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType;
 | 
			
		||||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
 | 
			
		||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 | 
			
		||||
import net.minecraft.util.text.TextComponentTranslation;
 | 
			
		||||
import net.minecraft.util.text.TranslationTextComponent;
 | 
			
		||||
 | 
			
		||||
public final class Exceptions
 | 
			
		||||
{
 | 
			
		||||
@@ -28,16 +28,16 @@ public final class Exceptions
 | 
			
		||||
 | 
			
		||||
    private static SimpleCommandExceptionType translated( String key )
 | 
			
		||||
    {
 | 
			
		||||
        return new SimpleCommandExceptionType( new TextComponentTranslation( key ) );
 | 
			
		||||
        return new SimpleCommandExceptionType( new TranslationTextComponent( key ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static DynamicCommandExceptionType translated1( String key )
 | 
			
		||||
    {
 | 
			
		||||
        return new DynamicCommandExceptionType( x -> new TextComponentTranslation( key, x ) );
 | 
			
		||||
        return new DynamicCommandExceptionType( x -> new TranslationTextComponent( key, x ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static Dynamic2CommandExceptionType translated2( String key )
 | 
			
		||||
    {
 | 
			
		||||
        return new Dynamic2CommandExceptionType( ( x, y ) -> new TextComponentTranslation( key, x, y ) );
 | 
			
		||||
        return new Dynamic2CommandExceptionType( ( x, y ) -> new TranslationTextComponent( key, x, y ) );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.command;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.command.CommandSource;
 | 
			
		||||
import net.minecraft.entity.Entity;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayer;
 | 
			
		||||
import net.minecraft.entity.player.PlayerEntity;
 | 
			
		||||
import net.minecraft.server.MinecraftServer;
 | 
			
		||||
 | 
			
		||||
import java.util.function.Predicate;
 | 
			
		||||
@@ -62,8 +62,8 @@ public enum UserLevel implements Predicate<CommandSource>
 | 
			
		||||
        MinecraftServer server = source.getServer();
 | 
			
		||||
        Entity sender = source.getEntity();
 | 
			
		||||
 | 
			
		||||
        if( server.isSinglePlayer() && sender instanceof EntityPlayer &&
 | 
			
		||||
            ((EntityPlayer) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ) )
 | 
			
		||||
        if( server.isSinglePlayer() && sender instanceof PlayerEntity &&
 | 
			
		||||
            ((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ) )
 | 
			
		||||
        {
 | 
			
		||||
            if( this == OWNER || this == OWNER_OP ) return true;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -18,12 +18,12 @@ public final class ArgumentSerializers
 | 
			
		||||
    @SuppressWarnings( "unchecked" )
 | 
			
		||||
    private static <T extends ArgumentType<?>> void registerUnsafe( ResourceLocation id, Class<T> type, IArgumentSerializer<?> serializer )
 | 
			
		||||
    {
 | 
			
		||||
        ArgumentTypes.register( id, type, (IArgumentSerializer<T>) serializer );
 | 
			
		||||
        ArgumentTypes.register( id.toString(), type, (IArgumentSerializer<T>) serializer );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static <T extends ArgumentType<?>> void register( ResourceLocation id, Class<T> type, IArgumentSerializer<T> serializer )
 | 
			
		||||
    {
 | 
			
		||||
        ArgumentTypes.register( id, type, serializer );
 | 
			
		||||
        ArgumentTypes.register( id.toString(), type, serializer );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static <T extends ArgumentType<?>> void register( ResourceLocation id, T instance )
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ import net.minecraft.command.arguments.ArgumentTypes;
 | 
			
		||||
import net.minecraft.command.arguments.IArgumentSerializer;
 | 
			
		||||
import net.minecraft.network.PacketBuffer;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextComponentString;
 | 
			
		||||
import net.minecraft.util.text.StringTextComponent;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
@@ -160,7 +160,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
 | 
			
		||||
        {
 | 
			
		||||
            Message message = arg.some.create().getRawMessage();
 | 
			
		||||
            if( message instanceof ITextComponent ) return (ITextComponent) message;
 | 
			
		||||
            return new TextComponentString( message.getString() );
 | 
			
		||||
            return new StringTextComponent( message.getString() );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,10 @@ import com.mojang.brigadier.context.CommandContext;
 | 
			
		||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A {@link Command} which accepts an argument
 | 
			
		||||
 * A {@link Command} which accepts an argument.
 | 
			
		||||
 *
 | 
			
		||||
 * @param <S> The command source we consume.
 | 
			
		||||
 * @param <T> The argument given to this command when executed.
 | 
			
		||||
 */
 | 
			
		||||
@FunctionalInterface
 | 
			
		||||
public interface ArgCommand<S, T>
 | 
			
		||||
 
 | 
			
		||||
@@ -25,8 +25,10 @@ import static dan200.computercraft.shared.command.Exceptions.ARGUMENT_EXPECTED;
 | 
			
		||||
import static dan200.computercraft.shared.command.builder.HelpingArgumentBuilder.literal;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An alternative way of building command nodes, so one does not have to nest
 | 
			
		||||
 * An alternative way of building command nodes, so one does not have to nest.
 | 
			
		||||
 * {@link ArgumentBuilder#then(CommandNode)}s.
 | 
			
		||||
 *
 | 
			
		||||
 * @param <S> The command source we consume.
 | 
			
		||||
 */
 | 
			
		||||
public class CommandBuilder<S> implements CommandNodeBuilder<S, Command<S>>
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,9 @@ import com.mojang.brigadier.tree.CommandNode;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A builder which generates a {@link CommandNode} from the provided action.
 | 
			
		||||
 *
 | 
			
		||||
 * @param <S> The command source we consume.
 | 
			
		||||
 * @param <T> The type of action to execute when this command is run.
 | 
			
		||||
 */
 | 
			
		||||
@FunctionalInterface
 | 
			
		||||
public interface CommandNodeBuilder<S, T>
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ import com.mojang.brigadier.tree.CommandNode;
 | 
			
		||||
import com.mojang.brigadier.tree.LiteralCommandNode;
 | 
			
		||||
import net.minecraft.command.CommandSource;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextComponentString;
 | 
			
		||||
import net.minecraft.util.text.StringTextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextFormatting;
 | 
			
		||||
import net.minecraft.util.text.event.ClickEvent;
 | 
			
		||||
 | 
			
		||||
@@ -174,7 +174,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
 | 
			
		||||
        temp.addChild( node );
 | 
			
		||||
        String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
 | 
			
		||||
 | 
			
		||||
        ITextComponent output = new TextComponentString( "" )
 | 
			
		||||
        ITextComponent output = new StringTextComponent( "" )
 | 
			
		||||
            .appendSibling( coloured( "/" + command + usage, HEADER ) )
 | 
			
		||||
            .appendText( " " )
 | 
			
		||||
            .appendSibling( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ import net.minecraft.util.text.event.ClickEvent;
 | 
			
		||||
import net.minecraft.util.text.event.HoverEvent;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Various helpers for building chat messages
 | 
			
		||||
 * Various helpers for building chat messages.
 | 
			
		||||
 */
 | 
			
		||||
public final class ChatHelpers
 | 
			
		||||
{
 | 
			
		||||
@@ -22,7 +22,7 @@ public final class ChatHelpers
 | 
			
		||||
 | 
			
		||||
    public static ITextComponent coloured( String text, TextFormatting colour )
 | 
			
		||||
    {
 | 
			
		||||
        ITextComponent component = new TextComponentString( text == null ? "" : text );
 | 
			
		||||
        ITextComponent component = new StringTextComponent( text == null ? "" : text );
 | 
			
		||||
        component.getStyle().setColor( colour );
 | 
			
		||||
        return component;
 | 
			
		||||
    }
 | 
			
		||||
@@ -35,22 +35,22 @@ public final class ChatHelpers
 | 
			
		||||
 | 
			
		||||
    public static ITextComponent text( String text )
 | 
			
		||||
    {
 | 
			
		||||
        return new TextComponentString( text == null ? "" : text );
 | 
			
		||||
        return new StringTextComponent( text == null ? "" : text );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static ITextComponent translate( String text )
 | 
			
		||||
    {
 | 
			
		||||
        return new TextComponentTranslation( text == null ? "" : text );
 | 
			
		||||
        return new TranslationTextComponent( text == null ? "" : text );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static ITextComponent translate( String text, Object... args )
 | 
			
		||||
    {
 | 
			
		||||
        return new TextComponentTranslation( text == null ? "" : text, args );
 | 
			
		||||
        return new TranslationTextComponent( text == null ? "" : text, args );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static ITextComponent list( ITextComponent... children )
 | 
			
		||||
    {
 | 
			
		||||
        ITextComponent component = new TextComponentString( "" );
 | 
			
		||||
        ITextComponent component = new StringTextComponent( "" );
 | 
			
		||||
        for( ITextComponent child : children )
 | 
			
		||||
        {
 | 
			
		||||
            component.appendSibling( child );
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.command.text;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.command.CommandSource;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextComponentString;
 | 
			
		||||
import net.minecraft.util.text.StringTextComponent;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
@@ -28,7 +28,7 @@ public class ServerTableFormatter implements TableFormatter
 | 
			
		||||
    {
 | 
			
		||||
        int extraWidth = width - getWidth( component );
 | 
			
		||||
        if( extraWidth <= 0 ) return null;
 | 
			
		||||
        return new TextComponentString( StringUtils.repeat( ' ', extraWidth ) );
 | 
			
		||||
        return new StringTextComponent( StringUtils.repeat( ' ', extraWidth ) );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ import dan200.computercraft.shared.command.CommandUtils;
 | 
			
		||||
import dan200.computercraft.shared.network.NetworkHandler;
 | 
			
		||||
import dan200.computercraft.shared.network.client.ChatTableClientMessage;
 | 
			
		||||
import net.minecraft.command.CommandSource;
 | 
			
		||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
			
		||||
import net.minecraft.entity.player.ServerPlayerEntity;
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
@@ -107,7 +107,7 @@ public class TableBuilder
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Trim this table to a given height
 | 
			
		||||
     * Trim this table to a given height.
 | 
			
		||||
     *
 | 
			
		||||
     * @param height The desired height.
 | 
			
		||||
     */
 | 
			
		||||
@@ -125,7 +125,7 @@ public class TableBuilder
 | 
			
		||||
        if( CommandUtils.isPlayer( source ) )
 | 
			
		||||
        {
 | 
			
		||||
            trim( 18 );
 | 
			
		||||
            NetworkHandler.sendToPlayer( (EntityPlayerMP) source.getEntity(), new ChatTableClientMessage( this ) );
 | 
			
		||||
            NetworkHandler.sendToPlayer( (ServerPlayerEntity) source.getEntity(), new ChatTableClientMessage( this ) );
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@
 | 
			
		||||
package dan200.computercraft.shared.command.text;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.text.ITextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextComponentString;
 | 
			
		||||
import net.minecraft.util.text.StringTextComponent;
 | 
			
		||||
import net.minecraft.util.text.TextFormatting;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
 | 
			
		||||
@@ -22,7 +22,7 @@ public interface TableFormatter
 | 
			
		||||
    ITextComponent HEADER = coloured( "=", TextFormatting.GRAY );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get additional padding for the component
 | 
			
		||||
     * Get additional padding for the component.
 | 
			
		||||
     *
 | 
			
		||||
     * @param component The component to pad
 | 
			
		||||
     * @param width     The desired width for the component
 | 
			
		||||
@@ -32,7 +32,7 @@ public interface TableFormatter
 | 
			
		||||
    ITextComponent getPadding( ITextComponent component, int width );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the minimum padding between each column
 | 
			
		||||
     * Get the minimum padding between each column.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The minimum padding.
 | 
			
		||||
     */
 | 
			
		||||
@@ -77,7 +77,7 @@ public interface TableFormatter
 | 
			
		||||
 | 
			
		||||
        if( headers != null )
 | 
			
		||||
        {
 | 
			
		||||
            TextComponentString line = new TextComponentString( "" );
 | 
			
		||||
            StringTextComponent line = new StringTextComponent( "" );
 | 
			
		||||
            for( int i = 0; i < columns - 1; i++ )
 | 
			
		||||
            {
 | 
			
		||||
                line.appendSibling( headers[i] );
 | 
			
		||||
@@ -98,7 +98,7 @@ public interface TableFormatter
 | 
			
		||||
 | 
			
		||||
        for( ITextComponent[] row : table.getRows() )
 | 
			
		||||
        {
 | 
			
		||||
            TextComponentString line = new TextComponentString( "" );
 | 
			
		||||
            StringTextComponent line = new StringTextComponent( "" );
 | 
			
		||||
            for( int i = 0; i < columns - 1; i++ )
 | 
			
		||||
            {
 | 
			
		||||
                line.appendSibling( row[i] );
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user