mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-05 15:00:29 +00:00
Split CC:T into common and forge projects
After several weeks of carefully arranging ribbons, we pull the string and end up with, ... a bit of a messy bow. There were still some things I'd missed. - Split the mod into a common (vanilla-only) project and Forge-specific project. This gives us room to add Fabric support later on. - Split the project into main/client source sets. This is not currently statically checked: we'll do that soon. - Rename block/item/tile entities to use suffixes rather than prefixes.
This commit is contained in:
parent
bdf590fa30
commit
f04acdc199
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
/classes
|
||||
/logs
|
||||
/build
|
||||
/projects/*/logs
|
||||
/projects/*/build
|
||||
/buildSrc/build
|
||||
/out
|
||||
@ -11,6 +12,7 @@
|
||||
|
||||
# Runtime directories
|
||||
/run
|
||||
/projects/*/run
|
||||
|
||||
*.ipr
|
||||
*.iws
|
||||
@ -25,4 +27,4 @@
|
||||
/.vscode
|
||||
*.launch
|
||||
|
||||
/src/generated/resources/.cache
|
||||
/projects/*/src/generated/resources/.cache
|
||||
|
@ -48,8 +48,7 @@ repos:
|
||||
|
||||
exclude: |
|
||||
(?x)^(
|
||||
src/generated|
|
||||
projects/[a-z]+/src/generated|
|
||||
projects/core/src/test/resources/test-rom/data/json-parsing/|
|
||||
src/testMod/server-files/|
|
||||
.*\.dfpwm
|
||||
)
|
||||
|
336
build.gradle.kts
336
build.gradle.kts
@ -1,345 +1,9 @@
|
||||
import cc.tweaked.gradle.*
|
||||
import groovy.util.Node
|
||||
import groovy.util.NodeList
|
||||
import net.darkhax.curseforgegradle.TaskPublishCurseForge
|
||||
import net.minecraftforge.gradle.common.util.RunConfig
|
||||
import org.jetbrains.gradle.ext.compiler
|
||||
import org.jetbrains.gradle.ext.settings
|
||||
|
||||
plugins {
|
||||
// Build
|
||||
id("cc-tweaked.forge")
|
||||
id("cc-tweaked.gametest")
|
||||
alias(libs.plugins.mixinGradle)
|
||||
alias(libs.plugins.shadow)
|
||||
// Publishing
|
||||
alias(libs.plugins.curseForgeGradle)
|
||||
alias(libs.plugins.githubRelease)
|
||||
alias(libs.plugins.minotaur)
|
||||
// Utility
|
||||
alias(libs.plugins.taskTree)
|
||||
id("org.jetbrains.gradle.plugin.idea-ext")
|
||||
|
||||
id("cc-tweaked.illuaminate")
|
||||
id("cc-tweaked.publishing")
|
||||
id("cc-tweaked")
|
||||
}
|
||||
|
||||
val isStable = true
|
||||
val modVersion: String by extra
|
||||
val mcVersion: String by extra
|
||||
|
||||
val allProjects = listOf(":core-api", ":core", ":forge-api").map { evaluationDependsOn(it) }
|
||||
cct {
|
||||
allProjects.forEach { externalSources(it) }
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
resources.srcDir("src/generated/resources")
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
runs {
|
||||
// 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")
|
||||
|
||||
forceExit = false
|
||||
|
||||
mods.register("computercraft") {
|
||||
cct.sourceDirectories.get().forEach {
|
||||
if (it.classes) sources(it.sourceSet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val client by registering {
|
||||
workingDirectory(file("run"))
|
||||
}
|
||||
|
||||
val server by registering {
|
||||
workingDirectory(file("run/server"))
|
||||
arg("--nogui")
|
||||
}
|
||||
|
||||
val data by registering {
|
||||
workingDirectory(file("run"))
|
||||
args(
|
||||
"--mod",
|
||||
"computercraft",
|
||||
"--all",
|
||||
"--output",
|
||||
file("src/generated/resources/"),
|
||||
"--existing",
|
||||
file("src/main/resources/"),
|
||||
)
|
||||
property("cct.pretty-json", "true")
|
||||
}
|
||||
|
||||
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"])
|
||||
// FIXME: We need this for running in-dev but not from Gradle:
|
||||
// source(project(":core").sourceSets.testFixtures.get())
|
||||
}
|
||||
}
|
||||
|
||||
val testClient by registering {
|
||||
workingDirectory(file("run/testClient"))
|
||||
parent(client.get())
|
||||
configureForGameTest()
|
||||
}
|
||||
|
||||
val gameTestServer by registering {
|
||||
workingDirectory(file("run/testServer"))
|
||||
configureForGameTest()
|
||||
|
||||
property("forge.logging.console.level", "info")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mixin {
|
||||
add(sourceSets.main.get(), "computercraft.mixins.refmap.json")
|
||||
config("computercraft.mixins.json")
|
||||
}
|
||||
|
||||
reobf {
|
||||
register("shadowJar")
|
||||
}
|
||||
|
||||
configurations {
|
||||
val shade by registering { isTransitive = false }
|
||||
implementation { extendsFrom(shade.get()) }
|
||||
register("cctJavadoc")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
annotationProcessor("org.spongepowered:mixin:0.8.5-SQUID:processor")
|
||||
|
||||
errorprone(project(":lints"))
|
||||
|
||||
compileOnly(libs.jetbrainsAnnotations)
|
||||
annotationProcessorEverywhere(libs.autoService)
|
||||
|
||||
libs.bundles.externalMods.forge.compile.get().map { compileOnly(fg.deobf(it)) }
|
||||
libs.bundles.externalMods.forge.runtime.get().map { runtimeOnly(fg.deobf(it)) }
|
||||
|
||||
implementation(project(":core"))
|
||||
implementation(commonClasses(project(":forge-api")))
|
||||
implementation(clientClasses(project(":forge-api")))
|
||||
"shade"(libs.cobalt)
|
||||
"shade"(libs.netty.http)
|
||||
|
||||
testFixturesApi(libs.bundles.test)
|
||||
testFixturesApi(libs.bundles.kotlin)
|
||||
|
||||
testImplementation(testFixtures(project(":core")))
|
||||
testImplementation(libs.bundles.test)
|
||||
testImplementation(libs.bundles.kotlin)
|
||||
testRuntimeOnly(libs.bundles.testRuntime)
|
||||
|
||||
testModImplementation(testFixtures(project(":core")))
|
||||
|
||||
"cctJavadoc"(libs.cctJavadoc)
|
||||
}
|
||||
|
||||
illuaminate {
|
||||
version.set(libs.versions.illuaminate)
|
||||
}
|
||||
|
||||
// Compile tasks
|
||||
|
||||
val luaJavadoc by tasks.registering(Javadoc::class) {
|
||||
description = "Generates documentation for Java-side Lua functions."
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
|
||||
source(sourceSets.main.get().java)
|
||||
source(project(":core").sourceSets.main.get().java)
|
||||
|
||||
setDestinationDir(buildDir.resolve("docs/luaJavadoc"))
|
||||
classpath = sourceSets.main.get().compileClasspath
|
||||
|
||||
options.docletpath = configurations["cctJavadoc"].files.toList()
|
||||
options.doclet = "cc.tweaked.javadoc.LuaDoclet"
|
||||
(options as StandardJavadocDocletOptions).noTimestamp(false)
|
||||
|
||||
javadocTool.set(
|
||||
javaToolchains.javadocToolFor {
|
||||
languageVersion.set(cc.tweaked.gradle.CCTweakedPlugin.JAVA_VERSION)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
inputs.property("modVersion", modVersion)
|
||||
inputs.property("forgeVersion", libs.versions.forge.get())
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand(mapOf("forgeVersion" to libs.versions.forge.get(), "file" to mapOf("jarVersion" to modVersion)))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
finalizedBy("reobfJar")
|
||||
archiveClassifier.set("slim")
|
||||
|
||||
from(allProjects.map { zipTree(it.tasks.jar.get().archiveFile) })
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
finalizedBy("reobfShadowJar")
|
||||
archiveClassifier.set("")
|
||||
|
||||
from(allProjects.map { zipTree(it.tasks.jar.get().archiveFile) })
|
||||
|
||||
configurations = listOf(project.configurations["shade"])
|
||||
relocate("org.squiddev.cobalt", "cc.tweaked.internal.cobalt")
|
||||
relocate("io.netty.handler", "cc.tweaked.internal.netty")
|
||||
// TODO: minimize(): Would be good to support once our build scripts are stabilised.
|
||||
}
|
||||
|
||||
tasks.assemble { dependsOn("shadowJar") }
|
||||
|
||||
// Check tasks
|
||||
|
||||
tasks.test {
|
||||
systemProperty("cct.test-files", buildDir.resolve("tmp/testFiles").absolutePath)
|
||||
}
|
||||
|
||||
val lintLua by tasks.registering(IlluaminateExec::class) {
|
||||
group = JavaBasePlugin.VERIFICATION_GROUP
|
||||
description = "Lint Lua (and Lua docs) with illuaminate"
|
||||
|
||||
// Config files
|
||||
inputs.file("illuaminate.sexp").withPropertyName("illuaminate.sexp")
|
||||
// Sources
|
||||
inputs.files(fileTree("doc")).withPropertyName("docs")
|
||||
inputs.files(fileTree("src/main/resources/data/computercraft/lua")).withPropertyName("lua rom")
|
||||
inputs.files(luaJavadoc)
|
||||
|
||||
args = listOf("lint")
|
||||
|
||||
doFirst { if (System.getenv("GITHUB_ACTIONS") != null) println("::add-matcher::.github/matchers/illuaminate.json") }
|
||||
doLast { if (System.getenv("GITHUB_ACTIONS") != null) println("::remove-matcher owner=illuaminate::") }
|
||||
}
|
||||
|
||||
val runGametest by tasks.registering(JavaExec::class) {
|
||||
group = LifecycleBasePlugin.VERIFICATION_GROUP
|
||||
description = "Runs tests on a temporary Minecraft instance."
|
||||
dependsOn("cleanRunGametest")
|
||||
|
||||
// Copy from runGameTestServer. We do it in this slightly odd way as runGameTestServer
|
||||
// isn't created until the task is configured (which is no good for us).
|
||||
val exec = tasks.getByName<JavaExec>("runGameTestServer")
|
||||
dependsOn(exec.dependsOn)
|
||||
exec.copyToFull(this)
|
||||
}
|
||||
|
||||
cct.jacoco(runGametest)
|
||||
|
||||
tasks.check { dependsOn(runGametest) }
|
||||
|
||||
// Upload tasks
|
||||
|
||||
val publishCurseForge by tasks.registering(TaskPublishCurseForge::class) {
|
||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||
description = "Upload artifacts to CurseForge"
|
||||
|
||||
apiToken = findProperty("curseForgeApiKey") ?: ""
|
||||
enabled = apiToken != ""
|
||||
|
||||
val mainFile = upload("282001", tasks.shadowJar.get().archiveFile)
|
||||
dependsOn(tasks.shadowJar) // Ughr.
|
||||
mainFile.changelog =
|
||||
"Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion)."
|
||||
mainFile.changelogType = "markdown"
|
||||
mainFile.releaseType = if (isStable) "release" else "alpha"
|
||||
mainFile.gameVersions.add(mcVersion)
|
||||
}
|
||||
|
||||
tasks.publish { dependsOn(publishCurseForge) }
|
||||
|
||||
modrinth {
|
||||
token.set(findProperty("modrinthApiKey") as String? ?: "")
|
||||
projectId.set("gu7yAYhd")
|
||||
versionNumber.set("$mcVersion-$modVersion")
|
||||
versionName.set(modVersion)
|
||||
versionType.set(if (isStable) "release" else "alpha")
|
||||
uploadFile.set(tasks.shadowJar as Any)
|
||||
gameVersions.add(mcVersion)
|
||||
changelog.set("Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion).")
|
||||
|
||||
syncBodyFrom.set(provider { file("doc/mod-page.md").readText() })
|
||||
}
|
||||
|
||||
tasks.publish { dependsOn(tasks.modrinth) }
|
||||
|
||||
githubRelease {
|
||||
token(findProperty("githubApiKey") as String? ?: "")
|
||||
owner.set("cc-tweaked")
|
||||
repo.set("CC-Tweaked")
|
||||
targetCommitish.set(cct.gitBranch)
|
||||
|
||||
tagName.set("v$mcVersion-$modVersion")
|
||||
releaseName.set("[$mcVersion] $modVersion")
|
||||
body.set(
|
||||
provider {
|
||||
"## " + file("src/main/resources/data/computercraft/lua/rom/help/whatsnew.md")
|
||||
.readLines()
|
||||
.takeWhile { it != "Type \"help changelog\" to see the full version history." }
|
||||
.joinToString("\n").trim()
|
||||
},
|
||||
)
|
||||
prerelease.set(!isStable)
|
||||
}
|
||||
|
||||
tasks.publish { dependsOn(tasks.githubRelease) }
|
||||
|
||||
// Don't publish the slim jar
|
||||
for (cfg in listOf(configurations.apiElements, configurations.runtimeElements)) {
|
||||
cfg.configure { artifacts.removeIf { it.classifier == "slim" } }
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
named("maven", MavenPublication::class) {
|
||||
fg.component(this)
|
||||
// Remove all dependencies: they're shaded anyway! This is very ugly, but not found a better way :(.
|
||||
pom.withXml {
|
||||
for (node in asNode().get("dependencies") as NodeList) {
|
||||
asNode().remove(node as Node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
idea.project.settings.compiler.javac {
|
||||
|
@ -19,7 +19,7 @@ minecraft {
|
||||
val libs = project.extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
mappings("parchment", "${libs.findVersion("parchmentMc").get()}-${libs.findVersion("parchment").get()}-$mcVersion")
|
||||
|
||||
accessTransformer(rootProject.file("src/main/resources/META-INF/accesstransformer.cfg"))
|
||||
accessTransformer(project(":forge").file("src/main/resources/META-INF/accesstransformer.cfg"))
|
||||
}
|
||||
|
||||
MinecraftConfigurations.setup(project)
|
||||
|
@ -1,3 +1,6 @@
|
||||
import cc.tweaked.gradle.clientClasses
|
||||
import cc.tweaked.gradle.commonClasses
|
||||
|
||||
/**
|
||||
* Sets up the configurations for writing game tests.
|
||||
*
|
||||
@ -9,12 +12,13 @@ plugins {
|
||||
id("cc-tweaked.java-convention")
|
||||
}
|
||||
|
||||
val main = sourceSets.main.get()
|
||||
val main = sourceSets["main"]
|
||||
val client = sourceSets["client"]
|
||||
|
||||
// Both testMod and testFixtures inherit from the main classpath, just so we have access to Minecraft classes.
|
||||
// Both testMod and testFixtures inherit from the main and client classpath, just so we have access to Minecraft classes.
|
||||
val testMod by sourceSets.creating {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
compileClasspath += main.compileClasspath + client.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath + client.runtimeClasspath
|
||||
}
|
||||
|
||||
configurations {
|
||||
@ -30,12 +34,13 @@ configurations {
|
||||
// Like the main test configurations, we're safe to depend on source set outputs.
|
||||
dependencies {
|
||||
add(testMod.implementationConfigurationName, main.output)
|
||||
add(testMod.implementationConfigurationName, client.output)
|
||||
}
|
||||
|
||||
// Similar to java-test-fixtures, but tries to avoid putting the obfuscated jar on the classpath.
|
||||
|
||||
val testFixtures by sourceSets.creating {
|
||||
compileClasspath += main.compileClasspath
|
||||
compileClasspath += main.compileClasspath + client.compileClasspath
|
||||
}
|
||||
|
||||
java.registerFeature("testFixtures") {
|
||||
@ -44,6 +49,12 @@ java.registerFeature("testFixtures") {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
add(testFixtures.implementationConfigurationName, main.output)
|
||||
val libs = project.extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
add(testFixtures.apiConfigurationName, libs.findBundle("test").get())
|
||||
// Consumers of this project already have the common and client classes on the classpath, so it's fine for these
|
||||
// to be compile-only.
|
||||
add(testFixtures.compileOnlyApiConfigurationName, commonClasses(project))
|
||||
add(testFixtures.compileOnlyApiConfigurationName, clientClasses(project))
|
||||
|
||||
testImplementation(testFixtures(project))
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ fun DependencyHandler.annotationProcessorEverywhere(dep: Any) {
|
||||
add("compileOnly", dep)
|
||||
add("annotationProcessor", dep)
|
||||
|
||||
add("clientCompileOnly", dep)
|
||||
add("clientAnnotationProcessor", dep)
|
||||
|
||||
add("testCompileOnly", dep)
|
||||
add("testAnnotationProcessor", dep)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
forge = "43.1.1"
|
||||
parchment = "2022.10.16"
|
||||
parchmentMc = "1.19.2"
|
||||
mixin = "0.8.5"
|
||||
|
||||
# Normal dependencies
|
||||
asm = "9.3"
|
||||
@ -23,8 +24,11 @@ nightConfig = "3.6.5"
|
||||
slf4j = "1.7.36"
|
||||
|
||||
# Minecraft mods
|
||||
forgeConfig = "4.2.6"
|
||||
iris = "1.19.x-v1.2.6"
|
||||
jei = "11.3.0.262"
|
||||
oculus = "1.2.5"
|
||||
rei = "9.1.550"
|
||||
|
||||
# Testing
|
||||
hamcrest = "2.2"
|
||||
@ -63,12 +67,16 @@ jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" }
|
||||
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
|
||||
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
|
||||
netty-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
|
||||
nightConfig-core = { module = "com.electronwill.night-config:core", version.ref = "nightConfig" }
|
||||
nightConfig-toml = { module = "com.electronwill.night-config:toml", version.ref = "nightConfig" }
|
||||
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
|
||||
|
||||
# Minecraft mods
|
||||
forgeConfig = { module = "net.minecraftforge:forgeconfigapiport-fabric", version.ref = "forgeConfig" }
|
||||
jei-api = { module = "mezz.jei:jei-1.19.2-common-api", version.ref = "jei" }
|
||||
jei-fabric = { module = "mezz.jei:jei-1.19.2-fabric", version.ref = "jei" }
|
||||
jei-forge = { module = "mezz.jei:jei-1.19.2-forge", version.ref = "jei" }
|
||||
mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }
|
||||
oculus = { module = "maven.modrinth:oculus", version.ref = "oculus" }
|
||||
|
||||
# Testing
|
||||
@ -110,7 +118,7 @@ taskTree = { id = "com.dorongold.task-tree", version.ref = "taskTree" }
|
||||
kotlin = ["kotlin-stdlib", "kotlin-coroutines"]
|
||||
|
||||
# Minecraft
|
||||
externalMods-common = ["jei-api"]
|
||||
externalMods-common = ["jei-api", "forgeConfig", "nightConfig-core", "nightConfig-toml"]
|
||||
externalMods-forge-compile = ["oculus", "jei-api"]
|
||||
externalMods-forge-runtime = ["jei-forge"]
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
(sources
|
||||
/doc/
|
||||
/build/docs/luaJavadoc/
|
||||
/projects/forge/build/docs/luaJavadoc/
|
||||
/projects/core/src/main/resources/data/computercraft/lua/bios.lua
|
||||
/projects/core/src/main/resources/data/computercraft/lua/rom/
|
||||
/projects/core/src/test/resources/test-rom
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
(site
|
||||
(title "CC: Tweaked")
|
||||
(logo src/main/resources/pack.png)
|
||||
(logo projects/common/src/main/resources/pack.png)
|
||||
(url https://tweaked.cc/)
|
||||
(source-link https://github.com/cc-tweaked/CC-Tweaked/blob/${commit}/${path}#L${line})
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
(library-path
|
||||
/doc/stub/
|
||||
/build/docs/luaJavadoc/
|
||||
/projects/forge/build/docs/luaJavadoc/
|
||||
|
||||
/projects/core/src/main/resources/data/computercraft/lua/rom/apis/
|
||||
/projects/core/src/main/resources/data/computercraft/lua/rom/apis/command/
|
||||
@ -87,7 +87,7 @@
|
||||
(lint (allow-toplevel-global true)))
|
||||
|
||||
;; Silence some variable warnings in documentation stubs.
|
||||
(at (/doc/stub/ /build/docs/luaJavadoc/)
|
||||
(at (/doc/stub/ /projects/forge/build/docs/luaJavadoc/)
|
||||
(linters -var:unused-global)
|
||||
(lint (allow-toplevel-global true)))
|
||||
|
||||
|
38
projects/common/build.gradle.kts
Normal file
38
projects/common/build.gradle.kts
Normal file
@ -0,0 +1,38 @@
|
||||
import cc.tweaked.gradle.annotationProcessorEverywhere
|
||||
import cc.tweaked.gradle.clientClasses
|
||||
import cc.tweaked.gradle.commonClasses
|
||||
|
||||
plugins {
|
||||
id("cc-tweaked.vanilla")
|
||||
id("cc-tweaked.gametest")
|
||||
}
|
||||
|
||||
minecraft {
|
||||
accessWideners(
|
||||
"src/main/resources/computercraft.accesswidener",
|
||||
"src/main/resources/computercraft-common.accesswidener",
|
||||
)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Pull in our other projects. See comments in MinecraftConfigurations on this nastiness.
|
||||
implementation(project(":core"))
|
||||
implementation(commonClasses(project(":common-api")))
|
||||
clientImplementation(clientClasses(project(":common-api")))
|
||||
|
||||
compileOnly(libs.bundles.externalMods.common)
|
||||
compileOnly(project(":forge-stubs"))
|
||||
|
||||
compileOnly(libs.mixin)
|
||||
annotationProcessorEverywhere(libs.autoService)
|
||||
|
||||
testImplementation(testFixtures(project(":core")))
|
||||
testImplementation(libs.bundles.test)
|
||||
testImplementation(project(":forge-stubs"))
|
||||
testRuntimeOnly(libs.bundles.testRuntime)
|
||||
|
||||
errorprone(project(":lints"))
|
||||
|
||||
testModImplementation(testFixtures(project(":core")))
|
||||
testModImplementation(libs.bundles.kotlin)
|
||||
}
|
@ -10,18 +10,18 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.client.pocket.ClientPocketComputers;
|
||||
import dan200.computercraft.client.render.CableHighlightRenderer;
|
||||
import dan200.computercraft.client.render.ItemPocketRenderer;
|
||||
import dan200.computercraft.client.render.ItemPrintoutRenderer;
|
||||
import dan200.computercraft.client.render.MonitorHighlightRenderer;
|
||||
import dan200.computercraft.client.render.PocketItemRenderer;
|
||||
import dan200.computercraft.client.render.PrintoutItemRenderer;
|
||||
import dan200.computercraft.client.render.monitor.MonitorHighlightRenderer;
|
||||
import dan200.computercraft.client.render.monitor.MonitorRenderState;
|
||||
import dan200.computercraft.client.sound.SpeakerManager;
|
||||
import dan200.computercraft.shared.CommonHooks;
|
||||
import dan200.computercraft.shared.command.CommandComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ServerContext;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.media.items.PrintoutItem;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlockEntity;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||
import dan200.computercraft.shared.util.PauseAwareTimer;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Camera;
|
||||
@ -76,12 +76,12 @@ public final class ClientHooks {
|
||||
PoseStack transform, MultiBufferSource render, int lightTexture, InteractionHand hand,
|
||||
float pitch, float equipProgress, float swingProgress, ItemStack stack
|
||||
) {
|
||||
if (stack.getItem() instanceof ItemPocketComputer) {
|
||||
ItemPocketRenderer.INSTANCE.renderItemFirstPerson(transform, render, lightTexture, hand, pitch, equipProgress, swingProgress, stack);
|
||||
if (stack.getItem() instanceof PocketComputerItem) {
|
||||
PocketItemRenderer.INSTANCE.renderItemFirstPerson(transform, render, lightTexture, hand, pitch, equipProgress, swingProgress, stack);
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() instanceof ItemPrintout) {
|
||||
ItemPrintoutRenderer.INSTANCE.renderItemFirstPerson(transform, render, lightTexture, hand, pitch, equipProgress, swingProgress, stack);
|
||||
if (stack.getItem() instanceof PrintoutItem) {
|
||||
PrintoutItemRenderer.INSTANCE.renderItemFirstPerson(transform, render, lightTexture, hand, pitch, equipProgress, swingProgress, stack);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -89,8 +89,8 @@ public final class ClientHooks {
|
||||
}
|
||||
|
||||
public static boolean onRenderItemFrame(PoseStack transform, MultiBufferSource render, ItemFrame frame, ItemStack stack, int light) {
|
||||
if (stack.getItem() instanceof ItemPrintout) {
|
||||
ItemPrintoutRenderer.onRenderInFrame(transform, render, frame, stack, light);
|
||||
if (stack.getItem() instanceof PrintoutItem) {
|
||||
PrintoutItemRenderer.onRenderInFrame(transform, render, frame, stack, light);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -141,12 +141,12 @@ public final class ClientHooks {
|
||||
|
||||
var tile = minecraft.level.getBlockEntity(((BlockHitResult) minecraft.hitResult).getBlockPos());
|
||||
|
||||
if (tile instanceof TileMonitor monitor) {
|
||||
if (tile instanceof MonitorBlockEntity monitor) {
|
||||
addText.accept("");
|
||||
addText.accept(
|
||||
String.format("Targeted monitor: (%d, %d), %d x %d", monitor.getXIndex(), monitor.getYIndex(), monitor.getWidth(), monitor.getHeight())
|
||||
);
|
||||
} else if (tile instanceof TileTurtle turtle) {
|
||||
} else if (tile instanceof TurtleBlockEntity turtle) {
|
||||
addText.accept("");
|
||||
addText.accept("Targeted turtle:");
|
||||
addText.accept(String.format("Id: %d", turtle.getComputerID()));
|
||||
@ -155,7 +155,7 @@ public final class ClientHooks {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addTurtleUpgrade(Consumer<String> out, TileTurtle turtle, TurtleSide side) {
|
||||
private static void addTurtleUpgrade(Consumer<String> out, TurtleBlockEntity turtle, TurtleSide side) {
|
||||
var upgrade = turtle.getUpgrade(side);
|
||||
if (upgrade != null) out.accept(String.format("Upgrade[%s]: %s", side, upgrade.getUpgradeID()));
|
||||
}
|
@ -11,30 +11,33 @@ import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
|
||||
import dan200.computercraft.client.gui.*;
|
||||
import dan200.computercraft.client.pocket.ClientPocketComputers;
|
||||
import dan200.computercraft.client.render.RenderTypes;
|
||||
import dan200.computercraft.client.render.TileEntityMonitorRenderer;
|
||||
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
|
||||
import dan200.computercraft.client.render.TurtleBlockEntityRenderer;
|
||||
import dan200.computercraft.client.render.monitor.MonitorBlockEntityRenderer;
|
||||
import dan200.computercraft.client.turtle.TurtleModemModeller;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
|
||||
import dan200.computercraft.shared.media.items.ItemDisk;
|
||||
import dan200.computercraft.shared.computer.inventory.AbstractComputerMenu;
|
||||
import dan200.computercraft.shared.computer.inventory.ViewComputerMenu;
|
||||
import dan200.computercraft.shared.media.items.DiskItem;
|
||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.client.renderer.item.ItemPropertyFunction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
@ -73,19 +76,19 @@ public final class ClientRegistry {
|
||||
* Register any client-side objects which must be done on the main thread.
|
||||
*/
|
||||
public static void registerMainThread() {
|
||||
MenuScreens.<ContainerComputerBase, GuiComputer<ContainerComputerBase>>register(ModRegistry.Menus.COMPUTER.get(), GuiComputer::new);
|
||||
MenuScreens.<ContainerComputerBase, GuiComputer<ContainerComputerBase>>register(ModRegistry.Menus.POCKET_COMPUTER.get(), GuiComputer::new);
|
||||
MenuScreens.<ContainerComputerBase, NoTermComputerScreen<ContainerComputerBase>>register(ModRegistry.Menus.POCKET_COMPUTER_NO_TERM.get(), NoTermComputerScreen::new);
|
||||
MenuScreens.register(ModRegistry.Menus.TURTLE.get(), GuiTurtle::new);
|
||||
MenuScreens.<AbstractComputerMenu, ComputerScreen<AbstractComputerMenu>>register(ModRegistry.Menus.COMPUTER.get(), ComputerScreen::new);
|
||||
MenuScreens.<AbstractComputerMenu, ComputerScreen<AbstractComputerMenu>>register(ModRegistry.Menus.POCKET_COMPUTER.get(), ComputerScreen::new);
|
||||
MenuScreens.<AbstractComputerMenu, NoTermComputerScreen<AbstractComputerMenu>>register(ModRegistry.Menus.POCKET_COMPUTER_NO_TERM.get(), NoTermComputerScreen::new);
|
||||
MenuScreens.register(ModRegistry.Menus.TURTLE.get(), TurtleScreen::new);
|
||||
|
||||
MenuScreens.register(ModRegistry.Menus.PRINTER.get(), GuiPrinter::new);
|
||||
MenuScreens.register(ModRegistry.Menus.DISK_DRIVE.get(), GuiDiskDrive::new);
|
||||
MenuScreens.register(ModRegistry.Menus.PRINTOUT.get(), GuiPrintout::new);
|
||||
MenuScreens.register(ModRegistry.Menus.PRINTER.get(), PrinterScreen::new);
|
||||
MenuScreens.register(ModRegistry.Menus.DISK_DRIVE.get(), DiskDriveScreen::new);
|
||||
MenuScreens.register(ModRegistry.Menus.PRINTOUT.get(), PrintoutScreen::new);
|
||||
|
||||
MenuScreens.<ContainerViewComputer, GuiComputer<ContainerViewComputer>>register(ModRegistry.Menus.VIEW_COMPUTER.get(), GuiComputer::new);
|
||||
MenuScreens.<ViewComputerMenu, ComputerScreen<ViewComputerMenu>>register(ModRegistry.Menus.VIEW_COMPUTER.get(), ComputerScreen::new);
|
||||
|
||||
registerItemProperty("state",
|
||||
(stack, world, player, random) -> ClientPocketComputers.get(stack).getState().ordinal(),
|
||||
new UnclampedPropertyFunction((stack, world, player, random) -> ClientPocketComputers.get(stack).getState().ordinal()),
|
||||
ModRegistry.Items.POCKET_COMPUTER_NORMAL, ModRegistry.Items.POCKET_COMPUTER_ADVANCED
|
||||
);
|
||||
registerItemProperty("coloured",
|
||||
@ -95,8 +98,7 @@ public final class ClientRegistry {
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void registerItemProperty(String name, ItemPropertyFunction getter, Supplier<? extends Item>... items) {
|
||||
private static void registerItemProperty(String name, ClampedItemPropertyFunction getter, Supplier<? extends Item>... items) {
|
||||
var id = new ResourceLocation(ComputerCraftAPI.MOD_ID, name);
|
||||
for (var item : items) ItemProperties.register(item.get(), id, getter);
|
||||
}
|
||||
@ -130,7 +132,7 @@ public final class ClientRegistry {
|
||||
|
||||
public static void registerItemColours(BiConsumer<ItemColor, ItemLike> register) {
|
||||
register.accept(
|
||||
(stack, layer) -> layer == 1 ? ((ItemDisk) stack.getItem()).getColour(stack) : 0xFFFFFF,
|
||||
(stack, layer) -> layer == 1 ? ((DiskItem) stack.getItem()).getColour(stack) : 0xFFFFFF,
|
||||
ModRegistry.Items.DISK.get()
|
||||
);
|
||||
|
||||
@ -165,10 +167,10 @@ public final class ClientRegistry {
|
||||
}
|
||||
|
||||
public static void registerBlockEntityRenderers(BlockEntityRenderRegistry register) {
|
||||
register.register(ModRegistry.BlockEntities.MONITOR_NORMAL.get(), TileEntityMonitorRenderer::new);
|
||||
register.register(ModRegistry.BlockEntities.MONITOR_ADVANCED.get(), TileEntityMonitorRenderer::new);
|
||||
register.register(ModRegistry.BlockEntities.TURTLE_NORMAL.get(), TileEntityTurtleRenderer::new);
|
||||
register.register(ModRegistry.BlockEntities.TURTLE_ADVANCED.get(), TileEntityTurtleRenderer::new);
|
||||
register.register(ModRegistry.BlockEntities.MONITOR_NORMAL.get(), MonitorBlockEntityRenderer::new);
|
||||
register.register(ModRegistry.BlockEntities.MONITOR_ADVANCED.get(), MonitorBlockEntityRenderer::new);
|
||||
register.register(ModRegistry.BlockEntities.TURTLE_NORMAL.get(), TurtleBlockEntityRenderer::new);
|
||||
register.register(ModRegistry.BlockEntities.TURTLE_ADVANCED.get(), TurtleBlockEntityRenderer::new);
|
||||
}
|
||||
|
||||
public interface BlockEntityRenderRegistry {
|
||||
@ -178,4 +180,19 @@ public final class ClientRegistry {
|
||||
public static void registerShaders(ResourceManager resources, BiConsumer<ShaderInstance, Consumer<ShaderInstance>> load) throws IOException {
|
||||
RenderTypes.registerShaders(resources, load);
|
||||
}
|
||||
|
||||
private record UnclampedPropertyFunction(
|
||||
ClampedItemPropertyFunction function
|
||||
) implements ClampedItemPropertyFunction {
|
||||
@Override
|
||||
public float unclampedCall(ItemStack stack, @Nullable ClientLevel level, @Nullable LivingEntity entity, int layer) {
|
||||
return function.unclampedCall(stack, level, entity, layer);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public float call(ItemStack stack, @Nullable ClientLevel level, @Nullable LivingEntity entity, int layer) {
|
||||
return function.unclampedCall(stack, level, entity, layer);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
|
||||
import dan200.computercraft.impl.client.ComputerCraftAPIClientService;
|
||||
|
||||
|
||||
@AutoService(ComputerCraftAPIClientService.class)
|
||||
public final class ComputerCraftAPIClientImpl implements ComputerCraftAPIClientService {
|
||||
@Override
|
@ -8,12 +8,12 @@ package dan200.computercraft.client.gui;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.client.gui.widgets.ComputerSidebar;
|
||||
import dan200.computercraft.client.gui.widgets.DynamicImageButton;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
import dan200.computercraft.client.gui.widgets.TerminalWidget;
|
||||
import dan200.computercraft.client.platform.ClientPlatformHelper;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.InputHandler;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.computer.inventory.AbstractComputerMenu;
|
||||
import dan200.computercraft.shared.computer.upload.FileUpload;
|
||||
import dan200.computercraft.shared.computer.upload.UploadResult;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
@ -40,15 +40,15 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static dan200.computercraft.core.util.Nullability.assertNonNull;
|
||||
|
||||
public abstract class ComputerScreenBase<T extends ContainerComputerBase> extends AbstractContainerScreen<T> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ComputerScreenBase.class);
|
||||
public abstract class AbstractComputerScreen<T extends AbstractComputerMenu> extends AbstractContainerScreen<T> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractComputerScreen.class);
|
||||
|
||||
private static final Component OK = Component.translatable("gui.ok");
|
||||
private static final Component NO_RESPONSE_TITLE = Component.translatable("gui.computercraft.upload.no_response");
|
||||
private static final Component NO_RESPONSE_MSG = Component.translatable("gui.computercraft.upload.no_response.msg",
|
||||
Component.literal("import").withStyle(ChatFormatting.DARK_GRAY));
|
||||
|
||||
protected @Nullable WidgetTerminal terminal;
|
||||
protected @Nullable TerminalWidget terminal;
|
||||
protected Terminal terminalData;
|
||||
protected final ComputerFamily family;
|
||||
protected final InputHandler input;
|
||||
@ -58,7 +58,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend
|
||||
private long uploadNagDeadline = Long.MAX_VALUE;
|
||||
private final ItemStack displayStack;
|
||||
|
||||
public ComputerScreenBase(T container, Inventory player, Component title, int sidebarYOffset) {
|
||||
public AbstractComputerScreen(T container, Inventory player, Component title, int sidebarYOffset) {
|
||||
super(container, player, title);
|
||||
terminalData = container.getTerminal();
|
||||
family = container.getFamily();
|
||||
@ -67,9 +67,9 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend
|
||||
this.sidebarYOffset = sidebarYOffset;
|
||||
}
|
||||
|
||||
protected abstract WidgetTerminal createTerminal();
|
||||
protected abstract TerminalWidget createTerminal();
|
||||
|
||||
protected final WidgetTerminal getTerminal() {
|
||||
protected final TerminalWidget getTerminal() {
|
||||
if (terminal == null) throw new IllegalStateException("Screen has not been initialised yet");
|
||||
return terminal;
|
||||
}
|
@ -7,26 +7,26 @@ package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.client.gui.widgets.ComputerSidebar;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
import dan200.computercraft.client.gui.widgets.TerminalWidget;
|
||||
import dan200.computercraft.client.render.ComputerBorderRenderer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.computer.inventory.AbstractComputerMenu;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER;
|
||||
import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMAP;
|
||||
|
||||
public final class GuiComputer<T extends ContainerComputerBase> extends ComputerScreenBase<T> {
|
||||
public GuiComputer(T container, Inventory player, Component title) {
|
||||
public final class ComputerScreen<T extends AbstractComputerMenu> extends AbstractComputerScreen<T> {
|
||||
public ComputerScreen(T container, Inventory player, Component title) {
|
||||
super(container, player, title, BORDER);
|
||||
|
||||
imageWidth = WidgetTerminal.getWidth(terminalData.getWidth()) + BORDER * 2 + ComputerSidebar.WIDTH;
|
||||
imageHeight = WidgetTerminal.getHeight(terminalData.getHeight()) + BORDER * 2;
|
||||
imageWidth = TerminalWidget.getWidth(terminalData.getWidth()) + BORDER * 2 + AbstractComputerMenu.SIDEBAR_WIDTH;
|
||||
imageHeight = TerminalWidget.getHeight(terminalData.getHeight()) + BORDER * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WidgetTerminal createTerminal() {
|
||||
return new WidgetTerminal(terminalData, input, leftPos + ComputerSidebar.WIDTH + BORDER, topPos + BORDER);
|
||||
protected TerminalWidget createTerminal() {
|
||||
return new TerminalWidget(terminalData, input, leftPos + AbstractComputerMenu.SIDEBAR_WIDTH + BORDER, topPos + BORDER);
|
||||
}
|
||||
|
||||
@Override
|
@ -7,17 +7,17 @@ package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveMenu;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
|
||||
public class GuiDiskDrive extends AbstractContainerScreen<ContainerDiskDrive> {
|
||||
public class DiskDriveScreen extends AbstractContainerScreen<DiskDriveMenu> {
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/disk_drive.png");
|
||||
|
||||
public GuiDiskDrive(ContainerDiskDrive container, Inventory player, Component title) {
|
||||
public DiskDriveScreen(DiskDriveMenu container, Inventory player, Component title) {
|
||||
super(container, player, title);
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
import dan200.computercraft.client.gui.widgets.TerminalWidget;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.computer.inventory.AbstractComputerMenu;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.MenuAccess;
|
||||
@ -20,10 +20,10 @@ import javax.annotation.Nullable;
|
||||
|
||||
import static dan200.computercraft.core.util.Nullability.assertNonNull;
|
||||
|
||||
public class NoTermComputerScreen<T extends ContainerComputerBase> extends Screen implements MenuAccess<T> {
|
||||
public class NoTermComputerScreen<T extends AbstractComputerMenu> extends Screen implements MenuAccess<T> {
|
||||
private final T menu;
|
||||
private final Terminal terminalData;
|
||||
private @Nullable WidgetTerminal terminal;
|
||||
private @Nullable TerminalWidget terminal;
|
||||
|
||||
public NoTermComputerScreen(T menu, Inventory player, Component title) {
|
||||
super(title);
|
||||
@ -48,7 +48,7 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> extends Scree
|
||||
super.init();
|
||||
minecraft.keyboardHandler.setSendRepeatsToGui(true);
|
||||
|
||||
terminal = addWidget(new WidgetTerminal(terminalData, new ClientInputHandler(menu), 0, 0));
|
||||
terminal = addWidget(new TerminalWidget(terminalData, new ClientInputHandler(menu), 0, 0));
|
||||
terminal.visible = false;
|
||||
terminal.active = false;
|
||||
setFocused(terminal);
|
@ -7,17 +7,17 @@ package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
|
||||
import dan200.computercraft.shared.peripheral.printer.PrinterMenu;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
|
||||
public class GuiPrinter extends AbstractContainerScreen<ContainerPrinter> {
|
||||
public class PrinterScreen extends AbstractContainerScreen<PrinterMenu> {
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/printer.png");
|
||||
|
||||
public GuiPrinter(ContainerPrinter container, Inventory player, Component title) {
|
||||
public PrinterScreen(PrinterMenu container, Inventory player, Component title) {
|
||||
super(container, player, title);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.common.ContainerHeldItem;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.common.HeldItemMenu;
|
||||
import dan200.computercraft.shared.media.items.PrintoutItem;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@ -20,29 +20,29 @@ import org.lwjgl.glfw.GLFW;
|
||||
import static dan200.computercraft.client.render.PrintoutRenderer.*;
|
||||
import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMAP;
|
||||
|
||||
public class GuiPrintout extends AbstractContainerScreen<ContainerHeldItem> {
|
||||
public class PrintoutScreen extends AbstractContainerScreen<HeldItemMenu> {
|
||||
private final boolean book;
|
||||
private final int pages;
|
||||
private final TextBuffer[] text;
|
||||
private final TextBuffer[] colours;
|
||||
private int page;
|
||||
|
||||
public GuiPrintout(ContainerHeldItem container, Inventory player, Component title) {
|
||||
public PrintoutScreen(HeldItemMenu container, Inventory player, Component title) {
|
||||
super(container, player, title);
|
||||
|
||||
imageHeight = Y_SIZE;
|
||||
|
||||
var text = ItemPrintout.getText(container.getStack());
|
||||
var text = PrintoutItem.getText(container.getStack());
|
||||
this.text = new TextBuffer[text.length];
|
||||
for (var i = 0; i < this.text.length; i++) this.text[i] = new TextBuffer(text[i]);
|
||||
|
||||
var colours = ItemPrintout.getColours(container.getStack());
|
||||
var colours = PrintoutItem.getColours(container.getStack());
|
||||
this.colours = new TextBuffer[colours.length];
|
||||
for (var i = 0; i < this.colours.length; i++) this.colours[i] = new TextBuffer(colours[i]);
|
||||
|
||||
page = 0;
|
||||
pages = Math.max(this.text.length / ItemPrintout.LINES_PER_PAGE, 1);
|
||||
book = ((ItemPrintout) container.getStack().getItem()).getType() == ItemPrintout.Type.BOOK;
|
||||
pages = Math.max(this.text.length / PrintoutItem.LINES_PER_PAGE, 1);
|
||||
book = ((PrintoutItem) container.getStack().getItem()).getType() == PrintoutItem.Type.BOOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +88,7 @@ public class GuiPrintout extends AbstractContainerScreen<ContainerHeldItem> {
|
||||
|
||||
var renderer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||
drawBorder(transform, renderer, leftPos, topPos, getBlitOffset(), page, pages, book, FULL_BRIGHT_LIGHTMAP);
|
||||
drawText(transform, renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours);
|
||||
drawText(transform, renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, PrintoutItem.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours);
|
||||
renderer.endBatch();
|
||||
}
|
||||
|
@ -9,17 +9,18 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.gui.widgets.ComputerSidebar;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
import dan200.computercraft.client.gui.widgets.TerminalWidget;
|
||||
import dan200.computercraft.client.render.ComputerBorderRenderer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||
import dan200.computercraft.shared.computer.inventory.AbstractComputerMenu;
|
||||
import dan200.computercraft.shared.turtle.inventory.TurtleMenu;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
import static dan200.computercraft.shared.turtle.inventory.ContainerTurtle.*;
|
||||
import static dan200.computercraft.shared.turtle.inventory.TurtleMenu.*;
|
||||
|
||||
public class GuiTurtle extends ComputerScreenBase<ContainerTurtle> {
|
||||
public class TurtleScreen extends AbstractComputerScreen<TurtleMenu> {
|
||||
private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_normal.png");
|
||||
private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_advanced.png");
|
||||
|
||||
@ -28,24 +29,24 @@ public class GuiTurtle extends ComputerScreenBase<ContainerTurtle> {
|
||||
|
||||
private final ComputerFamily family;
|
||||
|
||||
public GuiTurtle(ContainerTurtle container, Inventory player, Component title) {
|
||||
public TurtleScreen(TurtleMenu container, Inventory player, Component title) {
|
||||
super(container, player, title, BORDER);
|
||||
family = container.getFamily();
|
||||
|
||||
imageWidth = TEX_WIDTH + ComputerSidebar.WIDTH;
|
||||
imageWidth = TEX_WIDTH + AbstractComputerMenu.SIDEBAR_WIDTH;
|
||||
imageHeight = TEX_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WidgetTerminal createTerminal() {
|
||||
return new WidgetTerminal(terminalData, input, leftPos + BORDER + ComputerSidebar.WIDTH, topPos + BORDER);
|
||||
protected TerminalWidget createTerminal() {
|
||||
return new TerminalWidget(terminalData, input, leftPos + BORDER + AbstractComputerMenu.SIDEBAR_WIDTH, topPos + BORDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack transform, float partialTicks, int mouseX, int mouseY) {
|
||||
var advanced = family == ComputerFamily.ADVANCED;
|
||||
RenderSystem.setShaderTexture(0, advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL);
|
||||
blit(transform, leftPos + ComputerSidebar.WIDTH, topPos, 0, 0, TEX_WIDTH, TEX_HEIGHT);
|
||||
blit(transform, leftPos + AbstractComputerMenu.SIDEBAR_WIDTH, topPos, 0, 0, TEX_WIDTH, TEX_HEIGHT);
|
||||
|
||||
var slot = getMenu().getSelectedSlot();
|
||||
if (slot >= 0) {
|
@ -9,6 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.render.ComputerBorderRenderer;
|
||||
import dan200.computercraft.shared.computer.core.InputHandler;
|
||||
import dan200.computercraft.shared.computer.inventory.AbstractComputerMenu;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@ -39,7 +40,6 @@ public final class ComputerSidebar {
|
||||
|
||||
private static final int BUTTONS = 2;
|
||||
private static final int HEIGHT = (ICON_HEIGHT + ICON_MARGIN * 2) * BUTTONS + CORNERS_BORDER * 2;
|
||||
public static final int WIDTH = 17;
|
||||
|
||||
private ComputerSidebar() {
|
||||
}
|
||||
@ -73,18 +73,18 @@ public final class ComputerSidebar {
|
||||
|
||||
public static void renderBackground(PoseStack transform, int x, int y) {
|
||||
Screen.blit(transform,
|
||||
x, y, 0, 102, WIDTH, FULL_BORDER,
|
||||
x, y, 0, 102, AbstractComputerMenu.SIDEBAR_WIDTH, FULL_BORDER,
|
||||
ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE
|
||||
);
|
||||
|
||||
Screen.blit(transform,
|
||||
x, y + FULL_BORDER, WIDTH, HEIGHT - FULL_BORDER * 2,
|
||||
0, 107, WIDTH, 4,
|
||||
x, y + FULL_BORDER, AbstractComputerMenu.SIDEBAR_WIDTH, HEIGHT - FULL_BORDER * 2,
|
||||
0, 107, AbstractComputerMenu.SIDEBAR_WIDTH, 4,
|
||||
ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE
|
||||
);
|
||||
|
||||
Screen.blit(transform,
|
||||
x, y + HEIGHT - FULL_BORDER, 0, 111, WIDTH, FULL_BORDER,
|
||||
x, y + HEIGHT - FULL_BORDER, 0, 111, AbstractComputerMenu.SIDEBAR_WIDTH, FULL_BORDER,
|
||||
ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE
|
||||
);
|
||||
}
|
@ -25,7 +25,7 @@ import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN;
|
||||
import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_WIDTH;
|
||||
|
||||
public class WidgetTerminal extends AbstractWidget {
|
||||
public class TerminalWidget extends AbstractWidget {
|
||||
private static final float TERMINATE_TIME = 0.5f;
|
||||
|
||||
private final Terminal terminal;
|
||||
@ -47,7 +47,7 @@ public class WidgetTerminal extends AbstractWidget {
|
||||
|
||||
private final BitSet keysDown = new BitSet(256);
|
||||
|
||||
public WidgetTerminal(Terminal terminal, InputHandler computer, int x, int y) {
|
||||
public TerminalWidget(Terminal terminal, InputHandler computer, int x, int y) {
|
||||
super(x, y, terminal.getWidth() * FONT_WIDTH + MARGIN * 2, terminal.getHeight() * FONT_HEIGHT + MARGIN * 2, Component.empty());
|
||||
|
||||
this.terminal = terminal;
|
@ -7,7 +7,7 @@ package dan200.computercraft.client.integration;
|
||||
|
||||
import dan200.computercraft.client.render.RenderTypes;
|
||||
import dan200.computercraft.client.render.text.DirectFixedWidthFontRenderer;
|
||||
import dan200.computercraft.client.util.DirectVertexBuffer;
|
||||
import dan200.computercraft.client.render.vbo.DirectVertexBuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Optional;
|
@ -10,9 +10,10 @@ import com.mojang.math.Transformation;
|
||||
import dan200.computercraft.api.client.TransformedModel;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
|
||||
import dan200.computercraft.client.platform.ClientPlatformHelper;
|
||||
import dan200.computercraft.client.render.TurtleBlockEntityRenderer;
|
||||
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtle;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItem;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@ -70,7 +71,7 @@ public final class TurtleModelParts {
|
||||
}
|
||||
|
||||
public Combination getCombination(ItemStack stack) {
|
||||
var turtle = (ItemTurtle) stack.getItem();
|
||||
var turtle = (TurtleItem) stack.getItem();
|
||||
|
||||
var colour = turtle.getColour(stack);
|
||||
var leftUpgrade = turtle.getUpgrade(stack, TurtleSide.LEFT);
|
||||
@ -91,9 +92,9 @@ public final class TurtleModelParts {
|
||||
var parts = new ArrayList<BakedModel>(4);
|
||||
parts.add(transform(combo.colour() ? colourModel : familyModel, transformation));
|
||||
|
||||
var overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel(combo.overlay(), combo.christmas());
|
||||
var overlayModelLocation = TurtleBlockEntityRenderer.getTurtleOverlayModel(combo.overlay(), combo.christmas());
|
||||
if (overlayModelLocation != null) {
|
||||
parts.add(transform(modelManager.getModel(overlayModelLocation), transformation));
|
||||
parts.add(transform(ClientPlatformHelper.get().getModel(modelManager, overlayModelLocation), transformation));
|
||||
}
|
||||
if (combo.leftUpgrade() != null) {
|
||||
var model = TurtleUpgradeModellers.getModel(combo.leftUpgrade(), null, TurtleSide.LEFT);
|
@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.client.platform;
|
||||
|
||||
import dan200.computercraft.client.ClientTableFormatter;
|
||||
import dan200.computercraft.client.gui.ComputerScreenBase;
|
||||
import dan200.computercraft.client.gui.AbstractComputerScreen;
|
||||
import dan200.computercraft.client.gui.OptionScreen;
|
||||
import dan200.computercraft.client.pocket.ClientPocketComputers;
|
||||
import dan200.computercraft.client.sound.SpeakerManager;
|
||||
@ -16,7 +16,7 @@ import dan200.computercraft.shared.computer.menu.ComputerMenu;
|
||||
import dan200.computercraft.shared.computer.terminal.TerminalState;
|
||||
import dan200.computercraft.shared.computer.upload.UploadResult;
|
||||
import dan200.computercraft.shared.network.client.ClientNetworkContext;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlockEntity;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@ -54,7 +54,7 @@ public abstract class AbstractClientNetworkContext implements ClientNetworkConte
|
||||
if (player == null) return;
|
||||
|
||||
var te = player.level.getBlockEntity(pos);
|
||||
if (!(te instanceof TileMonitor monitor)) return;
|
||||
if (!(te instanceof MonitorBlockEntity monitor)) return;
|
||||
|
||||
monitor.read(terminal);
|
||||
}
|
||||
@ -101,8 +101,8 @@ public abstract class AbstractClientNetworkContext implements ClientNetworkConte
|
||||
var minecraft = Minecraft.getInstance();
|
||||
|
||||
var screen = OptionScreen.unwrap(minecraft.screen);
|
||||
if (screen instanceof ComputerScreenBase<?> && ((ComputerScreenBase<?>) screen).getMenu().containerId == containerId) {
|
||||
((ComputerScreenBase<?>) screen).uploadResult(result, errorMessage);
|
||||
if (screen instanceof AbstractComputerScreen<?> && ((AbstractComputerScreen<?>) screen).getMenu().containerId == containerId) {
|
||||
((AbstractComputerScreen<?>) screen).uploadResult(result, errorMessage);
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package dan200.computercraft.client.pocket;
|
||||
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItem;
|
||||
import dan200.computercraft.shared.network.client.PocketComputerDataMessage;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@ -47,7 +47,7 @@ public final class ClientPocketComputers {
|
||||
}
|
||||
|
||||
public static PocketComputerData get(ItemStack stack) {
|
||||
var family = stack.getItem() instanceof ItemComputer computer ? computer.getFamily() : ComputerFamily.NORMAL;
|
||||
return get(ItemPocketComputer.getInstanceID(stack), family != ComputerFamily.NORMAL);
|
||||
var family = stack.getItem() instanceof ComputerItem computer ? computer.getFamily() : ComputerFamily.NORMAL;
|
||||
return get(PocketComputerItem.getInstanceID(stack), family != ComputerFamily.NORMAL);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableBlock;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableShapes;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.client.Camera;
|
||||
@ -37,7 +37,7 @@ public final class CableHighlightRenderer {
|
||||
var state = world.getBlockState(pos);
|
||||
|
||||
// We only care about instances with both cable and modem.
|
||||
if (state.getBlock() != ModRegistry.Blocks.CABLE.get() || state.getValue(BlockCable.MODEM).getFacing() == null || !state.getValue(BlockCable.CABLE)) {
|
||||
if (state.getBlock() != ModRegistry.Blocks.CABLE.get() || state.getValue(CableBlock.MODEM).getFacing() == null || !state.getValue(CableBlock.CABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import dan200.computercraft.client.pocket.ClientPocketComputers;
|
||||
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@ -23,10 +23,10 @@ import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FON
|
||||
/**
|
||||
* Emulates map rendering for pocket computers.
|
||||
*/
|
||||
public final class ItemPocketRenderer extends ItemMapLikeRenderer {
|
||||
public static final ItemPocketRenderer INSTANCE = new ItemPocketRenderer();
|
||||
public final class PocketItemRenderer extends ItemMapLikeRenderer {
|
||||
public static final PocketItemRenderer INSTANCE = new PocketItemRenderer();
|
||||
|
||||
private ItemPocketRenderer() {
|
||||
private PocketItemRenderer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,7 +52,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer {
|
||||
transform.translate(-0.5 * width, -0.5 * height, 0);
|
||||
|
||||
// Render the main frame
|
||||
var item = (ItemPocketComputer) stack.getItem();
|
||||
var item = (PocketComputerItem) stack.getItem();
|
||||
var family = item.getFamily();
|
||||
var frameColour = item.getColour(stack);
|
||||
|
@ -7,7 +7,7 @@ package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.media.items.PrintoutItem;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
||||
@ -16,16 +16,16 @@ import net.minecraft.world.item.ItemStack;
|
||||
import static dan200.computercraft.client.render.PrintoutRenderer.*;
|
||||
import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_WIDTH;
|
||||
import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE;
|
||||
import static dan200.computercraft.shared.media.items.ItemPrintout.LINE_MAX_LENGTH;
|
||||
import static dan200.computercraft.shared.media.items.PrintoutItem.LINES_PER_PAGE;
|
||||
import static dan200.computercraft.shared.media.items.PrintoutItem.LINE_MAX_LENGTH;
|
||||
|
||||
/**
|
||||
* Emulates map and item-frame rendering for printouts.
|
||||
*/
|
||||
public final class ItemPrintoutRenderer extends ItemMapLikeRenderer {
|
||||
public static final ItemPrintoutRenderer INSTANCE = new ItemPrintoutRenderer();
|
||||
public final class PrintoutItemRenderer extends ItemMapLikeRenderer {
|
||||
public static final PrintoutItemRenderer INSTANCE = new PrintoutItemRenderer();
|
||||
|
||||
private ItemPrintoutRenderer() {
|
||||
private PrintoutItemRenderer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,7 +38,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer {
|
||||
}
|
||||
|
||||
public static void onRenderInFrame(PoseStack transform, MultiBufferSource render, ItemFrame frame, ItemStack stack, int packedLight) {
|
||||
if (!(stack.getItem() instanceof ItemPrintout)) return;
|
||||
if (!(stack.getItem() instanceof PrintoutItem)) return;
|
||||
|
||||
// Move a little bit forward to ensure we're not clipping with the frame
|
||||
transform.translate(0.0f, 0.0f, -0.001f);
|
||||
@ -51,8 +51,8 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer {
|
||||
}
|
||||
|
||||
private static void drawPrintout(PoseStack transform, MultiBufferSource render, ItemStack stack, int light) {
|
||||
var pages = ItemPrintout.getPageCount(stack);
|
||||
var book = ((ItemPrintout) stack.getItem()).getType() == ItemPrintout.Type.BOOK;
|
||||
var pages = PrintoutItem.getPageCount(stack);
|
||||
var book = ((PrintoutItem) stack.getItem()).getType() == PrintoutItem.Type.BOOK;
|
||||
|
||||
double width = LINE_MAX_LENGTH * FONT_WIDTH + X_TEXT_MARGIN * 2;
|
||||
double height = LINES_PER_PAGE * FONT_HEIGHT + Y_TEXT_MARGIN * 2;
|
||||
@ -78,7 +78,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer {
|
||||
drawBorder(transform, render, 0, 0, -0.01f, 0, pages, book, light);
|
||||
drawText(
|
||||
transform, render, X_TEXT_MARGIN, Y_TEXT_MARGIN, 0, light,
|
||||
ItemPrintout.getText(stack), ItemPrintout.getColours(stack)
|
||||
PrintoutItem.getText(stack), PrintoutItem.getColours(stack)
|
||||
);
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
||||
import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE;
|
||||
import static dan200.computercraft.shared.media.items.PrintoutItem.LINES_PER_PAGE;
|
||||
|
||||
public final class PrintoutRenderer {
|
||||
private static final float BG_SIZE = 256.0f;
|
@ -8,6 +8,7 @@ package dan200.computercraft.client.render;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.client.render.monitor.MonitorTextureBufferShader;
|
||||
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
@ -50,12 +51,12 @@ public class RenderTypes {
|
||||
*/
|
||||
public static final RenderType PRINTOUT_BACKGROUND = RenderType.text(new ResourceLocation("computercraft", "textures/gui/printout.png"));
|
||||
|
||||
static MonitorTextureBufferShader getMonitorTextureBufferShader() {
|
||||
public static MonitorTextureBufferShader getMonitorTextureBufferShader() {
|
||||
if (monitorTboShader == null) throw new NullPointerException("MonitorTboShader has not been registered");
|
||||
return monitorTboShader;
|
||||
}
|
||||
|
||||
static ShaderInstance getTerminalShader() {
|
||||
public static ShaderInstance getTerminalShader() {
|
||||
return Objects.requireNonNull(GameRenderer.getRendertypeTextShader(), "Text shader has not been registered");
|
||||
}
|
||||
|
||||
@ -63,14 +64,14 @@ public class RenderTypes {
|
||||
load.accept(
|
||||
new MonitorTextureBufferShader(
|
||||
resources,
|
||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "monitor_tbo"),
|
||||
ComputerCraftAPI.MOD_ID + "/monitor_tbo",
|
||||
MONITOR_TBO.format()
|
||||
),
|
||||
x -> monitorTboShader = (MonitorTextureBufferShader) x
|
||||
);
|
||||
}
|
||||
|
||||
private static final class Types extends RenderStateShard {
|
||||
private static final class Types extends RenderType {
|
||||
private static final RenderStateShard.TextureStateShard TERM_FONT_TEXTURE = new TextureStateShard(
|
||||
FixedWidthFontRenderer.FONT,
|
||||
false, false // blur, minimap
|
||||
@ -85,8 +86,9 @@ public class RenderTypes {
|
||||
.createCompositeState(false)
|
||||
);
|
||||
|
||||
private Types(String name, Runnable setup, Runnable destroy) {
|
||||
super(name, setup, destroy);
|
||||
@SuppressWarnings("UnusedMethod")
|
||||
private Types(String name, VertexFormat format, VertexFormat.Mode mode, int buffer, boolean crumbling, boolean sort, Runnable setup, Runnable teardown) {
|
||||
super(name, format, mode, buffer, crumbling, sort, setup, teardown);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,16 +7,19 @@ package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.client.platform.ClientPlatformHelper;
|
||||
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@ -33,7 +36,7 @@ import net.minecraft.world.phys.HitResult;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> {
|
||||
public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBlockEntity> {
|
||||
private static final ModelResourceLocation NORMAL_TURTLE_MODEL = new ModelResourceLocation("computercraft:turtle_normal", "inventory");
|
||||
private static final ModelResourceLocation ADVANCED_TURTLE_MODEL = new ModelResourceLocation("computercraft:turtle_advanced", "inventory");
|
||||
private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
|
||||
@ -42,9 +45,11 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
|
||||
private final RandomSource random = RandomSource.create(0);
|
||||
|
||||
private final BlockEntityRenderDispatcher renderer;
|
||||
private final Font font;
|
||||
|
||||
public TileEntityTurtleRenderer(BlockEntityRendererProvider.Context context) {
|
||||
public TurtleBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
|
||||
renderer = context.getBlockEntityRenderDispatcher();
|
||||
font = context.getFont();
|
||||
}
|
||||
|
||||
public static ResourceLocation getTurtleModel(ComputerFamily family, boolean coloured) {
|
||||
@ -61,13 +66,13 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileTurtle turtle, float partialTicks, PoseStack transform, MultiBufferSource buffers, int lightmapCoord, int overlayLight) {
|
||||
public void render(TurtleBlockEntity turtle, float partialTicks, PoseStack transform, MultiBufferSource buffers, int lightmapCoord, int overlayLight) {
|
||||
// Render the label
|
||||
var label = turtle.getLabel();
|
||||
var hit = renderer.cameraHitResult;
|
||||
if (label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getBlockPos().equals(((BlockHitResult) hit).getBlockPos())) {
|
||||
var mc = Minecraft.getInstance();
|
||||
var font = renderer.font;
|
||||
var font = this.font;
|
||||
|
||||
transform.pushPose();
|
||||
transform.translate(0.5, 1.2, 0.5);
|
||||
@ -119,7 +124,7 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
|
||||
transform.popPose();
|
||||
}
|
||||
|
||||
private void renderUpgrade(PoseStack transform, VertexConsumer renderer, int lightmapCoord, int overlayLight, TileTurtle turtle, TurtleSide side, float f) {
|
||||
private void renderUpgrade(PoseStack transform, VertexConsumer renderer, int lightmapCoord, int overlayLight, TurtleBlockEntity turtle, TurtleSide side, float f) {
|
||||
var upgrade = turtle.getUpgrade(side);
|
||||
if (upgrade == null) return;
|
||||
transform.pushPose();
|
||||
@ -130,7 +135,7 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
|
||||
transform.translate(0.0f, -0.5f, -0.5f);
|
||||
|
||||
var model = TurtleUpgradeModellers.getModel(upgrade, turtle.getAccess(), side);
|
||||
model.getMatrix().push(transform);
|
||||
pushPoseFromTransformation(transform, model.getMatrix());
|
||||
renderModel(transform, renderer, lightmapCoord, overlayLight, model.getModel(), null);
|
||||
transform.popPose();
|
||||
|
||||
@ -139,7 +144,7 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
|
||||
|
||||
private void renderModel(PoseStack transform, VertexConsumer renderer, int lightmapCoord, int overlayLight, ResourceLocation modelLocation, @Nullable int[] tints) {
|
||||
var modelManager = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getModelManager();
|
||||
renderModel(transform, renderer, lightmapCoord, overlayLight, modelManager.getModel(modelLocation), tints);
|
||||
renderModel(transform, renderer, lightmapCoord, overlayLight, ClientPlatformHelper.get().getModel(modelManager, modelLocation), tints);
|
||||
}
|
||||
|
||||
private void renderModel(PoseStack transform, VertexConsumer renderer, int lightmapCoord, int overlayLight, BakedModel model, @Nullable int[] tints) {
|
||||
@ -166,4 +171,18 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
|
||||
buffer.putBulkData(matrix, bakedquad, r, g, b, lightmapCoord, overlayLight);
|
||||
}
|
||||
}
|
||||
|
||||
private static void pushPoseFromTransformation(PoseStack stack, Transformation transformation) {
|
||||
stack.pushPose();
|
||||
|
||||
var trans = transformation.getTranslation();
|
||||
stack.translate(trans.x(), trans.y(), trans.z());
|
||||
|
||||
stack.mulPose(transformation.getLeftRotation());
|
||||
|
||||
var scale = transformation.getScale();
|
||||
stack.scale(scale.x(), scale.y(), scale.z());
|
||||
|
||||
stack.mulPose(transformation.getRightRotation());
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.client.render;
|
||||
package dan200.computercraft.client.render.monitor;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.platform.MemoryTracker;
|
||||
@ -17,16 +17,16 @@ import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import dan200.computercraft.client.FrameInfo;
|
||||
import dan200.computercraft.client.integration.ShaderMod;
|
||||
import dan200.computercraft.client.render.monitor.MonitorRenderState;
|
||||
import dan200.computercraft.client.render.RenderTypes;
|
||||
import dan200.computercraft.client.render.text.DirectFixedWidthFontRenderer;
|
||||
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.client.util.DirectBuffers;
|
||||
import dan200.computercraft.client.util.DirectVertexBuffer;
|
||||
import dan200.computercraft.client.render.vbo.DirectBuffers;
|
||||
import dan200.computercraft.client.render.vbo.DirectVertexBuffer;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlockEntity;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@ -47,24 +47,24 @@ import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FON
|
||||
import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_WIDTH;
|
||||
import static dan200.computercraft.core.util.Nullability.assertNonNull;
|
||||
|
||||
public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonitor> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TileEntityMonitorRenderer.class);
|
||||
public class MonitorBlockEntityRenderer implements BlockEntityRenderer<MonitorBlockEntity> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MonitorBlockEntityRenderer.class);
|
||||
|
||||
/**
|
||||
* {@link TileMonitor#RENDER_MARGIN}, but a tiny bit of additional padding to ensure that there is no space between
|
||||
* {@link MonitorBlockEntity#RENDER_MARGIN}, but a tiny bit of additional padding to ensure that there is no space between
|
||||
* the monitor frame and contents.
|
||||
*/
|
||||
private static final float MARGIN = (float) (TileMonitor.RENDER_MARGIN * 1.1);
|
||||
private static final float MARGIN = (float) (MonitorBlockEntity.RENDER_MARGIN * 1.1);
|
||||
|
||||
private static final Matrix3f IDENTITY_NORMAL = Util.make(new Matrix3f(), Matrix3f::setIdentity);
|
||||
|
||||
private static @Nullable ByteBuffer backingBuffer;
|
||||
|
||||
public TileEntityMonitorRenderer(BlockEntityRendererProvider.Context context) {
|
||||
public MonitorBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileMonitor monitor, float partialTicks, PoseStack transform, MultiBufferSource bufferSource, int lightmapCoord, int overlayLight) {
|
||||
public void render(MonitorBlockEntity monitor, float partialTicks, PoseStack transform, MultiBufferSource bufferSource, int lightmapCoord, int overlayLight) {
|
||||
// Render from the origin monitor
|
||||
var originTerminal = monitor.getClientMonitor();
|
||||
|
||||
@ -103,12 +103,12 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
transform.mulPose(Vector3f.YN.rotationDegrees(yaw));
|
||||
transform.mulPose(Vector3f.XP.rotationDegrees(pitch));
|
||||
transform.translate(
|
||||
-0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN,
|
||||
origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0,
|
||||
-0.5 + MonitorBlockEntity.RENDER_BORDER + MonitorBlockEntity.RENDER_MARGIN,
|
||||
origin.getHeight() - 0.5 - (MonitorBlockEntity.RENDER_BORDER + MonitorBlockEntity.RENDER_MARGIN) + 0,
|
||||
0.5
|
||||
);
|
||||
var xSize = origin.getWidth() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER);
|
||||
var ySize = origin.getHeight() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER);
|
||||
var xSize = origin.getWidth() - 2.0 * (MonitorBlockEntity.RENDER_MARGIN + MonitorBlockEntity.RENDER_BORDER);
|
||||
var ySize = origin.getHeight() - 2.0 * (MonitorBlockEntity.RENDER_MARGIN + MonitorBlockEntity.RENDER_BORDER);
|
||||
|
||||
// Draw the contents
|
||||
var terminal = originTerminal.getTerminal();
|
||||
@ -233,7 +233,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
}
|
||||
|
||||
private static void renderToBuffer(DirectVertexBuffer vbo, int size, Consumer<DirectFixedWidthFontRenderer.QuadEmitter> draw) {
|
||||
var sink = ShaderMod.get().getQuadEmitter(size, TileEntityMonitorRenderer::getBuffer);
|
||||
var sink = ShaderMod.get().getQuadEmitter(size, MonitorBlockEntityRenderer::getBuffer);
|
||||
var buffer = sink.buffer();
|
||||
|
||||
draw.accept(sink);
|
@ -3,13 +3,13 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.client.render;
|
||||
package dan200.computercraft.client.render.monitor;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlockEntity;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@ -36,7 +36,7 @@ public final class MonitorHighlightRenderer {
|
||||
var pos = hit.getBlockPos();
|
||||
|
||||
var tile = world.getBlockEntity(pos);
|
||||
if (!(tile instanceof TileMonitor monitor)) return false;
|
||||
if (!(tile instanceof MonitorBlockEntity monitor)) return false;
|
||||
|
||||
// Determine which sides are part of the external faces of the monitor, and so which need to be rendered.
|
||||
var faces = EnumSet.allOf(Direction.class);
|
@ -7,8 +7,8 @@ package dan200.computercraft.client.render.monitor;
|
||||
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import dan200.computercraft.client.util.DirectBuffers;
|
||||
import dan200.computercraft.client.util.DirectVertexBuffer;
|
||||
import dan200.computercraft.client.render.vbo.DirectBuffers;
|
||||
import dan200.computercraft.client.render.vbo.DirectVertexBuffer;
|
||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.client.render;
|
||||
package dan200.computercraft.client.render.monitor;
|
||||
|
||||
import com.mojang.blaze3d.shaders.Uniform;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
@ -13,7 +13,6 @@ import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -38,7 +37,7 @@ public class MonitorTextureBufferShader extends ShaderInstance {
|
||||
|
||||
private final @Nullable Uniform cursorBlink;
|
||||
|
||||
public MonitorTextureBufferShader(ResourceProvider provider, ResourceLocation location, VertexFormat format) throws IOException {
|
||||
public MonitorTextureBufferShader(ResourceProvider provider, String location, VertexFormat format) throws IOException {
|
||||
super(provider, location, format);
|
||||
monitorData = GL31.glGetUniformBlockIndex(getId(), "MonitorData");
|
||||
if (monitorData == -1) throw new IllegalStateException("Could not find MonitorData uniform.");
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.client.util;
|
||||
package dan200.computercraft.client.render.vbo;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.client.util;
|
||||
package dan200.computercraft.client.render.vbo;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client.sound;
|
||||
|
||||
import dan200.computercraft.annotations.ForgeOverride;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition;
|
||||
import net.minecraft.client.resources.sounds.AbstractSoundInstance;
|
||||
import net.minecraft.client.resources.sounds.Sound;
|
||||
@ -61,9 +62,9 @@ public class SpeakerSound extends AbstractSoundInstance implements TickableSound
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForgeOverride
|
||||
public CompletableFuture<AudioStream> getStream(SoundBufferLibrary soundBuffers, Sound sound, boolean looping) {
|
||||
return stream != null ? CompletableFuture.completedFuture(stream) : super.getStream(soundBuffers, sound, looping);
|
||||
return stream != null ? CompletableFuture.completedFuture(stream) : soundBuffers.getStream(sound.getPath(), looping);
|
||||
}
|
||||
|
||||
public @Nullable AudioStream getStream() {
|
@ -12,8 +12,8 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
import dan200.computercraft.shared.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.UpgradeManager;
|
||||
import dan200.computercraft.impl.TurtleUpgrades;
|
||||
import dan200.computercraft.impl.UpgradeManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import javax.annotation.Nullable;
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Equivalent to {@link Override}, but for Forge-specific methods.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface ForgeOverride {
|
||||
}
|
@ -8,16 +8,16 @@ package dan200.computercraft.data;
|
||||
import com.google.gson.JsonObject;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockWiredModemFull;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerBlock;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveBlock;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableBlock;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableModemVariant;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockWirelessModem;
|
||||
import dan200.computercraft.shared.peripheral.monitor.BlockMonitor;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.WiredModemFullBlock;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemBlock;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlock;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorEdgeState;
|
||||
import dan200.computercraft.shared.peripheral.printer.BlockPrinter;
|
||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
import dan200.computercraft.shared.peripheral.printer.PrinterBlock;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlock;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.models.BlockModelGenerators;
|
||||
@ -37,7 +37,7 @@ import java.util.function.Function;
|
||||
import static net.minecraft.data.models.model.ModelLocationUtils.getModelLocation;
|
||||
import static net.minecraft.data.models.model.TextureMapping.getBlockTexture;
|
||||
|
||||
class BlockModelGenerator {
|
||||
class BlockModelProvider {
|
||||
private static final ModelTemplate MONITOR_BASE = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/monitor_base")),
|
||||
Optional.empty(),
|
||||
@ -96,7 +96,7 @@ class BlockModelGenerator {
|
||||
var diskDrive = ModRegistry.Blocks.DISK_DRIVE.get();
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(diskDrive)
|
||||
.with(createHorizontalFacingDispatch())
|
||||
.with(createModelDispatch(BlockDiskDrive.STATE, value -> {
|
||||
.with(createModelDispatch(DiskDriveBlock.STATE, value -> {
|
||||
var textureSuffix = switch (value) {
|
||||
case EMPTY -> "_front";
|
||||
case INVALID -> "_front_rejected";
|
||||
@ -116,7 +116,7 @@ class BlockModelGenerator {
|
||||
var printer = ModRegistry.Blocks.PRINTER.get();
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(printer)
|
||||
.with(createHorizontalFacingDispatch())
|
||||
.with(createModelDispatch(BlockPrinter.TOP, BlockPrinter.BOTTOM, (top, bottom) -> {
|
||||
.with(createModelDispatch(PrinterBlock.TOP, PrinterBlock.BOTTOM, (top, bottom) -> {
|
||||
String model, texture;
|
||||
if (top && bottom) {
|
||||
model = "_both_full";
|
||||
@ -140,10 +140,10 @@ class BlockModelGenerator {
|
||||
generators.delegateItemModel(printer, getModelLocation(printer, "_empty"));
|
||||
}
|
||||
|
||||
private static void registerComputer(BlockModelGenerators generators, BlockComputer<?> block) {
|
||||
private static void registerComputer(BlockModelGenerators generators, ComputerBlock<?> block) {
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(block)
|
||||
.with(createHorizontalFacingDispatch())
|
||||
.with(createModelDispatch(BlockComputer.STATE, state -> ModelTemplates.CUBE_ORIENTABLE.createWithSuffix(
|
||||
.with(createModelDispatch(ComputerBlock.STATE, state -> ModelTemplates.CUBE_ORIENTABLE.createWithSuffix(
|
||||
block, "_" + state.getSerializedName(),
|
||||
TextureMapping.orientableCube(block).put(TextureSlot.FRONT, getBlockTexture(block, "_front" + state.getTexture())),
|
||||
generators.modelOutput
|
||||
@ -152,7 +152,7 @@ class BlockModelGenerator {
|
||||
generators.delegateItemModel(block, getModelLocation(block, "_blinking"));
|
||||
}
|
||||
|
||||
private static void registerTurtle(BlockModelGenerators generators, BlockTurtle block) {
|
||||
private static void registerTurtle(BlockModelGenerators generators, TurtleBlock block) {
|
||||
var model = TURTLE.create(block, TextureMapping.defaultTexture(block), generators.modelOutput);
|
||||
generators.blockStateOutput.accept(
|
||||
MultiVariantGenerator.multiVariant(block, Variant.variant().with(VariantProperties.MODEL, model))
|
||||
@ -167,10 +167,10 @@ class BlockModelGenerator {
|
||||
});
|
||||
}
|
||||
|
||||
private static void registerWirelessModem(BlockModelGenerators generators, BlockWirelessModem block) {
|
||||
private static void registerWirelessModem(BlockModelGenerators generators, WirelessModemBlock block) {
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(block)
|
||||
.with(createFacingDispatch())
|
||||
.with(createModelDispatch(BlockWirelessModem.ON,
|
||||
.with(createModelDispatch(WirelessModemBlock.ON,
|
||||
on -> modemModel(generators, getModelLocation(block, on ? "_on" : "_off"), getBlockTexture(block, "_face" + (on ? "_on" : "")))
|
||||
)));
|
||||
generators.delegateItemModel(block, getModelLocation(block, "_off"));
|
||||
@ -179,7 +179,7 @@ class BlockModelGenerator {
|
||||
private static void registerWiredModems(BlockModelGenerators generators) {
|
||||
var fullBlock = ModRegistry.Blocks.WIRED_MODEM_FULL.get();
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(fullBlock)
|
||||
.with(createModelDispatch(BlockWiredModemFull.MODEM_ON, BlockWiredModemFull.PERIPHERAL_ON, (on, peripheral) -> {
|
||||
.with(createModelDispatch(WiredModemFullBlock.MODEM_ON, WiredModemFullBlock.PERIPHERAL_ON, (on, peripheral) -> {
|
||||
var suffix = (on ? "_on" : "_off") + (peripheral ? "_peripheral" : "");
|
||||
var faceTexture = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem_face" + (peripheral ? "_peripheral" : "") + (on ? "_on" : ""));
|
||||
|
||||
@ -207,7 +207,7 @@ class BlockModelGenerator {
|
||||
);
|
||||
}
|
||||
|
||||
private static void registerMonitor(BlockModelGenerators generators, BlockMonitor block) {
|
||||
private static void registerMonitor(BlockModelGenerators generators, MonitorBlock block) {
|
||||
monitorModel(generators, block, "", 16, 4, 0, 32);
|
||||
monitorModel(generators, block, "_d", 20, 7, 0, 36);
|
||||
monitorModel(generators, block, "_l", 19, 4, 1, 33);
|
||||
@ -227,13 +227,13 @@ class BlockModelGenerator {
|
||||
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(block)
|
||||
.with(createHorizontalFacingDispatch())
|
||||
.with(createVerticalFacingDispatch(BlockMonitor.ORIENTATION))
|
||||
.with(createModelDispatch(BlockMonitor.STATE, edge -> getModelLocation(block, edge == MonitorEdgeState.NONE ? "" : "_" + edge.getSerializedName())))
|
||||
.with(createVerticalFacingDispatch(MonitorBlock.ORIENTATION))
|
||||
.with(createModelDispatch(MonitorBlock.STATE, edge -> getModelLocation(block, edge == MonitorEdgeState.NONE ? "" : "_" + edge.getSerializedName())))
|
||||
);
|
||||
generators.delegateItemModel(block, monitorModel(generators, block, "_item", 15, 4, 0, 32));
|
||||
}
|
||||
|
||||
private static ResourceLocation monitorModel(BlockModelGenerators generators, BlockMonitor block, String corners, int front, int side, int top, int back) {
|
||||
private static ResourceLocation monitorModel(BlockModelGenerators generators, MonitorBlock block, String corners, int front, int side, int top, int back) {
|
||||
return MONITOR_BASE.create(
|
||||
getModelLocation(block, corners),
|
||||
new TextureMapping()
|
||||
@ -253,8 +253,8 @@ class BlockModelGenerator {
|
||||
// Up/Down
|
||||
generator.with(
|
||||
Condition.or(
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST).term(BlockCable.UP, true),
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST).term(BlockCable.DOWN, true)
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST).term(CableBlock.UP, true),
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST).term(CableBlock.DOWN, true)
|
||||
),
|
||||
Variant.variant().with(VariantProperties.MODEL, coreFacing).with(VariantProperties.X_ROT, VariantProperties.Rotation.R90)
|
||||
);
|
||||
@ -263,8 +263,8 @@ class BlockModelGenerator {
|
||||
generator.with(
|
||||
Condition.or(
|
||||
cableNoNeighbour(Direction.UP, Direction.DOWN, Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST),
|
||||
cableNoNeighbour(Direction.UP, Direction.DOWN, Direction.EAST, Direction.WEST).term(BlockCable.NORTH, true),
|
||||
cableNoNeighbour(Direction.UP, Direction.DOWN, Direction.EAST, Direction.WEST).term(BlockCable.SOUTH, true)
|
||||
cableNoNeighbour(Direction.UP, Direction.DOWN, Direction.EAST, Direction.WEST).term(CableBlock.NORTH, true),
|
||||
cableNoNeighbour(Direction.UP, Direction.DOWN, Direction.EAST, Direction.WEST).term(CableBlock.SOUTH, true)
|
||||
),
|
||||
Variant.variant().with(VariantProperties.MODEL, coreFacing).with(VariantProperties.Y_ROT, VariantProperties.Rotation.R0)
|
||||
);
|
||||
@ -272,8 +272,8 @@ class BlockModelGenerator {
|
||||
// East/West
|
||||
generator.with(
|
||||
Condition.or(
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.UP, Direction.DOWN).term(BlockCable.EAST, true),
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.UP, Direction.DOWN).term(BlockCable.WEST, true)
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.UP, Direction.DOWN).term(CableBlock.EAST, true),
|
||||
cableNoNeighbour(Direction.NORTH, Direction.SOUTH, Direction.UP, Direction.DOWN).term(CableBlock.WEST, true)
|
||||
),
|
||||
Variant.variant().with(VariantProperties.MODEL, coreFacing).with(VariantProperties.Y_ROT, VariantProperties.Rotation.R90)
|
||||
);
|
||||
@ -286,7 +286,7 @@ class BlockModelGenerator {
|
||||
if (DirectionUtil.FACINGS[i].getAxis() == DirectionUtil.FACINGS[j].getAxis()) continue;
|
||||
|
||||
rightAngles.add(new Condition.TerminalCondition()
|
||||
.term(BlockCable.CABLE, true).term(CABLE_DIRECTIONS[i], true).term(CABLE_DIRECTIONS[j], true)
|
||||
.term(CableBlock.CABLE, true).term(CABLE_DIRECTIONS[i], true).term(CABLE_DIRECTIONS[j], true)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ class BlockModelGenerator {
|
||||
for (var peripheral : BOOLEANS) {
|
||||
var suffix = (on ? "_on" : "_off") + (peripheral ? "_peripheral" : "");
|
||||
generator.with(
|
||||
new Condition.TerminalCondition().term(BlockCable.MODEM, CableModemVariant.from(direction, on, peripheral)),
|
||||
new Condition.TerminalCondition().term(CableBlock.MODEM, CableModemVariant.from(direction, on, peripheral)),
|
||||
Variant.variant()
|
||||
.with(VariantProperties.MODEL, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem" + suffix))
|
||||
.with(VariantProperties.X_ROT, toXAngle(direction))
|
||||
@ -323,11 +323,11 @@ class BlockModelGenerator {
|
||||
generators.blockStateOutput.accept(generator);
|
||||
}
|
||||
|
||||
private static final BooleanProperty[] CABLE_DIRECTIONS = { BlockCable.DOWN, BlockCable.UP, BlockCable.NORTH, BlockCable.SOUTH, BlockCable.WEST, BlockCable.EAST };
|
||||
private static final BooleanProperty[] CABLE_DIRECTIONS = { CableBlock.DOWN, CableBlock.UP, CableBlock.NORTH, CableBlock.SOUTH, CableBlock.WEST, CableBlock.EAST };
|
||||
private static final boolean[] BOOLEANS = new boolean[]{ false, true };
|
||||
|
||||
private static Condition.TerminalCondition cableNoNeighbour(Direction... directions) {
|
||||
var condition = new Condition.TerminalCondition().term(BlockCable.CABLE, true);
|
||||
var condition = new Condition.TerminalCondition().term(CableBlock.CABLE, true);
|
||||
for (var direction : directions) condition.term(CABLE_DIRECTIONS[direction.ordinal()], false);
|
||||
return condition;
|
||||
}
|
@ -32,22 +32,22 @@ public final class DataProviders {
|
||||
}
|
||||
|
||||
public static void add(DataGenerator generator, GeneratorFactory generators, boolean includeServer, boolean includeClient) {
|
||||
var turtleUpgrades = new TurtleUpgradeGenerator(generator);
|
||||
var pocketUpgrades = new PocketUpgradeGenerator(generator);
|
||||
var turtleUpgrades = new TurtleUpgradeProvider(generator);
|
||||
var pocketUpgrades = new PocketUpgradeProvider(generator);
|
||||
|
||||
generator.addProvider(includeServer, turtleUpgrades);
|
||||
generator.addProvider(includeServer, pocketUpgrades);
|
||||
generator.addProvider(includeServer, generators.recipes(new RecipeGenerator(turtleUpgrades, pocketUpgrades)::addRecipes));
|
||||
generator.addProvider(includeServer, generators.recipes(new RecipeProvider(turtleUpgrades, pocketUpgrades)::addRecipes));
|
||||
|
||||
var blockTags = generators.blockTags(TagProvider::blockTags);
|
||||
generator.addProvider(includeServer, blockTags);
|
||||
generator.addProvider(includeServer, generators.itemTags(TagProvider::itemTags, blockTags));
|
||||
|
||||
for (var provider : generators.lootTable(LootTableGenerator.getTables())) {
|
||||
for (var provider : generators.lootTable(LootTableProvider.getTables())) {
|
||||
generator.addProvider(includeServer, provider);
|
||||
}
|
||||
|
||||
generator.addProvider(includeClient, generators.models(BlockModelGenerator::addBlockModels, ItemModelGenerator::addItemModels));
|
||||
generator.addProvider(includeClient, generators.models(BlockModelProvider::addBlockModels, ItemModelProvider::addItemModels));
|
||||
}
|
||||
|
||||
interface GeneratorFactory {
|
@ -19,8 +19,8 @@ import java.util.Optional;
|
||||
|
||||
import static net.minecraft.data.models.model.ModelLocationUtils.getModelLocation;
|
||||
|
||||
public final class ItemModelGenerator {
|
||||
private ItemModelGenerator() {
|
||||
public final class ItemModelProvider {
|
||||
private ItemModelProvider() {
|
||||
}
|
||||
|
||||
public static void addItemModels(ItemModelGenerators generators) {
|
@ -12,7 +12,7 @@ import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
|
||||
import dan200.computercraft.shared.data.HasComputerIdLootCondition;
|
||||
import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableBlock;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableModemVariant;
|
||||
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@ -36,11 +36,11 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class LootTableGenerator {
|
||||
class LootTableProvider {
|
||||
public static List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> getTables() {
|
||||
return List.of(
|
||||
Pair.of(() -> LootTableGenerator::registerBlocks, LootContextParamSets.BLOCK),
|
||||
Pair.of(() -> LootTableGenerator::registerGeneric, LootContextParamSets.ALL_PARAMS)
|
||||
Pair.of(() -> LootTableProvider::registerBlocks, LootContextParamSets.BLOCK),
|
||||
Pair.of(() -> LootTableProvider::registerGeneric, LootContextParamSets.ALL_PARAMS)
|
||||
);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class LootTableGenerator {
|
||||
.add(LootItem.lootTableItem(ModRegistry.Items.CABLE.get()))
|
||||
.when(ExplosionCondition.survivesExplosion())
|
||||
.when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(ModRegistry.Blocks.CABLE.get())
|
||||
.setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockCable.CABLE, true))
|
||||
.setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(CableBlock.CABLE, true))
|
||||
)
|
||||
)
|
||||
.withPool(LootPool.lootPool()
|
||||
@ -75,7 +75,7 @@ class LootTableGenerator {
|
||||
.add(LootItem.lootTableItem(ModRegistry.Items.WIRED_MODEM.get()))
|
||||
.when(ExplosionCondition.survivesExplosion())
|
||||
.when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(ModRegistry.Blocks.CABLE.get())
|
||||
.setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockCable.MODEM, CableModemVariant.None))
|
||||
.setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(CableBlock.MODEM, CableModemVariant.None))
|
||||
.invert()
|
||||
)
|
||||
));
|
@ -16,8 +16,8 @@ import java.util.function.Consumer;
|
||||
import static dan200.computercraft.shared.ModRegistry.Items;
|
||||
import static dan200.computercraft.shared.ModRegistry.PocketUpgradeSerialisers;
|
||||
|
||||
class PocketUpgradeGenerator extends PocketUpgradeDataProvider {
|
||||
PocketUpgradeGenerator(DataGenerator generator) {
|
||||
class PocketUpgradeProvider extends PocketUpgradeDataProvider {
|
||||
PocketUpgradeProvider(DataGenerator generator) {
|
||||
super(generator);
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ import java.util.function.Consumer;
|
||||
import static dan200.computercraft.api.ComputerCraftTags.Items.COMPUTER;
|
||||
import static dan200.computercraft.api.ComputerCraftTags.Items.WIRED_MODEM;
|
||||
|
||||
class RecipeGenerator {
|
||||
class RecipeProvider {
|
||||
private final RecipeIngredients ingredients = PlatformHelper.get().getRecipeIngredients();
|
||||
private final TurtleUpgradeDataProvider turtleUpgrades;
|
||||
private final PocketUpgradeDataProvider pocketUpgrades;
|
||||
|
||||
RecipeGenerator(TurtleUpgradeDataProvider turtleUpgrades, PocketUpgradeDataProvider pocketUpgrades) {
|
||||
RecipeProvider(TurtleUpgradeDataProvider turtleUpgrades, PocketUpgradeDataProvider pocketUpgrades) {
|
||||
this.turtleUpgrades = turtleUpgrades;
|
||||
this.pocketUpgrades = pocketUpgrades;
|
||||
}
|
@ -17,8 +17,8 @@ import java.util.function.Consumer;
|
||||
import static dan200.computercraft.shared.ModRegistry.Items;
|
||||
import static dan200.computercraft.shared.ModRegistry.TurtleSerialisers;
|
||||
|
||||
class TurtleUpgradeGenerator extends TurtleUpgradeDataProvider {
|
||||
TurtleUpgradeGenerator(DataGenerator generator) {
|
||||
class TurtleUpgradeProvider extends TurtleUpgradeDataProvider {
|
||||
TurtleUpgradeProvider(DataGenerator generator) {
|
||||
super(generator);
|
||||
}
|
||||
|
@ -3,14 +3,11 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft;
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.BlockReference;
|
||||
import dan200.computercraft.api.detail.DetailRegistry;
|
||||
import dan200.computercraft.api.detail.IDetailProvider;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.lua.GenericSource;
|
||||
import dan200.computercraft.api.lua.ILuaAPIFactory;
|
||||
@ -18,54 +15,32 @@ import dan200.computercraft.api.media.IMediaProvider;
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import dan200.computercraft.api.turtle.TurtleRefuelHandler;
|
||||
import dan200.computercraft.core.apis.ApiFactories;
|
||||
import dan200.computercraft.core.asm.GenericMethod;
|
||||
import dan200.computercraft.core.filesystem.FileMount;
|
||||
import dan200.computercraft.impl.ComputerCraftAPIForgeService;
|
||||
import dan200.computercraft.impl.ComputerCraftAPIService;
|
||||
import dan200.computercraft.impl.TurtleRefuelHandlers;
|
||||
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.computer.core.ResourceMount;
|
||||
import dan200.computercraft.impl.network.wired.WiredNode;
|
||||
import dan200.computercraft.shared.computer.core.ServerContext;
|
||||
import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider;
|
||||
import dan200.computercraft.shared.peripheral.generic.data.BlockData;
|
||||
import dan200.computercraft.shared.peripheral.generic.data.FluidData;
|
||||
import dan200.computercraft.shared.peripheral.generic.data.ItemData;
|
||||
import dan200.computercraft.shared.details.BlockDetails;
|
||||
import dan200.computercraft.shared.details.ItemDetails;
|
||||
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.server.MinecraftServer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
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 javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_WIRED_ELEMENT;
|
||||
|
||||
@AutoService(ComputerCraftAPIService.class)
|
||||
public final class ComputerCraftAPIImpl implements ComputerCraftAPIForgeService {
|
||||
private final DetailRegistry<ItemStack> itemStackDetails = new DetailRegistryImpl<>(ItemData::fillBasic);
|
||||
private final DetailRegistry<BlockReference> blockDetails = new DetailRegistryImpl<>(BlockData::fillBasic);
|
||||
private final DetailRegistry<FluidStack> fluidStackDetails = new DetailRegistryImpl<>(FluidData::fillBasic);
|
||||
|
||||
private @Nullable String version;
|
||||
public abstract class AbstractComputerCraftAPI implements ComputerCraftAPIService {
|
||||
private final DetailRegistry<ItemStack> itemStackDetails = new DetailRegistryImpl<>(ItemDetails::fillBasic);
|
||||
private final DetailRegistry<BlockReference> blockDetails = new DetailRegistryImpl<>(BlockDetails::fillBasic);
|
||||
|
||||
public static @Nullable InputStream getResourceFile(MinecraftServer server, String domain, String subPath) {
|
||||
var manager = server.getResourceManager();
|
||||
@ -79,22 +54,14 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIForgeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstalledVersion() {
|
||||
if (version != null) return version;
|
||||
return version = ModList.get().getModContainerById(ComputerCraftAPI.MOD_ID)
|
||||
.map(x -> x.getModInfo().getVersion().toString())
|
||||
.orElse("unknown");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createUniqueNumberedSaveDir(Level world, String parentSubPath) {
|
||||
public final int createUniqueNumberedSaveDir(Level world, String parentSubPath) {
|
||||
var server = world.getServer();
|
||||
if (server == null) throw new IllegalArgumentException("Cannot find server from provided level");
|
||||
return ServerContext.get(server).getNextId(parentSubPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IWritableMount createSaveDirMount(Level world, String subPath, long capacity) {
|
||||
public final @Nullable IWritableMount createSaveDirMount(Level world, String subPath, long capacity) {
|
||||
var server = world.getServer();
|
||||
if (server == null) throw new IllegalArgumentException("Cannot find server from provided level");
|
||||
|
||||
@ -106,52 +73,57 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIForgeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IMount createResourceMount(String domain, String subPath) {
|
||||
var manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
|
||||
var mount = ResourceMount.get(domain, subPath, manager);
|
||||
return mount.exists("") ? mount : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPeripheralProvider(IPeripheralProvider provider) {
|
||||
Peripherals.register(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGenericSource(GenericSource source) {
|
||||
public final void registerGenericSource(GenericSource source) {
|
||||
GenericMethod.register(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGenericCapability(Capability<?> capability) {
|
||||
GenericPeripheralProvider.addCapability(capability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBundledRedstoneProvider(IBundledRedstoneProvider provider) {
|
||||
public final void registerBundledRedstoneProvider(IBundledRedstoneProvider provider) {
|
||||
BundledRedstone.register(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side) {
|
||||
public final int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side) {
|
||||
return BundledRedstone.getDefaultOutput(world, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMediaProvider(IMediaProvider provider) {
|
||||
public final void registerMediaProvider(IMediaProvider provider) {
|
||||
MediaProviders.register(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketNetwork getWirelessNetwork() {
|
||||
public final IPacketNetwork getWirelessNetwork() {
|
||||
return WirelessNetwork.getUniversal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAPIFactory(ILuaAPIFactory factory) {
|
||||
public final void registerAPIFactory(ILuaAPIFactory factory) {
|
||||
ApiFactories.register(factory);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final IWiredNode createWiredNodeForElement(IWiredElement element) {
|
||||
return new WiredNode(element);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerRefuelHandler(TurtleRefuelHandler handler) {
|
||||
TurtleRefuelHandlers.register(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DetailRegistry<ItemStack> getItemStackDetailRegistry() {
|
||||
return itemStackDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DetailRegistry<BlockReference> getBlockInWorldDetailRegistry() {
|
||||
return blockDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -160,41 +132,8 @@ public final class ComputerCraftAPIImpl implements ComputerCraftAPIForgeService
|
||||
itemStackDetails.addProvider((IDetailProvider<ItemStack>) provider);
|
||||
} else if (type == BlockReference.class) {
|
||||
blockDetails.addProvider((IDetailProvider<BlockReference>) provider);
|
||||
} else if (type == FluidStack.class) {
|
||||
itemStackDetails.addProvider((IDetailProvider<ItemStack>) provider);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown detail provider " + type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWiredNode createWiredNodeForElement(IWiredElement element) {
|
||||
return new WiredNode(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LazyOptional<IWiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) {
|
||||
var tile = world.getBlockEntity(pos);
|
||||
return tile == null ? LazyOptional.empty() : tile.getCapability(CAPABILITY_WIRED_ELEMENT, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRefuelHandler(TurtleRefuelHandler handler) {
|
||||
TurtleRefuelHandlers.register(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DetailRegistry<ItemStack> getItemStackDetailRegistry() {
|
||||
return itemStackDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DetailRegistry<BlockReference> getBlockInWorldDetailRegistry() {
|
||||
return blockDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DetailRegistry<FluidStack> getFluidStackDetailRegistry() {
|
||||
return fluidStackDetails;
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.api.media.IMediaProvider;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared;
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import com.google.gson.*;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.wired;
|
||||
package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.wired;
|
||||
package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import dan200.computercraft.api.network.Packet;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.wired;
|
||||
package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import dan200.computercraft.api.network.wired.IWiredNetworkChange;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
@ -3,7 +3,7 @@
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.wired;
|
||||
package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import dan200.computercraft.api.network.IPacketReceiver;
|
||||
import dan200.computercraft.api.network.Packet;
|
@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(targets = "net/minecraft/data/HashCache$CacheUpdater")
|
||||
class CacheUpdaterMixin {
|
||||
public class CacheUpdaterMixin {
|
||||
@SuppressWarnings("UnusedMethod")
|
||||
@ModifyArg(
|
||||
method = "writeIfNeeded",
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.mixin;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(CreativeModeTab.class)
|
||||
public interface CreativeModeTabAccessor {
|
||||
@Accessor("langId")
|
||||
String computercraft$langId();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.mixin;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mixin(Explosion.class)
|
||||
public interface ExplosionAccessor {
|
||||
@Nullable
|
||||
@Accessor("source")
|
||||
Entity computercraft$getExploder();
|
||||
}
|
@ -7,6 +7,8 @@ package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.core.apis.http.NetworkUtils;
|
||||
import dan200.computercraft.impl.PocketUpgrades;
|
||||
import dan200.computercraft.impl.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.computer.core.ResourceMount;
|
||||
import dan200.computercraft.shared.computer.core.ServerContext;
|
||||
import dan200.computercraft.shared.computer.metrics.ComputerMBean;
|
@ -17,65 +17,62 @@ import dan200.computercraft.shared.command.arguments.ComputersArgumentType;
|
||||
import dan200.computercraft.shared.command.arguments.RepeatArgumentType;
|
||||
import dan200.computercraft.shared.command.arguments.TrackingFieldArgumentType;
|
||||
import dan200.computercraft.shared.common.ColourableRecipe;
|
||||
import dan200.computercraft.shared.common.ContainerHeldItem;
|
||||
import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider;
|
||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
|
||||
import dan200.computercraft.shared.computer.blocks.TileCommandComputer;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.common.HeldItemMenu;
|
||||
import dan200.computercraft.shared.computer.blocks.CommandComputerBlockEntity;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerBlock;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerBlockEntity;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.inventory.ComputerMenuWithoutInventory;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ViewComputerMenu;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItem;
|
||||
import dan200.computercraft.shared.computer.recipe.ComputerUpgradeRecipe;
|
||||
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
|
||||
import dan200.computercraft.shared.data.ConstantLootConditionSerializer;
|
||||
import dan200.computercraft.shared.data.HasComputerIdLootCondition;
|
||||
import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
|
||||
import dan200.computercraft.shared.media.items.ItemDisk;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.details.BlockDetails;
|
||||
import dan200.computercraft.shared.details.ItemDetails;
|
||||
import dan200.computercraft.shared.media.items.DiskItem;
|
||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
|
||||
import dan200.computercraft.shared.media.items.PrintoutItem;
|
||||
import dan200.computercraft.shared.media.items.RecordMedia;
|
||||
import dan200.computercraft.shared.media.recipes.DiskRecipe;
|
||||
import dan200.computercraft.shared.media.recipes.PrintoutRecipe;
|
||||
import dan200.computercraft.shared.network.container.ComputerContainerData;
|
||||
import dan200.computercraft.shared.network.container.ContainerData;
|
||||
import dan200.computercraft.shared.network.container.HeldItemContainerData;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.generic.data.BlockData;
|
||||
import dan200.computercraft.shared.peripheral.generic.data.ItemData;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveBlock;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveBlockEntity;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveMenu;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.*;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockWirelessModem;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.TileWirelessModem;
|
||||
import dan200.computercraft.shared.peripheral.monitor.BlockMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.peripheral.printer.BlockPrinter;
|
||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
|
||||
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
||||
import dan200.computercraft.shared.peripheral.speaker.BlockSpeaker;
|
||||
import dan200.computercraft.shared.peripheral.speaker.TileSpeaker;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemBlock;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemBlockEntity;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlock;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlockEntity;
|
||||
import dan200.computercraft.shared.peripheral.printer.PrinterBlock;
|
||||
import dan200.computercraft.shared.peripheral.printer.PrinterBlockEntity;
|
||||
import dan200.computercraft.shared.peripheral.printer.PrinterMenu;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerBlock;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerBlockEntity;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
import dan200.computercraft.shared.platform.RegistrationHelper;
|
||||
import dan200.computercraft.shared.platform.RegistryEntry;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
|
||||
import dan200.computercraft.shared.pocket.recipes.PocketComputerUpgradeRecipe;
|
||||
import dan200.computercraft.shared.turtle.FurnaceRefuelHandler;
|
||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtle;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlock;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||
import dan200.computercraft.shared.turtle.inventory.TurtleMenu;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItem;
|
||||
import dan200.computercraft.shared.turtle.recipes.TurtleRecipe;
|
||||
import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe;
|
||||
import dan200.computercraft.shared.turtle.upgrades.*;
|
||||
import dan200.computercraft.shared.util.CreativeTabMain;
|
||||
import dan200.computercraft.shared.util.ImpostorRecipe;
|
||||
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
|
||||
import net.minecraft.commands.synchronization.SingletonArgumentInfo;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
@ -83,7 +80,6 @@ import net.minecraft.core.cauldron.CauldronInteraction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.RecordItem;
|
||||
import net.minecraft.world.item.crafting.CustomRecipe;
|
||||
@ -107,8 +103,6 @@ import java.util.function.Function;
|
||||
* The functions in this class should be called from a loader-specific class.
|
||||
*/
|
||||
public final class ModRegistry {
|
||||
private static final CreativeModeTab mainItemGroup = new CreativeTabMain();
|
||||
|
||||
private ModRegistry() {
|
||||
}
|
||||
|
||||
@ -133,38 +127,38 @@ public final class ModRegistry {
|
||||
return BlockBehaviour.Properties.of(Material.STONE).strength(1.5f);
|
||||
}
|
||||
|
||||
public static final RegistryEntry<BlockComputer<TileComputer>> COMPUTER_NORMAL = REGISTRY.register("computer_normal",
|
||||
() -> new BlockComputer<>(computerProperties(), ComputerFamily.NORMAL, BlockEntities.COMPUTER_NORMAL));
|
||||
public static final RegistryEntry<BlockComputer<TileComputer>> COMPUTER_ADVANCED = REGISTRY.register("computer_advanced",
|
||||
() -> new BlockComputer<>(computerProperties(), ComputerFamily.ADVANCED, BlockEntities.COMPUTER_ADVANCED));
|
||||
public static final RegistryEntry<ComputerBlock<ComputerBlockEntity>> COMPUTER_NORMAL = REGISTRY.register("computer_normal",
|
||||
() -> new ComputerBlock<>(computerProperties(), ComputerFamily.NORMAL, BlockEntities.COMPUTER_NORMAL));
|
||||
public static final RegistryEntry<ComputerBlock<ComputerBlockEntity>> COMPUTER_ADVANCED = REGISTRY.register("computer_advanced",
|
||||
() -> new ComputerBlock<>(computerProperties(), ComputerFamily.ADVANCED, BlockEntities.COMPUTER_ADVANCED));
|
||||
|
||||
public static final RegistryEntry<BlockComputer<TileCommandComputer>> COMPUTER_COMMAND = REGISTRY.register("computer_command", () -> new BlockComputer<>(
|
||||
public static final RegistryEntry<ComputerBlock<CommandComputerBlockEntity>> COMPUTER_COMMAND = REGISTRY.register("computer_command", () -> new ComputerBlock<>(
|
||||
computerProperties().strength(-1, 6000000.0F),
|
||||
ComputerFamily.COMMAND, BlockEntities.COMPUTER_COMMAND
|
||||
));
|
||||
|
||||
public static final RegistryEntry<BlockTurtle> TURTLE_NORMAL = REGISTRY.register("turtle_normal",
|
||||
() -> new BlockTurtle(turtleProperties(), ComputerFamily.NORMAL, BlockEntities.TURTLE_NORMAL));
|
||||
public static final RegistryEntry<BlockTurtle> TURTLE_ADVANCED = REGISTRY.register("turtle_advanced",
|
||||
() -> new BlockTurtle(turtleProperties(), ComputerFamily.ADVANCED, BlockEntities.TURTLE_ADVANCED));
|
||||
public static final RegistryEntry<TurtleBlock> TURTLE_NORMAL = REGISTRY.register("turtle_normal",
|
||||
() -> new TurtleBlock(turtleProperties(), ComputerFamily.NORMAL, BlockEntities.TURTLE_NORMAL));
|
||||
public static final RegistryEntry<TurtleBlock> TURTLE_ADVANCED = REGISTRY.register("turtle_advanced",
|
||||
() -> new TurtleBlock(turtleProperties(), ComputerFamily.ADVANCED, BlockEntities.TURTLE_ADVANCED));
|
||||
|
||||
public static final RegistryEntry<BlockSpeaker> SPEAKER = REGISTRY.register("speaker", () -> new BlockSpeaker(properties()));
|
||||
public static final RegistryEntry<BlockDiskDrive> DISK_DRIVE = REGISTRY.register("disk_drive", () -> new BlockDiskDrive(properties()));
|
||||
public static final RegistryEntry<BlockPrinter> PRINTER = REGISTRY.register("printer", () -> new BlockPrinter(properties()));
|
||||
public static final RegistryEntry<SpeakerBlock> SPEAKER = REGISTRY.register("speaker", () -> new SpeakerBlock(properties()));
|
||||
public static final RegistryEntry<DiskDriveBlock> DISK_DRIVE = REGISTRY.register("disk_drive", () -> new DiskDriveBlock(properties()));
|
||||
public static final RegistryEntry<PrinterBlock> PRINTER = REGISTRY.register("printer", () -> new PrinterBlock(properties()));
|
||||
|
||||
public static final RegistryEntry<BlockMonitor> MONITOR_NORMAL = REGISTRY.register("monitor_normal",
|
||||
() -> new BlockMonitor(properties(), BlockEntities.MONITOR_NORMAL));
|
||||
public static final RegistryEntry<BlockMonitor> MONITOR_ADVANCED = REGISTRY.register("monitor_advanced",
|
||||
() -> new BlockMonitor(properties(), BlockEntities.MONITOR_ADVANCED));
|
||||
public static final RegistryEntry<MonitorBlock> MONITOR_NORMAL = REGISTRY.register("monitor_normal",
|
||||
() -> new MonitorBlock(properties(), BlockEntities.MONITOR_NORMAL));
|
||||
public static final RegistryEntry<MonitorBlock> MONITOR_ADVANCED = REGISTRY.register("monitor_advanced",
|
||||
() -> new MonitorBlock(properties(), BlockEntities.MONITOR_ADVANCED));
|
||||
|
||||
public static final RegistryEntry<BlockWirelessModem> WIRELESS_MODEM_NORMAL = REGISTRY.register("wireless_modem_normal",
|
||||
() -> new BlockWirelessModem(properties(), BlockEntities.WIRELESS_MODEM_NORMAL));
|
||||
public static final RegistryEntry<BlockWirelessModem> WIRELESS_MODEM_ADVANCED = REGISTRY.register("wireless_modem_advanced",
|
||||
() -> new BlockWirelessModem(properties(), BlockEntities.WIRELESS_MODEM_ADVANCED));
|
||||
public static final RegistryEntry<WirelessModemBlock> WIRELESS_MODEM_NORMAL = REGISTRY.register("wireless_modem_normal",
|
||||
() -> new WirelessModemBlock(properties(), BlockEntities.WIRELESS_MODEM_NORMAL));
|
||||
public static final RegistryEntry<WirelessModemBlock> WIRELESS_MODEM_ADVANCED = REGISTRY.register("wireless_modem_advanced",
|
||||
() -> new WirelessModemBlock(properties(), BlockEntities.WIRELESS_MODEM_ADVANCED));
|
||||
|
||||
public static final RegistryEntry<BlockWiredModemFull> WIRED_MODEM_FULL = REGISTRY.register("wired_modem_full",
|
||||
() -> new BlockWiredModemFull(modemProperties()));
|
||||
public static final RegistryEntry<BlockCable> CABLE = REGISTRY.register("cable", () -> new BlockCable(modemProperties()));
|
||||
public static final RegistryEntry<WiredModemFullBlock> WIRED_MODEM_FULL = REGISTRY.register("wired_modem_full",
|
||||
() -> new WiredModemFullBlock(modemProperties()));
|
||||
public static final RegistryEntry<CableBlock> CABLE = REGISTRY.register("cable", () -> new CableBlock(modemProperties()));
|
||||
}
|
||||
|
||||
public static class BlockEntities {
|
||||
@ -174,74 +168,74 @@ public final class ModRegistry {
|
||||
return REGISTRY.register(block.id().getPath(), () -> PlatformHelper.get().createBlockEntityType(factory, block.get()));
|
||||
}
|
||||
|
||||
public static final RegistryEntry<BlockEntityType<TileMonitor>> MONITOR_NORMAL =
|
||||
ofBlock(Blocks.MONITOR_NORMAL, (p, s) -> new TileMonitor(BlockEntities.MONITOR_NORMAL.get(), p, s, false));
|
||||
public static final RegistryEntry<BlockEntityType<TileMonitor>> MONITOR_ADVANCED =
|
||||
ofBlock(Blocks.MONITOR_ADVANCED, (p, s) -> new TileMonitor(BlockEntities.MONITOR_ADVANCED.get(), p, s, true));
|
||||
public static final RegistryEntry<BlockEntityType<MonitorBlockEntity>> MONITOR_NORMAL =
|
||||
ofBlock(Blocks.MONITOR_NORMAL, (p, s) -> new MonitorBlockEntity(BlockEntities.MONITOR_NORMAL.get(), p, s, false));
|
||||
public static final RegistryEntry<BlockEntityType<MonitorBlockEntity>> MONITOR_ADVANCED =
|
||||
ofBlock(Blocks.MONITOR_ADVANCED, (p, s) -> new MonitorBlockEntity(BlockEntities.MONITOR_ADVANCED.get(), p, s, true));
|
||||
|
||||
public static final RegistryEntry<BlockEntityType<TileComputer>> COMPUTER_NORMAL =
|
||||
ofBlock(Blocks.COMPUTER_NORMAL, (p, s) -> new TileComputer(BlockEntities.COMPUTER_NORMAL.get(), p, s, ComputerFamily.NORMAL));
|
||||
public static final RegistryEntry<BlockEntityType<TileComputer>> COMPUTER_ADVANCED =
|
||||
ofBlock(Blocks.COMPUTER_ADVANCED, (p, s) -> new TileComputer(BlockEntities.COMPUTER_ADVANCED.get(), p, s, ComputerFamily.ADVANCED));
|
||||
public static final RegistryEntry<BlockEntityType<TileCommandComputer>> COMPUTER_COMMAND =
|
||||
ofBlock(Blocks.COMPUTER_COMMAND, (p, s) -> new TileCommandComputer(BlockEntities.COMPUTER_COMMAND.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<ComputerBlockEntity>> COMPUTER_NORMAL =
|
||||
ofBlock(Blocks.COMPUTER_NORMAL, (p, s) -> new ComputerBlockEntity(BlockEntities.COMPUTER_NORMAL.get(), p, s, ComputerFamily.NORMAL));
|
||||
public static final RegistryEntry<BlockEntityType<ComputerBlockEntity>> COMPUTER_ADVANCED =
|
||||
ofBlock(Blocks.COMPUTER_ADVANCED, (p, s) -> new ComputerBlockEntity(BlockEntities.COMPUTER_ADVANCED.get(), p, s, ComputerFamily.ADVANCED));
|
||||
public static final RegistryEntry<BlockEntityType<CommandComputerBlockEntity>> COMPUTER_COMMAND =
|
||||
ofBlock(Blocks.COMPUTER_COMMAND, (p, s) -> new CommandComputerBlockEntity(BlockEntities.COMPUTER_COMMAND.get(), p, s));
|
||||
|
||||
public static final RegistryEntry<BlockEntityType<TileTurtle>> TURTLE_NORMAL =
|
||||
ofBlock(Blocks.TURTLE_NORMAL, (p, s) -> new TileTurtle(BlockEntities.TURTLE_NORMAL.get(), p, s, ComputerFamily.NORMAL));
|
||||
public static final RegistryEntry<BlockEntityType<TileTurtle>> TURTLE_ADVANCED =
|
||||
ofBlock(Blocks.TURTLE_ADVANCED, (p, s) -> new TileTurtle(BlockEntities.TURTLE_ADVANCED.get(), p, s, ComputerFamily.ADVANCED));
|
||||
public static final RegistryEntry<BlockEntityType<TurtleBlockEntity>> TURTLE_NORMAL =
|
||||
ofBlock(Blocks.TURTLE_NORMAL, (p, s) -> new TurtleBlockEntity(BlockEntities.TURTLE_NORMAL.get(), p, s, ComputerFamily.NORMAL));
|
||||
public static final RegistryEntry<BlockEntityType<TurtleBlockEntity>> TURTLE_ADVANCED =
|
||||
ofBlock(Blocks.TURTLE_ADVANCED, (p, s) -> new TurtleBlockEntity(BlockEntities.TURTLE_ADVANCED.get(), p, s, ComputerFamily.ADVANCED));
|
||||
|
||||
public static final RegistryEntry<BlockEntityType<TileSpeaker>> SPEAKER =
|
||||
ofBlock(Blocks.SPEAKER, (p, s) -> new TileSpeaker(BlockEntities.SPEAKER.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<TileDiskDrive>> DISK_DRIVE =
|
||||
ofBlock(Blocks.DISK_DRIVE, (p, s) -> new TileDiskDrive(BlockEntities.DISK_DRIVE.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<TilePrinter>> PRINTER =
|
||||
ofBlock(Blocks.PRINTER, (p, s) -> new TilePrinter(BlockEntities.PRINTER.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<TileWiredModemFull>> WIRED_MODEM_FULL =
|
||||
ofBlock(Blocks.WIRED_MODEM_FULL, (p, s) -> new TileWiredModemFull(BlockEntities.WIRED_MODEM_FULL.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<TileCable>> CABLE =
|
||||
ofBlock(Blocks.CABLE, (p, s) -> new TileCable(BlockEntities.CABLE.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<SpeakerBlockEntity>> SPEAKER =
|
||||
ofBlock(Blocks.SPEAKER, (p, s) -> new SpeakerBlockEntity(BlockEntities.SPEAKER.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<DiskDriveBlockEntity>> DISK_DRIVE =
|
||||
ofBlock(Blocks.DISK_DRIVE, (p, s) -> new DiskDriveBlockEntity(BlockEntities.DISK_DRIVE.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<PrinterBlockEntity>> PRINTER =
|
||||
ofBlock(Blocks.PRINTER, (p, s) -> new PrinterBlockEntity(BlockEntities.PRINTER.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<WiredModemFullBlockEntity>> WIRED_MODEM_FULL =
|
||||
ofBlock(Blocks.WIRED_MODEM_FULL, (p, s) -> new WiredModemFullBlockEntity(BlockEntities.WIRED_MODEM_FULL.get(), p, s));
|
||||
public static final RegistryEntry<BlockEntityType<CableBlockEntity>> CABLE =
|
||||
ofBlock(Blocks.CABLE, (p, s) -> new CableBlockEntity(BlockEntities.CABLE.get(), p, s));
|
||||
|
||||
public static final RegistryEntry<BlockEntityType<TileWirelessModem>> WIRELESS_MODEM_NORMAL =
|
||||
ofBlock(Blocks.WIRELESS_MODEM_NORMAL, (p, s) -> new TileWirelessModem(BlockEntities.WIRELESS_MODEM_NORMAL.get(), p, s, false));
|
||||
public static final RegistryEntry<BlockEntityType<TileWirelessModem>> WIRELESS_MODEM_ADVANCED =
|
||||
ofBlock(Blocks.WIRELESS_MODEM_ADVANCED, (p, s) -> new TileWirelessModem(BlockEntities.WIRELESS_MODEM_ADVANCED.get(), p, s, true));
|
||||
public static final RegistryEntry<BlockEntityType<WirelessModemBlockEntity>> WIRELESS_MODEM_NORMAL =
|
||||
ofBlock(Blocks.WIRELESS_MODEM_NORMAL, (p, s) -> new WirelessModemBlockEntity(BlockEntities.WIRELESS_MODEM_NORMAL.get(), p, s, false));
|
||||
public static final RegistryEntry<BlockEntityType<WirelessModemBlockEntity>> WIRELESS_MODEM_ADVANCED =
|
||||
ofBlock(Blocks.WIRELESS_MODEM_ADVANCED, (p, s) -> new WirelessModemBlockEntity(BlockEntities.WIRELESS_MODEM_ADVANCED.get(), p, s, true));
|
||||
}
|
||||
|
||||
public static final class Items {
|
||||
static final RegistrationHelper<Item> REGISTRY = PlatformHelper.get().createRegistrationHelper(Registry.ITEM_REGISTRY);
|
||||
|
||||
private static Item.Properties properties() {
|
||||
return new Item.Properties().tab(mainItemGroup);
|
||||
return new Item.Properties().tab(PlatformHelper.get().getCreativeTab());
|
||||
}
|
||||
|
||||
private static <B extends Block, I extends Item> RegistryEntry<I> ofBlock(RegistryEntry<B> parent, BiFunction<B, Item.Properties, I> supplier) {
|
||||
return REGISTRY.register(parent.id().getPath(), () -> supplier.apply(parent.get(), properties()));
|
||||
}
|
||||
|
||||
public static final RegistryEntry<ItemComputer> COMPUTER_NORMAL = ofBlock(Blocks.COMPUTER_NORMAL, ItemComputer::new);
|
||||
public static final RegistryEntry<ItemComputer> COMPUTER_ADVANCED = ofBlock(Blocks.COMPUTER_ADVANCED, ItemComputer::new);
|
||||
public static final RegistryEntry<ItemComputer> COMPUTER_COMMAND = ofBlock(Blocks.COMPUTER_COMMAND, ItemComputer::new);
|
||||
public static final RegistryEntry<ComputerItem> COMPUTER_NORMAL = ofBlock(Blocks.COMPUTER_NORMAL, ComputerItem::new);
|
||||
public static final RegistryEntry<ComputerItem> COMPUTER_ADVANCED = ofBlock(Blocks.COMPUTER_ADVANCED, ComputerItem::new);
|
||||
public static final RegistryEntry<ComputerItem> COMPUTER_COMMAND = ofBlock(Blocks.COMPUTER_COMMAND, ComputerItem::new);
|
||||
|
||||
public static final RegistryEntry<ItemPocketComputer> POCKET_COMPUTER_NORMAL = REGISTRY.register("pocket_computer_normal",
|
||||
() -> new ItemPocketComputer(properties().stacksTo(1), ComputerFamily.NORMAL));
|
||||
public static final RegistryEntry<ItemPocketComputer> POCKET_COMPUTER_ADVANCED = REGISTRY.register("pocket_computer_advanced",
|
||||
() -> new ItemPocketComputer(properties().stacksTo(1), ComputerFamily.ADVANCED));
|
||||
public static final RegistryEntry<PocketComputerItem> POCKET_COMPUTER_NORMAL = REGISTRY.register("pocket_computer_normal",
|
||||
() -> new PocketComputerItem(properties().stacksTo(1), ComputerFamily.NORMAL));
|
||||
public static final RegistryEntry<PocketComputerItem> POCKET_COMPUTER_ADVANCED = REGISTRY.register("pocket_computer_advanced",
|
||||
() -> new PocketComputerItem(properties().stacksTo(1), ComputerFamily.ADVANCED));
|
||||
|
||||
public static final RegistryEntry<ItemTurtle> TURTLE_NORMAL = ofBlock(Blocks.TURTLE_NORMAL, ItemTurtle::new);
|
||||
public static final RegistryEntry<ItemTurtle> TURTLE_ADVANCED = ofBlock(Blocks.TURTLE_ADVANCED, ItemTurtle::new);
|
||||
public static final RegistryEntry<TurtleItem> TURTLE_NORMAL = ofBlock(Blocks.TURTLE_NORMAL, TurtleItem::new);
|
||||
public static final RegistryEntry<TurtleItem> TURTLE_ADVANCED = ofBlock(Blocks.TURTLE_ADVANCED, TurtleItem::new);
|
||||
|
||||
public static final RegistryEntry<ItemDisk> DISK =
|
||||
REGISTRY.register("disk", () -> new ItemDisk(properties().stacksTo(1)));
|
||||
public static final RegistryEntry<DiskItem> DISK =
|
||||
REGISTRY.register("disk", () -> new DiskItem(properties().stacksTo(1)));
|
||||
public static final RegistryEntry<ItemTreasureDisk> TREASURE_DISK =
|
||||
REGISTRY.register("treasure_disk", () -> new ItemTreasureDisk(properties().stacksTo(1)));
|
||||
|
||||
public static final RegistryEntry<ItemPrintout> PRINTED_PAGE = REGISTRY.register("printed_page",
|
||||
() -> new ItemPrintout(properties().stacksTo(1), ItemPrintout.Type.PAGE));
|
||||
public static final RegistryEntry<ItemPrintout> PRINTED_PAGES = REGISTRY.register("printed_pages",
|
||||
() -> new ItemPrintout(properties().stacksTo(1), ItemPrintout.Type.PAGES));
|
||||
public static final RegistryEntry<ItemPrintout> PRINTED_BOOK = REGISTRY.register("printed_book",
|
||||
() -> new ItemPrintout(properties().stacksTo(1), ItemPrintout.Type.BOOK));
|
||||
public static final RegistryEntry<PrintoutItem> PRINTED_PAGE = REGISTRY.register("printed_page",
|
||||
() -> new PrintoutItem(properties().stacksTo(1), PrintoutItem.Type.PAGE));
|
||||
public static final RegistryEntry<PrintoutItem> PRINTED_PAGES = REGISTRY.register("printed_pages",
|
||||
() -> new PrintoutItem(properties().stacksTo(1), PrintoutItem.Type.PAGES));
|
||||
public static final RegistryEntry<PrintoutItem> PRINTED_BOOK = REGISTRY.register("printed_book",
|
||||
() -> new PrintoutItem(properties().stacksTo(1), PrintoutItem.Type.BOOK));
|
||||
|
||||
public static final RegistryEntry<BlockItem> SPEAKER = ofBlock(Blocks.SPEAKER, BlockItem::new);
|
||||
public static final RegistryEntry<BlockItem> DISK_DRIVE = ofBlock(Blocks.DISK_DRIVE, BlockItem::new);
|
||||
@ -252,10 +246,10 @@ public final class ModRegistry {
|
||||
public static final RegistryEntry<BlockItem> WIRELESS_MODEM_ADVANCED = ofBlock(Blocks.WIRELESS_MODEM_ADVANCED, BlockItem::new);
|
||||
public static final RegistryEntry<BlockItem> WIRED_MODEM_FULL = ofBlock(Blocks.WIRED_MODEM_FULL, BlockItem::new);
|
||||
|
||||
public static final RegistryEntry<ItemBlockCable.Cable> CABLE = REGISTRY.register("cable",
|
||||
() -> new ItemBlockCable.Cable(Blocks.CABLE.get(), properties()));
|
||||
public static final RegistryEntry<ItemBlockCable.WiredModem> WIRED_MODEM = REGISTRY.register("wired_modem",
|
||||
() -> new ItemBlockCable.WiredModem(Blocks.CABLE.get(), properties()));
|
||||
public static final RegistryEntry<CableBlockItem.Cable> CABLE = REGISTRY.register("cable",
|
||||
() -> new CableBlockItem.Cable(Blocks.CABLE.get(), properties()));
|
||||
public static final RegistryEntry<CableBlockItem.WiredModem> WIRED_MODEM = REGISTRY.register("wired_modem",
|
||||
() -> new CableBlockItem.WiredModem(Blocks.CABLE.get(), properties()));
|
||||
}
|
||||
|
||||
public static class TurtleSerialisers {
|
||||
@ -287,29 +281,29 @@ public final class ModRegistry {
|
||||
public static class Menus {
|
||||
static final RegistrationHelper<MenuType<?>> REGISTRY = PlatformHelper.get().createRegistrationHelper(Registry.MENU_REGISTRY);
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerComputerBase>> COMPUTER = REGISTRY.register("computer",
|
||||
public static final RegistryEntry<MenuType<ComputerMenuWithoutInventory>> COMPUTER = REGISTRY.register("computer",
|
||||
() -> ContainerData.toType(ComputerContainerData::new, (id, inv, data) -> new ComputerMenuWithoutInventory(Menus.COMPUTER.get(), id, inv, data)));
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerComputerBase>> POCKET_COMPUTER = REGISTRY.register("pocket_computer",
|
||||
public static final RegistryEntry<MenuType<ComputerMenuWithoutInventory>> POCKET_COMPUTER = REGISTRY.register("pocket_computer",
|
||||
() -> ContainerData.toType(ComputerContainerData::new, (id, inv, data) -> new ComputerMenuWithoutInventory(Menus.POCKET_COMPUTER.get(), id, inv, data)));
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerComputerBase>> POCKET_COMPUTER_NO_TERM = REGISTRY.register("pocket_computer_no_term",
|
||||
public static final RegistryEntry<MenuType<ComputerMenuWithoutInventory>> POCKET_COMPUTER_NO_TERM = REGISTRY.register("pocket_computer_no_term",
|
||||
() -> ContainerData.toType(ComputerContainerData::new, (id, inv, data) -> new ComputerMenuWithoutInventory(Menus.POCKET_COMPUTER_NO_TERM.get(), id, inv, data)));
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerTurtle>> TURTLE = REGISTRY.register("turtle",
|
||||
() -> ContainerData.toType(ComputerContainerData::new, ContainerTurtle::ofMenuData));
|
||||
public static final RegistryEntry<MenuType<TurtleMenu>> TURTLE = REGISTRY.register("turtle",
|
||||
() -> ContainerData.toType(ComputerContainerData::new, TurtleMenu::ofMenuData));
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerDiskDrive>> DISK_DRIVE = REGISTRY.register("disk_drive",
|
||||
() -> new MenuType<>(ContainerDiskDrive::new));
|
||||
public static final RegistryEntry<MenuType<DiskDriveMenu>> DISK_DRIVE = REGISTRY.register("disk_drive",
|
||||
() -> new MenuType<>(DiskDriveMenu::new));
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerPrinter>> PRINTER = REGISTRY.register("printer",
|
||||
() -> new MenuType<>(ContainerPrinter::new));
|
||||
public static final RegistryEntry<MenuType<PrinterMenu>> PRINTER = REGISTRY.register("printer",
|
||||
() -> new MenuType<>(PrinterMenu::new));
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerHeldItem>> PRINTOUT = REGISTRY.register("printout",
|
||||
() -> ContainerData.toType(HeldItemContainerData::new, ContainerHeldItem::createPrintout));
|
||||
public static final RegistryEntry<MenuType<HeldItemMenu>> PRINTOUT = REGISTRY.register("printout",
|
||||
() -> ContainerData.toType(HeldItemContainerData::new, HeldItemMenu::createPrintout));
|
||||
|
||||
public static final RegistryEntry<MenuType<ContainerViewComputer>> VIEW_COMPUTER = REGISTRY.register("view_computer",
|
||||
() -> ContainerData.toType(ComputerContainerData::new, ContainerViewComputer::new));
|
||||
public static final RegistryEntry<MenuType<ViewComputerMenu>> VIEW_COMPUTER = REGISTRY.register("view_computer",
|
||||
() -> ContainerData.toType(ComputerContainerData::new, ViewComputerMenu::new));
|
||||
}
|
||||
|
||||
static class ArgumentTypes {
|
||||
@ -317,11 +311,11 @@ public final class ModRegistry {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends ArgumentType<?>> void registerUnsafe(String name, Class<T> type, ArgumentTypeInfo<?, ?> serializer) {
|
||||
REGISTRY.register(name, () -> ArgumentTypeInfos.registerByClass(type, (ArgumentTypeInfo<T, ?>) serializer));
|
||||
REGISTRY.register(name, () -> PlatformHelper.get().registerArgumentTypeInfo(type, (ArgumentTypeInfo<T, ?>) serializer));
|
||||
}
|
||||
|
||||
private static <T extends ArgumentType<?>> void register(String name, Class<T> type, ArgumentTypeInfo<T, ?> serializer) {
|
||||
REGISTRY.register(name, () -> ArgumentTypeInfos.registerByClass(type, serializer));
|
||||
REGISTRY.register(name, () -> PlatformHelper.get().registerArgumentTypeInfo(type, serializer));
|
||||
}
|
||||
|
||||
private static <T extends ArgumentType<?>> void register(String name, Class<T> type, T instance) {
|
||||
@ -391,15 +385,15 @@ public final class ModRegistry {
|
||||
return null;
|
||||
});
|
||||
|
||||
VanillaDetailRegistries.ITEM_STACK.addProvider(ItemData::fill);
|
||||
VanillaDetailRegistries.BLOCK_IN_WORLD.addProvider(BlockData::fill);
|
||||
VanillaDetailRegistries.ITEM_STACK.addProvider(ItemDetails::fill);
|
||||
VanillaDetailRegistries.BLOCK_IN_WORLD.addProvider(BlockDetails::fill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any objects which must be done on the main thread.
|
||||
*/
|
||||
public static void registerMainThread() {
|
||||
CauldronInteraction.WATER.put(ModRegistry.Items.TURTLE_NORMAL.get(), ItemTurtle.CAULDRON_INTERACTION);
|
||||
CauldronInteraction.WATER.put(ModRegistry.Items.TURTLE_ADVANCED.get(), ItemTurtle.CAULDRON_INTERACTION);
|
||||
CauldronInteraction.WATER.put(ModRegistry.Items.TURTLE_NORMAL.get(), TurtleItem.CAULDRON_INTERACTION);
|
||||
CauldronInteraction.WATER.put(ModRegistry.Items.TURTLE_ADVANCED.get(), TurtleItem.CAULDRON_INTERACTION);
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ import dan200.computercraft.shared.command.text.TableBuilder;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.core.ServerContext;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ViewComputerMenu;
|
||||
import dan200.computercraft.shared.computer.metrics.basic.Aggregate;
|
||||
import dan200.computercraft.shared.computer.metrics.basic.AggregatedMetric;
|
||||
import dan200.computercraft.shared.computer.metrics.basic.BasicComputerMetricsObserver;
|
||||
@ -202,7 +202,7 @@ public final class CommandComputerCraft {
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int id, Inventory player, Player entity) {
|
||||
return new ContainerViewComputer(id, player, computer);
|
||||
return new ViewComputerMenu(id, player, computer);
|
||||
}
|
||||
});
|
||||
return 1;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user