1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-15 14:07:38 +00:00

Compare commits

...

79 Commits

Author SHA1 Message Date
Jonathan Coates
a913232e62 Merge branch 'mc-1.18.x' into mc-1.19.x 2022-06-10 00:04:35 +01:00
Jonathan Coates
557765d8f0 Merge branch 'mc-1.16.x' into mc-1.18.x 2022-06-10 00:00:19 +01:00
Jonathan Coates
5382d34d29 Bump Forge version
Nothing major has changed, just at this point it's best to be on latest.
2022-06-09 23:34:46 +01:00
Jonathan Coates
8f7719a8dc Update to Minecraft 1.19
Oh my, a same day release! Well, if we use the AoE timezone.

Entirely untested (well, aside from automated tests), I haven't even
launched a client. In my defence, its just past midnight and I've been
up since 4am.
2022-06-08 00:10:55 +01:00
Jonathan Coates
a07bba4ece Merge branch 'mc-1.16.x' into mc-1.18.x 2022-05-27 22:28:55 +01:00
Jonathan Coates
83a1af6526 Merge branch 'mc-1.16.x' into mc-1.18.x 2022-05-27 18:55:51 +01:00
Jonathan Coates
5052718428 Merge branch 'mc-1.16.x' into mc-1.18.x 2022-05-22 15:03:01 +01:00
Jonathan Coates
caa412b7d2 Merge branch 'mc-1.16.x' into mc-1.18.x 2022-04-28 20:27:48 +01:00
Jonathan Coates
159f90896e Merge branch 'mc-1.16.x' into mc-1.18.x 2022-04-27 13:52:11 +01:00
Jonathan Coates
2a4f75ba15 Use Forge's new sound stream API
- Bump Forge version to latest RB.
 - Generate an 8-bit audio stream again, as we no longer need to be
   compatible with MC's existing streams.

No functionality changes, just mildly less hacky.
2022-04-27 10:59:28 +01:00
Jonathan Coates
42b98bce28 Reset the BufferUploader state on Linux
GlStateManager.glDeleteBuffers clears a buffer before deleting it on
Linux - I assume otherwise there's memory leaks on some drivers? - which
clobbers BufferUploader's cache. Roll our own version which resets the
cache when needed.

Also always reset the cache when deleting/creating a DirectVertexBuffer.
2022-04-26 22:39:34 +01:00
Jonathan Coates
59e3608d2a Merge branch 'mc-1.16.x' into mc-1.18.x
I was right: I did not enjoy this.
2022-04-26 22:17:42 +01:00
Jonathan Coates
41fa95bce4 Cleanup and optimise terminal rendering (#1057)
- Remove the POSITION_COLOR render type. Instead we just render a
   background terminal quad as the pocket computer light - it's a little
   (lot?) more cheaty, but saves having to create a render type.

 - Use the existing position_color_tex shader instead of our copy. I
   looked at using RenderType.text, but had a bunch of problems with GUI
   terminals. Its possible we can fix it, but didn't want to spend too
   much time on it.

 - Remove some methods from FixedWidthFontRenderer, inlining them into
   the call site.

 - Switch back to using GL_QUADS rather than GL_TRIANGLES. I know Lig
   will shout at me for this, but the rest of MC uses QUADS, so I don't
   think best practice really matters here.

 - Fix the TBO backend monitor not rendering monitors with fog.
 
   Unfortunately we can't easily do this to the VBO one without writing
   a custom shader (which defeats the whole point of the VBO backend!),
   as the distance calculation of most render types expect an
   already-transformed position (camera-relative I think!) while we pass
   a world-relative one.

 - When rendering to a VBO we push vertices to a ByteBuffer directly,
   rather than going through MC's VertexConsumer system. This removes
   the overhead which comes with VertexConsumer, significantly improving
   performance.

 - Pre-convert palette colours to bytes, storing both the coloured and
   greyscale versions as a byte array. This allows us to remove the
   multiple casts and conversions (double -> float -> (greyscale) ->
   byte), offering noticeable performance improvements (multiple ms per
   frame).

   We're using a byte[] here rather than a record of three bytes as
   notionally it provides better performance when writing to a
   ByteBuffer directly compared to calling .put() four times. [^1]

 - Memorize getRenderBoundingBox. This was taking about 5% of the total
   time on the render thread[^2], so worth doing.

   I don't actually think the allocation is the heavy thing here -
   VisualVM says it's toWorldPos being slow. I'm not sure why - possibly
   just all the block property lookups? [^2]

Note that none of these changes improve compatibility with Optifine.
Right now there's some serious issues where monitors are writing _over_
blocks in front of them. To fix this, we probably need to remove the
depth blocker and just render characters with a z offset. Will do that
in a separate commit, as I need to evaluate how well that change will
work first.

The main advantage of this commit is the improved performance. In my 
stress test with 120 monitors updating every tick, I'm getting 10-20fps
[^3] (still much worse than TBOs, which manages a solid 60-100).

In practice, we'll actually be much better than this. Our network
bandwidth limits means only 40 change in a single tick - and so FPS is
much more reasonable (+60fps).

[^1]: In general, put(byte[]) is faster than put(byte) multiple times.
Just not clear if this is true when dealing with a small (and loop
unrolled) number of bytes.

[^2]: To be clear, this is with 120 monitors and no other block entities
with custom renderers. so not really representative.

[^3]: I wish I could provide a narrower range, but it varies so much
between me restarting the game. Makes it impossible to benchmark
anything!
2022-04-02 10:54:03 +01:00
Jonathan Coates
ba7598c689 Merge branch 'mc-1.17.x' into mc-1.18.x 2022-03-23 08:40:25 +00:00
Jonathan Coates
70c5cbafec Merge branch 'mc-1.16.x' into mc-1.17.x 2022-03-23 08:39:39 +00:00
Jonathan Coates
7731759c77 Bump Forge version one more time 2022-03-23 08:34:57 +00:00
Jonathan Coates
e6339b2847 Update to Forge's latest registry API
Forge 4.0.18 deprecated a lot of methods and moved where
RegistryEvent.NewRegistry lives, so we needed to update. This does break
the CC API a little bit (sorry!) though given Forge 1.18.2 is still in
flux, that's probably inevitable.
2022-03-19 08:45:14 +00:00
Jonathan Coates
6353e8d930 Merge branch 'mc-1.16.x' into mc-1.17.x 2022-03-03 10:45:25 +00:00
Jonathan Coates
78cce4981a Merge branch 'mc-1.17.x' into mc-1.18.x 2022-03-03 10:45:25 +00:00
Jonathan Coates
97c953a9be Fix not running the test server during a build 2022-03-03 10:11:17 +00:00
Jonathan Coates
52df7cb8a4 Switch to Forge's game test system
It's now impossible to run the client tests (tests are still there, but
none of the other infrastructure is). We've not run these for months now
due to their severe flakiness :(.
2022-03-03 09:57:36 +00:00
Jonathan Coates
6735cfd12e Update to 1.18.2
Did not enjoy, would not recommend.
2022-03-03 09:17:40 +00:00
Jonathan Coates
f994696161 Merge branch 'mc-1.17.x' into mc-1.18.x 2022-02-28 16:26:16 +00:00
Jonathan Coates
4a4e8bb4b6 Merge branch 'mc-1.16.x' into mc-1.17.x 2022-02-28 16:25:33 +00:00
Jonathan Coates
9edce36efd Merge branch 'mc-1.17.x' into mc-1.18.x 2022-01-14 23:01:12 +00:00
Jonathan Coates
e05588c662 Merge branch 'mc-1.16.x' into mc-1.17.x 2022-01-14 23:00:17 +00:00
Jonathan Coates
79366bf2f5 Merge branch 'mc-1.17.x' into mc-1.18.x 2022-01-01 15:41:24 +00:00
Jonathan Coates
413fa5bcc8 Merge branch 'mc-1.16.x' into mc-1.17.x 2022-01-01 15:41:05 +00:00
Jonathan Coates
2b901f2d5e Merge branch 'mc-1.17.x' into mc-1.18.x 2021-12-25 08:05:25 +00:00
Jonathan Coates
62f2cd5cb2 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-12-25 08:05:25 +00:00
Jonathan Coates
901d8d4c3b Merge branch 'mc-1.17.x' into mc-1.18.x 2021-12-21 15:15:53 +00:00
Jonathan Coates
f794ce42ab Merge branch 'mc-1.16.x' into mc-1.17.x 2021-12-21 15:10:19 +00:00
Jonathan Coates
2562642664 Re-add JEI integration 2021-12-18 11:42:22 +00:00
Jonathan Coates
632db1cfa5 Merge branch 'mc-1.17.x' into mc-1.18.x 2021-12-18 11:38:48 +00:00
Jonathan Coates
aa0d544bba Remove MoreRed integration
It's not been updated to 1.17/1.18, nor touched since July. Can easily
be added back in if this changes.
2021-12-18 11:35:52 +00:00
Jonathan Coates
2f6ad00764 Use Java 16 ByteBuffer methods where possible 2021-12-18 11:34:44 +00:00
Jonathan Coates
05da4dd362 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-12-18 11:25:28 +00:00
Jonathan Coates
fe3c42ce22 Mark 1.17 (and 1.18) as stable 2021-12-17 16:44:29 +00:00
Jonathan Coates
f6fcba7a39 Merge branch 'mc-1.17.x' into mc-1.18.x 2021-12-14 20:13:53 +00:00
Jonathan Coates
82a7edee12 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-12-14 20:07:48 +00:00
Jonathan Coates
7c373c6e06 Merge branch 'mc-1.17.x' into mc-1.18.x 2021-12-11 07:50:18 +00:00
Jonathan Coates
6196aae488 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-12-11 07:49:33 +00:00
Jonathan Coates
57c5d19f95 Update to Forge 1.18.1 2021-12-11 07:31:41 +00:00
Jonathan Coates
23c17075be save -> saveAdditional
Also add in a janky workabround for handleUpdateTag not being called.
Being an early porter is always fun :D:.
2021-12-02 09:20:06 +00:00
Jonathan Coates
87988a705b Exclude Jetbrains annotations from testModExtra
testModExtra must /strictly/ be the set of dependencies which are not
present in implementation - there can't be any duplicates.

Yes, it's stupid, but the whole lazyToken("minecraft_classpath") thing
wasn't really built with this in mind, so not much we can do :)
2021-12-01 20:40:46 +00:00
Jonathan Coates
179da1d8cf Update to MC 1.18
- Build fails right now due to module issues, so this won't be pushed
   to GitHub.
 - Monitors render transparently when loaded into the world. I don't
   think this is a 1.17 bug, so not sure what's going on here!
2021-11-30 22:48:38 +00:00
Jonathan Coates
92fd93c0e0 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-11-30 22:37:07 +00:00
Jonathan Coates
af966179ce Merge branch 'mc-1.16.x' into mc-1.17.x 2021-11-29 19:40:05 +00:00
Jonathan Coates
2418cfb87b More instanceof pattern matching 2021-11-28 15:58:30 +00:00
Jonathan Coates
095101831c Pin to an older ForgeGradle
This .25 is still borked I think
2021-11-27 09:34:20 +00:00
Jonathan Coates
7b7527ec80 Rewrite turtle upgrade registration to be more data driven (#967)
The feature nobody asked for, but we're getting anyway.

Old way to register a turtle/pocket computer upgrade:

    ComputerCraftAPI.registerTurtleUpgrade(new MyUpgrade(new ResourceLocation("my_mod", "my_upgrade")));

New way to register a turtle/pocket computer upgrade:

First, define a serialiser for your turtle upgrade type:

    static final DeferredRegister<TurtleUpgradeSerialiser<?>> SERIALISERS = DeferredRegister.create( TurtleUpgradeSerialiser.TYPE, "my_mod" );
    public static final RegistryObject<TurtleUpgradeSerialiser<MyUpgrade>> MY_UPGRADE =
        SERIALISERS.register( "my_upgrade", () -> TurtleUpgradeSerialiser.simple( MyUpgrade::new ) );
    SERIALISERS.register(bus); // Call in your mod constructor.

Now either create a JSON string or use a data generator to register your upgrades:

    class TurtleDataGenerator extends TurtleUpgradeDataProvider {
        @Override
        protected void addUpgrades( @Nonnull Consumer<Upgrade<TurtleUpgradeSerialiser<?>>> addUpgrade )
            simple(new ResourceLocation("my_mod", my_upgrade"), MY_UPGRADE.get()).add(addUpgrade);
        }
    }

See much better! In all seriousness, this does offer some benefits,
namely that it's now possible to overwrite or create upgrades via
datapacks.

Actual changes:
 - Remove ComputerCraftAPI.register{Turtle,Pocket}Upgrade functions.

 - Instead add {Turtle,Pocket}UpgradeSerialiser classes, which are used
   to load upgrades from JSON files in datapacks, and then read/write
   them to network packets (much like recipe serialisers).

 - The upgrade registries now subscribe to datapack reload events. They
   find all JSON files in the
   data/$mod_id/computercraft/{turtle,pocket}_upgrades directories,
   parse them, and then register them as upgrades.

   Once datapacks have fully reloaded, these upgrades are then sent over
   the network to the client.

 - Add data generators for turtle and pocket computer upgrades, to make
   the creation of JSON files a bit easier.

 - Port all of CC:T's upgrades over to use the new system.
2021-11-26 23:36:02 +00:00
Jonathan Coates
a4c5ecf8df Don't specify the version number in mods.toml 2021-11-25 14:54:32 +00:00
Jonathan Coates
99de00e16e Remove craft tweaker integration 2021-11-25 13:36:33 +00:00
Jonathan Coates
600227e481 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-11-25 13:34:19 +00:00
Jonathan Coates
cf3f1d3d48 Add correct tool to CC computers
Also rerun data generators, forgot to do it as part of the previous
commit.

Fixes #953
2021-11-03 09:40:30 +00:00
Jonathan Coates
bca964629a Merge branch 'mc-1.16.x' into mc-1.17.x 2021-11-03 09:34:21 +00:00
Jonathan Coates
0e94355a85 Some post-1.17 cleanup
- Fix broken Javadoc references
 - Apply a couple of refactoring suggestions from IDEA
2021-10-13 17:46:29 +01:00
Jonathan Coates
0d35331b82 Default to Java 16 in the gitpod environment 2021-10-06 18:52:36 +01:00
Jonathan Coates
076b454c8f Also convert the turtle model key to a record 2021-10-06 18:40:33 +01:00
Jonathan Coates
36e0dcbad0 Change network packet to a record
Look at all that code we can delete!
2021-10-06 18:38:51 +01:00
Jonathan Coates
0b5fe990e5 Bump Forge version
- Clean up NBT constants, replace with built-in ones
 - Switch over to the new capability system
2021-10-06 18:28:28 +01:00
Jonathan Coates
29ece2a6e3 Don't run client tests on CI
Kinda sucks, but they're so inconsistent between platforms right now,
and I cannot be bothered to get CI working. It only needs to work on my
machine.
2021-10-06 18:23:38 +01:00
Jonathan Coates
eba26dedab Merge branch 'mc-1.16.x' into mc-1.17.x 2021-10-06 18:10:45 +01:00
Jonathan Coates
3eb601e554 Pass lightmap variables around various renderers
- Add lightmap parameters to the text, computer and printout renderers.

 - Printouts are always rendered using the current lightmap. When
   interacting with the GUI, we use the fullbright lightmap coordinate.

 - Pocket computers render their border using the lightmap. Terminal and
   light do not use the lightmap at all.

There's some funkiness going on here with render types - it appears the
"correct" position_color_tex_lightmap render type is actually one used
for text.

Fixes #919. This bug does occur on 1.16 too, but given how complex the
rendering changes are between 1.16 and 1.17 I do /not/ want to have to
implement this twice. Sorry.
2021-09-19 15:49:31 +01:00
Jonathan Coates
d0e79f310e Bump Forge version
Not much has changed, just some cleanup.
2021-09-19 11:57:37 +01:00
Jonathan Coates
0d6528aaf0 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-09-19 11:38:25 +01:00
Jonathan Coates
b447b0e308 Increase memory limit of the gradle daemon
This has been standard in the mdk for a while, but never actually had to
do this before. IntelliJ finally started hitting this limit when
decompiling.
2021-09-18 12:42:36 +01:00
Jonathan Coates
b2273c9b29 Add back JEI integration 2021-08-29 22:20:06 +01:00
Jonathan Coates
bbf3e48763 Increase timeout of some more tests 2021-08-22 18:01:06 +01:00
Jonathan Coates
92fe1d4bc2 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-08-22 17:50:33 +01:00
Jonathan Coates
4d591c600c Use clearRemoved rather than onLoad
Latter is broken on Forge right now.
2021-08-20 21:48:34 +01:00
Jonathan Coates
0a8e427c61 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-08-20 21:47:55 +01:00
Jonathan Coates
0a537eaeee Rewrite some in-hand rendering code
- Fix missing shader for printout render type
 - Use current buffer provider for pocket computers rather than the
   tesselator. This requires us to use a non-depth-writing terminal +
   depth blocker, as otherwise one gets z-fighting.
 - Thus refactor some of the shaders to be terminal wide, not just for
   monitors.

Fixes #894
2021-08-17 13:00:52 +01:00
Jonathan Coates
aa857c1be3 Start using Java's instanceof pattern matching
Well, not really pattern matching, but it's still an improvement!
2021-08-08 12:45:30 +01:00
Jonathan Coates
e4ced551eb Remove most of the turtle events
I don't think anybody actually used these, and I'm not convinced they
had much value anyway.

It might be worth switching the refueling code to work as a registry
instead, though events are kinda nice.
2021-08-08 12:43:03 +01:00
Jonathan Coates
6eec9ba1a3 Merge branch 'mc-1.16.x' into mc-1.17.x 2021-08-08 12:40:00 +01:00
Jonathan Coates
a8f675c59d Make current branch detection more robust 2021-08-06 18:04:05 +01:00
Jonathan Coates
bb1ebaee4f Bump Forge and prepare for a release
I've been shown up[1]. Unacceptable!

[1]: https://twitter.com/SangarWasTaken/status/1423676992336060417
2021-08-06 17:25:34 +01:00
Jonathan Coates
bb1183d274 Update to Minecraft 1.17.1
- Remap everything to use MojMap class names too. This is what Forge
   uses, so \o/.

   This does NOT currently rename any classes to use suffix notation or
   BlockEntity. That will come in a later change. We do however rename
   references of "World" to "Level".

 - Move the test mod into a separate "cctest" source set. As Forge now
   works using Jigsaw we cannot have multiple mods defining the same
   package, which causes problems with our JUnit test classes.

 - Remove our custom test framework and replace it with vanilla's (this
   is no longer stripped from the jar). RIP kotlin coroutines.

   It's still worth using Kotlin here though, just for extension
   methods.

 - Other 1.17-related changes:
    - Use separate tile/block entity tick methods for server and client
      side, often avoiding ticking at all on the client.

    - Switch much of the monitor rendering code to use vanilla's
      built-in shader system. It's still an incredibly ugly hack, so not
      really expecting this to work with any rendering mods, but we'll
      cross that bridge when we come to it.
2021-08-06 17:18:09 +01:00
498 changed files with 9131 additions and 18400 deletions

View File

@@ -31,7 +31,7 @@ version = mod_version
group = "org.squiddev"
archivesBaseName = "cc-tweaked-${mc_version}"
def javaVersion = JavaLanguageVersion.of(8)
def javaVersion = JavaLanguageVersion.of(17)
java {
toolchain {
languageVersion = javaVersion
@@ -58,6 +58,10 @@ sourceSets {
minecraft {
runs {
all {
lazyToken('minecraft_classpath') {
configurations.shade.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
}
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
@@ -93,21 +97,33 @@ minecraft {
source sourceSets.testMod
}
}
lazyToken('minecraft_classpath') {
(configurations.shade.copyRecursive().resolve() + configurations.testModExtra.copyRecursive().resolve())
.collect { it.absolutePath }
.join(File.pathSeparator)
}
}
testServer {
gameTestServer {
workingDirectory project.file('test-files/server')
parent runs.server
mods {
cctest {
source sourceSets.testMod
}
}
lazyToken('minecraft_classpath') {
(configurations.shade.copyRecursive().resolve() + configurations.testModExtra.copyRecursive().resolve())
.collect { it.absolutePath }
.join(File.pathSeparator)
}
}
}
mappings channel: 'parchment', version: "${mapping_version}-${mc_version}"
// mappings channel: 'parchment', version: "${mapping_version}-${mc_version}"
mappings channel: 'official', version: mc_version
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
@@ -128,35 +144,37 @@ repositories {
configurations {
shade
implementation.extendsFrom shade
cctJavadoc
testModExtra
testModImplementation.extendsFrom(testModExtra)
testModImplementation.extendsFrom(implementation)
testModImplementation.extendsFrom(testImplementation)
}
dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:8.25"
checkstyle "com.puppycrawl.tools:checkstyle:8.45"
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104:api")
compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:7.1.0.313")
compileOnly fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0")
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104")
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")
shade 'org.squiddev:Cobalt:0.5.5'
shade 'io.netty:netty-codec-http:4.1.76.Final'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0'
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
testModImplementation sourceSets.main.output
testModExtra('org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0') {
exclude group: "org.jetbrains", module: "annotations"
}
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.6'
}
@@ -184,7 +202,7 @@ task luaJavadoc(type: Javadoc) {
options.noTimestamp = false
javadocTool = javaToolchains.javadocToolFor {
languageVersion = JavaLanguageVersion.of(11)
languageVersion = javaVersion
}
}
@@ -197,14 +215,19 @@ jar {
"Implementation-Title" : "CC: Tweaked",
"Implementation-Version" : "${mod_version}",
"Implementation-Vendor" : "SquidDev",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
,
"MixinConfigs" : "computercraft.mixins.json",
])
}
duplicatesStrategy(DuplicatesStrategy.WARN)
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}
jar.finalizedBy('reobfJar')
[compileJava, compileTestJava, compileTestModJava].forEach {
it.configure {
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
@@ -212,9 +235,6 @@ jar {
}
processResources {
inputs.property "version", mod_version
inputs.property "mcversion", mc_version
def hash = 'none'
Set<String> contributors = []
try {
@@ -254,16 +274,14 @@ processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
include 'data/computercraft/lua/rom/help/credits.txt'
expand 'version': mod_version,
'mcversion': mc_version,
'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
expand(
'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
)
}
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
exclude 'data/computercraft/lua/rom/help/credits.txt'
}
}
@@ -277,6 +295,7 @@ sourcesJar {
import com.hierynomus.gradle.license.tasks.LicenseCheck
import com.hierynomus.gradle.license.tasks.LicenseFormat
import com.modrinth.minotaur.TaskModrinthUpload
import org.apache.tools.ant.taskdefs.condition.Os
List<String> mkCommand(String command) {
@@ -401,69 +420,49 @@ task licenseFormatAPI(type: LicenseFormat)
}
}
task setupServer(type: Copy) {
group "test server"
description "Sets up the environment for the test server."
tasks.register("testServer", JavaExec.class).configure {
it.group('In-game tests')
it.description("Runs tests on a temporary Minecraft instance.")
it.dependsOn("prepareRunGameTestServer", "cleanTestServer", 'compileTestModJava')
from("src/testMod/server-files") {
include "eula.txt"
include "server.properties"
}
into "test-files/server"
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
// isn't created until the task is configured (which is no good for us).
JavaExec exec = tasks.getByName("runGameTestServer")
exec.copyTo(it)
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("test$name", JavaExec.class).configure {
it.group('In-game tests')
it.description("Runs tests on a temporary Minecraft instance.")
it.dependsOn(setupServer, "prepareRunTest$name", "cleanTest$name", 'compileTestModJava')
tasks.register("jacocoTestServerReport", JacocoReport.class).configure {
it.group('In-game')
it.description("Generate coverage reports for testServer")
it.dependsOn("testServer")
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
// isn't created until the task is configured (which is no good for us).
JavaExec exec = tasks.getByName("runTest$name")
exec.copyTo(it)
it.setClasspath(exec.getClasspath())
it.mainClass = exec.mainClass
it.setArgs(exec.getArgs())
it.executionData(new File(buildDir, "jacoco/testServer.exec"))
it.sourceDirectories.from(sourceSets.main.allJava.srcDirs)
it.classDirectories.from(new File(buildDir, "jacocoClassDump/testServer"))
it.systemProperty('forge.logging.console.level', 'info')
it.systemProperty('cctest.run', '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")
it.reports {
xml.enabled true
html.enabled true
}
}
check.dependsOn("jacocoTestServerReport")
// Upload tasks
@@ -507,18 +506,19 @@ task checkRelease {
}
check.dependsOn checkRelease
def isStable = true
curseforge {
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
project {
id = '282001'
releaseType = 'release'
releaseType = isStable ? 'release' : 'alpha'
changelog = "Release notes can be found on the GitHub repository (https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
addGameVersion "${mc_version}"
}
}
import com.modrinth.minotaur.TaskModrinthUpload
tasks.register('publishModrinth', TaskModrinthUpload.class).configure {
dependsOn('assemble', 'reobfJar')
onlyIf {
@@ -529,6 +529,7 @@ tasks.register('publishModrinth', TaskModrinthUpload.class).configure {
projectId = 'gu7yAYhd'
versionNumber = "${project.mc_version}-${project.mod_version}"
uploadFile = jar
versionType = isStable ? 'RELEASE' : 'ALPHA'
addGameVersion(project.mc_version)
changelog = "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
addLoader('forge')
@@ -589,12 +590,17 @@ githubRelease {
owner 'cc-tweaked'
repo 'CC-Tweaked'
targetCommitish.set(project.provider({
try {
return ["git", "-C", projectDir, "rev-parse", "--abbrev-ref", "HEAD"].execute().text.trim()
} catch (Exception e) {
e.printStackTrace()
def cmd = ["git", "rev-parse", "--abbrev-ref", "HEAD"]
println(cmd)
def proc = cmd.execute([], projectDir)
if (proc.waitFor() != 0) {
println(proc.err.text.trim())
throw new IllegalStateException("Executed with a non-0 exit code (${proc.exitValue()}).")
}
return "master"
def branch = proc.text.trim()
if (branch == "") throw new IllegalStateException("Cannot determine branch")
return branch
}))
tagName "v${mc_version}-${mod_version}"
@@ -605,7 +611,7 @@ githubRelease {
.takeWhile { it != 'Type "help changelog" to see the full version history.' }
.join("\n").trim()
}))
prerelease false
prerelease !isStable
}
def uploadTasks = ["publish", "curseforge", "publishModrinth", "githubRelease"]

View File

@@ -58,13 +58,20 @@
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="UnnecessaryParentheses" />
<module name="UnnecessaryParentheses">
<!-- Default minus LAND. -->
<property name="tokens" value="EXPR,IDENT,NUM_DOUBLE,NUM_FLOAT,NUM_INT,NUM_LONG,STRING_LITERAL,LITERAL_NULL,LITERAL_FALSE,LITERAL_TRUE,ASSIGN,BAND_ASSIGN,BOR_ASSIGN,BSR_ASSIGN,BXOR_ASSIGN,DIV_ASSIGN,MINUS_ASSIGN,MOD_ASSIGN,PLUS_ASSIGN,SL_ASSIGN,SR_ASSIGN,STAR_ASSIGN,LAMBDA,TEXT_BLOCK_LITERAL_BEGIN,LITERAL_INSTANCEOF,GT,LT,GE,LE,EQUAL,NOT_EQUAL,UNARY_MINUS,UNARY_PLUS,INC,DEC,LNOT,BNOT,POST_INC,POST_DEC" />
</module>
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
<module name="UnnecessarySemicolonInTryWithResources" />
<module name="UnnecessarySemicolonInEnumeration" />
<!-- Imports -->
<module name="CustomImportOrder" />
<module name="CustomImportOrder">
<property name="customImportOrderRules"
value="THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"
/>
</module>
<module name="IllegalImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />
@@ -156,6 +163,7 @@
<property name="allowEmptyLambdas" value="true" />
<property name="allowEmptyMethods" value="true" />
<property name="allowEmptyConstructors" value="true" />
<property name="allowEmptyTypes" value="true" />
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_RETURN,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND" />
</module>

View File

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

View File

@@ -1,8 +1,10 @@
org.gradle.jvmargs=-Xmx3G
# Mod properties
mod_version=1.100.6
# Minecraft properties (update mods.toml when changing)
mc_version=1.16.5
mapping_version=2021.08.08
forge_version=36.2.34
mc_version=1.19
mapping_version=2022.03.13
forge_version=41.0.16
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,7 +3,8 @@
"pools": [
{
"name": "cable",
"rolls": 1,
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
@@ -25,7 +26,8 @@
},
{
"name": "wired_modem",
"rolls": 1,
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,31 +16,30 @@ import dan200.computercraft.api.network.IPacketNetwork;
import dan200.computercraft.api.network.wired.IWiredElement;
import dan200.computercraft.api.network.wired.IWiredNode;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.core.apis.ApiFactories;
import dan200.computercraft.core.asm.GenericMethod;
import dan200.computercraft.core.filesystem.FileMount;
import dan200.computercraft.core.filesystem.ResourceMount;
import dan200.computercraft.shared.*;
import dan200.computercraft.shared.BundledRedstone;
import dan200.computercraft.shared.MediaProviders;
import dan200.computercraft.shared.Peripherals;
import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider;
import dan200.computercraft.shared.peripheral.generic.data.DetailProviders;
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
import dan200.computercraft.shared.util.IDAssigner;
import dan200.computercraft.shared.wired.WiredNode;
import net.minecraft.resources.IReloadableResourceManager;
import net.minecraft.resources.IResourceManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import net.minecraftforge.server.ServerLifecycleHooks;
import javax.annotation.Nonnull;
import java.io.File;
@@ -61,10 +60,12 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
public static InputStream getResourceFile( String domain, String subPath )
{
IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
var manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
var resource = manager.getResource( new ResourceLocation( domain, subPath ) ).orElse( null );
if( resource == null ) return null;
try
{
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
return resource.open();
}
catch( IOException ignored )
{
@@ -83,13 +84,13 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
}
@Override
public int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
public int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath )
{
return IDAssigner.getNextId( parentSubPath );
}
@Override
public IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
public IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity )
{
try
{
@@ -104,7 +105,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
@Override
public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
{
IResourceManager manager = ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
ResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
ResourceMount mount = ResourceMount.get( domain, subPath, manager );
return mount.exists( "" ) ? mount : null;
}
@@ -127,12 +128,6 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
GenericPeripheralProvider.addCapability( capability );
}
@Override
public void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
{
TurtleUpgrades.register( upgrade );
}
@Override
public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider )
{
@@ -140,7 +135,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
}
@Override
public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
public int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side )
{
return BundledRedstone.getDefaultOutput( world, pos, side );
}
@@ -151,12 +146,6 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
MediaProviders.register( provider );
}
@Override
public void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
{
PocketUpgrades.register( upgrade );
}
@Nonnull
@Override
public IPacketNetwork getWirelessNetwork()
@@ -185,9 +174,9 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
@Nonnull
@Override
public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side )
public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side )
{
TileEntity tile = world.getBlockEntity( pos );
BlockEntity tile = world.getBlockEntity( pos );
return tile == null ? LazyOptional.empty() : tile.getCapability( CAPABILITY_WIRED_ELEMENT, side );
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,61 +5,31 @@
*/
package dan200.computercraft.api.detail;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* A reference to a block in the world, used by block detail providers.
*
* @param level The level the block exists in.
* @param pos The position of the block.
* @param state The block state at this position.
* @param blockEntity The block entity at this position, if it exists.
*/
public class BlockReference
public record BlockReference(
@Nonnull Level level,
@Nonnull BlockPos pos,
@Nonnull BlockState state,
@Nullable BlockEntity blockEntity
)
{
private final World world;
private final BlockPos pos;
private final BlockState state;
private final TileEntity blockEntity;
public BlockReference( World world, BlockPos pos )
public BlockReference( Level level, BlockPos pos )
{
this.world = world;
this.pos = pos;
this.state = world.getBlockState( pos );
this.blockEntity = world.getBlockEntity( pos );
}
public BlockReference( World world, BlockPos pos, BlockState state, TileEntity blockEntity )
{
this.world = world;
this.pos = pos;
this.state = state;
this.blockEntity = blockEntity;
}
@Nonnull
public World getWorld()
{
return world;
}
@Nonnull
public BlockPos getPos()
{
return pos;
}
@Nonnull
public BlockState getState()
{
return state;
}
@Nullable
public TileEntity getBlockEntity()
{
return blockEntity;
this( level, pos, level.getBlockState( pos ), level.getBlockEntity( pos ) );
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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