mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-01 22:22:59 +00:00
Compare commits
32 Commits
v1.19-1.10
...
v1.16.5-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2041f7438 | ||
|
|
d61202e2b8 | ||
|
|
6ce88a7dcf | ||
|
|
5d65b3e654 | ||
|
|
abf857f864 | ||
|
|
ebef3117f2 | ||
|
|
b28c1ac8e0 | ||
|
|
ba976f9a16 | ||
|
|
969feb4a1c | ||
|
|
bd5de11ad5 | ||
|
|
5366fcb9c8 | ||
|
|
6335e77da6 | ||
|
|
4cfd0a2d1c | ||
|
|
be3a960273 | ||
|
|
954254e7e4 | ||
|
|
56f0e0674f | ||
|
|
4e438df9ad | ||
|
|
51c3a9d8af | ||
|
|
d967730085 | ||
|
|
d6afee8deb | ||
|
|
41bddcab9f | ||
|
|
b8d7695392 | ||
|
|
b7fa4102df | ||
|
|
718111787c | ||
|
|
d1e952770d | ||
|
|
2d30208631 | ||
|
|
03f50f9298 | ||
|
|
1a0e3fc2fa | ||
|
|
6d5b13dbbc | ||
|
|
f9f8233ef4 | ||
|
|
b7f698d6f7 | ||
|
|
93f3cd4a53 |
2
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@@ -9,8 +9,8 @@ body:
|
||||
description: What version of Minecraft are you using?
|
||||
options:
|
||||
- 1.16.x
|
||||
- 1.17.x
|
||||
- 1.18.x
|
||||
- 1.19.x
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
|
||||
133
CODE_OF_CONDUCT.md
Normal file
133
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,133 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
"conduct AT squiddev DOT cc". All complaints will be reviewed and investigated
|
||||
promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
@@ -35,7 +35,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fg.deobf("org.squiddev:cc-tweaked-${mc_version}:${cct_version}")
|
||||
compileOnly fg.deobf("org.squiddev:cc-tweaked-${mc_version}:${cct_version}:api")
|
||||
runtimeOnly fg.deobf("org.squiddev:cc-tweaked-${mc_version}:${cct_version}")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
298
build.gradle
298
build.gradle
@@ -1,30 +1,19 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = "https://maven.minecraftforge.net" }
|
||||
maven { url = 'https://maven.parchmentmc.org' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+'
|
||||
classpath "org.spongepowered:mixingradle:0.7.+"
|
||||
classpath 'org.parchmentmc:librarian:1.+'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "checkstyle"
|
||||
id "jacoco"
|
||||
id "maven-publish"
|
||||
id "com.github.hierynomus.license" version "0.16.1"
|
||||
id "org.cadixdev.licenser" version "0.6.1"
|
||||
id "com.matthewprenger.cursegradle" version "1.4.0"
|
||||
id "com.github.breadmoirai.github-release" version "2.2.12"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.6.0"
|
||||
id "com.modrinth.minotaur" version "1.2.1"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.7.0"
|
||||
id "com.modrinth.minotaur" version "2.+"
|
||||
id "net.minecraftforge.gradle" version "5.1.+"
|
||||
id "org.spongepowered.mixin" version "0.7.+"
|
||||
id "org.parchmentmc.librarian.forgegradle" version "1.+"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: "org.spongepowered.mixin"
|
||||
apply plugin: 'org.parchmentmc.librarian.forgegradle'
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
version = mod_version
|
||||
|
||||
@@ -39,12 +28,7 @@ java {
|
||||
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
tasks.withType(JavaExec).configureEach {
|
||||
javaLauncher = javaToolchains.launcherFor {
|
||||
languageVersion = javaVersion
|
||||
}
|
||||
registerFeature("extraMods") { usingSourceSet(sourceSets.main) }
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -60,6 +44,7 @@ minecraft {
|
||||
all {
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
forceExit = false
|
||||
|
||||
mods {
|
||||
computercraft {
|
||||
@@ -99,6 +84,9 @@ minecraft {
|
||||
workingDirectory project.file('test-files/server')
|
||||
parent runs.server
|
||||
|
||||
property("cctest.run", "true")
|
||||
property("forge.logging.console.level", "info")
|
||||
|
||||
mods {
|
||||
cctest {
|
||||
source sourceSets.testMod
|
||||
@@ -117,6 +105,10 @@ mixin {
|
||||
add sourceSets.main, 'computercraft.mixins.refmap.json'
|
||||
}
|
||||
|
||||
reobf {
|
||||
shadowJar {}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
@@ -126,7 +118,7 @@ repositories {
|
||||
}
|
||||
|
||||
configurations {
|
||||
shade
|
||||
shade { transitive = false }
|
||||
implementation.extendsFrom shade
|
||||
cctJavadoc
|
||||
|
||||
@@ -140,11 +132,11 @@ dependencies {
|
||||
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104:api")
|
||||
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")
|
||||
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")
|
||||
|
||||
runtimeOnly 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 'org.squiddev:Cobalt:0.5.5'
|
||||
|
||||
@@ -152,26 +144,29 @@ dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
|
||||
testImplementation 'org.hamcrest:hamcrest:2.2'
|
||||
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.kotlin:kotlin-stdlib-jdk8:1.7.0'
|
||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2'
|
||||
|
||||
testModImplementation sourceSets.main.output
|
||||
|
||||
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.6'
|
||||
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.7'
|
||||
}
|
||||
|
||||
// Compile tasks
|
||||
|
||||
compileTestModJava {
|
||||
dependsOn(compileJava)
|
||||
}
|
||||
|
||||
javadoc {
|
||||
include "dan200/computercraft/api/**/*.java"
|
||||
}
|
||||
|
||||
task luaJavadoc(type: Javadoc) {
|
||||
def apiJar = tasks.register("apiJar", Jar.class) {
|
||||
archiveClassifier.set("api")
|
||||
from(sourceSets.main.output) {
|
||||
include "dan200/computercraft/api/**/*"
|
||||
}
|
||||
}
|
||||
assemble.dependsOn(apiJar)
|
||||
|
||||
def luaJavadoc = tasks.register("luaJavadoc", Javadoc.class) {
|
||||
description "Generates documentation for Java-side Lua functions."
|
||||
group "documentation"
|
||||
|
||||
@@ -189,6 +184,9 @@ task luaJavadoc(type: Javadoc) {
|
||||
}
|
||||
|
||||
jar {
|
||||
finalizedBy("reobfJar")
|
||||
|
||||
archiveClassifier.set("slim")
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title" : "computercraft",
|
||||
@@ -201,11 +199,24 @@ jar {
|
||||
"MixinConfigs" : "computercraft.mixins.json",
|
||||
])
|
||||
}
|
||||
|
||||
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
|
||||
[compileJava, compileTestJava, compileTestModJava].forEach {
|
||||
shadowJar {
|
||||
finalizedBy("reobfShadowJar")
|
||||
|
||||
archiveClassifier.set("")
|
||||
configurations = [project.configurations.shade]
|
||||
relocate("org.squiddev.cobalt", "cc.tweaked.internal.cobalt")
|
||||
minimize()
|
||||
}
|
||||
|
||||
assemble.dependsOn("shadowJar")
|
||||
|
||||
[
|
||||
tasks.named("compileJava", JavaCompile.class),
|
||||
tasks.named("compileTestJava", JavaCompile.class),
|
||||
tasks.named("compileTestModJava", JavaCompile.class)
|
||||
].forEach {
|
||||
it.configure {
|
||||
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
|
||||
}
|
||||
@@ -258,8 +269,8 @@ processResources {
|
||||
include 'data/computercraft/lua/rom/help/credits.txt'
|
||||
|
||||
expand 'version': mod_version,
|
||||
'mcversion': mc_version,
|
||||
'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
|
||||
'mcversion': mc_version,
|
||||
'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
@@ -274,16 +285,11 @@ sourcesJar {
|
||||
|
||||
// Web tasks
|
||||
|
||||
|
||||
import com.hierynomus.gradle.license.tasks.LicenseCheck
|
||||
import com.hierynomus.gradle.license.tasks.LicenseFormat
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
List<String> mkCommand(String command) {
|
||||
return Os.isFamily(Os.FAMILY_WINDOWS) ? ["cmd", "/c", command] : ["sh", "-c", command]
|
||||
}
|
||||
|
||||
task rollup(type: Exec) {
|
||||
def rollup = tasks.register("rollup", Exec.class) {
|
||||
group = "build"
|
||||
description = "Bundles JS into rollup"
|
||||
|
||||
@@ -296,9 +302,10 @@ task rollup(type: Exec) {
|
||||
commandLine mkCommand('"node_modules/.bin/rollup" --config rollup.config.js')
|
||||
}
|
||||
|
||||
task illuaminateDocs(type: Exec, dependsOn: [rollup, luaJavadoc]) {
|
||||
group = "build"
|
||||
def illuaminateDocs = tasks.register("illuaminateDocs", Exec.class) {
|
||||
group = "documentation"
|
||||
description = "Generates docs using Illuaminate"
|
||||
dependsOn(rollup, luaJavadoc)
|
||||
|
||||
inputs.files(fileTree("doc")).withPropertyName("docs")
|
||||
inputs.files(fileTree("src/main/resources/data/computercraft/lua/rom")).withPropertyName("lua rom")
|
||||
@@ -311,9 +318,10 @@ task illuaminateDocs(type: Exec, dependsOn: [rollup, luaJavadoc]) {
|
||||
commandLine mkCommand('"bin/illuaminate" doc-gen')
|
||||
}
|
||||
|
||||
task jsxDocs(type: Exec, dependsOn: [illuaminateDocs]) {
|
||||
group = "build"
|
||||
def jsxDocs = tasks.register("jsxDocs", Exec) {
|
||||
group = "documentation"
|
||||
description = "Post-processes documentation to statically render some dynamic content."
|
||||
dependsOn(illuaminateDocs)
|
||||
|
||||
inputs.files(fileTree("src/web")).withPropertyName("sources")
|
||||
inputs.file("src/generated/export/index.json").withPropertyName("export")
|
||||
@@ -322,10 +330,14 @@ task jsxDocs(type: Exec, dependsOn: [illuaminateDocs]) {
|
||||
inputs.files(fileTree("$buildDir/docs/lua"))
|
||||
outputs.dir("$buildDir/docs/site")
|
||||
|
||||
commandLine mkCommand('"node_modules/.bin/ts-node" --esm src/web/transform.tsx')
|
||||
commandLine mkCommand('"node_modules/.bin/ts-node" -T --esm src/web/transform.tsx')
|
||||
}
|
||||
|
||||
task docWebsite(type: Copy, dependsOn: [jsxDocs]) {
|
||||
def docWebsite = tasks.register("docWebsite", Copy.class) {
|
||||
group = "documentation"
|
||||
description = "Copy additional assets to the website directory."
|
||||
dependsOn(jsxDocs)
|
||||
|
||||
from('doc') {
|
||||
include 'logo.png'
|
||||
include 'images/**'
|
||||
@@ -360,48 +372,26 @@ jacocoTestReport {
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn jacocoTestReport
|
||||
test.finalizedBy("jacocoTestReport")
|
||||
|
||||
license {
|
||||
mapping("java", "SLASHSTAR_STYLE")
|
||||
strictCheck true
|
||||
header = file('config/license/main.txt')
|
||||
lineEnding = '\n'
|
||||
newLine = false
|
||||
|
||||
ext.year = Calendar.getInstance().get(Calendar.YEAR)
|
||||
}
|
||||
properties {
|
||||
year = Calendar.getInstance().get(Calendar.YEAR)
|
||||
}
|
||||
|
||||
[licenseMain, licenseFormatMain].forEach {
|
||||
it.configure {
|
||||
include("**/*.java")
|
||||
exclude("dan200/computercraft/api/**")
|
||||
header file('config/license/main.txt')
|
||||
include("**/*.java") // We could apply to Kotlin, but for now let's not
|
||||
matching("dan200/computercraft/api/**") {
|
||||
header = file('config/license/api.txt')
|
||||
}
|
||||
}
|
||||
|
||||
[licenseTest, licenseFormatTest, licenseTestMod, licenseFormatTestMod].forEach {
|
||||
it.configure {
|
||||
include("**/*.java")
|
||||
header file('config/license/main.txt')
|
||||
}
|
||||
}
|
||||
check.dependsOn("licenseCheck")
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
tasks.withType(LicenseFormat) {
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
task licenseAPI(type: LicenseCheck)
|
||||
task licenseFormatAPI(type: LicenseFormat)
|
||||
[licenseAPI, licenseFormatAPI].forEach {
|
||||
it.configure {
|
||||
source = sourceSets.main.java
|
||||
include("dan200/computercraft/api/**")
|
||||
header file('config/license/api.txt')
|
||||
}
|
||||
}
|
||||
|
||||
task setupServer(type: Copy) {
|
||||
def setupServer = tasks.register("setupServer", Copy.class) {
|
||||
group "test server"
|
||||
description "Sets up the environment for the test server."
|
||||
|
||||
@@ -412,62 +402,56 @@ task setupServer(type: Copy) {
|
||||
into "test-files/server"
|
||||
}
|
||||
|
||||
["Client", "Server"].forEach { name ->
|
||||
tasks.register("test$name", JavaExec.class).configure {
|
||||
it.group('In-game tests')
|
||||
it.description("Runs tests on a temporary Minecraft instance.")
|
||||
it.dependsOn(setupServer, "prepareRunTest$name", "cleanTest$name", 'compileTestModJava')
|
||||
def testServerClassDumpDir = new File(buildDir, "jacocoClassDump/runTestServer")
|
||||
|
||||
// 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).
|
||||
JavaExec exec = tasks.getByName("runTest$name")
|
||||
exec.copyTo(it)
|
||||
it.setClasspath(exec.getClasspath())
|
||||
it.mainClass = exec.mainClass
|
||||
it.setArgs(exec.getArgs())
|
||||
def testServer = tasks.register("testServer", JavaExec.class) {
|
||||
group("In-game tests")
|
||||
description("Runs tests on a temporary Minecraft instance.")
|
||||
dependsOn(setupServer, "cleanTestServer")
|
||||
finalizedBy("jacocoTestServerReport")
|
||||
|
||||
it.systemProperty('forge.logging.console.level', 'info')
|
||||
it.systemProperty('cctest.run', 'true')
|
||||
// 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).
|
||||
JavaExec exec = tasks.getByName("runTestServer")
|
||||
dependsOn(exec.getDependsOn())
|
||||
exec.copyTo(it)
|
||||
setClasspath(exec.getClasspath())
|
||||
mainClass = exec.mainClass
|
||||
javaLauncher = exec.javaLauncher
|
||||
setArgs(exec.getArgs())
|
||||
|
||||
// Jacoco and modlauncher don't play well together as the classes loaded in-game don't
|
||||
// match up with those written to disk. We get Jacoco to dump all classes to disk, and
|
||||
// use that when generating the report.
|
||||
def coverageOut = new File(buildDir, "jacocoClassDump/test$name")
|
||||
jacoco.applyTo(it)
|
||||
it.jacoco.setIncludes(["dan200.computercraft.*"])
|
||||
it.jacoco.setClassDumpDir(coverageOut)
|
||||
it.outputs.dir(coverageOut)
|
||||
// Older versions of modlauncher don't include a protection domain (and thus no code
|
||||
// source). Jacoco skips such classes by default, so we need to explicitly include them.
|
||||
it.jacoco.setIncludeNoLocationClasses(true)
|
||||
}
|
||||
// Jacoco and modlauncher don't play well together as the classes loaded in-game don't
|
||||
// match up with those written to disk. We get Jacoco to dump all classes to disk, and
|
||||
// use that when generating the report.
|
||||
jacoco.applyTo(it)
|
||||
it.jacoco.setIncludes(["dan200.computercraft.*"])
|
||||
it.jacoco.setClassDumpDir(testServerClassDumpDir)
|
||||
outputs.dir(testServerClassDumpDir)
|
||||
// Older versions of modlauncher don't include a protection domain (and thus no code
|
||||
// source). Jacoco skips such classes by default, so we need to explicitly include them.
|
||||
it.jacoco.setIncludeNoLocationClasses(true)
|
||||
}
|
||||
|
||||
tasks.register("jacocoTest${name}Report", JacocoReport.class).configure {
|
||||
it.group('In-game')
|
||||
it.description("Generate coverage reports for test$name")
|
||||
it.dependsOn("test$name")
|
||||
tasks.register("jacocoTestServerReport", JacocoReport.class) {
|
||||
group("In-game tests")
|
||||
description("Generate coverage reports for testServer")
|
||||
dependsOn(testServer)
|
||||
|
||||
it.executionData(new File(buildDir, "jacoco/test${name}.exec"))
|
||||
it.sourceDirectories.from(sourceSets.main.allJava.srcDirs)
|
||||
it.classDirectories.from(new File(buildDir, "jacocoClassDump/test$name"))
|
||||
executionData(new File(buildDir, "jacoco/testServer.exec"))
|
||||
sourceDirectories.from(sourceSets.main.allJava.srcDirs)
|
||||
classDirectories.from(testServerClassDumpDir)
|
||||
|
||||
it.reports {
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
}
|
||||
}
|
||||
|
||||
if (name != "Client" || project.findProperty('cc.tweaked.clientTests') == 'true') {
|
||||
// Don't run client tests unless explicitly opted into them. They're a bit of a faff
|
||||
// to run and pretty flakey.
|
||||
check.dependsOn("jacocoTest${name}Report")
|
||||
reports {
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn(testServer)
|
||||
|
||||
// Upload tasks
|
||||
|
||||
task checkRelease {
|
||||
def checkRelease = tasks.register("checkRelease") {
|
||||
group "upload"
|
||||
description "Verifies that everything is ready for a release"
|
||||
|
||||
@@ -505,44 +489,39 @@ task checkRelease {
|
||||
if (!ok) throw new IllegalStateException("Could not check release")
|
||||
}
|
||||
}
|
||||
check.dependsOn checkRelease
|
||||
check.dependsOn(checkRelease)
|
||||
|
||||
def isStable = true
|
||||
|
||||
curseforge {
|
||||
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
|
||||
project {
|
||||
id = '282001'
|
||||
releaseType = 'release'
|
||||
releaseType = isStable ? 'release' : 'alpha'
|
||||
changelog = "Release notes can be found on the GitHub repository (https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
|
||||
mainArtifact(shadowJar)
|
||||
|
||||
addGameVersion "${mc_version}"
|
||||
}
|
||||
}
|
||||
|
||||
import com.modrinth.minotaur.TaskModrinthUpload
|
||||
tasks.register('publishModrinth', TaskModrinthUpload.class).configure {
|
||||
dependsOn('assemble', 'reobfJar')
|
||||
onlyIf {
|
||||
project.hasProperty('modrinthApiKey')
|
||||
}
|
||||
|
||||
modrinth {
|
||||
token = project.hasProperty('modrinthApiKey') ? project.getProperty('modrinthApiKey') : ''
|
||||
projectId = 'gu7yAYhd'
|
||||
versionNumber = "${project.mc_version}-${project.mod_version}"
|
||||
uploadFile = jar
|
||||
addGameVersion(project.mc_version)
|
||||
versionName = "${project.mod_version}"
|
||||
versionType = isStable ? 'release' : 'alpha'
|
||||
uploadFile = shadowJar
|
||||
gameVersions = [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})."
|
||||
addLoader('forge')
|
||||
}
|
||||
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
// We can't generate metadata as that includes Forge as a dependency.
|
||||
enabled = false
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
artifact(apiJar)
|
||||
fg.component(it)
|
||||
|
||||
pom {
|
||||
name = 'CC: Tweaked'
|
||||
@@ -561,11 +540,9 @@ publishing {
|
||||
licenses {
|
||||
license {
|
||||
name = 'ComputerCraft Public License, Version 1.0'
|
||||
url = 'https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.15.x/LICENSE'
|
||||
url = 'https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.16.x/LICENSE'
|
||||
}
|
||||
}
|
||||
|
||||
withXml { asNode().remove(asNode().get("dependencies")) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -605,13 +582,14 @@ githubRelease {
|
||||
.takeWhile { it != 'Type "help changelog" to see the full version history.' }
|
||||
.join("\n").trim()
|
||||
}))
|
||||
prerelease false
|
||||
prerelease !isStable
|
||||
}
|
||||
|
||||
def uploadTasks = ["publish", "curseforge", "publishModrinth", "githubRelease"]
|
||||
uploadTasks.forEach { tasks.getByName(it).dependsOn checkRelease }
|
||||
def uploadTasks = ["publish", "curseforge", "modrinth", "githubRelease"]
|
||||
uploadTasks.forEach { tasks.named(it) { dependsOn(checkRelease) } }
|
||||
|
||||
task uploadAll(dependsOn: uploadTasks) {
|
||||
group "upload"
|
||||
description "Uploads to all repositories (Maven, Curse, Modrinth, GitHub release)"
|
||||
tasks.register("uploadAll") {
|
||||
group = "upload"
|
||||
description = "Uploads to all repositories (Maven, Curse, Modrinth, GitHub release)"
|
||||
dependsOn(uploadTasks)
|
||||
}
|
||||
|
||||
90
doc/guides/gps_setup.md
Normal file
90
doc/guides/gps_setup.md
Normal file
@@ -0,0 +1,90 @@
|
||||
---
|
||||
module: [kind=guide] gps_setup
|
||||
---
|
||||
|
||||
# Setting up GPS
|
||||
The @{gps} API allows computers and turtles to find their current position using wireless modems.
|
||||
|
||||
In order to use GPS, you'll need to set up multiple *GPS hosts*. These are computers running the special `gps host`
|
||||
program, which tell other computers the host's position. Several hosts running together are known as a *GPS
|
||||
constellation*.
|
||||
|
||||
In order to give the best results, a GPS constellation needs at least four computers. More than four GPS hosts per
|
||||
constellation is redundant, but it does not cause problems.
|
||||
|
||||
## Building a GPS constellation
|
||||
{.big-image}
|
||||
|
||||
We are going to build our GPS constellation as shown in the image above. You will need 4 computers and either 4 wireless
|
||||
modems or 4 ender modems. Try not to mix ender and wireless modems together as you might get some odd behavior when your
|
||||
requesting computers are out of range.
|
||||
|
||||
:::tip Ender modems vs wireless modems
|
||||
Ender modems have a very large range, which makes them very useful for setting up GPS hosts. If you do this then you
|
||||
will likely only need one GPS constellation for the whole dimension (such as the Overworld or Nether).
|
||||
|
||||
If you do use wireless modems then you may find that you need multiple GPS constellations to cover your needs.
|
||||
|
||||
A computer needs a wireless or ender modem and to be in range of a GPS constellation that is in the same dimension as it
|
||||
to use the GPS API. The reason for this is that ComputerCraft mimics real-life GPS by making use of the distance
|
||||
parameter of @{modem_message|modem messages} and some maths.
|
||||
:::
|
||||
|
||||
Locate where you want to place your GPS constellation. You will need an area at least 6 blocks high, 6 blocks wide, and
|
||||
6 blocks deep (6x6x6). If you are using wireless modems then you may want to build your constellation as high as you can
|
||||
because high altitude boosts modem message range and thus the radius that your constellation covers.
|
||||
|
||||
The GPS constellation will only work when it is in a loaded chunk. If you want your constellation to always be
|
||||
accessible, you may want to permanently load the chunk using a vanilla or modded chunk loader. Make sure that your 6x6x6
|
||||
area fits in a single chunk to reduce the number of chunks that need to be kept loaded.
|
||||
|
||||
Let's get started building the constellation! Place your first computer in one of the corners of your 6x6x6. Remember
|
||||
which computer this is as other computers need to be placed relative to it. Place the second computer 4 blocks above the
|
||||
first. Go back to your first computer and place your third computer 5 blocks in front of your first computer, leaving 4
|
||||
blocks of air between them. Finally for the fourth computer, go back to your first computer and place it 5 blocks right
|
||||
of your first computer, leaving 4 blocks of air between them.
|
||||
|
||||
With all four computers placed within the 6x6x6, place one modem on top of each computer. You should have 4 modems and 4
|
||||
computers all within your 6x6x6 where each modem is attached to a computer and each computer has a modem.
|
||||
|
||||
Currently your GPS constellation will not work, that's because each host is not aware that it's a GPS host. We will fix
|
||||
this in the next section.
|
||||
|
||||
## Configuring the constellation
|
||||
Now that the structure of your constellation is built, we need to configure each host in it.
|
||||
|
||||
Go back to the first computer that you placed and create a startup file, by running `edit startup`.
|
||||
|
||||
Type the following code into the file:
|
||||
```lua
|
||||
shell.run("gps", "host", x, y, z)
|
||||
```
|
||||
|
||||
Escape from the computer GUI and then press <kbd>F3</kbd> to open Minecraft's debug screen and then look at the computer
|
||||
(without opening the GUI). On the right of the screen about halfway down you should see an entry labeled `Targeted
|
||||
Block`, the numbers correspond to the position of the block that you are looking at. Replace `x` with the first number,
|
||||
`y` with the second number, and `z` with the third number.
|
||||
|
||||
For example, if I had a computer at x = 59, y = 5, z = -150, then my <kbd>F3</kbd> debug screen entry would be `Target
|
||||
Block: 59, 5, -150` and I would change my startup file to this `shell.run("gps", "host", 59, 5, -150)`.
|
||||
|
||||
To hide Minecraft's debug screen, press <kbd>F3</kbd> again.
|
||||
|
||||
Create similar startup files for the other computers in your constellation, making sure to input the each computer's own
|
||||
coordinates.
|
||||
|
||||
:::caution Modem messages come from the computer's position, not the modem's
|
||||
Wireless modems transmit from the block that they are attached to *not* the block space that they occupy, the
|
||||
coordinates that you input into your GPS host should be the position of the computer and not the position of the modem.
|
||||
:::
|
||||
|
||||
Congratulations, your constellation is now fully set up! You can test it by placing another computer close by, placing a
|
||||
wireless modem on it, and running the `gps locate` program (or calling the @{gps.locate} function).
|
||||
|
||||
:::info Why use Minecraft's coordinates?
|
||||
CC doesn't care if you use Minecraft's coordinate system, so long as all of the GPS hosts with overlapping ranges use
|
||||
the same reference point (requesting computers will get confused if hosts have different reference points). However,
|
||||
using MC's coordinate system does provide a nice standard to adopt server-wide. It also is consistent with how command
|
||||
computers get their location, they use MC's command system to get their block which returns that in MC's coordinate
|
||||
system.
|
||||
:::
|
||||
BIN
doc/images/gps-constellation-example.png
Normal file
BIN
doc/images/gps-constellation-example.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 331 KiB |
@@ -1,5 +1,8 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
kotlin.stdlib.default.dependency=false
|
||||
|
||||
# Mod properties
|
||||
mod_version=1.100.6
|
||||
mod_version=1.100.9
|
||||
|
||||
# Minecraft properties (update mods.toml when changing)
|
||||
mc_version=1.16.5
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
640
package-lock.json
generated
640
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^8.2.5",
|
||||
"@rollup/plugin-url": "^6.1.0",
|
||||
"@rollup/plugin-url": "^7.0.0",
|
||||
"@types/glob": "^7.2.0",
|
||||
"@types/react-dom": "^18.0.5",
|
||||
"glob": "^8.0.3",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = "cc-tweaked-${mc_version}"
|
||||
17
settings.gradle.kts
Normal file
17
settings.gradle.kts
Normal file
@@ -0,0 +1,17 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.minecraftforge.net")
|
||||
maven("https://maven.parchmentmc.org")
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "org.spongepowered.mixin") {
|
||||
useModule("org.spongepowered:mixingradle:${requested.version}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val mc_version: String by settings
|
||||
rootProject.name = "cc-tweaked-${mc_version}"
|
||||
@@ -115,8 +115,11 @@ public final class PrintoutRenderer
|
||||
}
|
||||
}
|
||||
|
||||
// Left half
|
||||
drawTexture( transform, buffer, x, y, z, X_FOLD_SIZE * 2, 0, X_SIZE / 2.0f, Y_SIZE, light );
|
||||
// Current page background: Z-offset is interleaved between the "zeroth" left/right page and the first
|
||||
// left/right page, so that the "bold" border can be drawn over the edge where appropriate.
|
||||
drawTexture( transform, buffer, x, y, z - 1e-3f * 0.5f, X_FOLD_SIZE * 2, 0, X_SIZE, Y_SIZE, light );
|
||||
|
||||
// Left pages
|
||||
for( int n = 0; n <= leftPages; n++ )
|
||||
{
|
||||
drawTexture( transform, buffer,
|
||||
@@ -127,8 +130,7 @@ public final class PrintoutRenderer
|
||||
);
|
||||
}
|
||||
|
||||
// Right half
|
||||
drawTexture( transform, buffer, x + X_SIZE / 2.0f, y, z, X_FOLD_SIZE * 2 + X_SIZE / 2.0f, 0, X_SIZE / 2.0f, Y_SIZE, light );
|
||||
// Right pages
|
||||
for( int n = 0; n <= rightPages; n++ )
|
||||
{
|
||||
drawTexture( transform, buffer,
|
||||
|
||||
@@ -224,7 +224,7 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
||||
|
||||
FixedWidthFontRenderer.drawBlocker(
|
||||
matrix, bufferSource.getBuffer( RenderTypes.TERMINAL_BLOCKER ),
|
||||
-xMargin, -yMargin, pixelWidth + xMargin, pixelHeight + yMargin
|
||||
-xMargin, -yMargin, pixelWidth + xMargin * 2, pixelHeight + yMargin * 2
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -47,13 +47,15 @@ public class TextBuffer
|
||||
public void write( ByteBuffer text, int start )
|
||||
{
|
||||
int pos = start;
|
||||
int bufferPos = text.position();
|
||||
|
||||
start = Math.max( start, 0 );
|
||||
int length = text.remaining();
|
||||
int end = Math.min( start + length, pos + length );
|
||||
end = Math.min( end, this.text.length );
|
||||
for( int i = start; i < end; i++ )
|
||||
{
|
||||
this.text[i] = (char) (text.get( i - pos ) & 0xFF);
|
||||
this.text[i] = (char) (text.get( bufferPos + i - pos ) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public final class Config
|
||||
builder.push( "http" );
|
||||
|
||||
httpEnabled = builder
|
||||
.comment( "Enable the \"http\" API on Computers (see \"rules\" for more fine grained control than this)." )
|
||||
.comment( "Enable the \"http\" API on Computers. This also disables the \"pastebin\" and \"wget\"\nprograms, that many users rely on. It's recommended to leave this on and use the\n\"rules\" config option to impose more fine-grained control." )
|
||||
.define( "enabled", ComputerCraft.httpEnabled );
|
||||
|
||||
httpWebsocketEnabled = builder
|
||||
|
||||
@@ -9,6 +9,8 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.network.client.*;
|
||||
import dan200.computercraft.shared.network.server.*;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -26,7 +28,8 @@ import java.util.function.Function;
|
||||
|
||||
public final class NetworkHandler
|
||||
{
|
||||
public static SimpleChannel network;
|
||||
private static SimpleChannel network;
|
||||
private static final IntSet usedIds = new IntOpenHashSet();
|
||||
|
||||
private NetworkHandler()
|
||||
{
|
||||
@@ -100,6 +103,7 @@ public final class NetworkHandler
|
||||
*/
|
||||
private static <T extends NetworkMessage> void registerMainThread( int id, NetworkDirection direction, Class<T> type, Function<PacketBuffer, T> decoder )
|
||||
{
|
||||
if( !usedIds.add( id ) ) throw new IllegalStateException( "Duplicate message kind for for id " + id );
|
||||
network.messageBuilder( type, id, direction )
|
||||
.encoder( NetworkMessage::toBytes )
|
||||
.decoder( decoder )
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
}
|
||||
|
||||
ITextComponent customName;
|
||||
private LockCode lockCode;
|
||||
private LockCode lockCode = LockCode.NO_LOCK;
|
||||
|
||||
private final Map<IComputerAccess, MountInfo> computers = new HashMap<>();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import dan200.computercraft.shared.util.NBTUtil;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.item.EnchantedBookItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
@@ -67,6 +68,7 @@ public class ItemData
|
||||
}
|
||||
|
||||
data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) );
|
||||
data.put( "itemGroups", getItemGroups( stack ) );
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
if( tag != null && tag.contains( "display", Constants.NBT.TAG_COMPOUND ) )
|
||||
@@ -116,6 +118,30 @@ public class ItemData
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all item groups an item stack pertains to.
|
||||
*
|
||||
* @param stack Stack to analyse
|
||||
* @return A filled list that contains pairs of item group IDs and their display names.
|
||||
*/
|
||||
@Nonnull
|
||||
private static List<Map<String, Object>> getItemGroups( @Nonnull ItemStack stack )
|
||||
{
|
||||
List<Map<String, Object>> groups = new ArrayList<>( 1 );
|
||||
|
||||
for( ItemGroup group : stack.getItem().getCreativeTabs() )
|
||||
{
|
||||
if( group == null ) continue;
|
||||
|
||||
Map<String, Object> groupData = new HashMap<>( 2 );
|
||||
groupData.put( "id", group.langId );
|
||||
groupData.put( "displayName", group.displayName.getString() );
|
||||
groups.add( groupData );
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all visible enchantments from given stack. Try to follow all tooltip rules : order and visibility.
|
||||
*
|
||||
|
||||
@@ -107,7 +107,9 @@ public class InventoryMethods implements GenericPeripheral
|
||||
*
|
||||
* The returned information contains the same information as each item in
|
||||
* {@link #list}, as well as additional details like the display name
|
||||
* (`displayName`) and item durability (`damage`, `maxDamage`, `durability`).
|
||||
* (`displayName`), item groups (`itemGroups`), which are the creative tabs
|
||||
* an item will appear under, and item and item durability (`damage`,
|
||||
* `maxDamage`, `durability`).
|
||||
*
|
||||
* Some items include more information (such as enchantments) - it is
|
||||
* recommended to print it out using @{textutils.serialize} or in the Lua
|
||||
@@ -127,6 +129,11 @@ public class InventoryMethods implements GenericPeripheral
|
||||
*
|
||||
* print(("%s (%s)"):format(item.displayName, item.name))
|
||||
* print(("Count: %d/%d"):format(item.count, item.maxCount))
|
||||
*
|
||||
* for _, group in pairs(item.itemGroups) do
|
||||
* print(("Group: %s"):format(group.displayName))
|
||||
* end
|
||||
*
|
||||
* if item.damage then
|
||||
* print(("Damage: %d/%d"):format(item.damage, item.maxDamage))
|
||||
* end
|
||||
@@ -166,7 +173,7 @@ public class InventoryMethods implements GenericPeripheral
|
||||
public static int getItemLimit( IItemHandler inventory, int slot ) throws LuaException
|
||||
{
|
||||
assertBetween( slot, 1, inventory.getSlots(), "Slot out of range (%s)" );
|
||||
return inventory.getSlotLimit( slot );
|
||||
return inventory.getSlotLimit( slot - 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
private static final int[] SIDE_SLOTS = new int[] { 0 };
|
||||
|
||||
ITextComponent customName;
|
||||
private LockCode lockCode;
|
||||
private LockCode lockCode = LockCode.NO_LOCK;
|
||||
|
||||
private final NonNullList<ItemStack> inventory = NonNullList.withSize( SLOTS, ItemStack.EMPTY );
|
||||
private final SidedCaps<IItemHandler> itemHandlerCaps =
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.Optional;
|
||||
* an internal inventory of 16 slots, allowing them to store blocks they have broken or would like to place.
|
||||
*
|
||||
* ## Movement
|
||||
* Turtles are capable of moving throug the world. As turtles are blocks themselves, they are confined to Minecraft's
|
||||
* Turtles are capable of moving through the world. As turtles are blocks themselves, they are confined to Minecraft's
|
||||
* grid, moving a single block at a time.
|
||||
*
|
||||
* {@literal @}{turtle.forward} and @{turtle.back} move the turtle in the direction it is facing, while @{turtle.up} and
|
||||
|
||||
@@ -11,3 +11,7 @@ public net.minecraft.client.Minecraft field_71462_r # currentScreen
|
||||
# SpeakerInstance/SpeakerManager
|
||||
public net.minecraft.client.audio.SoundSource func_216421_a(I)V # pumpBuffers
|
||||
public net.minecraft.client.audio.SoundEngine field_217940_j # executor
|
||||
|
||||
# ItemData
|
||||
public net.minecraft.item.ItemGroup field_78034_o # langId
|
||||
public net.minecraft.item.ItemGroup field_242391_q # displayName
|
||||
|
||||
135
src/main/resources/assets/computercraft/lang/nb_no.json
Normal file
135
src/main/resources/assets/computercraft/lang/nb_no.json
Normal file
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"itemGroup.computercraft": "ComputerCraft",
|
||||
"block.computercraft.computer_normal": "Datamaskin",
|
||||
"block.computercraft.computer_advanced": "Avansert Datamaskin",
|
||||
"block.computercraft.computer_command": "Kommando Datamaskin",
|
||||
"block.computercraft.disk_drive": "Diskstasjon",
|
||||
"block.computercraft.printer": "Printer",
|
||||
"block.computercraft.speaker": "Høytaler",
|
||||
"block.computercraft.monitor_normal": "Skjerm",
|
||||
"block.computercraft.monitor_advanced": "Avansert Skjerm",
|
||||
"block.computercraft.wireless_modem_normal": "Trådløst Modem",
|
||||
"block.computercraft.wireless_modem_advanced": "Ender Modem",
|
||||
"block.computercraft.wired_modem": "Kablet Modem",
|
||||
"block.computercraft.cable": "Nettverks kabel",
|
||||
"block.computercraft.wired_modem_full": "Kablet Modem",
|
||||
"block.computercraft.turtle_normal": "Skilpadde",
|
||||
"block.computercraft.turtle_normal.upgraded": "%s Skilpadde",
|
||||
"block.computercraft.turtle_normal.upgraded_twice": "%s %s Skilpadde",
|
||||
"block.computercraft.turtle_advanced": "Avansert Skilpadde",
|
||||
"block.computercraft.turtle_advanced.upgraded": "Avansert %s Skilpadde",
|
||||
"block.computercraft.turtle_advanced.upgraded_twice": "Avansert %s %s Skilpadde",
|
||||
"item.computercraft.disk": "Floppy Disk",
|
||||
"item.computercraft.treasure_disk": "Floppy Disk",
|
||||
"item.computercraft.printed_page": "Printet Side",
|
||||
"item.computercraft.printed_pages": "Printet Sider",
|
||||
"item.computercraft.printed_book": "Printet Bok",
|
||||
"item.computercraft.pocket_computer_normal": "Lomme datamaskin",
|
||||
"item.computercraft.pocket_computer_normal.upgraded": "%s Lomme Datamaskin",
|
||||
"item.computercraft.pocket_computer_advanced": "Avansert Lomme Datamaskin",
|
||||
"item.computercraft.pocket_computer_advanced.upgraded": "Avansert %s Lomme Datamaskin",
|
||||
"upgrade.minecraft.diamond_sword.adjective": "Kjempende",
|
||||
"upgrade.minecraft.diamond_shovel.adjective": "Gravende",
|
||||
"upgrade.minecraft.diamond_pickaxe.adjective": "Brytende",
|
||||
"upgrade.minecraft.diamond_axe.adjective": "Hoggende",
|
||||
"upgrade.minecraft.diamond_hoe.adjective": "Dyrkende",
|
||||
"upgrade.minecraft.crafting_table.adjective": "Håndverks",
|
||||
"upgrade.computercraft.wireless_modem_normal.adjective": "Trådløs",
|
||||
"upgrade.computercraft.wireless_modem_advanced.adjective": "Ender",
|
||||
"upgrade.computercraft.speaker.adjective": "Høylydt",
|
||||
"chat.computercraft.wired_modem.peripheral_connected": "Perifer \"%s\" koblet til nettverk",
|
||||
"chat.computercraft.wired_modem.peripheral_disconnected": "Perifer \"%s\" koblet fra nettverk",
|
||||
"commands.computercraft.synopsis": "Forskjellige kommandoer for å kontrollere datamaskiner.",
|
||||
"commands.computercraft.desc": "Kommandoen /computercraft gir forskjellige feilsøkings- og administratorverktøy for å kontrollere og handle med datamaskiner.",
|
||||
"commands.computercraft.help.synopsis": "Gi hjelp til en spesifikk kommando",
|
||||
"commands.computercraft.help.desc": "Viser denne hjelpemeldingen",
|
||||
"commands.computercraft.help.no_children": "%s har ingen underkommandoer",
|
||||
"commands.computercraft.help.no_command": "Ingen kommando '%s'",
|
||||
"commands.computercraft.dump.synopsis": "Viser statusen av datamaskiner.",
|
||||
"commands.computercraft.dump.desc": "Viser statusen til alle datamaskiner eller spesifikk informasjon om én datamaskin. Du kan spesifisere datamaskinens forekomst id (f. eks 123), datamaskinens id (f. eks #123) eller datamaskinens merkelapp (f. eks \"@Min datamaskin\").",
|
||||
"commands.computercraft.dump.action": "Vis mer informasjon om denne datamaskinen",
|
||||
"commands.computercraft.dump.open_path": "Vis datamaskinens filer",
|
||||
"commands.computercraft.shutdown.synopsis": "Slå av datamaskiner eksternt.",
|
||||
"commands.computercraft.shutdown.desc": "Slå av de oppførte datamaskinene eller alle hvis ingen er spesifisert. Du kan spesifisere datamaskinens forekomst (f. eks 123), datamaskinens id (f. eks #123) eller merkelapp (f.eks \"@Min datamaskin\").",
|
||||
"commands.computercraft.shutdown.done": "Skrudde av %s/%s datamaskiner",
|
||||
"commands.computercraft.turn_on.synopsis": "Slå på datamaskiner eksternt.",
|
||||
"commands.computercraft.turn_on.desc": "Slå på de oppførte datamaskinene. Du kan spesifisere datamaskinens forekomst id (f. eks 123), datamaskinens id (f.eks #123) eller navnelapp (f. eks \"@Min Datamaskin\").",
|
||||
"commands.computercraft.turn_on.done": "Skrudde på %s/%s datamaskiner",
|
||||
"commands.computercraft.tp.synopsis": "Teleporter til en spesifikk datamaskin.",
|
||||
"commands.computercraft.tp.desc": "Teleporter til en datamaskin sin posisjon. Du kan enten spesifisere datamaskinens forekomst id (f. eks 123) eller datamaskinens id (f. eks #123).",
|
||||
"commands.computercraft.tp.action": "Teleporter til denne datamaskinen",
|
||||
"commands.computercraft.tp.not_player": "Kan kun åpne terminalen for spillere",
|
||||
"commands.computercraft.tp.not_there": "Greide ikke å finne datamaskinen i denne verdenen",
|
||||
"commands.computercraft.view.synopsis": "Vis terminal til en datamaskin.",
|
||||
"commands.computercraft.view.desc": "Åpner terminalen til en datamaskin, lar deg fjernstyre den. Dette gir deg ikke tilgang til skilpadders inventar. Du kan enten spesifisere datamaskinens forekomst id (f. eks 123) eller datamaskinens id (f. eks #123).",
|
||||
"commands.computercraft.view.action": "Vis denne datamaskinen",
|
||||
"commands.computercraft.view.not_player": "Kan kun åpne terminal for spillere",
|
||||
"commands.computercraft.track.synopsis": "Spor utførelsestider for datamaskiner.",
|
||||
"commands.computercraft.track.desc": "Spor hvor lenge datamaskiner kjører, samt hvor mange hendelser de handler. Dette presenterer informasjon i en lignende vei til /forge track og kan være nyttig for å diagnostisere lagg.",
|
||||
"commands.computercraft.track.start.synopsis": "Start sporing av alle datamaskiner",
|
||||
"commands.computercraft.track.start.desc": "Start sporing av alle datamaskiners utførselstider og hendelser. Dette vil fjerne resultatene fra tidligere kjøringer.",
|
||||
"commands.computercraft.track.start.stop": "Kjør %s for å stoppe sporingen og vise resultatene",
|
||||
"commands.computercraft.track.stop.synopsis": "Stopp sporing av alle datamaskiner",
|
||||
"commands.computercraft.track.stop.desc": "Stopp sporing av alle datamaskiners hendelser og utførelsestider",
|
||||
"commands.computercraft.track.stop.action": "Klikk for å stoppe sporing",
|
||||
"commands.computercraft.track.stop.not_enabled": "Sporer ingen datamaskiner",
|
||||
"commands.computercraft.track.dump.synopsis": "Dump nyeste sporingsresultater",
|
||||
"commands.computercraft.track.dump.desc": "Dump de nyeste resultatene av datamaskin sporing.",
|
||||
"commands.computercraft.track.dump.no_timings": "Ingen timere tilgjengelige",
|
||||
"commands.computercraft.track.dump.computer": "Datamaskin",
|
||||
"commands.computercraft.reload.synopsis": "Last inn ComputerCraft sin konfigurasjonsfil på nytt",
|
||||
"commands.computercraft.reload.desc": "Last inn ComputerCraft sin konfigurasjonsfil på nytt",
|
||||
"commands.computercraft.reload.done": "Lastet konfigurasjon på nytt",
|
||||
"commands.computercraft.queue.synopsis": "Send en computer_command hendelse til en kommando datamaskin",
|
||||
"commands.computercraft.queue.desc": "Send en computer_command hendelse til en kommando datamaskin, sender også tilleggs-argumentene Dette er hovedsakelig designet for kartskapere, og fungerer som en mer datamaskin vennlig versjon av /trigger. Enhver spiller kan kjøre kommandoen, som mest sannsynlig vil bli gjort gjennom en tekst komponent sin klikk hendelse.",
|
||||
"commands.computercraft.generic.no_position": "<ingen posisjon>",
|
||||
"commands.computercraft.generic.position": "%s, %s, %s",
|
||||
"commands.computercraft.generic.yes": "J",
|
||||
"commands.computercraft.generic.no": "N",
|
||||
"commands.computercraft.generic.exception": "Uhåndtert unntak (%s)",
|
||||
"commands.computercraft.generic.additional_rows": "%d flere rader…",
|
||||
"argument.computercraft.computer.no_matching": "Ingen datamaskiner som samsvarer med '%s'",
|
||||
"argument.computercraft.computer.many_matching": "Flere datamaskiner samsvarer '%s' (%s treff)",
|
||||
"argument.computercraft.tracking_field.no_field": "Ukjent felt '%s'",
|
||||
"argument.computercraft.argument_expected": "Argument forventet",
|
||||
"tracking_field.computercraft.tasks.name": "Jobber",
|
||||
"tracking_field.computercraft.total.name": "Total tid",
|
||||
"tracking_field.computercraft.average.name": "Gjennomsnitt tid",
|
||||
"tracking_field.computercraft.max.name": "Maksimum tid",
|
||||
"tracking_field.computercraft.server_count.name": "Server jobbantall",
|
||||
"tracking_field.computercraft.server_time.name": "Server jobb tid",
|
||||
"tracking_field.computercraft.peripheral.name": "Perifere kjøringer",
|
||||
"tracking_field.computercraft.fs.name": "Filsystem operasjoner",
|
||||
"tracking_field.computercraft.turtle.name": "Skilpadde operasjoner",
|
||||
"tracking_field.computercraft.http.name": "HTTP-forespørsler",
|
||||
"tracking_field.computercraft.http_upload.name": "HTTP-opplasting",
|
||||
"tracking_field.computercraft.http_download.name": "HTTP-nedlasting",
|
||||
"tracking_field.computercraft.websocket_incoming.name": "Innkommende Websocket",
|
||||
"tracking_field.computercraft.websocket_outgoing.name": "Utgående Websocket",
|
||||
"tracking_field.computercraft.coroutines_created.name": "Skapte coroutines",
|
||||
"tracking_field.computercraft.coroutines_dead.name": "Kastede coroutiner",
|
||||
"gui.computercraft.tooltip.copy": "Kopier til utklippstavle",
|
||||
"gui.computercraft.tooltip.computer_id": "Datamaskin ID: %s",
|
||||
"gui.computercraft.tooltip.disk_id": "Disk ID: %s",
|
||||
"gui.computercraft.tooltip.turn_on": "Slå denne datamaskinen på",
|
||||
"gui.computercraft.tooltip.turn_on.key": "Hold Ctrl + R",
|
||||
"gui.computercraft.tooltip.turn_off": "Skru denne datamaskinen av",
|
||||
"gui.computercraft.tooltip.turn_off.key": "Hold Ctrl + S",
|
||||
"gui.computercraft.tooltip.terminate": "Stopp den kjørende koden",
|
||||
"gui.computercraft.tooltip.terminate.key": "Hold Ctrl + T",
|
||||
"gui.computercraft.upload.success": "Vellykket opplasting",
|
||||
"gui.computercraft.upload.success.msg": "%d filer lastet opp.",
|
||||
"gui.computercraft.upload.failed": "Opplasting Feilet",
|
||||
"gui.computercraft.upload.failed.out_of_space": "Ikke nok lagringsplass på datamaskinen for disse filene.",
|
||||
"gui.computercraft.upload.failed.computer_off": "Du må skru på datamaskinen før du kan laste opp filer.",
|
||||
"gui.computercraft.upload.failed.too_much": "Filene dine er for store for å kunne bli lastet opp.",
|
||||
"gui.computercraft.upload.failed.name_too_long": "Fil navnene er for lange til å bli lastet opp.",
|
||||
"gui.computercraft.upload.failed.too_many_files": "Kan ikke laste opp så mange filer.",
|
||||
"gui.computercraft.upload.failed.overwrite_dir": "Kan ikke laste opp %s, siden det allerede er en mappe med det samme navnet.",
|
||||
"gui.computercraft.upload.failed.generic": "Opplasting av filer feilet (%s)",
|
||||
"gui.computercraft.upload.failed.corrupted": "Filene ble korrupt mens opplasting. Vennligst prøv igjen.",
|
||||
"gui.computercraft.upload.overwrite": "Filer ville blitt overskrevet",
|
||||
"gui.computercraft.upload.overwrite.detail": "Følgende filer vil bli overskrevet under opplasting. Fortsette?%s",
|
||||
"gui.computercraft.upload.overwrite_button": "Overskriv",
|
||||
"gui.computercraft.pocket_computer_overlay": "Lommedatamaskin åpen. Trykk ESC for å lukke."
|
||||
}
|
||||
@@ -10,8 +10,8 @@ gps program.
|
||||
|
||||
:::note
|
||||
When entering in the coordinates for the host you need to put in the `x`, `y`,
|
||||
and `z` coordinates of the computer, not the modem, as all modem distances are
|
||||
measured from the block the computer is in.
|
||||
and `z` coordinates of the block that the modem is connected to, not the modem.
|
||||
All modem distances are measured from the block that the modem is placed on.
|
||||
:::
|
||||
|
||||
Also note that you may choose which axes x, y, or z refers to - so long as your
|
||||
@@ -24,6 +24,7 @@ height in the way that Minecraft's debug screen displays.
|
||||
|
||||
@module gps
|
||||
@since 1.31
|
||||
@see gps_setup For more detailed instructions on setting up GPS
|
||||
]]
|
||||
|
||||
local expect = dofile("rom/modules/main/cc/expect.lua").expect
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
# New features in CC: Tweaked 1.100.9
|
||||
|
||||
* Add documentation for setting up GPS (Lupus590).
|
||||
* Add WAV support to the `speaker` program (MCJack123).
|
||||
* Expose item groups in `getItemDetail` (itisluiz).
|
||||
* Other fixes to documentation (Erb3, JohnnyIrvin).
|
||||
* Add Norwegian translation (Erb3).
|
||||
|
||||
Several bug fixes:
|
||||
* Fix z-fighting on bold printout borders (toad-dev).
|
||||
* Fix `term.blit` failing on certain strings.
|
||||
* Fix `getItemLimit()` using the wrong slot (heap-underflow).
|
||||
* Increase size of monitor depth blocker.
|
||||
|
||||
# New features in CC: Tweaked 1.100.8
|
||||
|
||||
Several bug fixes:
|
||||
* Fix NPE within disk drive and printer code.
|
||||
|
||||
# New features in CC: Tweaked 1.100.6
|
||||
|
||||
* Various documentation improvements (MCJack123, FayneAldan).
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
New features in CC: Tweaked 1.100.6
|
||||
New features in CC: Tweaked 1.100.9
|
||||
|
||||
* Various documentation improvements (MCJack123, FayneAldan).
|
||||
* Allow CC's blocks to be rotated when used in structure blocks (Seniorendi).
|
||||
* Several performance improvements to computer execution.
|
||||
* Add parse_empty_array option to textutils.unserialiseJSON (@ChickChicky).
|
||||
* Add an API to allow other mods to provide extra item/block details (Lemmmy).
|
||||
* All blocks with GUIs can now be "locked" (via a command or NBT editing tools) like vanilla inventories. Players can only interact with them with a specific named item.
|
||||
* Add documentation for setting up GPS (Lupus590).
|
||||
* Add WAV support to the `speaker` program (MCJack123).
|
||||
* Expose item groups in `getItemDetail` (itisluiz).
|
||||
* Other fixes to documentation (Erb3, JohnnyIrvin).
|
||||
* Add Norwegian translation (Erb3).
|
||||
|
||||
Several bug fixes:
|
||||
* Fix printouts being rendered with an offset in item frames (coolsa).
|
||||
* Reduce position latency when playing audio with a noisy pocket computer.
|
||||
* Fix total counts in /computercraft turn-on/shutdown commands.
|
||||
* Fix "Run" command not working in the editor when run from a subdirectory (Wojbie).
|
||||
* Pocket computers correctly preserve their on state.
|
||||
* Fix z-fighting on bold printout borders (toad-dev).
|
||||
* Fix `term.blit` failing on certain strings.
|
||||
* Fix `getItemLimit()` using the wrong slot (heap-underflow).
|
||||
* Increase size of monitor depth blocker.
|
||||
|
||||
Type "help changelog" to see the full version history.
|
||||
|
||||
@@ -18,6 +18,14 @@ local function get_speakers(name)
|
||||
end
|
||||
end
|
||||
|
||||
local function pcm_decoder(chunk)
|
||||
local buffer = {}
|
||||
for i = 1, #chunk do
|
||||
buffer[i] = chunk:byte(i) - 128
|
||||
end
|
||||
return buffer
|
||||
end
|
||||
|
||||
|
||||
local cmd = ...
|
||||
if cmd == "stop" then
|
||||
@@ -40,12 +48,63 @@ elseif cmd == "play" then
|
||||
error(err, 0)
|
||||
end
|
||||
|
||||
local start = handle.read(4)
|
||||
local pcm = false
|
||||
local size = 16 * 1024 - 4
|
||||
if start == "RIFF" then
|
||||
handle.read(4)
|
||||
if handle.read(8) ~= "WAVEfmt " then
|
||||
handle.close()
|
||||
error("Could not play audio: Unsupported WAV file", 0)
|
||||
end
|
||||
|
||||
local fmtsize = ("<I4"):unpack(handle.read(4))
|
||||
local fmt = handle.read(fmtsize)
|
||||
local format, channels, rate, _, _, bits = ("<I2I2I4I4I2I2"):unpack(fmt)
|
||||
if not ((format == 1 and bits == 8) or (format == 0xFFFE and bits == 1)) then
|
||||
handle.close()
|
||||
error("Could not play audio: Unsupported WAV file", 0)
|
||||
end
|
||||
if channels ~= 1 or rate ~= 48000 then
|
||||
print("Warning: Only 48 kHz mono WAV files are supported. This file may not play correctly.")
|
||||
end
|
||||
if format == 0xFFFE then
|
||||
local guid = fmt:sub(25)
|
||||
if guid ~= "\x3A\xC1\xFA\x38\x81\x1D\x43\x61\xA4\x0D\xCE\x53\xCA\x60\x7C\xD1" then -- DFPWM format GUID
|
||||
handle.close()
|
||||
error("Could not play audio: Unsupported WAV file", 0)
|
||||
end
|
||||
size = size + 4
|
||||
else
|
||||
pcm = true
|
||||
size = 16 * 1024 * 8
|
||||
end
|
||||
|
||||
repeat
|
||||
local chunk = handle.read(4)
|
||||
if chunk == nil then
|
||||
handle.close()
|
||||
error("Could not play audio: Invalid WAV file", 0)
|
||||
elseif chunk ~= "data" then -- Ignore extra chunks
|
||||
local size = ("<I4"):unpack(handle.read(4))
|
||||
handle.read(size)
|
||||
end
|
||||
until chunk == "data"
|
||||
|
||||
handle.read(4)
|
||||
start = nil
|
||||
end
|
||||
|
||||
print("Playing " .. file)
|
||||
|
||||
local decoder = require "cc.audio.dfpwm".make_decoder()
|
||||
local decoder = pcm and pcm_decoder or require "cc.audio.dfpwm".make_decoder()
|
||||
while true do
|
||||
local chunk = handle.read(16 * 1024)
|
||||
local chunk = handle.read(size)
|
||||
if not chunk then break end
|
||||
if start then
|
||||
chunk, start = start .. chunk, nil
|
||||
size = size + 4
|
||||
end
|
||||
|
||||
local buffer = decoder(chunk)
|
||||
while not speaker.playAudio(buffer) do
|
||||
|
||||
@@ -14,9 +14,12 @@ import net.minecraft.network.PacketBuffer;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static dan200.computercraft.core.terminal.TerminalMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class TerminalTest
|
||||
@@ -366,6 +369,19 @@ class TerminalTest
|
||||
callCounter.assertNotCalled();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlitPartialBuffer()
|
||||
{
|
||||
Terminal terminal = new Terminal( 4, 3 );
|
||||
|
||||
ByteBuffer text = LuaValues.encode( "123456" );
|
||||
text.position( 1 );
|
||||
|
||||
terminal.blit( text, LuaValues.encode( "aaaaaa" ), LuaValues.encode( "aaaaaa" ) );
|
||||
|
||||
assertThat( terminal.getLine( 0 ).toString(), equalTo( "2345" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWriteFromOrigin()
|
||||
{
|
||||
|
||||
@@ -117,6 +117,19 @@ describe("The os library", function()
|
||||
end)
|
||||
|
||||
describe("os.time", function()
|
||||
it("supports in-game time", function()
|
||||
expect(os.time("ingame")):equal(os.time())
|
||||
end)
|
||||
|
||||
it("supports local and utc time", function()
|
||||
os.time("utc")
|
||||
os.time("local")
|
||||
end)
|
||||
|
||||
it("fails on other times", function()
|
||||
expect.error(os.time, "unknown"):eq("Unsupported operation")
|
||||
end)
|
||||
|
||||
it("maps directly to seconds", function()
|
||||
local t1 = os.time { year = 2000, month = 10, day = 1, hour = 23, min = 12, sec = 17 }
|
||||
local t2 = os.time { year = 2000, month = 10, day = 1, hour = 23, min = 10, sec = 19 }
|
||||
@@ -124,6 +137,38 @@ describe("The os library", function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("os.day", function()
|
||||
it("supports in-game time", function()
|
||||
expect(os.day("ingame")):equal(os.day())
|
||||
end)
|
||||
|
||||
it("supports local and utc time", function()
|
||||
os.day("utc")
|
||||
os.day("local")
|
||||
end)
|
||||
|
||||
it("fails on other times", function()
|
||||
expect.error(os.day, "unknown"):eq("Unsupported operation")
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("os.epoch", function()
|
||||
it("supports in-game time", function()
|
||||
local in_game = os.epoch("ingame")
|
||||
local default = os.epoch()
|
||||
assert(math.abs(default - in_game) < 5)
|
||||
end)
|
||||
|
||||
it("supports local and utc time", function()
|
||||
os.epoch("utc")
|
||||
os.epoch("local")
|
||||
end)
|
||||
|
||||
it("fails on other times", function()
|
||||
expect.error(os.epoch, "unknown"):eq("Unsupported operation")
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("os.loadAPI", function()
|
||||
it("validates arguments", function()
|
||||
expect.error(os.loadAPI, nil):eq("bad argument #1 (expected string, got nil)")
|
||||
|
||||
Reference in New Issue
Block a user