1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-16 14:37:39 +00:00

Compare commits

..

12 Commits

Author SHA1 Message Date
Jonathan Coates
aa89e51639 Bump CC:T to 1.101.3
0/10, would not recommend.
2023-07-06 23:54:44 +01:00
Jonathan Coates
7436447a6e Several command permission fixes
- Attach permission checks to the first argument (so the literal
   command name) rather than the last argument. This fixes commands
   showing up when they shouldn't.

 - HelpingArgumentBuilder now inherits permissions of its leaf nodes.
   This only really impacts the "track" subcommand.

 - Don't autocomplete the computer selector for the "queue" subcommand.
   As everyone has permission for this command, it's possible to find
   all computer ids and labels in the world.

   I'm in mixed minds about this, but don't think this is an exploit -
   computer ids/labels are sent to in-range players so shouldn't be
   considered secret - but worth patching none-the-less.
2023-07-06 23:41:23 +01:00
Jonathan Coates
f629831b12 Tighten up the $private HTTP rule
- Block multicast and the fd00::/8 address ranges.
 - Block several cloud metadata providers which sit outside the
   standard address ranges.
2023-07-06 23:27:17 +01:00
Jonathan Coates
f7fdb6e729 Backport a couple of ROM commits
- Improve REPL's handling of expressions
   (655d5aeca8)

 - Some tiny optimisations to the window API
   (4accda6b8e)

 - Be lazy in reporting errors in the lexer
   (54ab98473f)

 - Update lua.lua require logic.
   (88f0c44152)
2023-07-06 23:15:57 +01:00
Jonathan Coates
db2616d1c0 Don't (metaphorically) explode on null explosions
Closes #1423.
2023-05-03 23:38:12 +01:00
Jonathan Coates
c0f982dc97 Use correct model for the turtle modem
Introduced in 0c3de1087e, so should only
affect 1.16.5 and 1.18.2.

Fixes #1426
2023-05-03 23:34:22 +01:00
Jonathan Coates
2a9f35de5e Backport several ROM/Lua commits
- Fix GPS returning nan on duplicate positions.
 - Distinguish between all parsers passing and failing.
 - Improve several comma related parse errors.
 - Ignore metatables in textutils.serialize.
 - Detect common audio containers in "speaker".

Co-authored-by: Wojbie <Wojbie@gmail.com>
2023-05-03 23:26:44 +01:00
Jonathan Coates
0fce3212a3 Distinguish between all parsers passing and failing
Given an input like f(x), which is both a valid statement and
expression, both parsers would accept the whole input. However, this was
treated the same as both parsers rejecting the input, resulting in a
crash when trying to print the error.

We now return immediately when any parser accepts the input.

Fixes #1354
2023-03-11 22:45:50 +00:00
Jonathan Coates
652f954886 Merge pull request #1352 from MCJack123/lets-encrypt
Add certificate workaround for Let's Encrypt on 1.16
2023-03-04 11:11:33 +00:00
JackMacWindows
6f65bad9af Fixed CI 2023-03-04 02:02:05 -05:00
JackMacWindows
e4dd4dbef0 Added version check to certificate addition 2023-03-02 18:30:54 -05:00
MCJack123
e1dffaa334 Add certificate workaround for Let's Encrypt 2023-02-28 20:52:14 -05:00
617 changed files with 20619 additions and 12441 deletions

View File

@@ -14,7 +14,7 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 8
distribution: 'temurin'
- name: Setup Gradle

View File

@@ -17,7 +17,7 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 8
distribution: 'temurin'
- name: Setup Gradle

View File

@@ -43,10 +43,6 @@ minecraft {
// configureEach would be better, but we need to eagerly configure configs or otherwise the run task doesn't
// get set up properly.
all {
lazyToken("minecraft_classpath") {
configurations["shade"].copyRecursive().resolve().joinToString(File.pathSeparator) { it.absolutePath }
}
property("forge.logging.markers", "REGISTRIES")
property("forge.logging.console.level", "debug")
@@ -79,24 +75,6 @@ minecraft {
}
fun RunConfig.configureForGameTest() {
val old = lazyTokens.get("minecraft_classpath")
lazyToken("minecraft_classpath") {
// We do some terrible hacks here to basically find all things not already on the runtime classpath
// and add them. /Except/ for our source sets, as those need to load inside the Minecraft classpath.
val testMod = configurations["testModRuntimeClasspath"].resolve()
val implementation = configurations.runtimeClasspath.get().resolve()
val new = (testMod - implementation)
.asSequence()
.filter { it.isFile && !it.name.endsWith("-test-fixtures.jar") }
.map { it.absolutePath }
.joinToString(File.pathSeparator)
if (old == null) new else old.get() + File.pathSeparator + new
}
property("cctest.sources", file("src/testMod/resources/data/cctest").absolutePath)
arg("--mixin.config=computercraft-gametest.mixins.json")
mods.register("cctest") {
source(sourceSets["testMod"])
source(sourceSets["testFixtures"])
@@ -109,10 +87,12 @@ minecraft {
configureForGameTest()
}
val gameTestServer by registering {
val testServer by registering {
workingDirectory(file("run/testServer"))
parent(server.get())
configureForGameTest()
property("cctest.run", "true")
property("forge.logging.console.level", "info")
}
}
@@ -120,6 +100,7 @@ minecraft {
mappings("parchment", "${libs.versions.parchmentMc.get()}-${libs.versions.parchment.get()}-$mcVersion")
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
accessTransformer(file("src/testMod/resources/META-INF/accesstransformer.cfg"))
}
mixin {
@@ -139,14 +120,16 @@ configurations {
dependencies {
minecraft("net.minecraftforge:forge:$mcVersion-${libs.versions.forge.get()}")
annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
annotationProcessor("org.spongepowered:mixin:0.8.4:processor")
compileOnly(libs.jetbrainsAnnotations)
annotationProcessorEverywhere(libs.autoService)
"extraModsCompileOnly"(fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116:api"))
"extraModsRuntimeOnly"(fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116"))
"extraModsCompileOnly"(fg.deobf("maven.modrinth:oculus:1.18.2-1.2.5"))
"extraModsCompileOnly"(fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104:api"))
"extraModsRuntimeOnly"(fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104"))
"extraModsCompileOnly"(fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:7.1.0.313"))
"extraModsCompileOnly"(fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0"))
"shade"(libs.cobalt)
@@ -168,7 +151,7 @@ illuaminate {
tasks.javadoc {
include("dan200/computercraft/api/**/*.java")
(options as StandardJavadocDocletOptions).links("https://docs.oracle.com/en/java/javase/17/docs/api/")
(options as StandardJavadocDocletOptions).links("https://docs.oracle.com/javase/8/docs/api/")
}
val apiJar by tasks.registering(Jar::class) {
@@ -194,7 +177,7 @@ val luaJavadoc by tasks.registering(Javadoc::class) {
javadocTool.set(
javaToolchains.javadocToolFor {
languageVersion.set(cc.tweaked.gradle.CCTweakedPlugin.JAVA_VERSION)
languageVersion.set(JavaLanguageVersion.of(11))
},
)
}
@@ -337,14 +320,25 @@ val lintLua by tasks.registering(IlluaminateExec::class) {
doLast { if (System.getenv("GITHUB_ACTIONS") != null) println("::remove-matcher owner=illuaminate::") }
}
val setupRunGametest by tasks.registering(Copy::class) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Sets up the environment for the test server."
from("src/testMod/server-files") {
include("eula.txt")
include("server.properties")
}
into("run/testServer")
}
val runGametest by tasks.registering(JavaExec::class) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Runs tests on a temporary Minecraft instance."
dependsOn("cleanRunGametest")
dependsOn(setupRunGametest, "cleanRunGametest")
// Copy from runGameTestServer. We do it in this slightly odd way as runGameTestServer
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
// isn't created until the task is configured (which is no good for us).
val exec = tasks.getByName<JavaExec>("runGameTestServer")
val exec = tasks.getByName<JavaExec>("runTestServer")
dependsOn(exec.dependsOn)
exec.copyToFull(this)
}

View File

@@ -13,6 +13,6 @@ class CCTweakedPlugin : Plugin<Project> {
}
companion object {
val JAVA_VERSION = JavaLanguageVersion.of(17)
val JAVA_VERSION = JavaLanguageVersion.of(8)
}
}

View File

@@ -58,29 +58,20 @@
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<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="UnnecessaryParentheses" />
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
<module name="UnnecessarySemicolonInTryWithResources" />
<module name="UnnecessarySemicolonInEnumeration" />
<!-- Imports -->
<module name="CustomImportOrder">
<property name="customImportOrderRules"
value="THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"
/>
</module>
<module name="CustomImportOrder" />
<module name="IllegalImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />
<!-- Javadoc -->
<!-- TODO: Missing* checks for the dan200.computercraft.api package? -->
<module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
</module>
<module name="AtclauseOrder" />
<module name="InvalidJavadocPosition" />
<module name="JavadocBlockTagLocation" />
<module name="JavadocMethod"/>
@@ -109,9 +100,7 @@
<module name="LocalFinalVariableName" />
<module name="LocalVariableName" />
<module name="MemberName" />
<module name="MethodName">
<property name="format" value="^(computercraft\$)?[a-z][a-zA-Z0-9]*$" />
</module>
<module name="MethodName" />
<module name="MethodTypeParameterName" />
<module name="PackageName">
<property name="format" value="^dan200\.computercraft(\.[a-z][a-z0-9]*)*" />
@@ -119,6 +108,11 @@
<module name="ParameterName" />
<module name="StaticVariableName">
<property name="format" value="^[a-z][a-zA-Z0-9]*|CAPABILITY(_[A-Z_]+)?$" />
<property name="applyToPrivate" value="false" />
</module>
<module name="StaticVariableName">
<property name="format" value="^(s_)?[a-z][a-zA-Z0-9]*|CAPABILITY(_[A-Z_]+)?$" />
<property name="applyToPrivate" value="true" />
</module>
<module name="TypeName" />
@@ -162,7 +156,6 @@
<property name="allowEmptyLambdas" value="true" />
<property name="allowEmptyMethods" 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" />
</module>

View File

@@ -3,6 +3,6 @@ FROM gitpod/workspace-base
USER gitpod
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 update-java-alternatives --set java-1.16.0-openjdk-amd64
&& sudo update-java-alternatives --set java-1.8.0-openjdk-amd64

View File

@@ -5,7 +5,7 @@ kotlin.stdlib.default.dependency=false
kotlin.jvm.target.validation.mode=error
# Mod properties
modVersion=1.101.2
modVersion=1.101.3
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
mcVersion=1.18.2
mcVersion=1.16.5

View File

@@ -2,9 +2,9 @@
# Minecraft
# MC version is specified in gradle.properties, as we need that in settings.gradle.
forge = "40.1.0"
parchment = "2022.03.13"
parchmentMc = "1.18.2"
forge = "36.2.34"
parchment = "2021.08.08"
parchmentMc = "1.16.5"
autoService = "1.0.1"
cobalt = "0.6.0"
@@ -19,7 +19,7 @@ junit = "5.9.1"
# Build tools
cctJavadoc = "1.5.2"
checkstyle = "10.3.4"
checkstyle = "8.25" # There's a reason we're pinned on an ancient version, but I can't remember what it is.
curseForgeGradle = "1.0.11"
forgeGradle = "5.1.+"
githubRelease = "2.2.12"

View File

@@ -3,8 +3,8 @@
{
"when": {
"OR": [
{"up": "true", "north": "false", "west": "false", "south": "false", "east": "false", "cable": "true"},
{"north": "false", "west": "false", "south": "false", "east": "false", "down": "true", "cable": "true"}
{"east": "false", "north": "false", "south": "false", "cable": "true", "up": "true", "west": "false"},
{"down": "true", "east": "false", "north": "false", "south": "false", "cable": "true", "west": "false"}
]
},
"apply": {"model": "computercraft:block/cable_core_facing", "x": 90}
@@ -13,16 +13,16 @@
"when": {
"OR": [
{
"up": "false",
"north": "false",
"west": "false",
"south": "false",
"east": "false",
"down": "false",
"cable": "true"
"east": "false",
"north": "false",
"south": "false",
"cable": "true",
"up": "false",
"west": "false"
},
{"up": "false", "west": "false", "north": "true", "east": "false", "down": "false", "cable": "true"},
{"up": "false", "west": "false", "south": "true", "east": "false", "down": "false", "cable": "true"}
{"down": "false", "east": "false", "north": "true", "cable": "true", "up": "false", "west": "false"},
{"down": "false", "east": "false", "south": "true", "cable": "true", "up": "false", "west": "false"}
]
},
"apply": {"model": "computercraft:block/cable_core_facing", "y": 0}
@@ -30,8 +30,8 @@
{
"when": {
"OR": [
{"up": "false", "north": "false", "south": "false", "east": "true", "down": "false", "cable": "true"},
{"up": "false", "north": "false", "west": "true", "south": "false", "down": "false", "cable": "true"}
{"down": "false", "east": "true", "north": "false", "south": "false", "cable": "true", "up": "false"},
{"down": "false", "north": "false", "south": "false", "cable": "true", "up": "false", "west": "true"}
]
},
"apply": {"model": "computercraft:block/cable_core_facing", "y": 90}
@@ -39,18 +39,18 @@
{
"when": {
"OR": [
{"north": "true", "down": "true", "cable": "true"},
{"south": "true", "down": "true", "cable": "true"},
{"west": "true", "down": "true", "cable": "true"},
{"east": "true", "down": "true", "cable": "true"},
{"up": "true", "north": "true", "cable": "true"},
{"up": "true", "south": "true", "cable": "true"},
{"up": "true", "west": "true", "cable": "true"},
{"up": "true", "east": "true", "cable": "true"},
{"north": "true", "west": "true", "cable": "true"},
{"north": "true", "east": "true", "cable": "true"},
{"west": "true", "south": "true", "cable": "true"},
{"south": "true", "east": "true", "cable": "true"}
{"down": "true", "north": "true", "cable": "true"},
{"down": "true", "south": "true", "cable": "true"},
{"down": "true", "cable": "true", "west": "true"},
{"down": "true", "east": "true", "cable": "true"},
{"north": "true", "cable": "true", "up": "true"},
{"south": "true", "cable": "true", "up": "true"},
{"cable": "true", "up": "true", "west": "true"},
{"east": "true", "cable": "true", "up": "true"},
{"north": "true", "cable": "true", "west": "true"},
{"east": "true", "north": "true", "cable": "true"},
{"south": "true", "cable": "true", "west": "true"},
{"east": "true", "south": "true", "cable": "true"}
]
},
"apply": {"model": "computercraft:block/cable_core_any"}

View File

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

View File

@@ -11,9 +11,7 @@
"conditions": {
"items": [
{
"items": [
"computercraft:computer_normal"
]
"item": "computercraft:computer_normal"
},
{
"tag": "forge:ingots/gold"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,9 +11,7 @@
"conditions": {
"items": [
{
"items": [
"computercraft:pocket_computer_normal"
]
"item": "computercraft:pocket_computer_normal"
},
{
"tag": "forge:ingots/gold"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,9 +11,7 @@
"conditions": {
"items": [
{
"items": [
"computercraft:turtle_normal"
]
"item": "computercraft:turtle_normal"
},
{
"tag": "forge:ingots/gold"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,9 +11,7 @@
"conditions": {
"items": [
{
"items": [
"computercraft:computer_advanced"
]
"item": "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

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
@@ -24,8 +23,7 @@
]
},
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:dynamic",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:dynamic",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:dynamic",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:dynamic",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:dynamic",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

@@ -2,8 +2,7 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"rolls": 1,
"entries": [
{
"type": "minecraft:item",

View File

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

View File

@@ -1,7 +1,6 @@
{
"replace": false,
"values": [
"#minecraft:mineable/shovel",
"minecraft:melon",
"minecraft: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,17 +5,20 @@
*/
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.AddressRule;
import dan200.computercraft.shared.Config;
import dan200.computercraft.shared.Registry;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import java.util.OptionalInt;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Mod( ComputerCraft.MOD_ID )
@@ -37,10 +40,10 @@ public final class ComputerCraft
public static boolean httpEnabled = 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", OptionalInt.empty(), Action.DENY.toPartial() ),
AddressRule.parse( "*", OptionalInt.empty(), Action.ALLOW.toPartial() )
);
) );
public static int httpMaxRequests = 16;
public static int httpMaxWebsockets = 4;
@@ -54,7 +57,7 @@ public final class ComputerCraft
public static int modemHighAltitudeRangeDuringStorm = 384;
public static int maxNotesPerTick = 8;
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 boolean turtlesNeedFuel = true;
@@ -62,6 +65,7 @@ public final class ComputerCraft
public static int advancedTurtleFuelLimit = 100000;
public static boolean turtlesObeyBlockProtection = true;
public static boolean turtlesCanPush = true;
public static EnumSet<TurtleAction> turtleDisabledActions = EnumSet.noneOf( TurtleAction.class );
public static int computerTermWidth = 51;
public static int computerTermHeight = 19;
@@ -77,7 +81,28 @@ public final class ComputerCraft
public static int uploadNagDelay = 5;
public static final Logger log = LoggerFactory.getLogger( MOD_ID );
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;
}
public static final Logger log = LogManager.getLogger( MOD_ID );
public ComputerCraft()
{

View File

@@ -18,16 +18,16 @@ import dan200.computercraft.api.network.IPacketNetwork;
import dan200.computercraft.api.network.wired.IWiredElement;
import dan200.computercraft.api.network.wired.IWiredNode;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.core.apis.ApiFactories;
import dan200.computercraft.core.asm.GenericMethod;
import dan200.computercraft.core.filesystem.FileMount;
import dan200.computercraft.shared.computer.core.ResourceMount;
import dan200.computercraft.core.filesystem.ResourceMount;
import dan200.computercraft.impl.ComputerCraftAPIService;
import dan200.computercraft.impl.detail.DetailRegistryImpl;
import dan200.computercraft.shared.BundledRedstone;
import dan200.computercraft.shared.MediaProviders;
import dan200.computercraft.shared.Peripherals;
import dan200.computercraft.shared.*;
import dan200.computercraft.shared.computer.core.ServerContext;
import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider;
import dan200.computercraft.shared.peripheral.generic.data.BlockData;
@@ -35,20 +35,20 @@ import dan200.computercraft.shared.peripheral.generic.data.FluidData;
import dan200.computercraft.shared.peripheral.generic.data.ItemData;
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
import dan200.computercraft.shared.wired.WiredNode;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.resources.IResourceManager;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.server.ServerLifecycleHooks;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import javax.annotation.Nonnull;
import java.io.File;
@@ -68,7 +68,7 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIService
public static InputStream getResourceFile( MinecraftServer server, String domain, String subPath )
{
ResourceManager manager = server.getResourceManager();
IResourceManager manager = server.getDataPackRegistries().getResourceManager();
try
{
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
@@ -90,13 +90,13 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIService
}
@Override
public int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath )
public int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
{
return ServerContext.get( world.getServer() ).getNextId( parentSubPath );
}
@Override
public IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity )
public IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
{
try
{
@@ -111,7 +111,7 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIService
@Override
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 );
return mount.exists( "" ) ? mount : null;
}
@@ -134,6 +134,12 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIService
GenericPeripheralProvider.addCapability( capability );
}
@Override
public void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
{
TurtleUpgrades.register( upgrade );
}
@Override
public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider )
{
@@ -141,7 +147,7 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIService
}
@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 );
}
@@ -152,6 +158,12 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIService
MediaProviders.register( provider );
}
@Override
public void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
{
PocketUpgrades.register( upgrade );
}
@Nonnull
@Override
public IPacketNetwork getWirelessNetwork()
@@ -197,9 +209,9 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIService
@Nonnull
@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 );
}

View File

@@ -20,13 +20,15 @@ import dan200.computercraft.api.network.wired.IWiredNode;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.impl.ComputerCraftAPIService;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
@@ -42,14 +44,19 @@ import javax.annotation.Nullable;
*/
public final class ComputerCraftAPI
{
public static final String MOD_ID = "computercraft";
@Nonnull
public static String 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.
* <p>
@@ -61,9 +68,9 @@ public final class ComputerCraftAPI
* <p>
* eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now
* 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 );
}
@@ -80,14 +87,14 @@ public final class ComputerCraftAPI
* @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()
* to mount this on a Computers' file system.
* @see #createUniqueNumberedSaveDir(Level, String)
* @see #createUniqueNumberedSaveDir(World, String)
* @see IComputerAccess#mount(String, IMount)
* @see IComputerAccess#mountWritable(String, IWritableMount)
* @see IMount
* @see IWritableMount
*/
@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 );
}
@@ -150,6 +157,19 @@ public final class ComputerCraftAPI
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.
*
@@ -171,7 +191,7 @@ 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 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 );
}
@@ -187,6 +207,11 @@ public final class ComputerCraftAPI
getInstance().registerMediaProvider( provider );
}
public static void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
{
getInstance().registerPocketUpgrade( upgrade );
}
/**
* Attempt to get the game-wide wireless network.
*
@@ -241,7 +266,7 @@ public final class ComputerCraftAPI
* @see IWiredElement#getNode()
*/
@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 );
}

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.TagKey;
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 TagKey<Item> COMPUTER = make( "computer" );
public static final TagKey<Item> TURTLE = make( "turtle" );
public static final TagKey<Item> WIRED_MODEM = make( "wired_modem" );
public static final TagKey<Item> MONITOR = make( "monitor" );
private static TagKey<Item> make( String name )
{
return ItemTags.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) );
}
}
public static class Blocks
{
public static final TagKey<Block> COMPUTER = make( "computer" );
public static final TagKey<Block> TURTLE = make( "turtle" );
public static final TagKey<Block> WIRED_MODEM = make( "wired_modem" );
public static final TagKey<Block> MONITOR = make( "monitor" );
/**
* Blocks which can be broken by any turtle tool.
*/
public static final TagKey<Block> TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" );
/**
* Blocks which can be broken by the default shovel tool.
*/
public static final TagKey<Block> TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" );
/**
* Blocks which can be broken with the default sword tool.
*/
public static final TagKey<Block> TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" );
/**
* Blocks which can be broken with the default hoe tool.
*/
public static final TagKey<Block> TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" );
private static TagKey<Block> make( String name )
{
return BlockTags.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) );
}
}
}

View File

@@ -3,14 +3,13 @@
* 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.upgrades;
package dan200.computercraft.api;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import net.minecraft.Util;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
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
// null one.
CompoundTag shareTag = stack.getItem().getShareTag( stack );
CompoundTag craftingShareTag = crafting.getItem().getShareTag( crafting );
CompoundNBT shareTag = stack.getItem().getShareTag( stack );
CompoundNBT craftingShareTag = crafting.getItem().getShareTag( crafting );
if( shareTag == craftingShareTag ) return true;
if( shareTag == null ) return craftingShareTag.isEmpty();
if( craftingShareTag == null ) return shareTag.isEmpty();
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,13 +5,13 @@
*/
package dan200.computercraft.api.client;
import com.mojang.math.Transformation;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ModelManager;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.TransformationMatrix;
import javax.annotation.Nonnull;
import java.util.Objects;
@@ -21,19 +21,19 @@ import java.util.Objects;
*/
public final class TransformedModel
{
private final BakedModel model;
private final Transformation matrix;
private final IBakedModel model;
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.matrix = Objects.requireNonNull( matrix );
}
public TransformedModel( @Nonnull BakedModel model )
public TransformedModel( @Nonnull IBakedModel model )
{
this.model = Objects.requireNonNull( model );
matrix = Transformation.identity();
matrix = TransformationMatrix.identity();
}
public static TransformedModel of( @Nonnull ModelResourceLocation location )
@@ -48,20 +48,20 @@ public final class TransformedModel
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 );
}
@Nonnull
public BakedModel getModel()
public IBakedModel getModel()
{
return model;
}
@Nonnull
public Transformation getMatrix()
public TransformationMatrix getMatrix()
{
return matrix;
}

View File

@@ -5,8 +5,8 @@
*/
package dan200.computercraft.api.detail;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.HashMap;

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