mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-07 00:42:59 +00:00
Compare commits
36 Commits
v1.17.1-1.
...
v1.18.2-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78cce4981a | ||
|
|
6353e8d930 | ||
|
|
97c953a9be | ||
|
|
52df7cb8a4 | ||
|
|
6735cfd12e | ||
|
|
bcc7dd6991 | ||
|
|
f994696161 | ||
|
|
4a4e8bb4b6 | ||
|
|
bd36185662 | ||
|
|
045c4fc88c | ||
|
|
e0fcc425c6 | ||
|
|
e01895d719 | ||
|
|
87b38f4249 | ||
|
|
60d1d1bb18 | ||
|
|
cdf8b77ffd | ||
|
|
e2ce52fe81 | ||
|
|
9edce36efd | ||
|
|
e05588c662 | ||
|
|
9cf70b10ef | ||
|
|
9ac8f3aeea | ||
|
|
e191b08eb5 | ||
|
|
a1221b99e1 | ||
|
|
85bced6b1d | ||
|
|
fc4569e0cc | ||
|
|
e7f08313d9 | ||
|
|
79366bf2f5 | ||
|
|
2b901f2d5e | ||
|
|
901d8d4c3b | ||
|
|
2562642664 | ||
|
|
632db1cfa5 | ||
|
|
f6fcba7a39 | ||
|
|
7c373c6e06 | ||
|
|
57c5d19f95 | ||
|
|
23c17075be | ||
|
|
87988a705b | ||
|
|
179da1d8cf |
126
build.gradle
126
build.gradle
@@ -5,7 +5,7 @@ buildscript {
|
|||||||
maven { url = 'https://maven.parchmentmc.org' }
|
maven { url = 'https://maven.parchmentmc.org' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.24'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+'
|
||||||
classpath "org.spongepowered:mixingradle:0.7.+"
|
classpath "org.spongepowered:mixingradle:0.7.+"
|
||||||
classpath 'org.parchmentmc:librarian:1.+'
|
classpath 'org.parchmentmc:librarian:1.+'
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ version = mod_version
|
|||||||
group = "org.squiddev"
|
group = "org.squiddev"
|
||||||
archivesBaseName = "cc-tweaked-${mc_version}"
|
archivesBaseName = "cc-tweaked-${mc_version}"
|
||||||
|
|
||||||
def javaVersion = JavaLanguageVersion.of(16)
|
def javaVersion = JavaLanguageVersion.of(17)
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion = javaVersion
|
languageVersion = javaVersion
|
||||||
@@ -88,26 +88,8 @@ minecraft {
|
|||||||
args '--mod', 'computercraft', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
args '--mod', 'computercraft', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||||
}
|
}
|
||||||
|
|
||||||
testClient {
|
gameTestServer {
|
||||||
workingDirectory project.file('test-files/client')
|
|
||||||
parent runs.client
|
|
||||||
|
|
||||||
mods {
|
|
||||||
cctest {
|
|
||||||
source sourceSets.testMod
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lazyToken('minecraft_classpath') {
|
|
||||||
(configurations.shade.copyRecursive().resolve() + configurations.testModExtra.copyRecursive().resolve())
|
|
||||||
.collect { it.absolutePath }
|
|
||||||
.join(File.pathSeparator)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testServer {
|
|
||||||
workingDirectory project.file('test-files/server')
|
workingDirectory project.file('test-files/server')
|
||||||
parent runs.server
|
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
cctest {
|
cctest {
|
||||||
@@ -123,7 +105,8 @@ minecraft {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mappings channel: 'parchment', version: "${mapping_version}-${mc_version}"
|
// mappings channel: 'parchment', version: "${mapping_version}-${mc_version}"
|
||||||
|
mappings channel: 'official', version: mc_version
|
||||||
|
|
||||||
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
|
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
|
accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
|
||||||
@@ -158,9 +141,8 @@ dependencies {
|
|||||||
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
||||||
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
||||||
|
|
||||||
compileOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14:api")
|
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116:api")
|
||||||
|
runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116")
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14")
|
|
||||||
|
|
||||||
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'
|
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'
|
||||||
|
|
||||||
@@ -172,7 +154,9 @@ dependencies {
|
|||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
|
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
|
||||||
|
|
||||||
testModImplementation sourceSets.main.output
|
testModImplementation sourceSets.main.output
|
||||||
testModExtra 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21'
|
testModExtra('org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0') {
|
||||||
|
exclude group: "org.jetbrains", module: "annotations"
|
||||||
|
}
|
||||||
|
|
||||||
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.5'
|
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.5'
|
||||||
}
|
}
|
||||||
@@ -372,69 +356,49 @@ task licenseFormatAPI(type: LicenseFormat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task setupServer(type: Copy) {
|
tasks.register("testServer", JavaExec.class).configure {
|
||||||
group "test server"
|
it.group('In-game tests')
|
||||||
description "Sets up the environment for the test server."
|
it.description("Runs tests on a temporary Minecraft instance.")
|
||||||
|
it.dependsOn("prepareRunGameTestServer", "cleanTestServer", 'compileTestModJava')
|
||||||
|
|
||||||
from("src/testMod/server-files") {
|
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
|
||||||
include "eula.txt"
|
// isn't created until the task is configured (which is no good for us).
|
||||||
include "server.properties"
|
JavaExec exec = tasks.getByName("runGameTestServer")
|
||||||
}
|
exec.copyTo(it)
|
||||||
into "test-files/server"
|
it.setClasspath(exec.getClasspath())
|
||||||
|
it.mainClass = exec.mainClass
|
||||||
|
it.setArgs(exec.getArgs())
|
||||||
|
|
||||||
|
// Jacoco and modlauncher don't play well together as the classes loaded in-game don't
|
||||||
|
// match up with those written to disk. We get Jacoco to dump all classes to disk, and
|
||||||
|
// use that when generating the report.
|
||||||
|
def coverageOut = new File(buildDir, "jacocoClassDump/testServer")
|
||||||
|
jacoco.applyTo(it)
|
||||||
|
it.jacoco.setIncludes(["dan200.computercraft.*"])
|
||||||
|
it.jacoco.setClassDumpDir(coverageOut)
|
||||||
|
it.outputs.dir(coverageOut)
|
||||||
|
// Older versions of modlauncher don't include a protection domain (and thus no code
|
||||||
|
// source). Jacoco skips such classes by default, so we need to explicitly include them.
|
||||||
|
it.jacoco.setIncludeNoLocationClasses(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
["Client", "Server"].forEach { name ->
|
tasks.register("jacocoTestServerReport", JacocoReport.class).configure {
|
||||||
tasks.register("test$name", JavaExec.class).configure {
|
it.group('In-game')
|
||||||
it.group('In-game tests')
|
it.description("Generate coverage reports for testServer")
|
||||||
it.description("Runs tests on a temporary Minecraft instance.")
|
it.dependsOn("testServer")
|
||||||
it.dependsOn(setupServer, "prepareRunTest$name", "cleanTest$name", 'compileTestModJava')
|
|
||||||
|
|
||||||
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
|
it.executionData(new File(buildDir, "jacoco/testServer.exec"))
|
||||||
// isn't created until the task is configured (which is no good for us).
|
it.sourceDirectories.from(sourceSets.main.allJava.srcDirs)
|
||||||
JavaExec exec = tasks.getByName("runTest$name")
|
it.classDirectories.from(new File(buildDir, "jacocoClassDump/testServer"))
|
||||||
exec.copyTo(it)
|
|
||||||
it.setClasspath(exec.getClasspath())
|
|
||||||
it.mainClass = exec.mainClass
|
|
||||||
it.setArgs(exec.getArgs())
|
|
||||||
|
|
||||||
it.systemProperty('forge.logging.console.level', 'info')
|
it.reports {
|
||||||
it.systemProperty('cctest.run', 'true')
|
xml.enabled true
|
||||||
|
html.enabled true
|
||||||
// Jacoco and modlauncher don't play well together as the classes loaded in-game don't
|
|
||||||
// match up with those written to disk. We get Jacoco to dump all classes to disk, and
|
|
||||||
// use that when generating the report.
|
|
||||||
def coverageOut = new File(buildDir, "jacocoClassDump/test$name")
|
|
||||||
jacoco.applyTo(it)
|
|
||||||
it.jacoco.setIncludes(["dan200.computercraft.*"])
|
|
||||||
it.jacoco.setClassDumpDir(coverageOut)
|
|
||||||
it.outputs.dir(coverageOut)
|
|
||||||
// Older versions of modlauncher don't include a protection domain (and thus no code
|
|
||||||
// source). Jacoco skips such classes by default, so we need to explicitly include them.
|
|
||||||
it.jacoco.setIncludeNoLocationClasses(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("jacocoTest${name}Report", JacocoReport.class).configure {
|
|
||||||
it.group('In-game')
|
|
||||||
it.description("Generate coverage reports for test$name")
|
|
||||||
it.dependsOn("test$name")
|
|
||||||
|
|
||||||
it.executionData(new File(buildDir, "jacoco/test${name}.exec"))
|
|
||||||
it.sourceDirectories.from(sourceSets.main.allJava.srcDirs)
|
|
||||||
it.classDirectories.from(new File(buildDir, "jacocoClassDump/test$name"))
|
|
||||||
|
|
||||||
it.reports {
|
|
||||||
xml.enabled true
|
|
||||||
html.enabled true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name != "Client" || project.findProperty('cc.tweaked.clientTests') == 'true') {
|
|
||||||
// Don't run client tests unless explicitly opted into them. They're a bit of a faff
|
|
||||||
// to run and pretty flakey.
|
|
||||||
check.dependsOn("jacocoTest${name}Report")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check.dependsOn("jacocoTestServerReport")
|
||||||
|
|
||||||
|
|
||||||
// Upload tasks
|
// Upload tasks
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ numerical value depending on which button on your mouse was last pressed when th
|
|||||||
<!-- Our markdown parser doesn't work on tables!? Guess I'll have to roll my own soonish :/. -->
|
<!-- Our markdown parser doesn't work on tables!? Guess I'll have to roll my own soonish :/. -->
|
||||||
<tr><th>Button code</th><th>Mouse button</th></tr>
|
<tr><th>Button code</th><th>Mouse button</th></tr>
|
||||||
<tr><td align="right">1</td><td>Left button</td></tr>
|
<tr><td align="right">1</td><td>Left button</td></tr>
|
||||||
<tr><td align="right">2</td><td>Middle button</td></tr>
|
<tr><td align="right">2</td><td>Right button</td></tr>
|
||||||
<tr><td align="right">3</td><td>Right button</td></tr>
|
<tr><td align="right">3</td><td>Middle button</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ representable value.
|
|||||||
|
|
||||||
This representation of sound - a long, uniformally sampled list of amplitudes is referred to as [Pulse-code
|
This representation of sound - a long, uniformally sampled list of amplitudes is referred to as [Pulse-code
|
||||||
Modulation][PCM] (PCM). PCM can be thought of as the "standard" audio format, as it's incredibly easy to work with. For
|
Modulation][PCM] (PCM). PCM can be thought of as the "standard" audio format, as it's incredibly easy to work with. For
|
||||||
instance, to mix two pieces of audio together, you can just samples from the two tracks together and take the average.
|
instance, to mix two pieces of audio together, you can just add samples from the two tracks together and take the average.
|
||||||
|
|
||||||
CC: Tweaked's speakers also work with PCM audio. It plays back 48,000 samples a second, where each sample is an integer
|
CC: Tweaked's speakers also work with PCM audio. It plays back 48,000 samples a second, where each sample is an integer
|
||||||
between -128 and 127. This is more commonly referred to as 48kHz and an 8-bit resolution.
|
between -128 and 127. This is more commonly referred to as 48kHz and an 8-bit resolution.
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
|
||||||
# Mod properties
|
# Mod properties
|
||||||
mod_version=1.100.1
|
mod_version=1.100.3
|
||||||
|
|
||||||
# Minecraft properties (update mods.toml when changing)
|
# Minecraft properties (update mods.toml when changing)
|
||||||
mc_version=1.17.1
|
mc_version=1.18.2
|
||||||
mapping_version=2021.09.05
|
mapping_version=2022.02.13
|
||||||
forge_version=37.0.85
|
forge_version=40.0.2
|
||||||
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING
|
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING
|
||||||
|
|||||||
@@ -22,8 +22,7 @@
|
|||||||
"cable": "true"
|
"cable": "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "wired_modem",
|
"name": "wired_modem",
|
||||||
@@ -49,8 +48,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
{
|
{
|
||||||
"condition": "minecraft:survives_explosion"
|
"condition": "minecraft:survives_explosion"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"functions": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@ import dan200.computercraft.shared.wired.WiredNode;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
@@ -38,7 +37,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -59,7 +58,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
|||||||
|
|
||||||
public static InputStream getResourceFile( String domain, String subPath )
|
public static InputStream getResourceFile( String domain, String subPath )
|
||||||
{
|
{
|
||||||
ReloadableResourceManager manager = (ReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getResourceManager();
|
var manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
|
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public final class ComputerCraftAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rers a peripheral provider to convert blocks into {@link IPeripheral} implementations.
|
* Registers a peripheral provider to convert blocks into {@link IPeripheral} implementations.
|
||||||
*
|
*
|
||||||
* @param provider The peripheral provider to register.
|
* @param provider The peripheral provider to register.
|
||||||
* @see IPeripheral
|
* @see IPeripheral
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dan200.computercraft.ComputerCraft;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
|
||||||
@@ -20,47 +20,47 @@ public class ComputerCraftTags
|
|||||||
{
|
{
|
||||||
public static class Items
|
public static class Items
|
||||||
{
|
{
|
||||||
public static final Tag.Named<Item> COMPUTER = make( "computer" );
|
public static final TagKey<Item> COMPUTER = make( "computer" );
|
||||||
public static final Tag.Named<Item> TURTLE = make( "turtle" );
|
public static final TagKey<Item> TURTLE = make( "turtle" );
|
||||||
public static final Tag.Named<Item> WIRED_MODEM = make( "wired_modem" );
|
public static final TagKey<Item> WIRED_MODEM = make( "wired_modem" );
|
||||||
public static final Tag.Named<Item> MONITOR = make( "monitor" );
|
public static final TagKey<Item> MONITOR = make( "monitor" );
|
||||||
|
|
||||||
private static Tag.Named<Item> make( String name )
|
private static TagKey<Item> make( String name )
|
||||||
{
|
{
|
||||||
return ItemTags.bind( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() );
|
return ItemTags.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Blocks
|
public static class Blocks
|
||||||
{
|
{
|
||||||
public static final Tag.Named<Block> COMPUTER = make( "computer" );
|
public static final TagKey<Block> COMPUTER = make( "computer" );
|
||||||
public static final Tag.Named<Block> TURTLE = make( "turtle" );
|
public static final TagKey<Block> TURTLE = make( "turtle" );
|
||||||
public static final Tag.Named<Block> WIRED_MODEM = make( "wired_modem" );
|
public static final TagKey<Block> WIRED_MODEM = make( "wired_modem" );
|
||||||
public static final Tag.Named<Block> MONITOR = make( "monitor" );
|
public static final TagKey<Block> MONITOR = make( "monitor" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocks which can be broken by any turtle tool.
|
* Blocks which can be broken by any turtle tool.
|
||||||
*/
|
*/
|
||||||
public static final Tag.Named<Block> TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" );
|
public static final TagKey<Block> TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocks which can be broken by the default shovel tool.
|
* Blocks which can be broken by the default shovel tool.
|
||||||
*/
|
*/
|
||||||
public static final Tag.Named<Block> TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" );
|
public static final TagKey<Block> TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocks which can be broken with the default sword tool.
|
* Blocks which can be broken with the default sword tool.
|
||||||
*/
|
*/
|
||||||
public static final Tag.Named<Block> TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" );
|
public static final TagKey<Block> TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocks which can be broken with the default hoe tool.
|
* Blocks which can be broken with the default hoe tool.
|
||||||
*/
|
*/
|
||||||
public static final Tag.Named<Block> TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" );
|
public static final TagKey<Block> TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" );
|
||||||
|
|
||||||
private static Tag.Named<Block> make( String name )
|
private static TagKey<Block> make( String name )
|
||||||
{
|
{
|
||||||
return BlockTags.bind( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() );
|
return BlockTags.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import dan200.computercraft.api.ComputerCraftTags;
|
|||||||
import dan200.computercraft.api.upgrades.UpgradeDataProvider;
|
import dan200.computercraft.api.upgrades.UpgradeDataProvider;
|
||||||
import net.minecraft.data.DataGenerator;
|
import net.minecraft.data.DataGenerator;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
@@ -42,7 +42,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
|||||||
*
|
*
|
||||||
* @param id The ID of this tool.
|
* @param id The ID of this tool.
|
||||||
* @param item The item used for tool actions. Note, this doesn't inherit all properties of the tool, you may need
|
* @param item The item used for tool actions. Note, this doesn't inherit all properties of the tool, you may need
|
||||||
* to specify {@link ToolBuilder#damageMultiplier(float)} and {@link ToolBuilder#breakable(Tag.Named)}.
|
* to specify {@link ToolBuilder#damageMultiplier(float)} and {@link ToolBuilder#breakable(TagKey)}.
|
||||||
* @return A tool builder,
|
* @return A tool builder,
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -64,7 +64,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
|||||||
private String adjective;
|
private String adjective;
|
||||||
private Item craftingItem;
|
private Item craftingItem;
|
||||||
private Float damageMultiplier = null;
|
private Float damageMultiplier = null;
|
||||||
private Tag.Named<Block> breakable;
|
private TagKey<Block> breakable;
|
||||||
|
|
||||||
ToolBuilder( ResourceLocation id, TurtleUpgradeSerialiser<?> serialiser, Item toolItem )
|
ToolBuilder( ResourceLocation id, TurtleUpgradeSerialiser<?> serialiser, Item toolItem )
|
||||||
{
|
{
|
||||||
@@ -123,7 +123,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
|||||||
* @return The tool builder, for further use.
|
* @return The tool builder, for further use.
|
||||||
* @see ComputerCraftTags.Blocks
|
* @see ComputerCraftTags.Blocks
|
||||||
*/
|
*/
|
||||||
public ToolBuilder breakable( @Nonnull Tag.Named<Block> breakable )
|
public ToolBuilder breakable( @Nonnull TagKey<Block> breakable )
|
||||||
{
|
{
|
||||||
this.breakable = breakable;
|
this.breakable = breakable;
|
||||||
return this;
|
return this;
|
||||||
@@ -141,7 +141,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
|
|||||||
if( adjective != null ) s.addProperty( "adjective", adjective );
|
if( adjective != null ) s.addProperty( "adjective", adjective );
|
||||||
if( craftingItem != null ) s.addProperty( "craftItem", craftingItem.getRegistryName().toString() );
|
if( craftingItem != null ) s.addProperty( "craftItem", craftingItem.getRegistryName().toString() );
|
||||||
if( damageMultiplier != null ) s.addProperty( "damageMultiplier", damageMultiplier );
|
if( damageMultiplier != null ) s.addProperty( "damageMultiplier", damageMultiplier );
|
||||||
if( breakable != null ) s.addProperty( "breakable", breakable.getName().toString() );
|
if( breakable != null ) s.addProperty( "breakable", breakable.location().toString() );
|
||||||
} ) );
|
} ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import dan200.computercraft.client.gui.*;
|
|||||||
import dan200.computercraft.client.render.TileEntityMonitorRenderer;
|
import dan200.computercraft.client.render.TileEntityMonitorRenderer;
|
||||||
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
|
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
|
||||||
import dan200.computercraft.client.render.TurtleModelLoader;
|
import dan200.computercraft.client.render.TurtleModelLoader;
|
||||||
import dan200.computercraft.client.render.TurtlePlayerRenderer;
|
|
||||||
import dan200.computercraft.shared.Registry;
|
import dan200.computercraft.shared.Registry;
|
||||||
import dan200.computercraft.shared.common.IColouredItem;
|
import dan200.computercraft.shared.common.IColouredItem;
|
||||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||||
@@ -30,9 +29,8 @@ import net.minecraft.resources.ResourceLocation;
|
|||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
|
||||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ForgeModelBakery;
|
||||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
@@ -76,7 +74,7 @@ public final class ClientRegistry
|
|||||||
ModelLoaderRegistry.registerLoader( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleModelLoader.INSTANCE );
|
ModelLoaderRegistry.registerLoader( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleModelLoader.INSTANCE );
|
||||||
for( String model : EXTRA_MODELS )
|
for( String model : EXTRA_MODELS )
|
||||||
{
|
{
|
||||||
ModelLoader.addSpecialModel( new ModelResourceLocation( new ResourceLocation( ComputerCraft.MOD_ID, model ), "inventory" ) );
|
ForgeModelBakery.addSpecialModel( new ModelResourceLocation( new ResourceLocation( ComputerCraft.MOD_ID, model ), "inventory" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,12 +120,6 @@ public final class ClientRegistry
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerEntityRenderers( EntityRenderersEvent.RegisterRenderers event )
|
|
||||||
{
|
|
||||||
event.registerEntityRenderer( Registry.ModEntities.TURTLE_PLAYER.get(), TurtlePlayerRenderer::new );
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void setupClient( FMLClientSetupEvent event )
|
public static void setupClient( FMLClientSetupEvent event )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ public class DynamicImageButton extends Button
|
|||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
|
|
||||||
int yTex = yTexStart;
|
int yTex = yTexStart;
|
||||||
if( isHovered() ) yTex += yDiffTex;
|
if( isHoveredOrFocused() ) yTex += yDiffTex;
|
||||||
|
|
||||||
blit( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight );
|
blit( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight );
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
|
|
||||||
if( isHovered() ) renderToolTip( stack, mouseX, mouseY );
|
if( isHovered ) renderToolTip( stack, mouseX, mouseY );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ public final class CableHighlightRenderer
|
|||||||
{
|
{
|
||||||
BlockHitResult hit = event.getTarget();
|
BlockHitResult hit = event.getTarget();
|
||||||
BlockPos pos = hit.getBlockPos();
|
BlockPos pos = hit.getBlockPos();
|
||||||
Level world = event.getInfo().getEntity().getCommandSenderWorld();
|
Level world = event.getCamera().getEntity().getCommandSenderWorld();
|
||||||
Camera info = event.getInfo();
|
Camera info = event.getCamera();
|
||||||
|
|
||||||
BlockState state = world.getBlockState( pos );
|
BlockState state = world.getBlockState( pos );
|
||||||
|
|
||||||
@@ -67,9 +67,9 @@ public final class CableHighlightRenderer
|
|||||||
double yOffset = pos.getY() - cameraPos.y();
|
double yOffset = pos.getY() - cameraPos.y();
|
||||||
double zOffset = pos.getZ() - cameraPos.z();
|
double zOffset = pos.getZ() - cameraPos.z();
|
||||||
|
|
||||||
VertexConsumer buffer = event.getBuffers().getBuffer( RenderType.lines() );
|
VertexConsumer buffer = event.getMultiBufferSource().getBuffer( RenderType.lines() );
|
||||||
Matrix4f matrix4f = event.getMatrix().last().pose();
|
Matrix4f matrix4f = event.getPoseStack().last().pose();
|
||||||
Matrix3f normal = event.getMatrix().last().normal();
|
Matrix3f normal = event.getPoseStack().last().normal();
|
||||||
// TODO: Can we just accesstransformer out LevelRenderer.renderShape?
|
// TODO: Can we just accesstransformer out LevelRenderer.renderShape?
|
||||||
shape.forAllEdges( ( x1, y1, z1, x2, y2, z2 ) -> {
|
shape.forAllEdges( ( x1, y1, z1, x2, y2, z2 ) -> {
|
||||||
float xDelta = (float) (x2 - x1);
|
float xDelta = (float) (x2 - x1);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
|||||||
|
|
||||||
event.setCanceled( true );
|
event.setCanceled( true );
|
||||||
INSTANCE.renderItemFirstPerson(
|
INSTANCE.renderItemFirstPerson(
|
||||||
event.getMatrixStack(), event.getBuffers(), event.getLight(),
|
event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight(),
|
||||||
event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack()
|
event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
|
|||||||
|
|
||||||
event.setCanceled( true );
|
event.setCanceled( true );
|
||||||
INSTANCE.renderItemFirstPerson(
|
INSTANCE.renderItemFirstPerson(
|
||||||
event.getMatrixStack(), event.getBuffers(), event.getLight(),
|
event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight(),
|
||||||
event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack()
|
event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -63,11 +63,11 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onRenderInFrame( RenderItemInFrameEvent event )
|
public static void onRenderInFrame( RenderItemInFrameEvent event )
|
||||||
{
|
{
|
||||||
ItemStack stack = event.getItem();
|
ItemStack stack = event.getItemStack();
|
||||||
if( !(stack.getItem() instanceof ItemPrintout) ) return;
|
if( !(stack.getItem() instanceof ItemPrintout) ) return;
|
||||||
event.setCanceled( true );
|
event.setCanceled( true );
|
||||||
|
|
||||||
PoseStack transform = event.getMatrix();
|
PoseStack transform = event.getPoseStack();
|
||||||
|
|
||||||
// Move a little bit forward to ensure we're not clipping with the frame
|
// Move a little bit forward to ensure we're not clipping with the frame
|
||||||
transform.translate( 0.0f, 0.0f, -0.001f );
|
transform.translate( 0.0f, 0.0f, -0.001f );
|
||||||
@@ -75,8 +75,8 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
|
|||||||
transform.scale( 0.95f, 0.95f, -0.95f );
|
transform.scale( 0.95f, 0.95f, -0.95f );
|
||||||
transform.translate( -0.5f, -0.5f, 0.0f );
|
transform.translate( -0.5f, -0.5f, 0.0f );
|
||||||
|
|
||||||
int light = event.getEntityItemFrame().getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : event.getLight(); // See getLightVal.
|
int light = event.getItemFrameEntity().getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : event.getPackedLight(); // See getLightVal.
|
||||||
drawPrintout( transform, event.getBuffers(), stack, light );
|
drawPrintout( transform, event.getMultiBufferSource(), stack, light );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawPrintout( PoseStack transform, MultiBufferSource render, ItemStack stack, int light )
|
private static void drawPrintout( PoseStack transform, MultiBufferSource render, ItemStack stack, int light )
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ public final class MonitorHighlightRenderer
|
|||||||
public static void drawHighlight( DrawSelectionEvent.HighlightBlock event )
|
public static void drawHighlight( DrawSelectionEvent.HighlightBlock event )
|
||||||
{
|
{
|
||||||
// Preserve normal behaviour when crouching.
|
// Preserve normal behaviour when crouching.
|
||||||
if( event.getInfo().getEntity().isCrouching() ) return;
|
if( event.getCamera().getEntity().isCrouching() ) return;
|
||||||
|
|
||||||
Level world = event.getInfo().getEntity().getCommandSenderWorld();
|
Level world = event.getCamera().getEntity().getCommandSenderWorld();
|
||||||
BlockPos pos = event.getTarget().getBlockPos();
|
BlockPos pos = event.getTarget().getBlockPos();
|
||||||
|
|
||||||
BlockEntity tile = world.getBlockEntity( pos );
|
BlockEntity tile = world.getBlockEntity( pos );
|
||||||
@@ -60,13 +60,13 @@ public final class MonitorHighlightRenderer
|
|||||||
if( monitor.getYIndex() != 0 ) faces.remove( monitor.getDown().getOpposite() );
|
if( monitor.getYIndex() != 0 ) faces.remove( monitor.getDown().getOpposite() );
|
||||||
if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() );
|
if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() );
|
||||||
|
|
||||||
PoseStack transformStack = event.getMatrix();
|
PoseStack transformStack = event.getPoseStack();
|
||||||
Vec3 cameraPos = event.getInfo().getPosition();
|
Vec3 cameraPos = event.getCamera().getPosition();
|
||||||
transformStack.pushPose();
|
transformStack.pushPose();
|
||||||
transformStack.translate( pos.getX() - cameraPos.x(), pos.getY() - cameraPos.y(), pos.getZ() - cameraPos.z() );
|
transformStack.translate( pos.getX() - cameraPos.x(), pos.getY() - cameraPos.y(), pos.getZ() - cameraPos.z() );
|
||||||
|
|
||||||
// I wish I could think of a better way to do this
|
// I wish I could think of a better way to do this
|
||||||
VertexConsumer buffer = event.getBuffers().getBuffer( RenderType.lines() );
|
VertexConsumer buffer = event.getMultiBufferSource().getBuffer( RenderType.lines() );
|
||||||
Matrix4f transform = transformStack.last().pose();
|
Matrix4f transform = transformStack.last().pose();
|
||||||
Matrix3f normal = transformStack.last().normal();
|
Matrix3f normal = transformStack.last().normal();
|
||||||
if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, normal, 0, 0, 0, UP );
|
if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, normal, 0, 0, 0, UP );
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public class SpeakerManager
|
|||||||
if( !(event.getSound() instanceof SpeakerSound sound) ) return;
|
if( !(event.getSound() instanceof SpeakerSound sound) ) return;
|
||||||
if( sound.stream == null ) return;
|
if( sound.stream == null ) return;
|
||||||
|
|
||||||
event.getSource().attachBufferStream( sound.stream );
|
event.getChannel().attachBufferStream( sound.stream );
|
||||||
event.getSource().play();
|
event.getChannel().play();
|
||||||
|
|
||||||
sound.channel = event.getSource();
|
sound.channel = event.getChannel();
|
||||||
sound.executor = event.getManager().executor;
|
sound.executor = event.getEngine().executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SpeakerInstance getSound( UUID source )
|
public static SpeakerInstance getSound( UUID source )
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import dan200.computercraft.core.computer.TimeoutState;
|
|||||||
import dan200.computercraft.core.tracking.Tracking;
|
import dan200.computercraft.core.tracking.Tracking;
|
||||||
import dan200.computercraft.core.tracking.TrackingField;
|
import dan200.computercraft.core.tracking.TrackingField;
|
||||||
import dan200.computercraft.shared.util.ThreadUtils;
|
import dan200.computercraft.shared.util.ThreadUtils;
|
||||||
import org.squiddev.cobalt.*;
|
|
||||||
import org.squiddev.cobalt.LuaTable;
|
import org.squiddev.cobalt.LuaTable;
|
||||||
|
import org.squiddev.cobalt.*;
|
||||||
import org.squiddev.cobalt.compiler.CompileException;
|
import org.squiddev.cobalt.compiler.CompileException;
|
||||||
import org.squiddev.cobalt.compiler.LoadState;
|
import org.squiddev.cobalt.compiler.LoadState;
|
||||||
import org.squiddev.cobalt.debug.DebugFrame;
|
import org.squiddev.cobalt.debug.DebugFrame;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import net.minecraft.world.level.storage.loot.predicates.AlternativeLootItemCond
|
|||||||
import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition;
|
import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition;
|
||||||
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition;
|
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition;
|
||||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import net.minecraft.data.DataGenerator;
|
|||||||
import net.minecraft.data.recipes.*;
|
import net.minecraft.data.recipes.*;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.item.*;
|
import net.minecraft.world.item.*;
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||||
import net.minecraft.world.item.crafting.SimpleRecipeSerializer;
|
import net.minecraft.world.item.crafting.SimpleRecipeSerializer;
|
||||||
@@ -370,7 +370,7 @@ class RecipeGenerator extends RecipeProvider
|
|||||||
return DyeColor.byId( 15 - colour.ordinal() );
|
return DyeColor.byId( 15 - colour.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InventoryChangeTrigger.TriggerInstance inventoryChange( Tag<Item> stack )
|
private static InventoryChangeTrigger.TriggerInstance inventoryChange( TagKey<Item> stack )
|
||||||
{
|
{
|
||||||
return InventoryChangeTrigger.TriggerInstance.hasItems( ItemPredicate.Builder.item().of( stack ).build() );
|
return InventoryChangeTrigger.TriggerInstance.hasItems( ItemPredicate.Builder.item().of( stack ).build() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||||
import net.minecraft.world.level.storage.loot.LootPool;
|
import net.minecraft.world.level.storage.loot.LootPool;
|
||||||
@@ -28,11 +29,11 @@ import net.minecraft.world.level.storage.loot.entries.LootTableReference;
|
|||||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
||||||
import net.minecraftforge.event.*;
|
import net.minecraftforge.event.*;
|
||||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||||
|
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||||
|
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||||
|
import net.minecraftforge.event.server.ServerStoppedEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fmlserverevents.FMLServerStartedEvent;
|
|
||||||
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
|
|
||||||
import net.minecraftforge.fmlserverevents.FMLServerStoppedEvent;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -84,7 +85,7 @@ public final class CommonHooks
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerStarting( FMLServerStartingEvent event )
|
public static void onServerStarting( ServerStartingEvent event )
|
||||||
{
|
{
|
||||||
MinecraftServer server = event.getServer();
|
MinecraftServer server = event.getServer();
|
||||||
if( server instanceof DedicatedServer dediServer && dediServer.getProperties().enableJmxMonitoring )
|
if( server instanceof DedicatedServer dediServer && dediServer.getProperties().enableJmxMonitoring )
|
||||||
@@ -94,7 +95,7 @@ public final class CommonHooks
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerStarted( FMLServerStartedEvent event )
|
public static void onServerStarted( ServerStartedEvent event )
|
||||||
{
|
{
|
||||||
ComputerCraft.serverComputerRegistry.reset();
|
ComputerCraft.serverComputerRegistry.reset();
|
||||||
WirelessNetwork.resetNetworks();
|
WirelessNetwork.resetNetworks();
|
||||||
@@ -104,7 +105,7 @@ public final class CommonHooks
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerStopped( FMLServerStoppedEvent event )
|
public static void onServerStopped( ServerStoppedEvent event )
|
||||||
{
|
{
|
||||||
ComputerCraft.serverComputerRegistry.reset();
|
ComputerCraft.serverComputerRegistry.reset();
|
||||||
WirelessNetwork.resetNetworks();
|
WirelessNetwork.resetNetworks();
|
||||||
@@ -161,4 +162,14 @@ public final class CommonHooks
|
|||||||
NetworkHandler.sendToPlayer( event.getPlayer(), packet );
|
NetworkHandler.sendToPlayer( event.getPlayer(), packet );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onMissingEntityMappingsEvent( RegistryEvent.MissingMappings<EntityType<?>> event )
|
||||||
|
{
|
||||||
|
ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, "turtle_player" );
|
||||||
|
for( RegistryEvent.MissingMappings.Mapping<EntityType<?>> mapping : event.getMappings( ComputerCraft.MOD_ID ) )
|
||||||
|
{
|
||||||
|
if( mapping.key.equals( id ) ) mapping.ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
|
|||||||
import dan200.computercraft.shared.pocket.recipes.PocketComputerUpgradeRecipe;
|
import dan200.computercraft.shared.pocket.recipes.PocketComputerUpgradeRecipe;
|
||||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||||
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
|
|
||||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||||
import dan200.computercraft.shared.turtle.items.ItemTurtle;
|
import dan200.computercraft.shared.turtle.items.ItemTurtle;
|
||||||
import dan200.computercraft.shared.turtle.recipes.TurtleRecipe;
|
import dan200.computercraft.shared.turtle.recipes.TurtleRecipe;
|
||||||
@@ -73,8 +72,6 @@ import dan200.computercraft.shared.util.ImpostorRecipe;
|
|||||||
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
|
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
|
||||||
import net.minecraft.core.cauldron.CauldronInteraction;
|
import net.minecraft.core.cauldron.CauldronInteraction;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.entity.MobCategory;
|
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
@@ -96,11 +93,11 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
|||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.RegistryBuilder;
|
import net.minecraftforge.registries.RegistryBuilder;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@@ -285,18 +282,6 @@ public final class Registry
|
|||||||
SERIALISERS.register( "wireless_modem_advanced", () -> PocketUpgradeSerialiser.simpleWithCustomItem( ( id, item ) -> new PocketModem( id, item, true ) ) );
|
SERIALISERS.register( "wireless_modem_advanced", () -> PocketUpgradeSerialiser.simpleWithCustomItem( ( id, item ) -> new PocketModem( id, item, true ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ModEntities
|
|
||||||
{
|
|
||||||
static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID );
|
|
||||||
|
|
||||||
public static final RegistryObject<EntityType<TurtlePlayer>> TURTLE_PLAYER = ENTITIES.register( "turtle_player", () ->
|
|
||||||
EntityType.Builder.<TurtlePlayer>createNothing( MobCategory.MISC )
|
|
||||||
.noSave()
|
|
||||||
.noSummon()
|
|
||||||
.sized( 0, 0 )
|
|
||||||
.build( ComputerCraft.MOD_ID + ":turtle_player" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ModContainers
|
public static class ModContainers
|
||||||
{
|
{
|
||||||
static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID );
|
static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID );
|
||||||
@@ -425,7 +410,6 @@ public final class Registry
|
|||||||
ModItems.ITEMS.register( bus );
|
ModItems.ITEMS.register( bus );
|
||||||
ModTurtleSerialisers.SERIALISERS.register( bus );
|
ModTurtleSerialisers.SERIALISERS.register( bus );
|
||||||
ModPocketUpgradeSerialisers.SERIALISERS.register( bus );
|
ModPocketUpgradeSerialisers.SERIALISERS.register( bus );
|
||||||
ModEntities.ENTITIES.register( bus );
|
|
||||||
ModContainers.CONTAINERS.register( bus );
|
ModContainers.CONTAINERS.register( bus );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||||||
import net.minecraftforge.client.event.ClientChatEvent;
|
import net.minecraftforge.client.event.ClientChatEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public final class CommandUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
public static CompletableFuture<Suggestions> suggestOnServer( CommandContext<?> context, SuggestionsBuilder builder, Function<CommandContext<CommandSourceStack>, CompletableFuture<Suggestions>> supplier )
|
public static CompletableFuture<Suggestions> suggestOnServer( CommandContext<?> context, Function<CommandContext<CommandSourceStack>, CompletableFuture<Suggestions>> supplier )
|
||||||
{
|
{
|
||||||
Object source = context.getSource();
|
Object source = context.getSource();
|
||||||
if( !(source instanceof SharedSuggestionProvider) )
|
if( !(source instanceof SharedSuggestionProvider) )
|
||||||
@@ -45,7 +45,7 @@ public final class CommandUtils
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ((SharedSuggestionProvider) source).customSuggestion( (CommandContext<SharedSuggestionProvider>) context, builder );
|
return ((SharedSuggestionProvider) source).customSuggestion( context );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public final class ComputersArgumentType implements ArgumentType<ComputersArgume
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify we've a command source and we're running on the server
|
// Verify we've a command source and we're running on the server
|
||||||
return suggestOnServer( context, builder, s -> {
|
return suggestOnServer( context, s -> {
|
||||||
if( remaining.startsWith( "@" ) )
|
if( remaining.startsWith( "@" ) )
|
||||||
{
|
{
|
||||||
suggestComputers( builder, remaining, x -> {
|
suggestComputers( builder, remaining, x -> {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
|||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.common.util.Constants;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public abstract class TileGeneric extends BlockEntity
|
|||||||
setChanged();
|
setChanged();
|
||||||
BlockPos pos = getBlockPos();
|
BlockPos pos = getBlockPos();
|
||||||
BlockState state = getBlockState();
|
BlockState state = getBlockState();
|
||||||
getLevel().sendBlockUpdated( pos, state, state, Constants.BlockFlags.DEFAULT );
|
getLevel().sendBlockUpdated( pos, state, state, Block.UPDATE_ALL );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -76,7 +76,8 @@ public abstract class TileGeneric extends BlockEntity
|
|||||||
@Override
|
@Override
|
||||||
public final void onDataPacket( Connection net, ClientboundBlockEntityDataPacket packet )
|
public final void onDataPacket( Connection net, ClientboundBlockEntityDataPacket packet )
|
||||||
{
|
{
|
||||||
if( packet.getType() == 0 ) handleUpdateTag( packet.getTag() );
|
var tag = packet.getTag();
|
||||||
|
if( tag != null ) handleUpdateTag( tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import net.minecraft.commands.CommandSourceStack;
|
|||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@@ -81,7 +80,7 @@ public class CommandAPI implements ILuaAPI
|
|||||||
Map<String, Object> table = BlockData.fill( new HashMap<>(), state );
|
Map<String, Object> table = BlockData.fill( new HashMap<>(), state );
|
||||||
|
|
||||||
BlockEntity tile = world.getBlockEntity( pos );
|
BlockEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile != null ) table.put( "nbt", NBTUtil.toLua( tile.save( new CompoundTag() ) ) );
|
if( tile != null ) table.put( "nbt", NBTUtil.toLua( tile.saveWithFullMetadata() ) );
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
|||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -119,7 +119,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock( BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player )
|
public ItemStack getCloneItemStack( BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player )
|
||||||
{
|
{
|
||||||
BlockEntity tile = world.getBlockEntity( pos );
|
BlockEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile instanceof TileComputerBase )
|
if( tile instanceof TileComputerBase )
|
||||||
@@ -128,7 +128,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
|||||||
if( !result.isEmpty() ) return result;
|
if( !result.isEmpty() ) return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getPickBlock( state, target, world, pos, player );
|
return super.getCloneItemStack( state, target, world, pos, player );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -188,16 +188,15 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
protected abstract void updateBlockState( ComputerState newState );
|
protected abstract void updateBlockState( ComputerState newState );
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save( @Nonnull CompoundTag nbt )
|
public void saveAdditional( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
// Save ID, label and power state
|
// Save ID, label and power state
|
||||||
if( computerID >= 0 ) nbt.putInt( NBT_ID, computerID );
|
if( computerID >= 0 ) nbt.putInt( NBT_ID, computerID );
|
||||||
if( label != null ) nbt.putString( NBT_LABEL, label );
|
if( label != null ) nbt.putString( NBT_LABEL, label );
|
||||||
nbt.putBoolean( NBT_ON, on );
|
nbt.putBoolean( NBT_ON, on );
|
||||||
|
|
||||||
return super.save( nbt );
|
super.saveAdditional( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -388,7 +387,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
@Override
|
@Override
|
||||||
public final ClientboundBlockEntityDataPacket getUpdatePacket()
|
public final ClientboundBlockEntityDataPacket getUpdatePacket()
|
||||||
{
|
{
|
||||||
return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() );
|
return ClientboundBlockEntityDataPacket.create( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import net.minecraft.server.MinecraftServer;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
import net.minecraftforge.versions.mcp.MCPVersion;
|
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class JEIComputerCraft implements IModPlugin
|
|||||||
IRecipeCategory<?> category = registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING, false );
|
IRecipeCategory<?> category = registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING, false );
|
||||||
if( category != null )
|
if( category != null )
|
||||||
{
|
{
|
||||||
for( Object wrapper : registry.getRecipes( category, null, false ) )
|
for( Object wrapper : registry.getRecipes( category, List.of(), false ) )
|
||||||
{
|
{
|
||||||
if( !(wrapper instanceof Recipe) ) continue;
|
if( !(wrapper instanceof Recipe) ) continue;
|
||||||
ResourceLocation id = ((Recipe<?>) wrapper).getId();
|
ResourceLocation id = ((Recipe<?>) wrapper).getId();
|
||||||
|
|||||||
@@ -97,10 +97,10 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
@Override
|
@Override
|
||||||
public <V> List<ResourceLocation> getRecipeCategoryUids( @Nonnull IFocus<V> focus )
|
public <V> List<ResourceLocation> getRecipeCategoryUids( @Nonnull IFocus<V> focus )
|
||||||
{
|
{
|
||||||
V value = focus.getValue();
|
V value = focus.getTypedValue().getIngredient();
|
||||||
if( !(value instanceof ItemStack stack) ) return Collections.emptyList();
|
if( !(value instanceof ItemStack stack) ) return Collections.emptyList();
|
||||||
|
|
||||||
switch( focus.getMode() )
|
switch( focus.getRole() )
|
||||||
{
|
{
|
||||||
case INPUT:
|
case INPUT:
|
||||||
return stack.getItem() instanceof ITurtleItem || stack.getItem() instanceof ItemPocketComputer ||
|
return stack.getItem() instanceof ITurtleItem || stack.getItem() instanceof ItemPocketComputer ||
|
||||||
@@ -120,12 +120,12 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
@Override
|
@Override
|
||||||
public <T, V> List<T> getRecipes( @Nonnull IRecipeCategory<T> recipeCategory, @Nonnull IFocus<V> focus )
|
public <T, V> List<T> getRecipes( @Nonnull IRecipeCategory<T> recipeCategory, @Nonnull IFocus<V> focus )
|
||||||
{
|
{
|
||||||
if( !(focus.getValue() instanceof ItemStack stack) || !recipeCategory.getUid().equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
if( !(focus.getTypedValue().getIngredient() instanceof ItemStack stack) || !recipeCategory.getUid().equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( focus.getMode() )
|
switch( focus.getRole() )
|
||||||
{
|
{
|
||||||
case INPUT:
|
case INPUT:
|
||||||
return cast( findRecipesWithInput( stack ) );
|
return cast( findRecipesWithInput( stack ) );
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class DiskRecipe extends CustomRecipe
|
|||||||
if( paperFound ) return false;
|
if( paperFound ) return false;
|
||||||
paperFound = true;
|
paperFound = true;
|
||||||
}
|
}
|
||||||
else if( Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) )
|
else if( stack.is( Tags.Items.DUSTS_REDSTONE ) )
|
||||||
{
|
{
|
||||||
if( redstoneFound ) return false;
|
if( redstoneFound ) return false;
|
||||||
redstoneFound = true;
|
redstoneFound = true;
|
||||||
@@ -73,7 +73,7 @@ public class DiskRecipe extends CustomRecipe
|
|||||||
|
|
||||||
if( stack.isEmpty() ) continue;
|
if( stack.isEmpty() ) continue;
|
||||||
|
|
||||||
if( stack.getItem() != Items.PAPER && !Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) )
|
if( stack.getItem() != Items.PAPER && !stack.is( Tags.Items.DUSTS_REDSTONE ) )
|
||||||
{
|
{
|
||||||
DyeColor dye = ColourUtils.getStackColour( stack );
|
DyeColor dye = ColourUtils.getStackColour( stack );
|
||||||
if( dye != null ) tracker.addColour( dye );
|
if( dye != null ) tracker.addColour( dye );
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ public final class PrintoutRecipe extends CustomRecipe
|
|||||||
numPages++;
|
numPages++;
|
||||||
numPrintouts++;
|
numPrintouts++;
|
||||||
}
|
}
|
||||||
else if( Tags.Items.STRING.contains( stack.getItem() ) && !stringFound )
|
else if( stack.is( Tags.Items.STRING ) && !stringFound )
|
||||||
{
|
{
|
||||||
stringFound = true;
|
stringFound = true;
|
||||||
}
|
}
|
||||||
else if( Tags.Items.LEATHER.contains( stack.getItem() ) && !leatherFound )
|
else if( stack.is( Tags.Items.LEATHER ) && !leatherFound )
|
||||||
{
|
{
|
||||||
leatherFound = true;
|
leatherFound = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.chunk.LevelChunk;
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkDirection;
|
import net.minecraftforge.network.NetworkDirection;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkRegistry;
|
import net.minecraftforge.network.NetworkRegistry;
|
||||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
|
import net.minecraftforge.network.simple.SimpleChannel;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
package dan200.computercraft.shared.network;
|
package dan200.computercraft.shared.network;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import dan200.computercraft.shared.command.text.TableBuilder;
|
|||||||
import dan200.computercraft.shared.network.NetworkMessage;
|
import dan200.computercraft.shared.network.NetworkMessage;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.ComputerState;
|
|||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package dan200.computercraft.shared.network.client;
|
|||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
public class ComputerDeletedClientMessage extends ComputerClientMessage
|
public class ComputerDeletedClientMessage extends ComputerClientMessage
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
package dan200.computercraft.shared.network.client;
|
package dan200.computercraft.shared.network.client;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.minecraft.client.player.LocalPlayer;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import net.minecraft.network.chat.TextComponent;
|
|||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
|||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
|||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import dan200.computercraft.shared.network.NetworkMessage;
|
|||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import dan200.computercraft.shared.UpgradeManager;
|
|||||||
import dan200.computercraft.shared.network.NetworkMessage;
|
import dan200.computercraft.shared.network.NetworkMessage;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.minecraftforge.registries.IForgeRegistry;
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
import net.minecraftforge.registries.RegistryManager;
|
import net.minecraftforge.registries.RegistryManager;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ import net.minecraft.world.entity.player.Inventory;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||||
import net.minecraftforge.fmllegacy.network.IContainerFactory;
|
import net.minecraftforge.network.IContainerFactory;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extension over the basic {@link IForgeContainerType}/{@link NetworkHooks#openGui(ServerPlayer, MenuProvider, Consumer)}
|
* An extension over the basic {@link IForgeMenuType}/{@link NetworkHooks#openGui(ServerPlayer, MenuProvider, Consumer)}
|
||||||
* hooks, with a more convenient way of reading and writing data.
|
* hooks, with a more convenient way of reading and writing data.
|
||||||
*/
|
*/
|
||||||
public interface ContainerData
|
public interface ContainerData
|
||||||
@@ -35,7 +35,7 @@ public interface ContainerData
|
|||||||
|
|
||||||
static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, Factory<C, T> factory )
|
static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, Factory<C, T> factory )
|
||||||
{
|
{
|
||||||
return IForgeContainerType.create( ( id, player, data ) -> factory.create( id, player, reader.apply( data ) ) );
|
return IForgeMenuType.create( ( id, player, data ) -> factory.create( id, player, reader.apply( data ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory )
|
static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory )
|
||||||
@@ -60,7 +60,7 @@ public interface ContainerData
|
|||||||
|
|
||||||
private FixedPointContainerFactory( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory )
|
private FixedPointContainerFactory( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory )
|
||||||
{
|
{
|
||||||
MenuType<C> type = this.type = IForgeContainerType.create( this );
|
MenuType<C> type = this.type = IForgeMenuType.create( this );
|
||||||
impl = ( id, player, data ) -> factory.create( type, id, player, reader.apply( data ) );
|
impl = ( id, player, data ) -> factory.create( type, id, player, reader.apply( data ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.network.server;
|
|||||||
import dan200.computercraft.shared.computer.core.IContainerComputer;
|
import dan200.computercraft.shared.computer.core.IContainerComputer;
|
||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
|
|||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import dan200.computercraft.shared.network.NetworkMessage;
|
import dan200.computercraft.shared.network.NetworkMessage;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
|
|||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
|
|||||||
import dan200.computercraft.shared.computer.core.InputState;
|
import dan200.computercraft.shared.computer.core.InputState;
|
||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
|
|||||||
import dan200.computercraft.shared.computer.core.InputState;
|
import dan200.computercraft.shared.computer.core.InputState;
|
||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
|||||||
import dan200.computercraft.shared.util.NBTUtil;
|
import dan200.computercraft.shared.util.NBTUtil;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dan200.computercraft.ComputerCraft;
|
|||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import dan200.computercraft.shared.network.NetworkMessage;
|
import dan200.computercraft.shared.network.NetworkMessage;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.network.NetworkHandler;
|
|||||||
import io.netty.handler.codec.DecoderException;
|
import io.netty.handler.codec.DecoderException;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@@ -160,6 +160,7 @@ public class UploadFileMessage extends ComputerServerMessage
|
|||||||
contents.position( currentOffset ).limit( currentOffset + canWrite );
|
contents.position( currentOffset ).limit( currentOffset + canWrite );
|
||||||
slices.add( new FileSlice( fileId, currentOffset, contents.slice() ) );
|
slices.add( new FileSlice( fileId, currentOffset, contents.slice() ) );
|
||||||
currentOffset += canWrite;
|
currentOffset += canWrite;
|
||||||
|
remaining -= canWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
contents.position( 0 ).limit( capacity );
|
contents.position( 0 ).limit( capacity );
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkHooks;
|
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||||
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -137,9 +137,8 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save( @Nonnull CompoundTag nbt )
|
public void saveAdditional( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
if( customName != null ) nbt.putString( NBT_NAME, Component.Serializer.toJson( customName ) );
|
if( customName != null ) nbt.putString( NBT_NAME, Component.Serializer.toJson( customName ) );
|
||||||
|
|
||||||
@@ -149,7 +148,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
diskStack.save( item );
|
diskStack.save( item );
|
||||||
nbt.put( NBT_ITEM, item );
|
nbt.put( NBT_ITEM, item );
|
||||||
}
|
}
|
||||||
return super.save( nbt );
|
super.saveAdditional( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
void serverTick()
|
void serverTick()
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class BlockData
|
|||||||
stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) );
|
stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) );
|
||||||
}
|
}
|
||||||
data.put( "state", stateTable );
|
data.put( "state", stateTable );
|
||||||
data.put( "tags", DataHelpers.getTags( state.getBlock().getTags() ) );
|
data.put( "tags", DataHelpers.getTags( state.getTags() ) );
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,26 +5,31 @@
|
|||||||
*/
|
*/
|
||||||
package dan200.computercraft.shared.peripheral.generic.data;
|
package dan200.computercraft.shared.peripheral.generic.data;
|
||||||
|
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public final class DataHelpers
|
public final class DataHelpers
|
||||||
{
|
{
|
||||||
private DataHelpers()
|
private DataHelpers()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@Nonnull
|
public static <T> Map<String, Boolean> getTags( Holder.Reference<T> object )
|
||||||
public static Map<String, Boolean> getTags( @Nonnull Collection<ResourceLocation> tags )
|
|
||||||
{
|
{
|
||||||
Map<String, Boolean> result = new HashMap<>( tags.size() );
|
return getTags( object.tags() );
|
||||||
for( ResourceLocation location : tags ) result.put( location.toString(), true );
|
}
|
||||||
return result;
|
|
||||||
|
@Nonnull
|
||||||
|
public static <T> Map<String, Boolean> getTags( @Nonnull Stream<TagKey<T>> tags )
|
||||||
|
{
|
||||||
|
return tags.collect( Collectors.toMap( x -> x.location().toString(), x -> true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ public class FluidData
|
|||||||
public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @Nonnull FluidStack stack )
|
public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @Nonnull FluidStack stack )
|
||||||
{
|
{
|
||||||
fillBasic( data, stack );
|
fillBasic( data, stack );
|
||||||
data.put( "tags", DataHelpers.getTags( stack.getFluid().getTags() ) );
|
// FluidStack doesn't have a getTags method, so we need to use the deprecated builtInRegistryHolder.
|
||||||
|
@SuppressWarnings( "deprecation" )
|
||||||
|
var holder = stack.getFluid().builtInRegistryHolder();
|
||||||
|
data.put( "tags", DataHelpers.getTags( holder ) );
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ public class ItemData
|
|||||||
data.put( "maxDamage", stack.getMaxDamage() );
|
data.put( "maxDamage", stack.getMaxDamage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( stack.getItem().showDurabilityBar( stack ) )
|
if( stack.getItem().isBarVisible( stack ) )
|
||||||
{
|
{
|
||||||
data.put( "durability", stack.getItem().getDurabilityForDisplay( stack ) );
|
data.put( "durability", stack.getItem().getBarWidth( stack ) / 13.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) );
|
data.put( "tags", DataHelpers.getTags( stack.getTags() ) );
|
||||||
|
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
if( tag != null && tag.contains( "display", Tag.TAG_COMPOUND ) )
|
if( tag != null && tag.contains( "display", Tag.TAG_COMPOUND ) )
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removedByPlayer( BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid )
|
public boolean onDestroyedByPlayer( BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid )
|
||||||
{
|
{
|
||||||
if( state.getValue( CABLE ) && state.getValue( MODEM ).getFacing() != null )
|
if( state.getValue( CABLE ) && state.getValue( MODEM ).getFacing() != null )
|
||||||
{
|
{
|
||||||
@@ -140,12 +140,12 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.removedByPlayer( state, world, pos, player, willHarvest, fluid );
|
return super.onDestroyedByPlayer( state, world, pos, player, willHarvest, fluid );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock( BlockState state, HitResult hit, BlockGetter world, BlockPos pos, Player player )
|
public ItemStack getCloneItemStack( BlockState state, HitResult hit, BlockGetter world, BlockPos pos, Player player )
|
||||||
{
|
{
|
||||||
Direction modem = state.getValue( MODEM ).getFacing();
|
Direction modem = state.getValue( MODEM ).getFacing();
|
||||||
boolean cable = state.getValue( CABLE );
|
boolean cable = state.getValue( CABLE );
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public enum CableModemVariant implements StringRepresentable
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
public static CableModemVariant from( Direction facing, boolean modem, boolean peripheral )
|
public static CableModemVariant from( Direction facing, boolean modem, boolean peripheral )
|
||||||
{
|
{
|
||||||
int state = (modem ? 2 : 0) + (peripheral ? 1 : 0);
|
int state = (modem ? 1 : 0) + (peripheral ? 2 : 0);
|
||||||
return facing == null ? None : VALUES[1 + 6 * state + facing.get3DDataValue()];
|
return facing == null ? None : VALUES[1 + 6 * state + facing.get3DDataValue()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -292,13 +292,12 @@ public class TileCable extends TileGeneric
|
|||||||
peripheral.read( nbt, "" );
|
peripheral.read( nbt, "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save( CompoundTag nbt )
|
public void saveAdditional( CompoundTag nbt )
|
||||||
{
|
{
|
||||||
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
|
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
|
||||||
peripheral.write( nbt, "" );
|
peripheral.write( nbt, "" );
|
||||||
return super.save( nbt );
|
super.saveAdditional( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBlockState()
|
private void updateBlockState()
|
||||||
@@ -346,7 +345,7 @@ public class TileCable extends TileGeneric
|
|||||||
for( Direction facing : DirectionUtil.FACINGS )
|
for( Direction facing : DirectionUtil.FACINGS )
|
||||||
{
|
{
|
||||||
BlockPos offset = current.relative( facing );
|
BlockPos offset = current.relative( facing );
|
||||||
if( !world.isAreaLoaded( offset, 0 ) ) continue;
|
if( !world.isLoaded( offset ) ) continue;
|
||||||
|
|
||||||
LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() );
|
LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() );
|
||||||
if( !element.isPresent() ) continue;
|
if( !element.isPresent() ) continue;
|
||||||
|
|||||||
@@ -241,13 +241,12 @@ public class TileWiredModemFull extends TileGeneric
|
|||||||
for( int i = 0; i < peripherals.length; i++ ) peripherals[i].read( nbt, Integer.toString( i ) );
|
for( int i = 0; i < peripherals.length; i++ ) peripherals[i].read( nbt, Integer.toString( i ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save( CompoundTag nbt )
|
public void saveAdditional( CompoundTag nbt )
|
||||||
{
|
{
|
||||||
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
|
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
|
||||||
for( int i = 0; i < peripherals.length; i++ ) peripherals[i].write( nbt, Integer.toString( i ) );
|
for( int i = 0; i < peripherals.length; i++ ) peripherals[i].write( nbt, Integer.toString( i ) );
|
||||||
return super.save( nbt );
|
super.saveAdditional( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBlockState()
|
private void updateBlockState()
|
||||||
@@ -306,7 +305,7 @@ public class TileWiredModemFull extends TileGeneric
|
|||||||
for( Direction facing : DirectionUtil.FACINGS )
|
for( Direction facing : DirectionUtil.FACINGS )
|
||||||
{
|
{
|
||||||
BlockPos offset = current.relative( facing );
|
BlockPos offset = current.relative( facing );
|
||||||
if( !world.isAreaLoaded( offset, 0 ) ) continue;
|
if( !world.isLoaded( offset ) ) continue;
|
||||||
|
|
||||||
LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() );
|
LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() );
|
||||||
if( !element.isPresent() ) continue;
|
if( !element.isPresent() ) continue;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
|||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|||||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public final class MonitorWatcher
|
|||||||
if( !(world instanceof ServerLevel) ) continue;
|
if( !(world instanceof ServerLevel) ) continue;
|
||||||
|
|
||||||
LevelChunk chunk = world.getChunkAt( pos );
|
LevelChunk chunk = world.getChunkAt( pos );
|
||||||
if( ((ServerLevel) world).getChunkSource().chunkMap.getPlayers( chunk.getPos(), false ).findAny().isEmpty() )
|
if( ((ServerLevel) world).getChunkSource().chunkMap.getPlayers( chunk.getPos(), false ).isEmpty() )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,15 +127,14 @@ public class TileMonitor extends TileGeneric
|
|||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save( CompoundTag tag )
|
public void saveAdditional( CompoundTag tag )
|
||||||
{
|
{
|
||||||
tag.putInt( NBT_X, xIndex );
|
tag.putInt( NBT_X, xIndex );
|
||||||
tag.putInt( NBT_Y, yIndex );
|
tag.putInt( NBT_Y, yIndex );
|
||||||
tag.putInt( NBT_WIDTH, width );
|
tag.putInt( NBT_WIDTH, width );
|
||||||
tag.putInt( NBT_HEIGHT, height );
|
tag.putInt( NBT_HEIGHT, height );
|
||||||
return super.save( tag );
|
super.saveAdditional( tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -261,7 +260,7 @@ public class TileMonitor extends TileGeneric
|
|||||||
@Override
|
@Override
|
||||||
public final ClientboundBlockEntityDataPacket getUpdatePacket()
|
public final ClientboundBlockEntityDataPacket getUpdatePacket()
|
||||||
{
|
{
|
||||||
return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() );
|
return ClientboundBlockEntityDataPacket.create( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -398,7 +397,7 @@ public class TileMonitor extends TileGeneric
|
|||||||
BlockPos pos = toWorldPos( x, y );
|
BlockPos pos = toWorldPos( x, y );
|
||||||
|
|
||||||
Level world = getLevel();
|
Level world = getLevel();
|
||||||
if( world == null || !world.isAreaLoaded( pos, 0 ) ) return MonitorState.UNLOADED;
|
if( world == null || !world.isLoaded( pos ) ) return MonitorState.UNLOADED;
|
||||||
|
|
||||||
BlockEntity tile = world.getBlockEntity( pos );
|
BlockEntity tile = world.getBlockEntity( pos );
|
||||||
if( !(tile instanceof TileMonitor monitor) ) return MonitorState.MISSING;
|
if( !(tile instanceof TileMonitor monitor) ) return MonitorState.MISSING;
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkHooks;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||||
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -113,9 +113,8 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
ContainerHelper.loadAllItems( nbt, inventory );
|
ContainerHelper.loadAllItems( nbt, inventory );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save( @Nonnull CompoundTag nbt )
|
public void saveAdditional( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
if( customName != null ) nbt.putString( NBT_NAME, Component.Serializer.toJson( customName ) );
|
if( customName != null ) nbt.putString( NBT_NAME, Component.Serializer.toJson( customName ) );
|
||||||
|
|
||||||
@@ -130,7 +129,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
// Write inventory
|
// Write inventory
|
||||||
ContainerHelper.saveAllItems( nbt, inventory );
|
ContainerHelper.saveAllItems( nbt, inventory );
|
||||||
|
|
||||||
return super.save( nbt );
|
super.saveAdditional( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isPrinting()
|
boolean isPrinting()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
|||||||
import dan200.computercraft.shared.network.NetworkHandler;
|
import dan200.computercraft.shared.network.NetworkHandler;
|
||||||
import dan200.computercraft.shared.network.client.SpeakerStopClientMessage;
|
import dan200.computercraft.shared.network.client.SpeakerStopClientMessage;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@@ -289,9 +289,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
brain.readFromNBT( nbt );
|
brain.readFromNBT( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save( @Nonnull CompoundTag nbt )
|
public void saveAdditional( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
// Write inventory
|
// Write inventory
|
||||||
ListTag nbttaglist = new ListTag();
|
ListTag nbttaglist = new ListTag();
|
||||||
@@ -310,7 +309,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
// Write brain
|
// Write brain
|
||||||
nbt = brain.writeToNBT( nbt );
|
nbt = brain.writeToNBT( nbt );
|
||||||
|
|
||||||
return super.save( nbt );
|
super.saveAdditional( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ public class TurtleBrain implements ITurtleAccess
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the chunk is loaded
|
// Ensure the chunk is loaded
|
||||||
if( !world.isAreaLoaded( pos, 0 ) ) return false;
|
if( !world.isLoaded( pos ) ) return false;
|
||||||
|
|
||||||
// Ensure we're inside the world border
|
// Ensure we're inside the world border
|
||||||
if( !world.getWorldBorder().isWithinBounds( pos ) ) return false;
|
if( !world.getWorldBorder().isWithinBounds( pos ) ) return false;
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class TurtleMoveCommand implements ITurtleCommand
|
|||||||
return TurtleCommandResult.failure( "Cannot enter protected area" );
|
return TurtleCommandResult.failure( "Cannot enter protected area" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !world.isAreaLoaded( position, 0 ) ) return TurtleCommandResult.failure( "Cannot leave loaded world" );
|
if( !world.isLoaded( position ) ) return TurtleCommandResult.failure( "Cannot leave loaded world" );
|
||||||
if( !world.getWorldBorder().isWithinBounds( position ) )
|
if( !world.getWorldBorder().isWithinBounds( position ) )
|
||||||
{
|
{
|
||||||
return TurtleCommandResult.failure( "Cannot pass the world border" );
|
return TurtleCommandResult.failure( "Cannot pass the world border" );
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ import net.minecraft.world.item.*;
|
|||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.common.util.Constants;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.eventbus.api.Event.Result;
|
import net.minecraftforge.eventbus.api.Event.Result;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
@@ -321,7 +321,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
signTile.setChanged();
|
signTile.setChanged();
|
||||||
world.sendBlockUpdated( tile.getBlockPos(), tile.getBlockState(), tile.getBlockState(), Constants.BlockFlags.DEFAULT );
|
world.sendBlockUpdated( tile.getBlockPos(), tile.getBlockState(), tile.getBlockState(), Block.UPDATE_ALL );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ErrorMessage
|
private static class ErrorMessage
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package dan200.computercraft.shared.turtle.core;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||||
import dan200.computercraft.shared.Registry;
|
|
||||||
import dan200.computercraft.shared.util.DirectionUtil;
|
import dan200.computercraft.shared.util.DirectionUtil;
|
||||||
import dan200.computercraft.shared.util.InventoryUtil;
|
import dan200.computercraft.shared.util.InventoryUtil;
|
||||||
import dan200.computercraft.shared.util.WorldUtil;
|
import dan200.computercraft.shared.util.WorldUtil;
|
||||||
@@ -22,7 +21,6 @@ import net.minecraft.world.MenuProvider;
|
|||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.entity.Pose;
|
import net.minecraft.world.entity.Pose;
|
||||||
import net.minecraft.world.entity.animal.horse.AbstractHorse;
|
import net.minecraft.world.entity.animal.horse.AbstractHorse;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -197,13 +195,6 @@ public final class TurtlePlayer extends FakePlayer
|
|||||||
getInventory().setChanged();
|
getInventory().setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public EntityType<?> getType()
|
|
||||||
{
|
|
||||||
return Registry.ModEntities.TURTLE_PLAYER.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3 position()
|
public Vec3 position()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import net.minecraft.world.item.crafting.Recipe;
|
|||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.fmllegacy.hooks.BasicEventHooks;
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -91,7 +91,7 @@ public class TurtleInventoryCrafting extends CraftingContainer
|
|||||||
results.add( result );
|
results.add( result );
|
||||||
|
|
||||||
result.onCraftedBy( world, player, result.getCount() );
|
result.onCraftedBy( world, player, result.getCount() );
|
||||||
BasicEventHooks.firePlayerCraftingEvent( player, result, this );
|
ForgeEventFactory.firePlayerCraftingEvent( player, result, this );
|
||||||
|
|
||||||
ForgeHooks.setCraftingPlayer( player );
|
ForgeHooks.setCraftingPlayer( player );
|
||||||
NonNullList<ItemStack> remainders = recipe.getRemainingItems( this );
|
NonNullList<ItemStack> remainders = recipe.getRemainingItems( this );
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import net.minecraft.core.BlockPos;
|
|||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
@@ -60,16 +60,13 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
|||||||
final ItemStack item;
|
final ItemStack item;
|
||||||
final float damageMulitiplier;
|
final float damageMulitiplier;
|
||||||
@Nullable
|
@Nullable
|
||||||
final ResourceLocation breakableName;
|
final TagKey<Block> breakable;
|
||||||
@Nullable
|
|
||||||
final Tag<Block> breakable;
|
|
||||||
|
|
||||||
public TurtleTool( ResourceLocation id, String adjective, Item craftItem, ItemStack toolItem, float damageMulitiplier, @Nullable ResourceLocation breakableName, @Nullable Tag<Block> breakable )
|
public TurtleTool( ResourceLocation id, String adjective, Item craftItem, ItemStack toolItem, float damageMulitiplier, @Nullable TagKey<Block> breakable )
|
||||||
{
|
{
|
||||||
super( id, TurtleUpgradeType.TOOL, adjective, new ItemStack( craftItem ) );
|
super( id, TurtleUpgradeType.TOOL, adjective, new ItemStack( craftItem ) );
|
||||||
item = toolItem;
|
item = toolItem;
|
||||||
this.damageMulitiplier = damageMulitiplier;
|
this.damageMulitiplier = damageMulitiplier;
|
||||||
this.breakableName = breakableName;
|
|
||||||
this.breakable = breakable;
|
this.breakable = breakable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +121,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
|||||||
return UNBREAKABLE;
|
return UNBREAKABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return breakable == null || breakable.contains( state.getBlock() ) || isTriviallyBreakable( world, pos, state )
|
return breakable == null || state.is( breakable ) || isTriviallyBreakable( world, pos, state )
|
||||||
? TurtleCommandResult.success() : INEFFECTIVE;
|
? TurtleCommandResult.success() : INEFFECTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +252,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
|||||||
|
|
||||||
// Destroy the block
|
// Destroy the block
|
||||||
boolean canHarvest = state.canHarvestBlock( world, blockPosition, turtlePlayer );
|
boolean canHarvest = state.canHarvestBlock( world, blockPosition, turtlePlayer );
|
||||||
boolean canBreak = state.removedByPlayer( world, blockPosition, turtlePlayer, canHarvest, fluidState );
|
boolean canBreak = state.onDestroyedByPlayer( world, blockPosition, turtlePlayer, canHarvest, fluidState );
|
||||||
if( canBreak ) state.getBlock().destroy( world, blockPosition, state );
|
if( canBreak ) state.getBlock().destroy( world, blockPosition, state );
|
||||||
if( canHarvest && canBreak )
|
if( canHarvest && canBreak )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,14 +6,12 @@
|
|||||||
package dan200.computercraft.shared.turtle.upgrades;
|
package dan200.computercraft.shared.turtle.upgrades;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||||
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.SerializationTags;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.tags.Tag;
|
|
||||||
import net.minecraft.util.GsonHelper;
|
import net.minecraft.util.GsonHelper;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
@@ -36,18 +34,14 @@ public final class TurtleToolSerialiser extends TurtleUpgradeSerialiser.Base<Tur
|
|||||||
var craftingItem = GsonHelper.getAsItem( object, "craftingItem", toolItem );
|
var craftingItem = GsonHelper.getAsItem( object, "craftingItem", toolItem );
|
||||||
var damageMultiplier = GsonHelper.getAsFloat( object, "damageMultiplier", 3.0f );
|
var damageMultiplier = GsonHelper.getAsFloat( object, "damageMultiplier", 3.0f );
|
||||||
|
|
||||||
ResourceLocation breakableName = null;
|
TagKey<Block> breakable = null;
|
||||||
Tag<Block> breakable = null;
|
|
||||||
if( object.has( "breakable" ) )
|
if( object.has( "breakable" ) )
|
||||||
{
|
{
|
||||||
breakableName = new ResourceLocation( GsonHelper.getAsString( object, "breakable" ) );
|
ResourceLocation tag = new ResourceLocation( GsonHelper.getAsString( object, "breakable" ) );
|
||||||
breakable = SerializationTags.getInstance().getTagOrThrow(
|
breakable = TagKey.create( Registry.BLOCK_REGISTRY, tag );
|
||||||
Registry.BLOCK_REGISTRY, breakableName,
|
|
||||||
tagId -> new JsonSyntaxException( "Unknown item tag '" + tagId + "'" )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TurtleTool( id, adjective, craftingItem, new ItemStack( toolItem ), damageMultiplier, breakableName, breakable );
|
return new TurtleTool( id, adjective, craftingItem, new ItemStack( toolItem ), damageMultiplier, breakable );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -61,14 +55,8 @@ public final class TurtleToolSerialiser extends TurtleUpgradeSerialiser.Base<Tur
|
|||||||
// as otherwise syncing on an SP world will overwrite the (shared) upgrade registry with an invalid upgrade!
|
// as otherwise syncing on an SP world will overwrite the (shared) upgrade registry with an invalid upgrade!
|
||||||
var damageMultiplier = buffer.readFloat();
|
var damageMultiplier = buffer.readFloat();
|
||||||
|
|
||||||
ResourceLocation breakableName = null;
|
TagKey<Block> breakable = buffer.readBoolean() ? TagKey.create( Registry.BLOCK_REGISTRY, buffer.readResourceLocation() ) : null;
|
||||||
Tag<Block> breakable = null;
|
return new TurtleTool( id, adjective, craftingItem, toolItem, damageMultiplier, breakable );
|
||||||
if( buffer.readBoolean() )
|
|
||||||
{
|
|
||||||
breakableName = buffer.readResourceLocation();
|
|
||||||
breakable = SerializationTags.getInstance().getOrEmpty( Registry.BLOCK_REGISTRY ).getTagOrEmpty( breakableName );
|
|
||||||
}
|
|
||||||
return new TurtleTool( id, adjective, craftingItem, toolItem, damageMultiplier, breakableName, breakable );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,7 +66,7 @@ public final class TurtleToolSerialiser extends TurtleUpgradeSerialiser.Base<Tur
|
|||||||
buffer.writeRegistryIdUnsafe( ForgeRegistries.ITEMS, upgrade.getCraftingItem().getItem() );
|
buffer.writeRegistryIdUnsafe( ForgeRegistries.ITEMS, upgrade.getCraftingItem().getItem() );
|
||||||
buffer.writeItem( upgrade.item );
|
buffer.writeItem( upgrade.item );
|
||||||
buffer.writeFloat( upgrade.damageMulitiplier );
|
buffer.writeFloat( upgrade.damageMulitiplier );
|
||||||
buffer.writeBoolean( upgrade.breakableName != null );
|
buffer.writeBoolean( upgrade.breakable != null );
|
||||||
if( upgrade.breakableName != null ) buffer.writeResourceLocation( upgrade.breakableName );
|
if( upgrade.breakable != null ) buffer.writeResourceLocation( upgrade.breakable.location() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package dan200.computercraft.shared.util;
|
package dan200.computercraft.shared.util;
|
||||||
|
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.item.DyeColor;
|
import net.minecraft.world.item.DyeColor;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -14,7 +14,7 @@ import net.minecraftforge.common.Tags;
|
|||||||
public final class ColourUtils
|
public final class ColourUtils
|
||||||
{
|
{
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||||
private static final Tag<Item>[] DYES = new Tag[] {
|
private static final TagKey<Item>[] DYES = new TagKey[] {
|
||||||
Tags.Items.DYES_WHITE,
|
Tags.Items.DYES_WHITE,
|
||||||
Tags.Items.DYES_ORANGE,
|
Tags.Items.DYES_ORANGE,
|
||||||
Tags.Items.DYES_MAGENTA,
|
Tags.Items.DYES_MAGENTA,
|
||||||
@@ -41,8 +41,8 @@ public final class ColourUtils
|
|||||||
|
|
||||||
for( int i = 0; i < DYES.length; i++ )
|
for( int i = 0; i < DYES.length; i++ )
|
||||||
{
|
{
|
||||||
Tag<Item> dye = DYES[i];
|
TagKey<Item> dye = DYES[i];
|
||||||
if( dye.contains( stack.getItem() ) ) return DyeColor.byId( i );
|
if( stack.is( dye ) ) return DyeColor.byId( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.level.storage.LevelResource;
|
import net.minecraft.world.level.storage.LevelResource;
|
||||||
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
@@ -45,21 +45,17 @@ public final class IDAssigner
|
|||||||
return ServerLifecycleHooks.getCurrentServer().getWorldPath( FOLDER ).toFile();
|
return ServerLifecycleHooks.getCurrentServer().getWorldPath( FOLDER ).toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MinecraftServer getCachedServer()
|
private static boolean hasServerChanged()
|
||||||
{
|
{
|
||||||
if( server == null ) return null;
|
if( server == null ) return true;
|
||||||
|
|
||||||
MinecraftServer currentServer = server.get();
|
MinecraftServer currentServer = server.get();
|
||||||
if( currentServer == null ) return null;
|
return currentServer == null || currentServer != ServerLifecycleHooks.getCurrentServer();
|
||||||
|
|
||||||
if( currentServer != ServerLifecycleHooks.getCurrentServer() ) return null;
|
|
||||||
return currentServer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized int getNextId( String kind )
|
public static synchronized int getNextId( String kind )
|
||||||
{
|
{
|
||||||
MinecraftServer currentServer = getCachedServer();
|
if( hasServerChanged() )
|
||||||
if( currentServer == null )
|
|
||||||
{
|
{
|
||||||
// The server has changed, refetch our ID map
|
// The server has changed, refetch our ID map
|
||||||
server = new WeakReference<>( ServerLifecycleHooks.getCurrentServer() );
|
server = new WeakReference<>( ServerLifecycleHooks.getCurrentServer() );
|
||||||
@@ -68,23 +64,22 @@ public final class IDAssigner
|
|||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
|
|
||||||
// Load our ID file from disk
|
// Load our ID file from disk
|
||||||
|
Map<String, Integer> newIds = null;
|
||||||
idFile = new File( dir, "ids.json" ).toPath();
|
idFile = new File( dir, "ids.json" ).toPath();
|
||||||
if( Files.isRegularFile( idFile ) )
|
if( Files.isRegularFile( idFile ) )
|
||||||
{
|
{
|
||||||
try( Reader reader = Files.newBufferedReader( idFile, StandardCharsets.UTF_8 ) )
|
try( Reader reader = Files.newBufferedReader( idFile, StandardCharsets.UTF_8 ) )
|
||||||
{
|
{
|
||||||
ids = GSON.fromJson( reader, ID_TOKEN );
|
newIds = GSON.fromJson( reader, ID_TOKEN );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
ComputerCraft.log.error( "Cannot load id file '" + idFile + "'", e );
|
ComputerCraft.log.error( "Cannot load id file '" + idFile + "'", e );
|
||||||
ids = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if( newIds == null ) newIds = new HashMap<>();
|
||||||
ids = new HashMap<>();
|
ids = newIds;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer existing = ids.get( kind );
|
Integer existing = ids.get( kind );
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package dan200.computercraft.shared.util;
|
package dan200.computercraft.shared.util;
|
||||||
|
|
||||||
|
import com.google.common.io.BaseEncoding;
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
import net.minecraft.nbt.*;
|
import net.minecraft.nbt.*;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -22,6 +22,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public final class NBTUtil
|
public final class NBTUtil
|
||||||
{
|
{
|
||||||
|
private static final BaseEncoding ENCODING = BaseEncoding.base16().lowerCase();
|
||||||
|
|
||||||
private NBTUtil() {}
|
private NBTUtil() {}
|
||||||
|
|
||||||
private static Tag toNBTTag( Object object )
|
private static Tag toNBTTag( Object object )
|
||||||
@@ -177,7 +179,7 @@ public final class NBTUtil
|
|||||||
DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) );
|
DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) );
|
||||||
NbtIo.write( tag, output );
|
NbtIo.write( tag, output );
|
||||||
byte[] hash = digest.digest();
|
byte[] hash = digest.digest();
|
||||||
return new String( Hex.encodeHex( hash ) );
|
return ENCODING.encode( hash );
|
||||||
}
|
}
|
||||||
catch( NoSuchAlgorithmException | IOException e )
|
catch( NoSuchAlgorithmException | IOException e )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import dan200.computercraft.ComputerCraft;
|
|||||||
import dan200.computercraft.shared.common.TileGeneric;
|
import dan200.computercraft.shared.common.TileGeneric;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.TickList;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
@@ -21,7 +22,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thread-safe version of {@link TickList#scheduleTick(BlockPos, Object, int)}.
|
* A thread-safe version of {@link LevelAccessor#scheduleTick(BlockPos, Block, int)}.
|
||||||
*
|
*
|
||||||
* We use this when modems and other peripherals change a block in a different thread.
|
* We use this when modems and other peripherals change a block in a different thread.
|
||||||
*/
|
*/
|
||||||
@@ -58,9 +59,9 @@ public final class TickScheduler
|
|||||||
Level world = tile.getLevel();
|
Level world = tile.getLevel();
|
||||||
BlockPos pos = tile.getBlockPos();
|
BlockPos pos = tile.getBlockPos();
|
||||||
|
|
||||||
if( world != null && pos != null && world.isAreaLoaded( pos, 0 ) && world.getBlockEntity( pos ) == tile )
|
if( world != null && pos != null && world.isLoaded( pos ) && world.getBlockEntity( pos ) == tile )
|
||||||
{
|
{
|
||||||
world.getBlockTicks().scheduleTick( pos, tile.getBlockState().getBlock(), 0 );
|
world.scheduleTick( pos, tile.getBlockState().getBlock(), 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public final class WaterloggableHelpers
|
|||||||
{
|
{
|
||||||
if( state.getValue( WATERLOGGED ) )
|
if( state.getValue( WATERLOGGED ) )
|
||||||
{
|
{
|
||||||
world.getLiquidTicks().scheduleTick( pos, Fluids.WATER, Fluids.WATER.getTickDelay( world ) );
|
world.scheduleTick( pos, Fluids.WATER, Fluids.WATER.getTickDelay( world ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user