1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-04 15:43:00 +00:00

Compare commits

..

11 Commits

Author SHA1 Message Date
Jonathan Coates
2c64186965 Bump version to 1.100.4 2022-03-23 08:36:09 +00:00
Jonathan Coates
31ba17d085 Don't wait for the chunk to be loaded when checking for monitors
There's a couple of alternative ways to solve this. Ideally we'd send
our network messages at the same time as MC does
(ChunkManager.playerLoadedChunk), but this'd require a mixin.

Instead we just rely on the fact that if the chunk isn't loaded,
monitors won't have done anything and so we don't need to send their
contents!

Fixes #1047, probably doesn't cause any regressions. I've not seen any
issues on 1.16, but I also hadn't before so ¯\_(ツ)_/¯.
2022-03-18 19:59:02 +00:00
Jonathan Coates
bcc7dd6991 Fix typo in Javadoc 2022-03-02 12:54:59 +00:00
Jonathan Coates
bd36185662 Bump version
Holding off until Forge releases for 1.18.2
2022-02-28 15:35:16 +00:00
Jonathan Coates
045c4fc88c Merge pull request #1027 from Toad-Dev/issue-1026
Fix large file uploads producing oversized packets.
2022-02-28 11:06:59 +00:00
Jonathan Coates
e0fcc425c6 Prevent id map being null when file is empty
Fixes #1030
2022-02-28 11:01:04 +00:00
Jonathan Coates
e01895d719 Remove turtle_player EntityType
This was added in the 1.13 update and I'm still not sure why. Other mods
seem to get away without it, so I think it's fine to remove.

Also remove the fake net manager, as that's part of Forge nowadays.

Fixes #1044.
2022-02-28 10:34:41 +00:00
Jonathan Coates
87b38f4249 Fix incorrect recipe name in turtle advancement 2022-02-28 10:32:33 +00:00
Toad-Dev
60d1d1bb18 Fix large file uploads producing oversized packets.
- Fixes #1026
- The remaining bytes counter wasn't being decremented, so the code that
  splits off smaller packets was unreachable. Thus all file slices were
  being put into a single UploadFileMessage packet.
2022-01-23 22:31:27 -08:00
Jonathan Coates
cdf8b77ffd Merge pull request #1017 from Possseidon/patch-1
Fix table with mouse button codes in documentation.
2022-01-20 12:40:09 +00:00
Possseidon
e2ce52fe81 Fix table with mouse button codes.
Codes for right and middle mouse buttons were swapped.
2022-01-19 17:39:19 +01:00
485 changed files with 17775 additions and 8904 deletions

View File

@@ -31,7 +31,7 @@ version = mod_version
group = "org.squiddev" group = "org.squiddev"
archivesBaseName = "cc-tweaked-${mc_version}" archivesBaseName = "cc-tweaked-${mc_version}"
def javaVersion = JavaLanguageVersion.of(17) def javaVersion = JavaLanguageVersion.of(8)
java { java {
toolchain { toolchain {
languageVersion = javaVersion languageVersion = javaVersion
@@ -58,10 +58,6 @@ sourceSets {
minecraft { minecraft {
runs { runs {
all { all {
lazyToken('minecraft_classpath') {
configurations.shade.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
}
property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
@@ -97,12 +93,6 @@ minecraft {
source sourceSets.testMod source sourceSets.testMod
} }
} }
lazyToken('minecraft_classpath') {
(configurations.shade.copyRecursive().resolve() + configurations.testModExtra.copyRecursive().resolve())
.collect { it.absolutePath }
.join(File.pathSeparator)
}
} }
testServer { testServer {
@@ -114,17 +104,10 @@ minecraft {
source sourceSets.testMod source sourceSets.testMod
} }
} }
lazyToken('minecraft_classpath') {
(configurations.shade.copyRecursive().resolve() + configurations.testModExtra.copyRecursive().resolve())
.collect { it.absolutePath }
.join(File.pathSeparator)
}
} }
} }
// mappings channel: 'parchment', version: "${mapping_version}-${mc_version}" mappings channel: 'parchment', version: "${mapping_version}-${mc_version}"
mappings channel: 'official', version: mc_version
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg') accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg') accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
@@ -145,22 +128,23 @@ repositories {
configurations { configurations {
shade shade
implementation.extendsFrom shade implementation.extendsFrom shade
cctJavadoc cctJavadoc
testModExtra
testModImplementation.extendsFrom(testModExtra)
testModImplementation.extendsFrom(implementation) testModImplementation.extendsFrom(implementation)
testModImplementation.extendsFrom(testImplementation)
} }
dependencies { dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:8.45" checkstyle "com.puppycrawl.tools:checkstyle:8.25"
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor' annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47:api") compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47") compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:7.1.0.313")
compileOnly fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0")
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104")
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT' shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'
@@ -169,12 +153,10 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation 'org.hamcrest:hamcrest:2.2' testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0' testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0'
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
testModImplementation sourceSets.main.output testModImplementation sourceSets.main.output
testModExtra('org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0') {
exclude group: "org.jetbrains", module: "annotations"
}
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.5' cctJavadoc 'cc.tweaked:cct-javadoc:1.4.5'
} }
@@ -202,7 +184,7 @@ task luaJavadoc(type: Javadoc) {
options.noTimestamp = false options.noTimestamp = false
javadocTool = javaToolchains.javadocToolFor { javadocTool = javaToolchains.javadocToolFor {
languageVersion = javaVersion languageVersion = JavaLanguageVersion.of(11)
} }
} }
@@ -215,8 +197,7 @@ jar {
"Implementation-Title" : "CC: Tweaked", "Implementation-Title" : "CC: Tweaked",
"Implementation-Version" : "${mod_version}", "Implementation-Version" : "${mod_version}",
"Implementation-Vendor" : "SquidDev", "Implementation-Vendor" : "SquidDev",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
,
"MixinConfigs" : "computercraft.mixins.json", "MixinConfigs" : "computercraft.mixins.json",
]) ])
} }
@@ -224,8 +205,6 @@ jar {
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) } from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
} }
jar.finalizedBy('reobfJar')
[compileJava, compileTestJava, compileTestModJava].forEach { [compileJava, compileTestJava, compileTestModJava].forEach {
it.configure { it.configure {
options.compilerArgs << "-Xlint" << "-Xlint:-processing" options.compilerArgs << "-Xlint" << "-Xlint:-processing"
@@ -233,6 +212,9 @@ jar.finalizedBy('reobfJar')
} }
processResources { processResources {
inputs.property "version", mod_version
inputs.property "mcversion", mc_version
def hash = 'none' def hash = 'none'
Set<String> contributors = [] Set<String> contributors = []
try { try {
@@ -249,14 +231,16 @@ processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
include 'data/computercraft/lua/rom/help/credits.txt' include 'data/computercraft/lua/rom/help/credits.txt'
expand( expand 'version': mod_version,
'mcversion': mc_version,
'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n') 'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
)
} }
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
exclude 'data/computercraft/lua/rom/help/credits.txt' exclude 'data/computercraft/lua/rom/help/credits.txt'
} }
} }
@@ -270,7 +254,6 @@ sourcesJar {
import com.hierynomus.gradle.license.tasks.LicenseCheck import com.hierynomus.gradle.license.tasks.LicenseCheck
import com.hierynomus.gradle.license.tasks.LicenseFormat import com.hierynomus.gradle.license.tasks.LicenseFormat
import com.modrinth.minotaur.TaskModrinthUpload
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
List<String> mkCommand(String command) { List<String> mkCommand(String command) {
@@ -480,19 +463,18 @@ task checkRelease {
} }
check.dependsOn checkRelease check.dependsOn checkRelease
def isStable = true
curseforge { curseforge {
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : '' apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
project { project {
id = '282001' id = '282001'
releaseType = isStable ? 'release' : 'alpha' releaseType = 'release'
changelog = "Release notes can be found on the GitHub repository (https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})." changelog = "Release notes can be found on the GitHub repository (https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
addGameVersion "${mc_version}" addGameVersion "${mc_version}"
} }
} }
import com.modrinth.minotaur.TaskModrinthUpload
tasks.register('publishModrinth', TaskModrinthUpload.class).configure { tasks.register('publishModrinth', TaskModrinthUpload.class).configure {
dependsOn('assemble', 'reobfJar') dependsOn('assemble', 'reobfJar')
onlyIf { onlyIf {
@@ -503,7 +485,6 @@ tasks.register('publishModrinth', TaskModrinthUpload.class).configure {
projectId = 'gu7yAYhd' projectId = 'gu7yAYhd'
versionNumber = "${project.mc_version}-${project.mod_version}" versionNumber = "${project.mc_version}-${project.mod_version}"
uploadFile = jar uploadFile = jar
versionType = isStable ? 'RELEASE' : 'ALPHA'
addGameVersion(project.mc_version) addGameVersion(project.mc_version)
changelog = "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})." changelog = "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
addLoader('forge') addLoader('forge')
@@ -564,17 +545,12 @@ githubRelease {
owner 'cc-tweaked' owner 'cc-tweaked'
repo 'CC-Tweaked' repo 'CC-Tweaked'
targetCommitish.set(project.provider({ targetCommitish.set(project.provider({
def cmd = ["git", "rev-parse", "--abbrev-ref", "HEAD"] try {
println(cmd) return ["git", "-C", projectDir, "rev-parse", "--abbrev-ref", "HEAD"].execute().text.trim()
def proc = cmd.execute([], projectDir) } catch (Exception e) {
if (proc.waitFor() != 0) { e.printStackTrace()
println(proc.err.text.trim())
throw new IllegalStateException("Executed with a non-0 exit code (${proc.exitValue()}).")
} }
return "master"
def branch = proc.text.trim()
if (branch == "") throw new IllegalStateException("Cannot determine branch")
return branch
})) }))
tagName "v${mc_version}-${mod_version}" tagName "v${mc_version}-${mod_version}"
@@ -585,7 +561,7 @@ githubRelease {
.takeWhile { it != 'Type "help changelog" to see the full version history.' } .takeWhile { it != 'Type "help changelog" to see the full version history.' }
.join("\n").trim() .join("\n").trim()
})) }))
prerelease !isStable prerelease false
} }
def uploadTasks = ["publish", "curseforge", "publishModrinth", "githubRelease"] def uploadTasks = ["publish", "curseforge", "publishModrinth", "githubRelease"]

View File

@@ -58,20 +58,13 @@
<module name="SimplifyBooleanExpression" /> <module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" /> <module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" /> <module name="StringLiteralEquality" />
<module name="UnnecessaryParentheses"> <module name="UnnecessaryParentheses" />
<!-- Default minus LAND. -->
<property name="tokens" value="EXPR,IDENT,NUM_DOUBLE,NUM_FLOAT,NUM_INT,NUM_LONG,STRING_LITERAL,LITERAL_NULL,LITERAL_FALSE,LITERAL_TRUE,ASSIGN,BAND_ASSIGN,BOR_ASSIGN,BSR_ASSIGN,BXOR_ASSIGN,DIV_ASSIGN,MINUS_ASSIGN,MOD_ASSIGN,PLUS_ASSIGN,SL_ASSIGN,SR_ASSIGN,STAR_ASSIGN,LAMBDA,TEXT_BLOCK_LITERAL_BEGIN,LITERAL_INSTANCEOF,GT,LT,GE,LE,EQUAL,NOT_EQUAL,UNARY_MINUS,UNARY_PLUS,INC,DEC,LNOT,BNOT,POST_INC,POST_DEC" />
</module>
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration" /> <module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
<module name="UnnecessarySemicolonInTryWithResources" /> <module name="UnnecessarySemicolonInTryWithResources" />
<module name="UnnecessarySemicolonInEnumeration" /> <module name="UnnecessarySemicolonInEnumeration" />
<!-- Imports --> <!-- Imports -->
<module name="CustomImportOrder"> <module name="CustomImportOrder" />
<property name="customImportOrderRules"
value="THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"
/>
</module>
<module name="IllegalImport" /> <module name="IllegalImport" />
<module name="RedundantImport" /> <module name="RedundantImport" />
<module name="UnusedImports" /> <module name="UnusedImports" />
@@ -161,7 +154,6 @@
<property name="allowEmptyLambdas" value="true" /> <property name="allowEmptyLambdas" value="true" />
<property name="allowEmptyMethods" value="true" /> <property name="allowEmptyMethods" value="true" />
<property name="allowEmptyConstructors" value="true" /> <property name="allowEmptyConstructors" value="true" />
<property name="allowEmptyTypes" value="true" />
<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" /> <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>

View File

@@ -3,6 +3,6 @@ FROM gitpod/workspace-base
USER gitpod USER gitpod
RUN sudo apt-get -q update \ RUN sudo apt-get -q update \
&& sudo apt-get install -yq openjdk-16-jdk python3-pip npm \ && sudo apt-get install -yq openjdk-8-jdk openjdk-16-jdk python3-pip npm \
&& sudo pip3 install pre-commit \ && sudo pip3 install pre-commit \
&& sudo update-java-alternatives --set java-1.16.0-openjdk-amd64 && sudo update-java-alternatives --set java-1.8.0-openjdk-amd64

View File

@@ -19,8 +19,8 @@ numerical value depending on which button on your mouse was last pressed when th
<!-- Our markdown parser doesn't work on tables!? Guess I'll have to roll my own soonish :/. --> <!-- Our markdown parser doesn't work on tables!? Guess I'll have to roll my own soonish :/. -->
<tr><th>Button code</th><th>Mouse button</th></tr> <tr><th>Button code</th><th>Mouse button</th></tr>
<tr><td align="right">1</td><td>Left button</td></tr> <tr><td align="right">1</td><td>Left button</td></tr>
<tr><td align="right">2</td><td>Middle button</td></tr> <tr><td align="right">2</td><td>Right button</td></tr>
<tr><td align="right">3</td><td>Right button</td></tr> <tr><td align="right">3</td><td>Middle button</td></tr>
</table> </table>
## Example ## Example

View File

@@ -1,10 +1,8 @@
org.gradle.jvmargs=-Xmx3G
# Mod properties # Mod properties
mod_version=1.100.2 mod_version=1.100.4
# Minecraft properties (update mods.toml when changing) # Minecraft properties (update mods.toml when changing)
mc_version=1.18.1 mc_version=1.16.5
mapping_version=2021.09.05 mapping_version=2021.08.08
forge_version=39.0.0 forge_version=36.2.20
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING # NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "minecraft:redstone"
"minecraft:redstone"
]
}, },
{ {
"items": [ "item": "minecraft:gold_ingot"
"minecraft:gold_ingot"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "minecraft:command_block"
"minecraft:command_block"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:disk_drive"
"computercraft:disk_drive"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:pocket_computer_advanced"
"computercraft:pocket_computer_advanced"
]
}, },
{ {
"items": [ "item": "computercraft:speaker"
"computercraft:speaker"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:pocket_computer_advanced"
"computercraft:pocket_computer_advanced"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_advanced"
"computercraft:wireless_modem_advanced"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:pocket_computer_advanced"
"computercraft:pocket_computer_advanced"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_normal"
"computercraft:wireless_modem_normal"
]
} }
] ]
} }

View File

@@ -21,9 +21,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "minecraft:golden_apple"
"minecraft:golden_apple"
]
} }
] ]
} }

View File

@@ -21,9 +21,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "minecraft:golden_apple"
"minecraft:golden_apple"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:pocket_computer_normal"
"computercraft:pocket_computer_normal"
]
}, },
{ {
"items": [ "item": "computercraft:speaker"
"computercraft:speaker"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:pocket_computer_normal"
"computercraft:pocket_computer_normal"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_advanced"
"computercraft:wireless_modem_advanced"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:pocket_computer_normal"
"computercraft:pocket_computer_normal"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_normal"
"computercraft:wireless_modem_normal"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:printer"
"computercraft:printer"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:printer"
"computercraft:printer"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "computercraft:speaker"
"computercraft:speaker"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_advanced"
"computercraft:wireless_modem_advanced"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_normal"
"computercraft:wireless_modem_normal"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "minecraft:crafting_table"
"minecraft:crafting_table"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_axe"
"minecraft:diamond_axe"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_hoe"
"minecraft:diamond_hoe"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_pickaxe"
"minecraft:diamond_pickaxe"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_shovel"
"minecraft:diamond_shovel"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_advanced"
"computercraft:turtle_advanced"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_sword"
"minecraft:diamond_sword"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "computercraft:speaker"
"computercraft:speaker"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_advanced"
"computercraft:wireless_modem_advanced"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "computercraft:wireless_modem_normal"
"computercraft:wireless_modem_normal"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "minecraft:crafting_table"
"minecraft:crafting_table"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_axe"
"minecraft:diamond_axe"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_hoe"
"minecraft:diamond_hoe"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_pickaxe"
"minecraft:diamond_pickaxe"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_shovel"
"minecraft:diamond_shovel"
]
} }
] ]
} }

View File

@@ -11,14 +11,10 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:turtle_normal"
"computercraft:turtle_normal"
]
}, },
{ {
"items": [ "item": "minecraft:diamond_sword"
"minecraft:diamond_sword"
]
} }
] ]
} }

View File

@@ -21,9 +21,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:cable"
"computercraft:cable"
]
} }
] ]
} }

View File

@@ -21,9 +21,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:wireless_modem_normal"
"computercraft:wireless_modem_normal"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:monitor_normal"
"computercraft:monitor_normal"
]
} }
] ]
} }

View File

@@ -11,9 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "item": "computercraft:computer_advanced"
"computercraft:computer_advanced"
]
} }
] ]
} }

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:speaker",
"item": "computercraft:speaker"
}

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:wireless_modem_advanced",
"item": "computercraft:wireless_modem_advanced"
}

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:wireless_modem_normal",
"item": "computercraft:wireless_modem_normal"
}

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:speaker",
"item": "computercraft:speaker"
}

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:wireless_modem_advanced",
"item": "computercraft:wireless_modem_advanced"
}

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:wireless_modem_normal",
"item": "computercraft:wireless_modem_normal"
}

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "cable", "name": "cable",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -22,13 +21,11 @@
"cable": "true" "cable": "true"
} }
} }
], ]
"functions": []
}, },
{ {
"name": "wired_modem", "name": "wired_modem",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -49,8 +46,7 @@
} }
} }
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:dynamic", "type": "minecraft:dynamic",
@@ -29,8 +28,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:dynamic", "type": "minecraft:dynamic",
@@ -29,8 +28,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:dynamic", "type": "minecraft:dynamic",
@@ -29,8 +28,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:dynamic", "type": "minecraft:dynamic",
@@ -29,8 +28,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:dynamic", "type": "minecraft:dynamic",
@@ -29,8 +28,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -3,8 +3,7 @@
"pools": [ "pools": [
{ {
"name": "main", "name": "main",
"rolls": 1.0, "rolls": 1,
"bonus_rolls": 0.0,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
@@ -15,8 +14,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -2,7 +2,6 @@
"replace": false, "replace": false,
"values": [ "values": [
"#minecraft:crops", "#minecraft:crops",
"#minecraft:mineable/hoe",
"minecraft:cactus", "minecraft:cactus",
"minecraft:melon", "minecraft:melon",
"minecraft:pumpkin", "minecraft:pumpkin",

View File

@@ -1,7 +1,6 @@
{ {
"replace": false, "replace": false,
"values": [ "values": [
"#minecraft:mineable/shovel",
"minecraft:melon", "minecraft:melon",
"minecraft:pumpkin", "minecraft:pumpkin",
"minecraft:carved_pumpkin", "minecraft:carved_pumpkin",

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:workbench",
"item": "minecraft:crafting_table"
}

View File

@@ -1,5 +0,0 @@
{
"type": "computercraft:tool",
"item": "minecraft:diamond_axe",
"damageMultiplier": 6.0
}

View File

@@ -1,5 +0,0 @@
{
"type": "computercraft:tool",
"item": "minecraft:diamond_hoe",
"breakable": "computercraft:turtle_hoe_harvestable"
}

View File

@@ -1,4 +0,0 @@
{
"type": "computercraft:tool",
"item": "minecraft:diamond_pickaxe"
}

View File

@@ -1,5 +0,0 @@
{
"type": "computercraft:tool",
"item": "minecraft:diamond_shovel",
"breakable": "computercraft:turtle_shovel_harvestable"
}

View File

@@ -1,6 +0,0 @@
{
"type": "computercraft:tool",
"item": "minecraft:diamond_sword",
"damageMultiplier": 9.0,
"breakable": "computercraft:turtle_sword_harvestable"
}

View File

@@ -1,18 +0,0 @@
{
"replace": false,
"values": [
"computercraft:computer_normal",
"computercraft:computer_advanced",
"computercraft:turtle_normal",
"computercraft:turtle_advanced",
"computercraft:speaker",
"computercraft:disk_drive",
"computercraft:printer",
"computercraft:monitor_normal",
"computercraft:monitor_advanced",
"computercraft:wireless_modem_normal",
"computercraft:wireless_modem_advanced",
"computercraft:wired_modem_full",
"computercraft:cable"
]
}

View File

@@ -5,6 +5,7 @@
*/ */
package dan200.computercraft; package dan200.computercraft;
import dan200.computercraft.api.turtle.event.TurtleAction;
import dan200.computercraft.core.apis.http.options.Action; import dan200.computercraft.core.apis.http.options.Action;
import dan200.computercraft.core.apis.http.options.AddressRule; import dan200.computercraft.core.apis.http.options.AddressRule;
import dan200.computercraft.shared.Config; import dan200.computercraft.shared.Config;
@@ -12,10 +13,16 @@ import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.computer.core.ClientComputerRegistry; import dan200.computercraft.shared.computer.core.ClientComputerRegistry;
import dan200.computercraft.shared.computer.core.ServerComputerRegistry; import dan200.computercraft.shared.computer.core.ServerComputerRegistry;
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer; import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
import dan200.computercraft.shared.turtle.upgrades.*;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -38,10 +45,10 @@ public final class ComputerCraft
public static boolean httpEnabled = true; public static boolean httpEnabled = true;
public static boolean httpWebsocketEnabled = true; public static boolean httpWebsocketEnabled = true;
public static List<AddressRule> httpRules = List.of( public static List<AddressRule> httpRules = Collections.unmodifiableList( Arrays.asList(
AddressRule.parse( "$private", null, Action.DENY.toPartial() ), AddressRule.parse( "$private", null, Action.DENY.toPartial() ),
AddressRule.parse( "*", null, Action.ALLOW.toPartial() ) AddressRule.parse( "*", null, Action.ALLOW.toPartial() )
); ) );
public static int httpMaxRequests = 16; public static int httpMaxRequests = 16;
public static int httpMaxWebsockets = 4; public static int httpMaxWebsockets = 4;
@@ -55,7 +62,7 @@ public final class ComputerCraft
public static int modemHighAltitudeRangeDuringStorm = 384; public static int modemHighAltitudeRangeDuringStorm = 384;
public static int maxNotesPerTick = 8; public static int maxNotesPerTick = 8;
public static MonitorRenderer monitorRenderer = MonitorRenderer.BEST; public static MonitorRenderer monitorRenderer = MonitorRenderer.BEST;
public static int monitorDistance = 65; public static double monitorDistanceSq = 4096;
public static long monitorBandwidth = 1_000_000; public static long monitorBandwidth = 1_000_000;
public static boolean turtlesNeedFuel = true; public static boolean turtlesNeedFuel = true;
@@ -63,6 +70,7 @@ public final class ComputerCraft
public static int advancedTurtleFuelLimit = 100000; public static int advancedTurtleFuelLimit = 100000;
public static boolean turtlesObeyBlockProtection = true; public static boolean turtlesObeyBlockProtection = true;
public static boolean turtlesCanPush = true; public static boolean turtlesCanPush = true;
public static EnumSet<TurtleAction> turtleDisabledActions = EnumSet.noneOf( TurtleAction.class );
public static int computerTermWidth = 51; public static int computerTermWidth = 51;
public static int computerTermHeight = 19; public static int computerTermHeight = 19;
@@ -76,6 +84,27 @@ public final class ComputerCraft
public static int monitorWidth = 8; public static int monitorWidth = 8;
public static int monitorHeight = 6; public static int monitorHeight = 6;
public static final class TurtleUpgrades
{
public static TurtleModem wirelessModemNormal;
public static TurtleModem wirelessModemAdvanced;
public static TurtleSpeaker speaker;
public static TurtleCraftingTable craftingTable;
public static TurtleSword diamondSword;
public static TurtleShovel diamondShovel;
public static TurtleTool diamondPickaxe;
public static TurtleAxe diamondAxe;
public static TurtleHoe diamondHoe;
}
public static final class PocketUpgrades
{
public static PocketModem wirelessModemNormal;
public static PocketModem wirelessModemAdvanced;
public static PocketSpeaker speaker;
}
// Registries // Registries
public static final ClientComputerRegistry clientComputerRegistry = new ClientComputerRegistry(); public static final ClientComputerRegistry clientComputerRegistry = new ClientComputerRegistry();
public static final ServerComputerRegistry serverComputerRegistry = new ServerComputerRegistry(); public static final ServerComputerRegistry serverComputerRegistry = new ServerComputerRegistry();

View File

@@ -15,30 +15,30 @@ import dan200.computercraft.api.network.IPacketNetwork;
import dan200.computercraft.api.network.wired.IWiredElement; import dan200.computercraft.api.network.wired.IWiredElement;
import dan200.computercraft.api.network.wired.IWiredNode; import dan200.computercraft.api.network.wired.IWiredNode;
import dan200.computercraft.api.peripheral.IPeripheralProvider; import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider; import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.core.apis.ApiFactories; import dan200.computercraft.core.apis.ApiFactories;
import dan200.computercraft.core.asm.GenericMethod; import dan200.computercraft.core.asm.GenericMethod;
import dan200.computercraft.core.filesystem.FileMount; import dan200.computercraft.core.filesystem.FileMount;
import dan200.computercraft.core.filesystem.ResourceMount; import dan200.computercraft.core.filesystem.ResourceMount;
import dan200.computercraft.shared.BundledRedstone; import dan200.computercraft.shared.*;
import dan200.computercraft.shared.MediaProviders;
import dan200.computercraft.shared.Peripherals;
import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider; import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider;
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork; import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
import dan200.computercraft.shared.util.IDAssigner; import dan200.computercraft.shared.util.IDAssigner;
import dan200.computercraft.shared.wired.WiredNode; import dan200.computercraft.shared.wired.WiredNode;
import net.minecraft.core.BlockPos; import net.minecraft.resources.IReloadableResourceManager;
import net.minecraft.core.Direction; import net.minecraft.resources.IResourceManager;
import net.minecraft.resources.ResourceLocation; import net.minecraft.tileentity.TileEntity;
import net.minecraft.server.packs.resources.ReloadableResourceManager; import net.minecraft.util.Direction;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.level.BlockGetter; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.level.Level; import net.minecraft.world.IBlockReader;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import net.minecraftforge.server.ServerLifecycleHooks; import net.minecraftforge.fml.server.ServerLifecycleHooks;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
@@ -59,7 +59,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
public static InputStream getResourceFile( String domain, String subPath ) public static InputStream getResourceFile( String domain, String subPath )
{ {
ReloadableResourceManager manager = (ReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getResourceManager(); IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
try try
{ {
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream(); return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
@@ -81,13 +81,13 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
} }
@Override @Override
public int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath ) public int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
{ {
return IDAssigner.getNextId( parentSubPath ); return IDAssigner.getNextId( parentSubPath );
} }
@Override @Override
public IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity ) public IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
{ {
try try
{ {
@@ -102,7 +102,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
@Override @Override
public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath ) public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
{ {
ResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager(); IResourceManager manager = ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
ResourceMount mount = ResourceMount.get( domain, subPath, manager ); ResourceMount mount = ResourceMount.get( domain, subPath, manager );
return mount.exists( "" ) ? mount : null; return mount.exists( "" ) ? mount : null;
} }
@@ -125,6 +125,12 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
GenericPeripheralProvider.addCapability( capability ); GenericPeripheralProvider.addCapability( capability );
} }
@Override
public void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
{
TurtleUpgrades.register( upgrade );
}
@Override @Override
public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider ) public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider )
{ {
@@ -132,7 +138,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
} }
@Override @Override
public int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ) public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
{ {
return BundledRedstone.getDefaultOutput( world, pos, side ); return BundledRedstone.getDefaultOutput( world, pos, side );
} }
@@ -143,6 +149,12 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
MediaProviders.register( provider ); MediaProviders.register( provider );
} }
@Override
public void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
{
PocketUpgrades.register( upgrade );
}
@Nonnull @Nonnull
@Override @Override
public IPacketNetwork getWirelessNetwork() public IPacketNetwork getWirelessNetwork()
@@ -165,9 +177,9 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
@Nonnull @Nonnull
@Override @Override
public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side ) public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side )
{ {
BlockEntity tile = world.getBlockEntity( pos ); TileEntity tile = world.getBlockEntity( pos );
return tile == null ? LazyOptional.empty() : tile.getCapability( CAPABILITY_WIRED_ELEMENT, side ); return tile == null ? LazyOptional.empty() : tile.getCapability( CAPABILITY_WIRED_ELEMENT, side );
} }
} }

View File

@@ -17,11 +17,13 @@ import dan200.computercraft.api.network.wired.IWiredNode;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider; import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider; import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import net.minecraft.core.BlockPos; import dan200.computercraft.api.turtle.ITurtleUpgrade;
import net.minecraft.core.Direction; import net.minecraft.util.Direction;
import net.minecraft.world.level.BlockGetter; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.level.Level; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
@@ -36,14 +38,19 @@ import javax.annotation.Nullable;
*/ */
public final class ComputerCraftAPI public final class ComputerCraftAPI
{ {
public static final String MOD_ID = "computercraft";
@Nonnull @Nonnull
public static String getInstalledVersion() public static String getInstalledVersion()
{ {
return getInstance().getInstalledVersion(); return getInstance().getInstalledVersion();
} }
@Nonnull
@Deprecated
public static String getAPIVersion()
{
return getInstalledVersion();
}
/** /**
* Creates a numbered directory in a subfolder of the save directory for a given world, and returns that number. * Creates a numbered directory in a subfolder of the save directory for a given world, and returns that number.
* *
@@ -55,9 +62,9 @@ public final class ComputerCraftAPI
* *
* eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now * eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now
* available for writing. * available for writing.
* @see #createSaveDirMount(Level, String, long) * @see #createSaveDirMount(World, String, long)
*/ */
public static int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath ) public static int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
{ {
return getInstance().createUniqueNumberedSaveDir( world, parentSubPath ); return getInstance().createUniqueNumberedSaveDir( world, parentSubPath );
} }
@@ -74,14 +81,14 @@ public final class ComputerCraftAPI
* @param capacity The amount of data that can be stored in the directory before it fills up, in bytes. * @param capacity The amount of data that can be stored in the directory before it fills up, in bytes.
* @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable() * @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable()
* to mount this on a Computers' file system. * to mount this on a Computers' file system.
* @see #createUniqueNumberedSaveDir(Level, String) * @see #createUniqueNumberedSaveDir(World, String)
* @see IComputerAccess#mount(String, IMount) * @see IComputerAccess#mount(String, IMount)
* @see IComputerAccess#mountWritable(String, IWritableMount) * @see IComputerAccess#mountWritable(String, IWritableMount)
* @see IMount * @see IMount
* @see IWritableMount * @see IWritableMount
*/ */
@Nullable @Nullable
public static IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity ) public static IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
{ {
return getInstance().createSaveDirMount( world, subPath, capacity ); return getInstance().createSaveDirMount( world, subPath, capacity );
} }
@@ -111,7 +118,7 @@ public final class ComputerCraftAPI
} }
/** /**
* rers a peripheral provider to convert blocks into {@link IPeripheral} implementations. * Registers a peripheral provider to convert blocks into {@link IPeripheral} implementations.
* *
* @param provider The peripheral provider to register. * @param provider The peripheral provider to register.
* @see IPeripheral * @see IPeripheral
@@ -144,6 +151,19 @@ public final class ComputerCraftAPI
getInstance().registerGenericCapability( capability ); getInstance().registerGenericCapability( capability );
} }
/**
* Registers a new turtle turtle for use in ComputerCraft. After calling this,
* users should be able to craft Turtles with your new turtle. It is recommended to call
* this during the load() method of your mod.
*
* @param upgrade The turtle upgrade to register.
* @see ITurtleUpgrade
*/
public static void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
{
getInstance().registerTurtleUpgrade( upgrade );
}
/** /**
* Registers a bundled redstone provider to provide bundled redstone output for blocks. * Registers a bundled redstone provider to provide bundled redstone output for blocks.
* *
@@ -165,7 +185,7 @@ public final class ComputerCraftAPI
* If there is no block capable of emitting bundled redstone at the location, -1 will be returned. * If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
* @see IBundledRedstoneProvider * @see IBundledRedstoneProvider
*/ */
public static int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ) public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
{ {
return getInstance().getBundledRedstoneOutput( world, pos, side ); return getInstance().getBundledRedstoneOutput( world, pos, side );
} }
@@ -181,6 +201,11 @@ public final class ComputerCraftAPI
getInstance().registerMediaProvider( provider ); getInstance().registerMediaProvider( provider );
} }
public static void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
{
getInstance().registerPocketUpgrade( upgrade );
}
/** /**
* Attempt to get the game-wide wireless network. * Attempt to get the game-wide wireless network.
* *
@@ -219,7 +244,7 @@ public final class ComputerCraftAPI
* @see IWiredElement#getNode() * @see IWiredElement#getNode()
*/ */
@Nonnull @Nonnull
public static LazyOptional<IWiredElement> getWiredElementAt( @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side ) public static LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side )
{ {
return getInstance().getWiredElementAt( world, pos, side ); return getInstance().getWiredElementAt( world, pos, side );
} }
@@ -247,10 +272,10 @@ public final class ComputerCraftAPI
@Nonnull @Nonnull
String getInstalledVersion(); String getInstalledVersion();
int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath ); int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath );
@Nullable @Nullable
IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity ); IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity );
@Nullable @Nullable
IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath ); IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath );
@@ -261,12 +286,16 @@ public final class ComputerCraftAPI
void registerGenericCapability( @Nonnull Capability<?> capability ); void registerGenericCapability( @Nonnull Capability<?> capability );
void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade );
void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider ); void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider );
int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ); int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side );
void registerMediaProvider( @Nonnull IMediaProvider provider ); void registerMediaProvider( @Nonnull IMediaProvider provider );
void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade );
@Nonnull @Nonnull
IPacketNetwork getWirelessNetwork(); IPacketNetwork getWirelessNetwork();
@@ -276,6 +305,6 @@ public final class ComputerCraftAPI
IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element ); IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element );
@Nonnull @Nonnull
LazyOptional<IWiredElement> getWiredElementAt( @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side ); LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side );
} }
} }

View File

@@ -1,66 +0,0 @@
/*
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2022. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api;
import dan200.computercraft.ComputerCraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
/**
* Tags provided by ComputerCraft.
*/
public class ComputerCraftTags
{
public static class Items
{
public static final Tag.Named<Item> COMPUTER = make( "computer" );
public static final Tag.Named<Item> TURTLE = make( "turtle" );
public static final Tag.Named<Item> WIRED_MODEM = make( "wired_modem" );
public static final Tag.Named<Item> MONITOR = make( "monitor" );
private static Tag.Named<Item> make( String name )
{
return ItemTags.bind( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() );
}
}
public static class Blocks
{
public static final Tag.Named<Block> COMPUTER = make( "computer" );
public static final Tag.Named<Block> TURTLE = make( "turtle" );
public static final Tag.Named<Block> WIRED_MODEM = make( "wired_modem" );
public static final Tag.Named<Block> MONITOR = make( "monitor" );
/**
* Blocks which can be broken by any turtle tool.
*/
public static final Tag.Named<Block> TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" );
/**
* Blocks which can be broken by the default shovel tool.
*/
public static final Tag.Named<Block> TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" );
/**
* Blocks which can be broken with the default sword tool.
*/
public static final Tag.Named<Block> TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" );
/**
* Blocks which can be broken with the default hoe tool.
*/
public static final Tag.Named<Block> TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" );
private static Tag.Named<Block> make( String name )
{
return BlockTags.bind( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() );
}
}
}

View File

@@ -3,14 +3,13 @@
* Copyright Daniel Ratcliffe, 2011-2022. This API may be redistributed unmodified and in full only. * Copyright Daniel Ratcliffe, 2011-2022. 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. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
package dan200.computercraft.api.upgrades; package dan200.computercraft.api;
import dan200.computercraft.api.pocket.IPocketUpgrade; import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.ITurtleUpgrade;
import net.minecraft.Util; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.resources.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -77,25 +76,11 @@ public interface IUpgradeBase
// A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a // A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a
// null one. // null one.
CompoundTag shareTag = stack.getItem().getShareTag( stack ); CompoundNBT shareTag = stack.getItem().getShareTag( stack );
CompoundTag craftingShareTag = crafting.getItem().getShareTag( crafting ); CompoundNBT craftingShareTag = crafting.getItem().getShareTag( crafting );
if( shareTag == craftingShareTag ) return true; if( shareTag == craftingShareTag ) return true;
if( shareTag == null ) return craftingShareTag.isEmpty(); if( shareTag == null ) return craftingShareTag.isEmpty();
if( craftingShareTag == null ) return shareTag.isEmpty(); if( craftingShareTag == null ) return shareTag.isEmpty();
return shareTag.equals( craftingShareTag ); return shareTag.equals( craftingShareTag );
} }
/**
* Get a suitable default unlocalised adjective for an upgrade ID. This converts "modid:some_upgrade" to
* "upgrade.modid.some_upgrade.adjective".
*
* @param id The upgrade ID.
* @return The generated adjective.
* @see #getUnlocalisedAdjective()
*/
@Nonnull
static String getDefaultAdjective( @Nonnull ResourceLocation id )
{
return Util.makeDescriptionId( "upgrade", id ) + ".adjective";
}
} }

View File

@@ -5,12 +5,12 @@
*/ */
package dan200.computercraft.api.client; package dan200.computercraft.api.client;
import com.mojang.math.Transformation;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.resources.model.ModelManager; import net.minecraft.client.renderer.model.ModelManager;
import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.vector.TransformationMatrix;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Objects; import java.util.Objects;
@@ -20,19 +20,19 @@ import java.util.Objects;
*/ */
public final class TransformedModel public final class TransformedModel
{ {
private final BakedModel model; private final IBakedModel model;
private final Transformation matrix; private final TransformationMatrix matrix;
public TransformedModel( @Nonnull BakedModel model, @Nonnull Transformation matrix ) public TransformedModel( @Nonnull IBakedModel model, @Nonnull TransformationMatrix matrix )
{ {
this.model = Objects.requireNonNull( model ); this.model = Objects.requireNonNull( model );
this.matrix = Objects.requireNonNull( matrix ); this.matrix = Objects.requireNonNull( matrix );
} }
public TransformedModel( @Nonnull BakedModel model ) public TransformedModel( @Nonnull IBakedModel model )
{ {
this.model = Objects.requireNonNull( model ); this.model = Objects.requireNonNull( model );
matrix = Transformation.identity(); matrix = TransformationMatrix.identity();
} }
public static TransformedModel of( @Nonnull ModelResourceLocation location ) public static TransformedModel of( @Nonnull ModelResourceLocation location )
@@ -41,20 +41,20 @@ public final class TransformedModel
return new TransformedModel( modelManager.getModel( location ) ); return new TransformedModel( modelManager.getModel( location ) );
} }
public static TransformedModel of( @Nonnull ItemStack item, @Nonnull Transformation transform ) public static TransformedModel of( @Nonnull ItemStack item, @Nonnull TransformationMatrix transform )
{ {
BakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getItemModel( item ); IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getItemModel( item );
return new TransformedModel( model, transform ); return new TransformedModel( model, transform );
} }
@Nonnull @Nonnull
public BakedModel getModel() public IBakedModel getModel()
{ {
return model; return model;
} }
@Nonnull @Nonnull
public Transformation getMatrix() public TransformationMatrix getMatrix()
{ {
return matrix; return matrix;
} }

View File

@@ -7,7 +7,7 @@ package dan200.computercraft.api.filesystem;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import net.minecraft.world.level.Level; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
@@ -20,10 +20,10 @@ import java.util.List;
* {@link IComputerAccess#mount(String, IMount)}. * {@link IComputerAccess#mount(String, IMount)}.
* *
* Ready made implementations of this interface can be created using * Ready made implementations of this interface can be created using
* {@link ComputerCraftAPI#createSaveDirMount(Level, String, long)} or * {@link ComputerCraftAPI#createSaveDirMount(World, String, long)} or
* {@link ComputerCraftAPI#createResourceMount(String, String)}, or you're free to implement it yourselves! * {@link ComputerCraftAPI#createResourceMount(String, String)}, or you're free to implement it yourselves!
* *
* @see ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see ComputerCraftAPI#createResourceMount(String, String) * @see ComputerCraftAPI#createResourceMount(String, String)
* @see IComputerAccess#mount(String, IMount) * @see IComputerAccess#mount(String, IMount)
* @see IWritableMount * @see IWritableMount

View File

@@ -7,7 +7,7 @@ package dan200.computercraft.api.filesystem;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import net.minecraft.world.level.Level; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
@@ -20,9 +20,9 @@ import java.util.OptionalLong;
* or {@link IComputerAccess#mountWritable(String, IWritableMount)}, that can also be written to. * or {@link IComputerAccess#mountWritable(String, IWritableMount)}, that can also be written to.
* *
* Ready made implementations of this interface can be created using * Ready made implementations of this interface can be created using
* {@link ComputerCraftAPI#createSaveDirMount(Level, String, long)}, or you're free to implement it yourselves! * {@link ComputerCraftAPI#createSaveDirMount(World, String, long)}, or you're free to implement it yourselves!
* *
* @see ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see IComputerAccess#mount(String, IMount) * @see IComputerAccess#mount(String, IMount)
* @see IComputerAccess#mountWritable(String, IWritableMount) * @see IComputerAccess#mountWritable(String, IWritableMount)
* @see IMount * @see IMount

View File

@@ -9,7 +9,7 @@ import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider; import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.core.asm.LuaMethod; import dan200.computercraft.core.asm.LuaMethod;
import net.minecraft.resources.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;

View File

@@ -6,10 +6,10 @@
package dan200.computercraft.api.media; package dan200.computercraft.api.media;
import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IMount;
import net.minecraft.sounds.SoundEvent; import net.minecraft.item.Item;
import net.minecraft.world.item.Item; import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack; import net.minecraft.util.SoundEvent;
import net.minecraft.world.level.Level; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -78,11 +78,11 @@ public interface IMedia
* implements {@link dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable() * implements {@link dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable()
* @see IMount * @see IMount
* @see dan200.computercraft.api.filesystem.IWritableMount * @see dan200.computercraft.api.filesystem.IWritableMount
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(String, String) * @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(String, String)
*/ */
@Nullable @Nullable
default IMount createDataMount( @Nonnull ItemStack stack, @Nonnull Level world ) default IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
return null; return null;
} }

View File

@@ -5,7 +5,7 @@
*/ */
package dan200.computercraft.api.media; package dan200.computercraft.api.media;
import net.minecraft.world.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@@ -5,8 +5,8 @@
*/ */
package dan200.computercraft.api.network; package dan200.computercraft.api.network;
import net.minecraft.world.level.Level; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -21,7 +21,7 @@ public interface IPacketReceiver
* @return The receivers's world. * @return The receivers's world.
*/ */
@Nonnull @Nonnull
Level getLevel(); World getWorld();
/** /**
* Get the position in the world at which this receiver exists. * Get the position in the world at which this receiver exists.
@@ -29,7 +29,7 @@ public interface IPacketReceiver
* @return The receiver's position. * @return The receiver's position.
*/ */
@Nonnull @Nonnull
Vec3 getPosition(); Vector3d getPosition();
/** /**
* Get the maximum distance this receiver can send and receive messages. * Get the maximum distance this receiver can send and receive messages.

View File

@@ -5,8 +5,8 @@
*/ */
package dan200.computercraft.api.network; package dan200.computercraft.api.network;
import net.minecraft.world.level.Level; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -21,7 +21,7 @@ public interface IPacketSender
* @return The sender's world. * @return The sender's world.
*/ */
@Nonnull @Nonnull
Level getLevel(); World getWorld();
/** /**
* Get the position in the world at which this sender exists. * Get the position in the world at which this sender exists.
@@ -29,7 +29,7 @@ public interface IPacketSender
* @return The sender's position. * @return The sender's position.
*/ */
@Nonnull @Nonnull
Vec3 getPosition(); Vector3d getPosition();
/** /**
* Get some sort of identification string for this sender. This does not strictly need to be unique, but you * Get some sort of identification string for this sender. This does not strictly need to be unique, but you

View File

@@ -5,26 +5,113 @@
*/ */
package dan200.computercraft.api.network; package dan200.computercraft.api.network;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Objects;
/** /**
* Represents a packet which may be sent across a {@link IPacketNetwork}. * Represents a packet which may be sent across a {@link IPacketNetwork}.
* *
* @see IPacketSender
* @see IPacketNetwork#transmitSameDimension(Packet, double)
* @see IPacketNetwork#transmitInterdimensional(Packet)
* @see IPacketReceiver#receiveDifferentDimension(Packet)
* @see IPacketReceiver#receiveSameDimension(Packet, double)
*/
public class Packet
{
private final int channel;
private final int replyChannel;
private final Object payload;
private final IPacketSender sender;
/**
* Create a new packet, ready for transmitting across the network.
*
* @param channel The channel to send the packet along. Receiving devices should only process packets from on * @param channel The channel to send the packet along. Receiving devices should only process packets from on
* channels they are listening to. * channels they are listening to.
* @param replyChannel The channel to reply on. * @param replyChannel The channel to reply on.
* @param payload The contents of this packet. This should be a "valid" Lua object, safe for queuing as an * @param payload The contents of this packet. This should be a "valid" Lua object, safe for queuing as an
* event or returning from a peripheral call. * event or returning from a peripheral call.
* @param sender The object which sent this packet. * @param sender The object which sent this packet.
* @see IPacketSender
* @see IPacketNetwork#transmitSameDimension(Packet, double)
* @see IPacketNetwork#transmitInterdimensional(Packet)
* @see IPacketReceiver#receiveDifferentDimension(Packet)
* @see IPacketReceiver#receiveSameDimension(Packet, double)
*/ */
public record Packet( public Packet( int channel, int replyChannel, @Nullable Object payload, @Nonnull IPacketSender sender )
int channel, {
int replyChannel, Objects.requireNonNull( sender, "sender cannot be null" );
Object payload,
IPacketSender sender this.channel = channel;
) this.replyChannel = replyChannel;
{ this.payload = payload;
this.sender = sender;
}
/**
* Get the channel this packet is sent along. Receivers should generally only process packets from on channels they
* are listening to.
*
* @return This packet's channel.
*/
public int getChannel()
{
return channel;
}
/**
* The channel to reply on. Objects which will reply should send it along this channel.
*
* @return This channel to reply on.
*/
public int getReplyChannel()
{
return replyChannel;
}
/**
* The actual data of this packet. This should be a "valid" Lua object, safe for queuing as an
* event or returning from a peripheral call.
*
* @return The packet's payload
*/
@Nullable
public Object getPayload()
{
return payload;
}
/**
* The object which sent this message.
*
* @return The sending object.
*/
@Nonnull
public IPacketSender getSender()
{
return sender;
}
@Override
public boolean equals( Object o )
{
if( this == o ) return true;
if( o == null || getClass() != o.getClass() ) return false;
Packet packet = (Packet) o;
if( channel != packet.channel ) return false;
if( replyChannel != packet.replyChannel ) return false;
if( !Objects.equals( payload, packet.payload ) ) return false;
return sender.equals( packet.sender );
}
@Override
public int hashCode()
{
int result;
result = channel;
result = 31 * result + replyChannel;
result = 31 * result + (payload != null ? payload.hashCode() : 0);
result = 31 * result + sender.hashCode();
return result;
}
} }

View File

@@ -6,7 +6,7 @@
package dan200.computercraft.api.peripheral; package dan200.computercraft.api.peripheral;
import dan200.computercraft.api.lua.GenericSource; import dan200.computercraft.api.lua.GenericSource;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -15,7 +15,7 @@ import javax.annotation.Nonnull;
* A {@link GenericSource} which provides methods for a peripheral. * A {@link GenericSource} which provides methods for a peripheral.
* *
* Unlike a {@link GenericSource}, all methods <strong>should</strong> target the same type, for instance a * Unlike a {@link GenericSource}, all methods <strong>should</strong> target the same type, for instance a
* {@link BlockEntity} subclass or a capability interface. This is not currently enforced. * {@link TileEntity} subclass or a capability interface. This is not currently enforced.
*/ */
public interface GenericPeripheral extends GenericSource public interface GenericPeripheral extends GenericSource
{ {
@@ -23,7 +23,7 @@ public interface GenericPeripheral extends GenericSource
* Get the type of the exposed peripheral. * Get the type of the exposed peripheral.
* *
* Unlike normal {@link IPeripheral}s, {@link GenericPeripheral} do not have to have a type. By default, the * Unlike normal {@link IPeripheral}s, {@link GenericPeripheral} do not have to have a type. By default, the
* resulting peripheral uses the resource name of the wrapped {@link BlockEntity} (for instance {@code minecraft:chest}). * resulting peripheral uses the resource name of the wrapped {@link TileEntity} (for instance {@code minecraft:chest}).
* *
* However, in some cases it may be more appropriate to specify a more readable name. Overriding this method allows * However, in some cases it may be more appropriate to specify a more readable name. Overriding this method allows
* you to do so. * you to do so.

View File

@@ -12,7 +12,7 @@ import dan200.computercraft.api.lua.ILuaCallback;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.ILuaTask; import dan200.computercraft.api.lua.ILuaTask;
import dan200.computercraft.api.lua.MethodResult; import dan200.computercraft.api.lua.MethodResult;
import net.minecraft.world.level.Level; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -33,7 +33,7 @@ public interface IComputerAccess
* @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a
* file in the desired location. Store this value if you wish to unmount the mount later. * file in the desired location. Store this value if you wish to unmount the mount later.
* @throws NotAttachedException If the peripheral has been detached. * @throws NotAttachedException If the peripheral has been detached.
* @see ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see ComputerCraftAPI#createResourceMount(String, String) * @see ComputerCraftAPI#createResourceMount(String, String)
* @see #mount(String, IMount, String) * @see #mount(String, IMount, String)
* @see #mountWritable(String, IWritableMount) * @see #mountWritable(String, IWritableMount)
@@ -55,7 +55,7 @@ public interface IComputerAccess
* @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a
* file in the desired location. Store this value if you wish to unmount the mount later. * file in the desired location. Store this value if you wish to unmount the mount later.
* @throws NotAttachedException If the peripheral has been detached. * @throws NotAttachedException If the peripheral has been detached.
* @see ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see ComputerCraftAPI#createResourceMount(String, String) * @see ComputerCraftAPI#createResourceMount(String, String)
* @see #mount(String, IMount) * @see #mount(String, IMount)
* @see #mountWritable(String, IWritableMount) * @see #mountWritable(String, IWritableMount)
@@ -73,7 +73,7 @@ public interface IComputerAccess
* @return The location on the computer's file system where you the mount mounted, or null if there was already a * @return The location on the computer's file system where you the mount mounted, or null if there was already a
* file in the desired location. Store this value if you wish to unmount the mount later. * file in the desired location. Store this value if you wish to unmount the mount later.
* @throws NotAttachedException If the peripheral has been detached. * @throws NotAttachedException If the peripheral has been detached.
* @see ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see ComputerCraftAPI#createResourceMount(String, String) * @see ComputerCraftAPI#createResourceMount(String, String)
* @see #mount(String, IMount) * @see #mount(String, IMount)
* @see #unmount(String) * @see #unmount(String)
@@ -94,7 +94,7 @@ public interface IComputerAccess
* @return The location on the computer's file system where you the mount mounted, or null if there was already a * @return The location on the computer's file system where you the mount mounted, or null if there was already a
* file in the desired location. Store this value if you wish to unmount the mount later. * file in the desired location. Store this value if you wish to unmount the mount later.
* @throws NotAttachedException If the peripheral has been detached. * @throws NotAttachedException If the peripheral has been detached.
* @see ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see ComputerCraftAPI#createResourceMount(String, String) * @see ComputerCraftAPI#createResourceMount(String, String)
* @see #mount(String, IMount) * @see #mount(String, IMount)
* @see #unmount(String) * @see #unmount(String)

Some files were not shown because too many files have changed in this diff Show More