diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml new file mode 100644 index 000000000..f8b36ff7d --- /dev/null +++ b/.github/workflows/build-and-publish.yaml @@ -0,0 +1,64 @@ +name: Build and Test + +on: + workflow_dispatch: + push: + pull_request: + types: + - opened + - synchronize + +jobs: + generate-artifact-name: + runs-on: self-hosted + outputs: + name: ${{ steps.name.outputs.name }} + steps: + - name: Generate Name + id: name + run: | + if [[ "${{ github.event_name }}" == 'pull_request' ]]; then + suffix="PR ${{ github.event.number }}" + else + ref="${{ github.ref }}" + ref="${ref#refs/heads/}" + suffix="${ref//\//-}" + fi + name="AdvancedPeripherals $suffix" + echo "name: $name" + echo "name=$name" >> "$GITHUB_OUTPUT" + + build-and-test: + needs: + - generate-artifact-name + uses: IntelligenceModding/actions/.github/workflows/build-and-test.yaml@master + with: + build_name: ${{ needs.generate-artifact-name.outputs.name }} + pr: ${{ github.event_name == 'pull_request' && github.event.number || '' }} + check: ${{ github.event_name != 'push' }} + + publish: + if: ${{ github.event_name == 'push' && contains(github.ref, 'release/') }} + runs-on: self-hosted + needs: + - build-and-test + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Download Builds + uses: actions/download-artifact@v4 + with: + name: ${{ needs.build-and-test.outputs.artifact-name }} + path: build/libs + - name: Patch Changelog + run: ./gradlew patchChangelog + - name: Github Release + run: ./gradlew githubRelease + - name: Publish Maven + run: ./gradlew publishAllPublicationsToPublicRepository + - name: Publish Modrinth + run: ./gradlew modrinth + - name: Publish CurseForge + run: ./gradlew publishCurseForge diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml deleted file mode 100644 index 3e33d0adf..000000000 --- a/.github/workflows/build-and-test.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: Build and Test - -on: - workflow_dispatch: - push: - pull_request: - types: - - opened - - synchronize - -jobs: - build-and-test: - uses: IntelligenceModding/actions/.github/workflows/build-and-test.yaml@master diff --git a/.github/workflows/pr-comment-artifacts.yaml b/.github/workflows/pr-comment-artifacts.yaml new file mode 100644 index 000000000..8f5b3360a --- /dev/null +++ b/.github/workflows/pr-comment-artifacts.yaml @@ -0,0 +1,124 @@ +# /~https://github.com/orgs/community/discussions/51403 + +name: Comment Artifacts + +on: + workflow_run: + types: + - "completed" + workflows: + - "Build and Test" + +permissions: + actions: read + attestations: read + contents: read + pull-requests: write + +jobs: + parse-metadata: + runs-on: ubuntu-latest + outputs: + PR_NUMBER: ${{ steps.metadata.outputs.PR_NUMBER }} + HEAD_SHA: ${{ steps.metadata.outputs.HEAD_SHA }} + ARTIFACT_ID: ${{ steps.metadata.outputs.ARTIFACT_ID }} + ARTIFACT_URL: ${{ steps.metadata.outputs.ARTIFACT_URL }} + ARTIFACT_EXP: ${{ steps.metadata.outputs.ARTIFACT_EXP }} + ARTIFACT_NAME: ${{ steps.metadata.outputs.ARTIFACT_NAME }} + steps: + - name: Get Artifact URL & PR Info + id: metadata + env: + GITHUB_TOKEN: ${{ github.token }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }} + PREVIOUS_JOB_ID: ${{ github.event.workflow_run.id }} + run: | + echo "Previous Job ID: $PREVIOUS_JOB_ID" + + LOG_URL="/repos/$OWNER/$REPO/actions/runs/$PREVIOUS_JOB_ID/logs" + echo "Getting previous logs: $LOG_URL" + gh api "$LOG_URL" >_logs.zip + echo "Unzipping logs" + unzip -p _logs.zip >_build.txt + + echo "Parsing logs" + function parse_var { + name=$1 + echo "Parsing output $name" + line=$(cat _build.txt | grep -m 1 "output:${name}=" | cat) + export parsed=${line#*"output:${name}="} + } + parse_var PR_NUMBER + PR_NUMBER=$parsed + echo "PR Number: $PR_NUMBER" + echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_OUTPUT" + + parse_var HEAD_SHA + HEAD_SHA=$parsed + echo "Head sha: $HEAD_SHA" + echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_OUTPUT" + + parse_var ARTIFACT_ID + ARTIFACT_ID=$parsed + echo "ARTIFACT ID: $ARTIFACT_ID" + echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_OUTPUT" + + parse_var ARTIFACT_URL + ARTIFACT_URL=$parsed + echo "ARTIFACT URL: $ARTIFACT_URL" + echo "ARTIFACT_URL=$ARTIFACT_URL" >> "$GITHUB_OUTPUT" + + if [[ "$ARTIFACT_ID" != "" ]]; then + ARTIFACT_INFO="$(gh api "/repos/$OWNER/$REPO/actions/artifacts/$ARTIFACT_ID")" + ARTIFACT_EXP=$(echo "$ARTIFACT_INFO" | jq -r ".expires_at") + echo "ARTIFACT EXP: $ARTIFACT_EXP" + echo "ARTIFACT_EXP=$ARTIFACT_EXP" >> "$GITHUB_OUTPUT" + ARTIFACT_NAME=$(echo "$ARTIFACT_INFO" | jq -r ".name") + echo "ARTIFACT NAME: $ARTIFACT_NAME" + echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" + fi + exit 0 + + comment-success: + if: ${{ needs.parse-metadata.outputs.PR_NUMBER != '' }} + runs-on: ubuntu-latest + needs: + - parse-metadata + steps: + - name: Find Comment + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ needs.parse-metadata.outputs.PR_NUMBER }} + comment-author: 'github-actions[bot]' + body-includes: '## Build Preview' + + - name: Update Comment + env: + JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}" + HEAD_SHA: ${{ needs.parse-metadata.outputs.HEAD_SHA }} + ARTIFACT_URL: ${{ needs.parse-metadata.outputs.ARTIFACT_URL }} + ARTIFACT_EXP: ${{ needs.parse-metadata.outputs.ARTIFACT_EXP }} + ARTIFACT_NAME: ${{ needs.parse-metadata.outputs.ARTIFACT_NAME }} + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ needs.parse-metadata.outputs.PR_NUMBER }} + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace + body: |- + ## Build Preview + + [![badge]](${{ env.JOB_PATH }}) + + You can find files attached to the below linked Workflow Run URL (Logs). + + | Name | Link | + |-----------|-------------------------| + | Commit | ${{ env.HEAD_SHA }} | + | Logs | ${{ env.JOB_PATH }} | + ${{ env.ARTIFACT_URL && format('| Jar Files | [{0}]({1}) |', env.ARTIFACT_NAME, env.ARTIFACT_URL) || '' }} + ${{ env.ARTIFACT_EXP && format('| Expires At | {0} |', env.ARTIFACT_EXP) || '' }} + + [badge]: https://img.shields.io/badge/${{ format('{0}-{1}', github.event.workflow_run.conclusion, github.event.workflow_run.conclusion == 'success' && '3fb950' || 'f85149') }}?style=for-the-badge&logo=github&label=build diff --git a/CHANGELOG.md b/CHANGELOG.md index 53c786e9b..1605d5130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## First official Advanced Peripherals 1.21.1 alpha release to the whole public. Please report any bug to github! + +### Added +- Added our new textures! + +### Fixed +- Fixed that several item export and import related functions would not work with blocks from other mods +- Fixed that functions with cooldowns which are used for the first time would throw an error + +## [1.21.1-0.7.44a] - 2025-01-14 + +### Added +- Colony Integrator back to 1.21.1 + +### Fixed +- Villager & Wandering trader pocket and turtle trades +- ME Bridges `getUsedItemStorage` and `getUsedFluidStorage` + +## [1.21.1-0.7.43a] - 2025-01-13 + +Alpha 1.21.1 release +The only thing that's missing is the colony integrator - we will add that soon. +Please report any bugs to github! + ## [1.20.4-0.7.43a] - 2024-12-27 First official Advanced Peripherals 1.20.4 alpha release. Please report any bug to github! diff --git a/build.gradle b/build.gradle index 93eb8695c..60cd4ec88 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,22 @@ import net.darkhax.curseforgegradle.TaskPublishCurseForge import java.text.SimpleDateFormat -import net.neoforged.gradle.dsl.common.runs.run.Run plugins { id "maven-publish" id 'net.darkhax.curseforgegradle' version '1.1.16' id 'org.jetbrains.changelog' version '1.2.1' id "com.modrinth.minotaur" version "2.+" - id 'net.neoforged.gradle.userdev' version '7.0.145' + id 'net.neoforged.moddev' version '2.+' id "com.github.breadmoirai.github-release" version "2.5.2" id 'checkstyle' id 'java' + id 'idea' } java { toolchain { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(21) } withSourcesJar() } @@ -28,7 +28,7 @@ wrapper { def isSnapshotVersion = project.hasProperty('teamcityBuild') -version = "${mod_version}" + (isSnapshotVersion ? "-SNAPSHOT" : "") +version = "${mod_version}" + (isSnapshotVersion ? "-SNAPSHOT" : "") + "${mod_artifact_suffix}" group = 'de.srendi.advancedperipherals' def static getenv(path = ".env") { @@ -56,32 +56,57 @@ def githubKey = secretEnv["GITHUB_KEY"] ?: System.getenv("GITHUB_KEY") // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } -minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') -runs { - // applies to all the run configs below - configureEach { - systemProperty 'forge.logging.markers', 'REGISTRIES' +neoForge { + // Specify the version of NeoForge to use. + version = project.neo_version - systemProperty 'forge.logging.console.level', 'debug' - - modSource project.sourceSets.main + parchment { + mappingsVersion = project.parchment_mappings_version + minecraftVersion = project.parchment_minecraft_version } - client { run -> setupClientAcc(run) } + validateAccessTransformers = true - server { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - } + runs { + // applies to all the run configs below + configureEach { + systemProperty 'forge.logging.markers', 'REGISTRIES' + + logLevel = org.slf4j.event.Level.DEBUG + } + + client { + client() + + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } + + server { + server() + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } + + gameTestServer { + type = "gameTestServer" + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } + + data { + data() + + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + } - gameTestServer { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id } - data { - programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + mods { + "${mod_id}" { + sourceSet(sourceSets.main) + } } } + repositories { mavenCentral() maven { @@ -94,7 +119,7 @@ repositories { } maven { name = "Squiddev maven cct" - url = 'https://squiddev.cc/maven/' + url = 'https://maven.squiddev.cc' content { includeGroup("cc.tweaked") includeModule("org.squiddev", "Cobalt") @@ -176,7 +201,6 @@ configurations { testModImplementation.extendsFrom(implementation) testModImplementation.extendsFrom(testImplementation) runtimeClasspath.extendsFrom localRuntime - } dependencies { @@ -193,64 +217,38 @@ dependencies { // Extended requirements // We don't use the api since we need a specific class from mekanism compileOnly "mekanism:Mekanism:${mekanism_version}" - runtimeOnly "mekanism:Mekanism:${mekanism_version}" + //runtimeOnly "mekanism:Mekanism:${mekanism_version}" // Applied Energistics 2 - runtimeOnly "appeng:appliedenergistics2-neoforge:${appliedenergistics_version}" - compileOnly "appeng:appliedenergistics2-neoforge:${appliedenergistics_version}" + runtimeOnly "appeng:appliedenergistics2:${appliedenergistics_version}" + compileOnly "appeng:appliedenergistics2:${appliedenergistics_version}" // Applied Mekanistics - runtimeOnly "curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}" + //runtimeOnly "curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}" compileOnly "curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}" - // Curios - runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}" - compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api" - - // Refined Storage - compileOnly "curse.maven:refined-storage-243076:${refinedstorage_version}" - runtimeOnly "curse.maven:refined-storage-243076:${refinedstorage_version}" - // AE2 Things - //compileOnly "curse.maven:ae2things-609977:${ae2things_version}-sources" + compileOnly "curse.maven:ae2things-609977:${ae2things_version}-sources" //runtimeOnly "curse.maven:ae2things-609977:${ae2things_version}-sources" - // AE2 Additions - //compileOnly "curse.maven:ae-additions-493962:${ae2additions_version}" - //runtimeOnly "curse.maven:ae-additions-493962:${ae2additions_version}" - - //implementation "thedarkcolour:kotlinforforge:${kotlinforforge_version}" - - // Botania - //compileOnly "vazkii.botania:Botania:${botania_version}" - //runtimeOnly "vazkii.botania:Botania:${botania_version}" - // Minecolonies // Remove/Comment this section if you want to use runData. - //runtimeOnly "com.ldtteam:minecolonies:${minecolonies_version}" - //runtimeOnly "com.ldtteam:structurize:${structurize_version}" - //runtimeOnly "com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal" - //runtimeOnly "com.ldtteam:blockui:${blockui_version}" + runtimeOnly "com.ldtteam:minecolonies:${minecolonies_version}" + runtimeOnly "com.ldtteam:structurize:${structurize_version}" + runtimeOnly "com.ldtteam:domum-ornamentum:${domumornamentum_version}" + runtimeOnly "com.ldtteam:blockui:${blockui_version}" - //compileOnly "com.ldtteam:minecolonies:${minecolonies_version}" - //compileOnly "com.ldtteam:structurize:${structurize_version}" - //compileOnly "com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal" - //compileOnly "com.ldtteam:blockui:${blockui_version}" + compileOnly "com.ldtteam:minecolonies:${minecolonies_version}" + compileOnly "com.ldtteam:structurize:${structurize_version}" + compileOnly "com.ldtteam:domum-ornamentum:${domumornamentum_version}" + compileOnly "com.ldtteam:blockui:${blockui_version}" //Patchouli - //runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}-FORGE" - - // Create - //compileOnly "com.simibubi.create:create-1.20.1:${create_version}:all" - //runtimeOnly "com.simibubi.create:create-1.20.1:${create_version}:all" + //runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}-NEOFORGE" + compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}-NEOFORGE" //Powah - implementation "curse.maven:powah-633483:${powah_version}" - implementation "me.shedaniel.cloth:cloth-config-forge:11.1.106" - implementation "dev.architectury:architectury-forge:9.1.10" - - //Removed until fully ported - //testImplementation "site.siredvin.ttoolkit:ttoolkit-${minecraft_version}:${ttoolkit_version}" + //implementation "curse.maven:powah-633483:${powah_version}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}" testImplementation "org.junit.jupiter:junit-jupiter-params:${junit_version}" @@ -263,10 +261,6 @@ dependencies { // Testing stuff // JEI implementation "mezz.jei:jei-${jei_version}" - - // Create Crafts & Additions - //compileOnly "curse.maven:createaddition-439890:${createadditions_version}" - //runtimeOnly "curse.maven:createaddition-439890:${createadditions_version}" } @@ -321,19 +315,16 @@ tasks.withType(ProcessResources).configureEach { mod_id : mod_id, version : version, cc_version : cc_version, - curios_version : curios_version, minecolonies_version : minecolonies_version, appliedenergistics_version: appliedenergistics_version, patchouli_version : patchouli_version, - refinedstorage_version : refinedstorage_version, - botania_version : botania_version, mekanism_version : mekanism_version, ae2things_version : ae2things_version, powah_version : powah_version,] inputs.properties replaceProperties - filesMatching(['META-INF/mods.toml']) { + filesMatching(['META-INF/neoforge.mods.toml']) { expand replaceProperties } } @@ -413,37 +404,13 @@ modrinth { } } -// Stolen from mekanism -static void setupClientAcc(Run run) { - //The below if statements are to add args to your gradle.properties file in user home - // (DO NOT add them directly to the gradle.properties file for this project) - // Setting the below properties allows use of your normal Minecraft account in the - // dev environment including having your skin load. Each property also has a comment - // explaining what information to set the value to/format it expects - // One thing to note is because of the caching that goes on, after changing these - // variables, you need to refresh the project and rerun genIntellijRuns/genEclipseRuns - if (run.project.hasProperty('mc_uuid')) { - //Your uuid without any dashes in the middle - run.programArguments('--uuid', (String) run.project.property('mc_uuid')) - } - if (run.project.hasProperty('mc_username')) { - //Your username/display name, this is the name that shows up in chat - // Note: This is not your email, even if you have a Mojang account - run.programArguments('--username', (String) run.project.property('mc_username')) - } - if (run.project.hasProperty('mc_accessToken')) { - //Your access token, you can find it in your '.minecraft/launcher_accounts.json' file - run.programArguments('--accessToken', (String) run.project.property('mc_accessToken')) - } -} - publishing { publications { PublicationContainer publicationContainer -> publicationContainer.register("maven", MavenPublication) { MavenPublication publication -> publication.from((SoftwareComponent) components.java) publication.groupId = project.group publication.version = isSnapshotVersion ? "${minecraft_version}-${version}-${project.teamcityBuild}" : "${minecraft_version}-${version}" - publication.artifactId = isSnapshotVersion ? "advancedperipherals-snapshots" : "advancedperipherals" + publication.artifactId = isSnapshotVersion ? "advancedperipherals-snapshots" : "advancedperipherals" publication.artifacts = [jar, sourcesJar] publication.pom { name.set("AdvancedPeripherals") diff --git a/docs/RELEASE.md b/docs/RELEASE.md index 4f276d4e6..41bce4134 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -33,7 +33,9 @@ PUBLIC_REP_KEY= ### Release process - Execute `./gradlew patchChangelog` or manually update `CHANGELOG.md` and commit result to repository -- Run `git tag -` to create git tag and push it to repository via `git push --tags` +- ~~Run `git tag -` to create git tag and push it to repository via `git push --tags`~~ +- Upload project to github via `./gradlew githubRelease` - Upload project to curseforge via `./gradlew curseforge` - Upload project to modrinth via `./gradlew publishModrinth` +- Upload project to maven via `./gradlew publishAllPublicationsToPublicRepository` - Update `mod_version` to next patch or minor version, what you want diff --git a/gradle.properties b/gradle.properties index b23e2f3cc..6c14e9fb4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,13 +4,17 @@ org.gradle.logging.level=info # Minecraft related mod_id=advancedperipherals -minecraft_version=1.20.4 -neo_version=20.4.231 -loader_version=20 -mod_version=0.7.43a +# do not include mod_version/minecraft_version with equals sign anywhere else in the file (even in comments) +# also do not add space around the equal sign +# since we are using poor grep command to do automation :p +mod_version=0.7.45a +minecraft_version=1.21.1 +mod_artifact_suffix= +neo_version=21.1.93 +parchment_minecraft_version=1.21.1 +parchment_mappings_version=2024.11.17 +loader_version=4 release_type=alpha -neogradle.subsystems.parchment.minecraftVersion=1.20.4 -neogradle.subsystems.parchment.mappingsVersion=2024.04.14 jb_annotations=21.0.1 # Test dependencies @@ -21,29 +25,22 @@ kotlinx_coroutines_version=1.6.0-RC3 ttoolkit_version=0.1.3 # Mod dependencies -cc_version=1.110.2 -curios_version=7.4.3+1.20.4 -minecolonies_version=1.20.1-1.1.472-BETA -appliedenergistics_version=17.13.0-beta -patchouli_version=1.20.1-84 -refinedstorage_version=5165548 -botania_version=1.20.1-443-FORGE -create_version=0.5.1.f-27 -createca_version=5099757 -mekanism_version=1.20.4-10.5.20.41 -ae2things_version=4616683 +cc_version=1.114.2 +minecolonies_version=1.1.846-1.21.1-snapshot +appliedenergistics_version=19.1.2-beta +patchouli_version=1.21-87 +mekanism_version=1.21.1-10.7.8.70 +ae2things_version=5637783 powah_version=4638301 -ae2additions_version=5077081 -kotlinforforge_version=4.10.0 -appliedmekanistics_version=5294358 +appliedmekanistics_version=5978711 # Mod dependencies which are needed for other mods # For minecolonies -structurize_version=1.20.1-1.0.662-BETA -multipiston_version=1.20-1.2.30-ALPHA -blockui_version=1.20.1-0.0.101-ALPHA -domumornamentum_version=1.20-1.0.150-BETA +structurize_version=1.0.755-1.21.1-snapshot +multipiston_version=1.2.51-1.21.1-snapshot +blockui_version=1.0.192-1.21.1-snapshot +domumornamentum_version=1.0.204-1.21.1-snapshot # Mod dependencies for testing stuff(Only used in the dev environment) -jei_version=1.20.4-neoforge:17.3.1.5 +jei_version=1.21.1-neoforge:19.19.6.235 createadditions_version=5099752 \ No newline at end of file diff --git a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 new file mode 100644 index 000000000..cc7d898af --- /dev/null +++ b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 @@ -0,0 +1,18 @@ +// 1.21.1 2025-01-15T03:22:26.2758694 Registries +b672635324c0df354e587efc81d0b19a581eae2f data/advancedperipherals/computercraft/pocket_upgrade/chatty_pocket.json +30b8f663613c7ce77048fd69631afcc11a682276 data/advancedperipherals/computercraft/pocket_upgrade/colony_pocket.json +d4647159c2f2693a9c5e8d12bf740635751d29a8 data/advancedperipherals/computercraft/pocket_upgrade/environment_pocket.json +8216a0a7d8ebe3ae738c8fc3626df25eb0a2e07a data/advancedperipherals/computercraft/pocket_upgrade/geoscanner_pocket.json +a38aa83593f7ad0ace98e01bb3b5f06f272ef734 data/advancedperipherals/computercraft/pocket_upgrade/player_pocket.json +b8f19ae0fb5bb898facc08e3787e0f96c8211881 data/advancedperipherals/computercraft/turtle_upgrade/chatty_turtle.json +fe98c60e7d61139aacf2d0872873e610aac8a37b data/advancedperipherals/computercraft/turtle_upgrade/chunky_turtle.json +ae619da638ad89d7302d832d6c09e2c87401c539 data/advancedperipherals/computercraft/turtle_upgrade/compass_turtle.json +a25b955d6db4ad48d43255d48d05c7f3acd60ea3 data/advancedperipherals/computercraft/turtle_upgrade/end_automata.json +98d71a2e17f3d30bbb76c1ba2f94a1cd610c2cd2 data/advancedperipherals/computercraft/turtle_upgrade/environment_turtle.json +d16f77b8c8c50dfefd757439802a13568cdcd5ec data/advancedperipherals/computercraft/turtle_upgrade/geoscanner_turtle.json +522bb2a1afb9f2be97af7cf65cd9aa159d76d13a data/advancedperipherals/computercraft/turtle_upgrade/husbandry_automata.json +c9b2df2d4fed11f60a8e6f8da77b2fa53dd13572 data/advancedperipherals/computercraft/turtle_upgrade/overpowered_end_automata.json +42fc2b9a2601ef44d617cb18302c2c4fff31d282 data/advancedperipherals/computercraft/turtle_upgrade/overpowered_husbandry_automata.json +fa7743922ef6b4dd3e633f2857e4047d533f13b5 data/advancedperipherals/computercraft/turtle_upgrade/overpowered_weak_automata.json +4054c59ceb099f17c4555fd5f36b2f8b4109f624 data/advancedperipherals/computercraft/turtle_upgrade/player_turtle.json +c8059a2717cfac5b02898658c4d2d52fbd5710d4 data/advancedperipherals/computercraft/turtle_upgrade/weak_automata.json diff --git a/src/generated/resources/.cache/2db41954e490230d51b10affff25ee2ee27b8d5b b/src/generated/resources/.cache/2db41954e490230d51b10affff25ee2ee27b8d5b index 9d4678740..1109593e8 100644 --- a/src/generated/resources/.cache/2db41954e490230d51b10affff25ee2ee27b8d5b +++ b/src/generated/resources/.cache/2db41954e490230d51b10affff25ee2ee27b8d5b @@ -1,2 +1,2 @@ -// 1.20.4 2024-12-22T16:09:31.6895785 AP POI Type Tags +// 1.21.1 2025-01-13T17:28:09.7081276 AP POI Type Tags d3d6b837660a4e213f287ad9d11e12368b90cd8e data/minecraft/tags/point_of_interest_type/acquirable_job_site.json diff --git a/src/generated/resources/.cache/2f719b8031aed5e605ed8d6694b19245ca45c6ca b/src/generated/resources/.cache/2f719b8031aed5e605ed8d6694b19245ca45c6ca index a43e67e3f..f9b340e45 100644 --- a/src/generated/resources/.cache/2f719b8031aed5e605ed8d6694b19245ca45c6ca +++ b/src/generated/resources/.cache/2f719b8031aed5e605ed8d6694b19245ca45c6ca @@ -1,2 +1,2 @@ -// 1.20.4 2024-12-22T16:09:31.694585 Languages: en_us for mod: advancedperipherals -d669461c50102af6d4058086e2f12af8b0020157 assets/advancedperipherals/lang/en_us.json +// 1.21.1 2025-01-15T03:22:26.2798836 Languages: en_us for mod: advancedperipherals +df95afe714aeff7559b0093257aeca501dabb1e2 assets/advancedperipherals/lang/en_us.json diff --git a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index 6200b5c67..f4d319548 100644 --- a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,13 +1,13 @@ -// 1.20.4 2024-12-22T16:09:31.6905785 Loot Tables -fdf4d9f8220d3a5207f8e4334bff2f06cd203b04 data/advancedperipherals/loot_tables/blocks/block_reader.json -8c3dba853066f5f8da0a27b0783e68fc33e8bebc data/advancedperipherals/loot_tables/blocks/chat_box.json -765df45ccaef4e908a480da9cb6f13ab1b4d7545 data/advancedperipherals/loot_tables/blocks/energy_detector.json -9144fbb590a4c6e9cf7b8ef87fc80faf321c7e16 data/advancedperipherals/loot_tables/blocks/environment_detector.json -4e184ec10657d1dc11ee7da33f244b2e23d61460 data/advancedperipherals/loot_tables/blocks/geo_scanner.json -266e98d8eeec6ef465832cac664e5ab05bca96af data/advancedperipherals/loot_tables/blocks/inventory_manager.json -ee86218933f0da283ae1dd6617d74ed41a04575b data/advancedperipherals/loot_tables/blocks/me_bridge.json -6aec9d25423531f9236266e2535d6c4633129935 data/advancedperipherals/loot_tables/blocks/nbt_storage.json -e9ed113da52cddcce17768d0999d4f9aefb4cfa7 data/advancedperipherals/loot_tables/blocks/peripheral_casing.json -33c81013355b11d7c8630c811ddd80232d3c1c7c data/advancedperipherals/loot_tables/blocks/player_detector.json -e88dae55b3850e66ce81752eb060b1e0fe8f707e data/advancedperipherals/loot_tables/blocks/redstone_integrator.json -dfb4e28d40828f2ef96dc9bd7b2a67e40fcd0c78 data/advancedperipherals/loot_tables/blocks/rs_bridge.json +// 1.21.1 2025-01-14T18:51:29.8897473 Loot Tables +9b54955770745d55de988a86cbd08aa9ae23ff86 data/advancedperipherals/loot_table/blocks/block_reader.json +d4f1bc579f83dc67ce9f94d35926d34b8894c990 data/advancedperipherals/loot_table/blocks/chat_box.json +9ac96b8e3da827886d8da459a2f146e8ae3ee798 data/advancedperipherals/loot_table/blocks/colony_integrator.json +6da40a0a9d46855710272fe9d40bb5a7f0219ff2 data/advancedperipherals/loot_table/blocks/energy_detector.json +85cd3af52c824db96403e6fceea480bceda3a186 data/advancedperipherals/loot_table/blocks/environment_detector.json +7f607d7476252b89a57eb4c227cc69f4f28995e3 data/advancedperipherals/loot_table/blocks/geo_scanner.json +fddf157b52a210846f5737dcc39a16b7ab6a587a data/advancedperipherals/loot_table/blocks/inventory_manager.json +ae62bfa75e39a59374602c8a87cc2afe8b4923dd data/advancedperipherals/loot_table/blocks/me_bridge.json +51ceb7b82ba8424a2c6f03f280c14d1c2d0d18d7 data/advancedperipherals/loot_table/blocks/nbt_storage.json +fa56de9a073f32ab8a65b5f17c57f360a157b5c1 data/advancedperipherals/loot_table/blocks/peripheral_casing.json +d61b1c54dd6da8f0213d5eb8a5b40d78bff5ba90 data/advancedperipherals/loot_table/blocks/player_detector.json +6bad9bed7baa7af4b5ca3cae7c4cb8d47dc7b593 data/advancedperipherals/loot_table/blocks/redstone_integrator.json diff --git a/src/generated/resources/.cache/5a761efb7472ef97566e41e81451930a004134bf b/src/generated/resources/.cache/5a761efb7472ef97566e41e81451930a004134bf deleted file mode 100644 index 8a5b83224..000000000 --- a/src/generated/resources/.cache/5a761efb7472ef97566e41e81451930a004134bf +++ /dev/null @@ -1,13 +0,0 @@ -// 1.20.4 2024-12-22T16:09:31.6865744 Turtle Upgrades -b8f19ae0fb5bb898facc08e3787e0f96c8211881 data/advancedperipherals/computercraft/turtle_upgrades/chatty_turtle.json -fe98c60e7d61139aacf2d0872873e610aac8a37b data/advancedperipherals/computercraft/turtle_upgrades/chunky_turtle.json -ae619da638ad89d7302d832d6c09e2c87401c539 data/advancedperipherals/computercraft/turtle_upgrades/compass_turtle.json -a25b955d6db4ad48d43255d48d05c7f3acd60ea3 data/advancedperipherals/computercraft/turtle_upgrades/end_automata.json -98d71a2e17f3d30bbb76c1ba2f94a1cd610c2cd2 data/advancedperipherals/computercraft/turtle_upgrades/environment_turtle.json -d16f77b8c8c50dfefd757439802a13568cdcd5ec data/advancedperipherals/computercraft/turtle_upgrades/geoscanner_turtle.json -522bb2a1afb9f2be97af7cf65cd9aa159d76d13a data/advancedperipherals/computercraft/turtle_upgrades/husbandry_automata.json -c9b2df2d4fed11f60a8e6f8da77b2fa53dd13572 data/advancedperipherals/computercraft/turtle_upgrades/overpowered_end_automata.json -42fc2b9a2601ef44d617cb18302c2c4fff31d282 data/advancedperipherals/computercraft/turtle_upgrades/overpowered_husbandry_automata.json -fa7743922ef6b4dd3e633f2857e4047d533f13b5 data/advancedperipherals/computercraft/turtle_upgrades/overpowered_weak_automata.json -4054c59ceb099f17c4555fd5f36b2f8b4109f624 data/advancedperipherals/computercraft/turtle_upgrades/player_turtle.json -c8059a2717cfac5b02898658c4d2d52fbd5710d4 data/advancedperipherals/computercraft/turtle_upgrades/weak_automata.json diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 60ae63aa6..7d5df1cf6 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,39 +1,39 @@ -// 1.20.4 2024-12-26T22:13:53.2984235 Recipes -81b2ee485995edeeb21c577d141a3fb3008561a4 data/advancedperipherals/advancements/recipes/redstone/block_reader.json -4900b8e92c78828e42f434730ad93917bb298a4a data/advancedperipherals/advancements/recipes/redstone/chat_box.json -397a6604bd3c093806aac1eabaa30819a83362ce data/advancedperipherals/advancements/recipes/redstone/chunk_controller.json -15310470ad28a44c968a2e3c56b4107c081f78cd data/advancedperipherals/advancements/recipes/redstone/computer_tool.json -2df5ece90c2fe8855feafab794beab1d00458f63 data/advancedperipherals/advancements/recipes/redstone/energy_detector.json -4b4ad3153a2061dd69646750e437ee85668c2a31 data/advancedperipherals/advancements/recipes/redstone/environment_detector.json -3bafb8fde05ec490e8f0211b0e97382fe713c08e data/advancedperipherals/advancements/recipes/redstone/geo_scanner.json -6f48a77e11a886df80c6672a514bd320915c9dee data/advancedperipherals/advancements/recipes/redstone/inventory_manager.json -7e27b6eb8d0d192dc319f646ba6447d2c9f4bd01 data/advancedperipherals/advancements/recipes/redstone/memory_card.json -e43499b6608246efc710214f24aa8c0ec4a65188 data/advancedperipherals/advancements/recipes/redstone/me_bridge.json -6550380146553418c22f70bef035aa7948fe58c5 data/advancedperipherals/advancements/recipes/redstone/nbt_storage.json -60949a6e0f4e50aee869fe617c256673b37e05f6 data/advancedperipherals/advancements/recipes/redstone/overpowered_end_automata_core.json -f7aaa36a885ee058e357422ef3261ed2e0e06c2f data/advancedperipherals/advancements/recipes/redstone/overpowered_husbandry_automata_core.json -6f8a6c4e74a4208915ec1f4c0065d62294c67c15 data/advancedperipherals/advancements/recipes/redstone/overpowered_weak_automata_core.json -1b08adf8952253e016be01157f749f6ab1bd3f0d data/advancedperipherals/advancements/recipes/redstone/peripheral_casing.json -6cefb0700ed4ff952ade60ca4ef9e48a9c0ff3fb data/advancedperipherals/advancements/recipes/redstone/player_detector.json -8f28aab37ae3dd8935ba3f827f2f0b1101852565 data/advancedperipherals/advancements/recipes/redstone/redstone_integrator.json -66277f490809169783247e32f37b501be83dfa6c data/advancedperipherals/advancements/recipes/redstone/rs_bridge.json -712fb0a23a9ab7cadab8bd05175c247a0b5295b4 data/advancedperipherals/advancements/recipes/redstone/weak_automata_core.json -f8acf88364459d1b38a9ac0fc3a2e87821f98edf data/advancedperipherals/recipes/block_reader.json -b1f3b9f50e62e2f53b23ad14248cb91acb745c37 data/advancedperipherals/recipes/chat_box.json -3c6f45e5977b200c900a71bad4b531d2b7e1164c data/advancedperipherals/recipes/chunk_controller.json -a39d46363291e5d98a8b96e17bfcfd44fbe3789d data/advancedperipherals/recipes/computer_tool.json -66d1e3ed636629a9a5f7e1a8b0b7d222f0300e00 data/advancedperipherals/recipes/energy_detector.json -85920e576d404f5ad78ba228f9d6cb9aed3d4962 data/advancedperipherals/recipes/environment_detector.json -4bf49ae496c60e5487c1e87013ef25e14bb13e3a data/advancedperipherals/recipes/geo_scanner.json -2eb633f159ac1b9feaffab383548f56b573f1519 data/advancedperipherals/recipes/inventory_manager.json -dbefebf13084fce55660cffabb955f25901a30f9 data/advancedperipherals/recipes/memory_card.json -f270bf14c921f717d294d8009356deeabf403053 data/advancedperipherals/recipes/me_bridge.json -fddcb2d34c37f4fd5834e077efd27f2cb6127c73 data/advancedperipherals/recipes/nbt_storage.json -afb8673c5643adbbf69a469776ac4cd908ab17e8 data/advancedperipherals/recipes/overpowered_end_automata_core.json -7c98974c9e5999b0186011ff7f910ae2b3cc76b6 data/advancedperipherals/recipes/overpowered_husbandry_automata_core.json -40110dc9c8616e5c9b30b087cfc2f9254c433025 data/advancedperipherals/recipes/overpowered_weak_automata_core.json -346dd97a088087077c157c29cb1ac7b25b0a0cef data/advancedperipherals/recipes/peripheral_casing.json -cba141d36a134a03ae91869abb91c9695bd92898 data/advancedperipherals/recipes/player_detector.json -d5a72afad727dd9814f4c8ef6b177a0db0bc9989 data/advancedperipherals/recipes/redstone_integrator.json -6354df82d465eba4f7f6c2bedf744a97bd6c8de6 data/advancedperipherals/recipes/rs_bridge.json -96aadb6d4a930083832331a5ad6f1b7970fa4cc7 data/advancedperipherals/recipes/weak_automata_core.json +// 1.21.1 2025-01-14T19:12:56.350339 Recipes +f5ba1f7d129c88dca1a13c8deaae2d269644c7fa data/advancedperipherals/advancement/recipes/redstone/block_reader.json +e172645262ade9fc4a1c999a2c0041711c2eab55 data/advancedperipherals/advancement/recipes/redstone/chat_box.json +213de9a7e340c5eb9c01d82a72e7b58921c5290a data/advancedperipherals/advancement/recipes/redstone/chunk_controller.json +90018942364ec1928abbad8597106d888fa640bd data/advancedperipherals/advancement/recipes/redstone/colony_integrator.json +22a3e69547b1747232ad31eae8421e5e19b99fbe data/advancedperipherals/advancement/recipes/redstone/computer_tool.json +6ceff500825afce815e8e18973f1ad4d67c1fe12 data/advancedperipherals/advancement/recipes/redstone/energy_detector.json +a681c8e71de169543d040cb642a73c78c869996a data/advancedperipherals/advancement/recipes/redstone/environment_detector.json +6185db5c5e46fd50689be5a09148fac3ca6597a4 data/advancedperipherals/advancement/recipes/redstone/geo_scanner.json +e42a673e5560588d9e15a588fde9b1007cb5cb92 data/advancedperipherals/advancement/recipes/redstone/inventory_manager.json +baecdaf090fa243789d5556b7805ffef90982b89 data/advancedperipherals/advancement/recipes/redstone/memory_card.json +dc9dca7938a135dd5457ecf87c4f7d381a903412 data/advancedperipherals/advancement/recipes/redstone/me_bridge.json +c348c8990fc9bbd21509241ce44d082588a22acb data/advancedperipherals/advancement/recipes/redstone/nbt_storage.json +f218420f4c94524614229bb2d50e5c7f8e6beb28 data/advancedperipherals/advancement/recipes/redstone/overpowered_end_automata_core.json +5c2eb93fbe93dadac77d14a9c8aa2e93e3e926c0 data/advancedperipherals/advancement/recipes/redstone/overpowered_husbandry_automata_core.json +2c0460050e7eb58ee2600585dc503e6d5570d148 data/advancedperipherals/advancement/recipes/redstone/overpowered_weak_automata_core.json +2c38bc3468e8db1caac94d8ddfff68f50d596439 data/advancedperipherals/advancement/recipes/redstone/peripheral_casing.json +7dd96be9f8e31ce60752727119aa9fc738c43e3b data/advancedperipherals/advancement/recipes/redstone/player_detector.json +38be5210a7d2bb22d63674af46867a1b38c022e1 data/advancedperipherals/advancement/recipes/redstone/redstone_integrator.json +6489fff67f0d703c3a087d728eb4801413b686f5 data/advancedperipherals/advancement/recipes/redstone/weak_automata_core.json +b48e0eed6f4cfbe62c8b7c411e92e3b38ad4e4f9 data/advancedperipherals/recipe/block_reader.json +c8d06dd085c0477f94d90f3a5f0800c3efc08d02 data/advancedperipherals/recipe/chat_box.json +8c04e36fa4b88e827a5587990dc4ad94aade2eab data/advancedperipherals/recipe/chunk_controller.json +3c3b7235fbd6c45d8329ee0057e7ddc76fe4c517 data/advancedperipherals/recipe/colony_integrator.json +94d7248693fc9c5f4a307aaa72cc51136d54c7fe data/advancedperipherals/recipe/computer_tool.json +7e16f0709dfe728a5d1c677d3bee4d82bda28895 data/advancedperipherals/recipe/energy_detector.json +a276eb3b9827c19ced8123f46a69c1a0e767604f data/advancedperipherals/recipe/environment_detector.json +99514e8880e42821c00e7faafb2e722bb01a326c data/advancedperipherals/recipe/geo_scanner.json +68bc0e72ef07f424ea6e911b1aa02c6791100c1a data/advancedperipherals/recipe/inventory_manager.json +4f6d83b8d9f9b07bea06e382ae2858e019f27b8f data/advancedperipherals/recipe/memory_card.json +75c8f4f5c1c9edd1d94f3d9dfb0ac2dc6a1a3cbc data/advancedperipherals/recipe/me_bridge.json +51a26059ee5e9d8572560d404cb9874e8fd30416 data/advancedperipherals/recipe/nbt_storage.json +ba80666226c2a0d1aa30709e31756ca27076069a data/advancedperipherals/recipe/overpowered_end_automata_core.json +54f0e79105f168a6cb67772b39d73f0a6c3da563 data/advancedperipherals/recipe/overpowered_husbandry_automata_core.json +75de49f386b0f8d7a461420bc4c97759da8a1238 data/advancedperipherals/recipe/overpowered_weak_automata_core.json +0d659e0d2c832e4eef3e43cb77ddad64e071345a data/advancedperipherals/recipe/peripheral_casing.json +205166613824976d691cd0503f0e399e5b17616e data/advancedperipherals/recipe/player_detector.json +b219e8902fcea47776cb23c85e25e58efecc8f00 data/advancedperipherals/recipe/redstone_integrator.json +898d1243e5d1038e934f3ef5522aeae2f0468f43 data/advancedperipherals/recipe/weak_automata_core.json diff --git a/src/generated/resources/.cache/ae219fa7c7d3297c14e454863eac3998a4eab78c b/src/generated/resources/.cache/ae219fa7c7d3297c14e454863eac3998a4eab78c deleted file mode 100644 index dd38e436c..000000000 --- a/src/generated/resources/.cache/ae219fa7c7d3297c14e454863eac3998a4eab78c +++ /dev/null @@ -1,5 +0,0 @@ -// 1.20.4 2024-12-22T16:09:31.6935769 Pocket Computer Upgrades -b672635324c0df354e587efc81d0b19a581eae2f data/advancedperipherals/computercraft/pocket_upgrades/chatty_pocket.json -d4647159c2f2693a9c5e8d12bf740635751d29a8 data/advancedperipherals/computercraft/pocket_upgrades/environment_pocket.json -8216a0a7d8ebe3ae738c8fc3626df25eb0a2e07a data/advancedperipherals/computercraft/pocket_upgrades/geoscanner_pocket.json -a38aa83593f7ad0ace98e01bb3b5f06f272ef734 data/advancedperipherals/computercraft/pocket_upgrades/player_pocket.json diff --git a/src/generated/resources/.cache/b8526e444ae7356037f3a813274f6835d1f3dd16 b/src/generated/resources/.cache/b8526e444ae7356037f3a813274f6835d1f3dd16 index 52588e36c..0b5e6c2a4 100644 --- a/src/generated/resources/.cache/b8526e444ae7356037f3a813274f6835d1f3dd16 +++ b/src/generated/resources/.cache/b8526e444ae7356037f3a813274f6835d1f3dd16 @@ -1,6 +1,7 @@ -// 1.20.4 2024-12-22T16:09:31.694585 Block States: advancedperipherals +// 1.21.1 2025-01-15T03:30:04.6987737 Block States: advancedperipherals 5e28ce1be9a6996d982641e5df1fa7162090b8cc assets/advancedperipherals/blockstates/block_reader.json f42bdde60f84fdb312f7cf3b2be461d9c11ebdc8 assets/advancedperipherals/blockstates/chat_box.json +1227aa092fcf1327547ace6ccc9db230e45891b0 assets/advancedperipherals/blockstates/colony_integrator.json 67420f28031606ca03db9a044141bb22b0fa78b7 assets/advancedperipherals/blockstates/energy_detector.json 340b5baa62e5e6a2c35a05b4411be5937ac2bbb8 assets/advancedperipherals/blockstates/environment_detector.json 57c00996bcf1d783116a9210842f246612089555 assets/advancedperipherals/blockstates/geo_scanner.json @@ -10,16 +11,15 @@ d1fe6188b0b0ce8779cb9795a746177858cbaa41 assets/advancedperipherals/blockstates/ 51d1ce8b8772773acc82895ff6314370138c9d5a assets/advancedperipherals/blockstates/peripheral_casing.json ff12c7217911184266589813a2c8f9b0d46cfd65 assets/advancedperipherals/blockstates/player_detector.json 726cf2599b0c765bcfacda88a1943be74f985877 assets/advancedperipherals/blockstates/redstone_integrator.json -6b176e8fdb048f7b6678bfbc1c4baf2bcfa67a1f assets/advancedperipherals/blockstates/rs_bridge.json 544ff1ecb58622350b58940036b4b1908e1146da assets/advancedperipherals/models/block/block_reader.json -b28693973b6bbbb61e0c1ffc59e8ca98d8bb7e97 assets/advancedperipherals/models/block/chat_box.json -96ef564804fdc2b5184462747935f52baa35c651 assets/advancedperipherals/models/block/energy_detector.json -41556ddf5c5e67def6efd8e2e0645718d950af25 assets/advancedperipherals/models/block/environment_detector.json -ba233597a497c1032d884fc3058e27b9d965725e assets/advancedperipherals/models/block/geo_scanner.json -fb58e0b712f1f6ce1b2ea4dcfa0747905cf6ed95 assets/advancedperipherals/models/block/inventory_manager.json -75b59d2b73a96a27e3d4a1ed3b9a928b7dff102e assets/advancedperipherals/models/block/me_bridge.json -a647b86b8a7862af738136c9375a5d27d3b08860 assets/advancedperipherals/models/block/nbt_storage.json +dab55424ec184c5495c7ca11e5bbe77210e04c26 assets/advancedperipherals/models/block/chat_box.json +7e207db9b2b170f52565c8ed23bcc92762be6c4d assets/advancedperipherals/models/block/colony_integrator.json +1e9a2e3931bfe77f2d42a95c539b365c4517095d assets/advancedperipherals/models/block/energy_detector.json +434c2505b18d1313c0377c6bf8d5e4dba93765cc assets/advancedperipherals/models/block/environment_detector.json +51ab0a2a78453e711e6aa3c3020b9658bf379628 assets/advancedperipherals/models/block/geo_scanner.json +32f7941037838f9d77c5c3a4eb3b56c8786e500e assets/advancedperipherals/models/block/inventory_manager.json +674d6ee74ef7fd0360c0e1ea0b2e21734f67c096 assets/advancedperipherals/models/block/me_bridge.json +65cdb0ff57aa8439c5d80eea5c741866da9af81e assets/advancedperipherals/models/block/nbt_storage.json 36b6ac01be085492aa6298eeb89e6ecaa3cb6f82 assets/advancedperipherals/models/block/peripheral_casing.json -40369caaaf2f593d786a9c64284647fed8ae3a47 assets/advancedperipherals/models/block/player_detector.json -bed2ba2ba497ccde06c99712483fe220c277b4be assets/advancedperipherals/models/block/redstone_integrator.json -019c10d5062b5e7ae3e641527b9badab7a50878d assets/advancedperipherals/models/block/rs_bridge.json +120df29f21059aa9d4dff53bbb80953dee8d5214 assets/advancedperipherals/models/block/player_detector.json +d08b8946e1eb01cc9c8af4fa297b582614d1034b assets/advancedperipherals/models/block/redstone_integrator.json diff --git a/src/generated/resources/.cache/f95c7003282837dabaa33e3ffceec4e6865b5218 b/src/generated/resources/.cache/f95c7003282837dabaa33e3ffceec4e6865b5218 index c2b367e41..7f7c59f7e 100644 --- a/src/generated/resources/.cache/f95c7003282837dabaa33e3ffceec4e6865b5218 +++ b/src/generated/resources/.cache/f95c7003282837dabaa33e3ffceec4e6865b5218 @@ -1,4 +1,4 @@ -// 1.20.4 2024-12-22T16:09:31.6885763 Block tags -e1f71dcb4f9e7e36e29b0ad09d6520dc3adfa4a6 data/forge/tags/blocks/needs_wood_tool.json -c51355cf8bc6acdfc555d90d3a4562790e0e006b data/minecraft/tags/blocks/mineable/pickaxe.json -9359859937d9d03ddcb8a5cba399bdea6300c89b data/minecraft/tags/blocks/needs_iron_tool.json +// 1.21.1 2025-01-14T18:51:29.8886424 Block tags +6566cca83fe6d74441cb2b220aa517b93951dac9 data/minecraft/tags/blocks/mineable/pickaxe.json +5c9d90b6cb82fe772165b794f1eb511db72cb639 data/minecraft/tags/blocks/needs_iron_tool.json +e1f71dcb4f9e7e36e29b0ad09d6520dc3adfa4a6 data/neoforge/tags/blocks/needs_wood_tool.json diff --git a/src/generated/resources/assets/advancedperipherals/blockstates/colony_integrator.json b/src/generated/resources/assets/advancedperipherals/blockstates/colony_integrator.json new file mode 100644 index 000000000..22543544e --- /dev/null +++ b/src/generated/resources/assets/advancedperipherals/blockstates/colony_integrator.json @@ -0,0 +1,57 @@ +{ + "variants": { + "orientation=down_east": { + "model": "advancedperipherals:block/colony_integrator", + "x": 90, + "y": 90 + }, + "orientation=down_north": { + "model": "advancedperipherals:block/colony_integrator", + "x": 90 + }, + "orientation=down_south": { + "model": "advancedperipherals:block/colony_integrator", + "x": 90, + "y": 180 + }, + "orientation=down_west": { + "model": "advancedperipherals:block/colony_integrator", + "x": 90, + "y": 270 + }, + "orientation=east_up": { + "model": "advancedperipherals:block/colony_integrator", + "y": 90 + }, + "orientation=north_up": { + "model": "advancedperipherals:block/colony_integrator" + }, + "orientation=south_up": { + "model": "advancedperipherals:block/colony_integrator", + "y": 180 + }, + "orientation=up_east": { + "model": "advancedperipherals:block/colony_integrator", + "x": 270, + "y": 90 + }, + "orientation=up_north": { + "model": "advancedperipherals:block/colony_integrator", + "x": 270 + }, + "orientation=up_south": { + "model": "advancedperipherals:block/colony_integrator", + "x": 270, + "y": 180 + }, + "orientation=up_west": { + "model": "advancedperipherals:block/colony_integrator", + "x": 270, + "y": 270 + }, + "orientation=west_up": { + "model": "advancedperipherals:block/colony_integrator", + "y": 270 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/blockstates/rs_bridge.json b/src/generated/resources/assets/advancedperipherals/blockstates/rs_bridge.json deleted file mode 100644 index a1b1d565a..000000000 --- a/src/generated/resources/assets/advancedperipherals/blockstates/rs_bridge.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "variants": { - "orientation=down_east": { - "model": "advancedperipherals:block/rs_bridge", - "x": 90, - "y": 90 - }, - "orientation=down_north": { - "model": "advancedperipherals:block/rs_bridge", - "x": 90 - }, - "orientation=down_south": { - "model": "advancedperipherals:block/rs_bridge", - "x": 90, - "y": 180 - }, - "orientation=down_west": { - "model": "advancedperipherals:block/rs_bridge", - "x": 90, - "y": 270 - }, - "orientation=east_up": { - "model": "advancedperipherals:block/rs_bridge", - "y": 90 - }, - "orientation=north_up": { - "model": "advancedperipherals:block/rs_bridge" - }, - "orientation=south_up": { - "model": "advancedperipherals:block/rs_bridge", - "y": 180 - }, - "orientation=up_east": { - "model": "advancedperipherals:block/rs_bridge", - "x": 270, - "y": 90 - }, - "orientation=up_north": { - "model": "advancedperipherals:block/rs_bridge", - "x": 270 - }, - "orientation=up_south": { - "model": "advancedperipherals:block/rs_bridge", - "x": 270, - "y": 180 - }, - "orientation=up_west": { - "model": "advancedperipherals:block/rs_bridge", - "x": 270, - "y": 270 - }, - "orientation=west_up": { - "model": "advancedperipherals:block/rs_bridge", - "y": 270 - } - } -} \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/lang/en_us.json b/src/generated/resources/assets/advancedperipherals/lang/en_us.json index bc55241ae..7ac6af552 100644 --- a/src/generated/resources/assets/advancedperipherals/lang/en_us.json +++ b/src/generated/resources/assets/advancedperipherals/lang/en_us.json @@ -18,6 +18,7 @@ "advancements.advancedperipherals.weak_automata_core.description": "Does the afterlife exist in minecraft?", "block.advancedperipherals.block_reader": "Block Reader", "block.advancedperipherals.chat_box": "Chat Box", + "block.advancedperipherals.colony_integrator": "Colony Integrator", "block.advancedperipherals.energy_detector": "Energy Detector", "block.advancedperipherals.environment_detector": "Environment Detector", "block.advancedperipherals.geo_scanner": "Geo Scanner", @@ -27,7 +28,6 @@ "block.advancedperipherals.peripheral_casing": "Peripheral Casing", "block.advancedperipherals.player_detector": "Player Detector", "block.advancedperipherals.redstone_integrator": "Redstone Integrator", - "block.advancedperipherals.rs_bridge": "RS Bridge", "entity.minecraft.villager.advancedperipherals.computer_scientist": "Computer Scientist", "item.advancedperipherals.chunk_controller": "Chunk Controller", "item.advancedperipherals.computer_tool": "Computer Tool", @@ -40,6 +40,7 @@ "item.advancedperipherals.tooltip.block_reader": "&7Reads nbt data of blocks to interact with blocks which do not have computer support.", "item.advancedperipherals.tooltip.chat_box": "&7Interacts with the ingame chat, can read and write messages.", "item.advancedperipherals.tooltip.chunk_controller": "&7A crafting ingredient for the Chunky Turtle.", + "item.advancedperipherals.tooltip.colony_integrator": "&7Interacts with Minecolonies to read data about your colony and citizens.", "item.advancedperipherals.tooltip.computer_tool": "&7This tool was made to tune our blocks. But for now, it's just a blue useless wrench.", "item.advancedperipherals.tooltip.disabled": "&cThis item is disabled in the config, so you can craft it, but it'll not have any functionality.", "item.advancedperipherals.tooltip.end_automata_core": "&7Upgrade for turtles, that allows basic interaction with the world and teleportation in one dimension.", @@ -58,7 +59,6 @@ "item.advancedperipherals.tooltip.peripheral_casing": "&7An empty hull without the love it deserves. Used as a crafting ingredient", "item.advancedperipherals.tooltip.player_detector": "&7This peripheral can be used to interact with players, but don't be a stalker.", "item.advancedperipherals.tooltip.redstone_integrator": "&7This block is able to interact with redstone. Works exactly like the redstone api of an computer.", - "item.advancedperipherals.tooltip.rs_bridge": "&7The RS Bridge interacts with Refined Storage to manage your items.", "item.advancedperipherals.tooltip.show_desc": "&b[&7%s&b] &7For Description", "item.advancedperipherals.tooltip.weak_automata_core": "&7Upgrade for turtles, which makes turtles more useful.", "item.advancedperipherals.weak_automata_core": "Weak Automata Core", diff --git a/src/generated/resources/assets/advancedperipherals/models/block/chat_box.json b/src/generated/resources/assets/advancedperipherals/models/block/chat_box.json index 487d0eb4e..b2dc05216 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/chat_box.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/chat_box.json @@ -3,6 +3,7 @@ "textures": { "all": "advancedperipherals:block/chat_box", "north": "advancedperipherals:block/chat_box_front", - "particle": "advancedperipherals:block/chat_box_front" + "particle": "advancedperipherals:block/chat_box_front", + "up": "advancedperipherals:block/chat_box_top" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/colony_integrator.json b/src/generated/resources/assets/advancedperipherals/models/block/colony_integrator.json new file mode 100644 index 000000000..71048304d --- /dev/null +++ b/src/generated/resources/assets/advancedperipherals/models/block/colony_integrator.json @@ -0,0 +1,9 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "advancedperipherals:block/colony_integrator", + "north": "advancedperipherals:block/colony_integrator_front", + "particle": "advancedperipherals:block/colony_integrator_front", + "up": "advancedperipherals:block/colony_integrator_top" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/energy_detector.json b/src/generated/resources/assets/advancedperipherals/models/block/energy_detector.json index d1b21431d..4b3b4c8d2 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/energy_detector.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/energy_detector.json @@ -2,8 +2,10 @@ "parent": "minecraft:block/cube_all", "textures": { "all": "advancedperipherals:block/energy_detector", + "east": "advancedperipherals:block/energy_detector_east", "north": "advancedperipherals:block/energy_detector_front", "particle": "advancedperipherals:block/energy_detector_front", - "south": "advancedperipherals:block/energy_detector_back" + "south": "advancedperipherals:block/energy_detector_back", + "up": "advancedperipherals:block/energy_detector_top" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/environment_detector.json b/src/generated/resources/assets/advancedperipherals/models/block/environment_detector.json index e049a94d1..90630831d 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/environment_detector.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/environment_detector.json @@ -3,6 +3,7 @@ "textures": { "all": "advancedperipherals:block/environment_detector", "north": "advancedperipherals:block/environment_detector_front", - "particle": "advancedperipherals:block/environment_detector_front" + "particle": "advancedperipherals:block/environment_detector_front", + "up": "advancedperipherals:block/environment_detector_top" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/geo_scanner.json b/src/generated/resources/assets/advancedperipherals/models/block/geo_scanner.json index d81084e52..6752a0106 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/geo_scanner.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/geo_scanner.json @@ -3,6 +3,7 @@ "textures": { "all": "advancedperipherals:block/geo_scanner", "north": "advancedperipherals:block/geo_scanner_front", - "particle": "advancedperipherals:block/geo_scanner_front" + "particle": "advancedperipherals:block/geo_scanner_front", + "up": "advancedperipherals:block/geo_scanner_top" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/inventory_manager.json b/src/generated/resources/assets/advancedperipherals/models/block/inventory_manager.json index 16ac6a767..818e46153 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/inventory_manager.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/inventory_manager.json @@ -3,6 +3,7 @@ "textures": { "all": "advancedperipherals:block/inventory_manager", "north": "advancedperipherals:block/inventory_manager_front", - "particle": "advancedperipherals:block/inventory_manager_front" + "particle": "advancedperipherals:block/inventory_manager_front", + "up": "advancedperipherals:block/inventory_manager_top" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/me_bridge.json b/src/generated/resources/assets/advancedperipherals/models/block/me_bridge.json index 0d5355f55..42e6388e4 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/me_bridge.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/me_bridge.json @@ -3,6 +3,7 @@ "textures": { "all": "advancedperipherals:block/me_bridge", "north": "advancedperipherals:block/me_bridge_front", - "particle": "advancedperipherals:block/me_bridge_front" + "particle": "advancedperipherals:block/me_bridge_front", + "up": "advancedperipherals:block/me_bridge_top" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/nbt_storage.json b/src/generated/resources/assets/advancedperipherals/models/block/nbt_storage.json index 4472f8466..dce7d353e 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/nbt_storage.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/nbt_storage.json @@ -3,6 +3,7 @@ "textures": { "all": "advancedperipherals:block/nbt_storage", "north": "advancedperipherals:block/nbt_storage_front", - "particle": "advancedperipherals:block/nbt_storage_front" + "particle": "advancedperipherals:block/nbt_storage_front", + "up": "advancedperipherals:block/nbt_storage_top" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/player_detector.json b/src/generated/resources/assets/advancedperipherals/models/block/player_detector.json index f3d2db295..a979dadf1 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/player_detector.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/player_detector.json @@ -1,12 +1,12 @@ { "parent": "minecraft:block/cube_all", "textures": { - "all": "advancedperipherals:block/player_detector", "east": "advancedperipherals:block/player_detector_side", "north": "advancedperipherals:block/player_detector_front", "particle": "advancedperipherals:block/player_detector_front", "side": "advancedperipherals:block/player_detector_side", "south": "advancedperipherals:block/player_detector_side", + "up": "advancedperipherals:block/player_detector_top", "west": "advancedperipherals:block/player_detector_side" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/redstone_integrator.json b/src/generated/resources/assets/advancedperipherals/models/block/redstone_integrator.json index 2fa89aaa5..038dd8561 100644 --- a/src/generated/resources/assets/advancedperipherals/models/block/redstone_integrator.json +++ b/src/generated/resources/assets/advancedperipherals/models/block/redstone_integrator.json @@ -1,8 +1,13 @@ { "parent": "minecraft:block/cube_all", "textures": { - "all": "advancedperipherals:block/redstone_integrator", + "down": "advancedperipherals:block/redstone_integrator_bottom", + "east": "advancedperipherals:block/redstone_integrator_side", "north": "advancedperipherals:block/redstone_integrator_front", - "particle": "advancedperipherals:block/redstone_integrator_front" + "particle": "advancedperipherals:block/redstone_integrator_front", + "side": "advancedperipherals:block/redstone_integrator_side", + "south": "advancedperipherals:block/redstone_integrator_side", + "up": "advancedperipherals:block/redstone_integrator_top", + "west": "advancedperipherals:block/redstone_integrator_side" } } \ No newline at end of file diff --git a/src/generated/resources/assets/advancedperipherals/models/block/rs_bridge.json b/src/generated/resources/assets/advancedperipherals/models/block/rs_bridge.json deleted file mode 100644 index 10e0f003a..000000000 --- a/src/generated/resources/assets/advancedperipherals/models/block/rs_bridge.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "minecraft:block/cube_all", - "textures": { - "all": "advancedperipherals:block/rs_bridge", - "north": "advancedperipherals:block/rs_bridge_front", - "particle": "advancedperipherals:block/rs_bridge_front" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/block_reader.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/block_reader.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/block_reader.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/block_reader.json index baff01fb2..3b6c3f43f 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/block_reader.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/block_reader.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/chat_box.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/chat_box.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/chat_box.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/chat_box.json index 69aff301e..66e036f58 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/chat_box.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/chat_box.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/chunk_controller.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/chunk_controller.json similarity index 87% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/chunk_controller.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/chunk_controller.json index 9146a4ebe..323c64bd8 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/chunk_controller.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/chunk_controller.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "minecraft:respawn_anchor" - ] + "items": "minecraft:respawn_anchor" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/rs_bridge.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/colony_integrator.json similarity index 71% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/rs_bridge.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/colony_integrator.json index fb191d49d..27dc373d1 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/rs_bridge.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/colony_integrator.json @@ -2,7 +2,7 @@ "neoforge:conditions": [ { "type": "neoforge:mod_loaded", - "modid": "refinedstorage" + "modid": "minecolonies" } ], "parent": "minecraft:recipes/root", @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, @@ -21,7 +19,7 @@ }, "has_the_recipe": { "conditions": { - "recipe": "advancedperipherals:rs_bridge" + "recipe": "advancedperipherals:colony_integrator" }, "trigger": "minecraft:recipe_unlocked" } @@ -34,7 +32,7 @@ ], "rewards": { "recipes": [ - "advancedperipherals:rs_bridge" + "advancedperipherals:colony_integrator" ] } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/computer_tool.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/computer_tool.json similarity index 87% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/computer_tool.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/computer_tool.json index d9d0b79fe..3672da48a 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/computer_tool.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/computer_tool.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "minecraft:blue_terracotta" - ] + "items": "minecraft:blue_terracotta" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/energy_detector.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/energy_detector.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/energy_detector.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/energy_detector.json index 165dc38bd..d3e48cf1b 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/energy_detector.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/energy_detector.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/environment_detector.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/environment_detector.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/environment_detector.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/environment_detector.json index d56a7c98e..35311e197 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/environment_detector.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/environment_detector.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/geo_scanner.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/geo_scanner.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/geo_scanner.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/geo_scanner.json index 1b5f3e59a..fd4981b81 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/geo_scanner.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/geo_scanner.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/inventory_manager.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/inventory_manager.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/inventory_manager.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/inventory_manager.json index 9cfc93ca8..316fad0a6 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/inventory_manager.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/inventory_manager.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/me_bridge.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/me_bridge.json similarity index 87% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/me_bridge.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/me_bridge.json index 930c9e93c..32fbd51b2 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/me_bridge.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/me_bridge.json @@ -11,9 +11,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/memory_card.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/memory_card.json similarity index 88% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/memory_card.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/memory_card.json index e5330b121..bd385e3a4 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/memory_card.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/memory_card.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "minecraft:observer" - ] + "items": "minecraft:observer" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/nbt_storage.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/nbt_storage.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/nbt_storage.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/nbt_storage.json index 5bfb877ae..b4eb90e53 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/nbt_storage.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/nbt_storage.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_end_automata_core.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_end_automata_core.json similarity index 86% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_end_automata_core.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_end_automata_core.json index 79d0548be..6d4b1b19b 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_end_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_end_automata_core.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:end_automata_core" - ] + "items": "advancedperipherals:end_automata_core" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_husbandry_automata_core.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_husbandry_automata_core.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_husbandry_automata_core.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_husbandry_automata_core.json index 8b6951afc..42a9e1e84 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_husbandry_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_husbandry_automata_core.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:husbandry_automata_core" - ] + "items": "advancedperipherals:husbandry_automata_core" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_weak_automata_core.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_weak_automata_core.json similarity index 86% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_weak_automata_core.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_weak_automata_core.json index c3381a9d6..9037b83e7 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/overpowered_weak_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/overpowered_weak_automata_core.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:weak_automata_core" - ] + "items": "advancedperipherals:weak_automata_core" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/peripheral_casing.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/peripheral_casing.json similarity index 87% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/peripheral_casing.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/peripheral_casing.json index 7b892d630..af54056ee 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/peripheral_casing.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/peripheral_casing.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "minecraft:redstone_block" - ] + "items": "minecraft:redstone_block" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/player_detector.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/player_detector.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/player_detector.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/player_detector.json index 48537c8b4..164111fb6 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/player_detector.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/player_detector.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/redstone_integrator.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/redstone_integrator.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/redstone_integrator.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/redstone_integrator.json index 1c5a17343..2265fddf2 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/redstone_integrator.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/redstone_integrator.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/weak_automata_core.json b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/weak_automata_core.json similarity index 85% rename from src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/weak_automata_core.json rename to src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/weak_automata_core.json index 40d82492e..81c45ced6 100644 --- a/src/generated/resources/data/advancedperipherals/advancements/recipes/redstone/weak_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/advancement/recipes/redstone/weak_automata_core.json @@ -5,9 +5,7 @@ "conditions": { "items": [ { - "items": [ - "advancedperipherals:peripheral_casing" - ] + "items": "advancedperipherals:peripheral_casing" } ] }, diff --git a/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/chatty_pocket.json b/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/chatty_pocket.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/chatty_pocket.json rename to src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/chatty_pocket.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/colony_pocket.json b/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/colony_pocket.json new file mode 100644 index 000000000..7bc588c1d --- /dev/null +++ b/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/colony_pocket.json @@ -0,0 +1,4 @@ +{ + "type": "advancedperipherals:colony_pocket", + "item": "advancedperipherals:colony_integrator" +} \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/environment_pocket.json b/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/environment_pocket.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/environment_pocket.json rename to src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/environment_pocket.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/geoscanner_pocket.json b/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/geoscanner_pocket.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/geoscanner_pocket.json rename to src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/geoscanner_pocket.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/player_pocket.json b/src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/player_pocket.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrades/player_pocket.json rename to src/generated/resources/data/advancedperipherals/computercraft/pocket_upgrade/player_pocket.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/chatty_turtle.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/chatty_turtle.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/chatty_turtle.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/chatty_turtle.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/chunky_turtle.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/chunky_turtle.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/chunky_turtle.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/chunky_turtle.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/compass_turtle.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/compass_turtle.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/compass_turtle.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/compass_turtle.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/end_automata.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/end_automata.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/end_automata.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/end_automata.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/environment_turtle.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/environment_turtle.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/environment_turtle.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/environment_turtle.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/geoscanner_turtle.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/geoscanner_turtle.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/geoscanner_turtle.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/geoscanner_turtle.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/husbandry_automata.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/husbandry_automata.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/husbandry_automata.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/husbandry_automata.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/overpowered_end_automata.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/overpowered_end_automata.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/overpowered_end_automata.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/overpowered_end_automata.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/overpowered_husbandry_automata.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/overpowered_husbandry_automata.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/overpowered_husbandry_automata.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/overpowered_husbandry_automata.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/overpowered_weak_automata.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/overpowered_weak_automata.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/overpowered_weak_automata.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/overpowered_weak_automata.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/player_turtle.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/player_turtle.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/player_turtle.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/player_turtle.json diff --git a/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/weak_automata.json b/src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/weak_automata.json similarity index 100% rename from src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrades/weak_automata.json rename to src/generated/resources/data/advancedperipherals/computercraft/turtle_upgrade/weak_automata.json diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/block_reader.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/block_reader.json similarity index 78% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/block_reader.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/block_reader.json index c6c5746be..343f7fa6d 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/block_reader.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/block_reader.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/chat_box.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/chat_box.json similarity index 78% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/chat_box.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/chat_box.json index 1c2aef2a3..e51cf3b02 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/chat_box.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/chat_box.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_table/blocks/colony_integrator.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/colony_integrator.json new file mode 100644 index 000000000..018188d67 --- /dev/null +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/colony_integrator.json @@ -0,0 +1,30 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], + "source": "block_entity" + } + ], + "name": "advancedperipherals:colony_integrator" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "advancedperipherals:blocks/colony_integrator" +} \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/energy_detector.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/energy_detector.json similarity index 79% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/energy_detector.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/energy_detector.json index 2b4c2c7b2..66c904f1c 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/energy_detector.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/energy_detector.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/environment_detector.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/environment_detector.json similarity index 79% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/environment_detector.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/environment_detector.json index 47cbb35c0..72c6d5e16 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/environment_detector.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/environment_detector.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/geo_scanner.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/geo_scanner.json similarity index 78% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/geo_scanner.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/geo_scanner.json index 7f9d55082..419af5176 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/geo_scanner.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/geo_scanner.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/inventory_manager.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/inventory_manager.json similarity index 79% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/inventory_manager.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/inventory_manager.json index de0e972f6..6054afad9 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/inventory_manager.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/inventory_manager.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/me_bridge.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/me_bridge.json similarity index 78% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/me_bridge.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/me_bridge.json index 1921ca589..5f633bbbc 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/me_bridge.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/me_bridge.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/nbt_storage.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/nbt_storage.json similarity index 78% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/nbt_storage.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/nbt_storage.json index 5b96bf783..90fd59757 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/nbt_storage.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/nbt_storage.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/peripheral_casing.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/peripheral_casing.json similarity index 79% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/peripheral_casing.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/peripheral_casing.json index ebc512b29..2f5bd44c9 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/peripheral_casing.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/peripheral_casing.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/player_detector.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/player_detector.json similarity index 79% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/player_detector.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/player_detector.json index 9c06f68ef..41835021a 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/player_detector.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/player_detector.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/redstone_integrator.json b/src/generated/resources/data/advancedperipherals/loot_table/blocks/redstone_integrator.json similarity index 79% rename from src/generated/resources/data/advancedperipherals/loot_tables/blocks/redstone_integrator.json rename to src/generated/resources/data/advancedperipherals/loot_table/blocks/redstone_integrator.json index 771e2e3d3..d91f4150c 100644 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/redstone_integrator.json +++ b/src/generated/resources/data/advancedperipherals/loot_table/blocks/redstone_integrator.json @@ -13,7 +13,10 @@ "type": "minecraft:item", "functions": [ { - "function": "minecraft:copy_name", + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], "source": "block_entity" } ], diff --git a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/rs_bridge.json b/src/generated/resources/data/advancedperipherals/loot_tables/blocks/rs_bridge.json deleted file mode 100644 index 5065b7f85..000000000 --- a/src/generated/resources/data/advancedperipherals/loot_tables/blocks/rs_bridge.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "bonus_rolls": 0.0, - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ], - "entries": [ - { - "type": "minecraft:item", - "functions": [ - { - "function": "minecraft:copy_name", - "source": "block_entity" - } - ], - "name": "advancedperipherals:rs_bridge" - } - ], - "rolls": 1.0 - } - ], - "random_sequence": "advancedperipherals:blocks/rs_bridge" -} \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/block_reader.json b/src/generated/resources/data/advancedperipherals/recipe/block_reader.json similarity index 74% rename from src/generated/resources/data/advancedperipherals/recipes/block_reader.json rename to src/generated/resources/data/advancedperipherals/recipe/block_reader.json index e93bf3731..fc4280770 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/block_reader.json +++ b/src/generated/resources/data/advancedperipherals/recipe/block_reader.json @@ -6,7 +6,7 @@ "item": "advancedperipherals:peripheral_casing" }, "I": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "M": { "item": "computercraft:wired_modem_full" @@ -15,7 +15,7 @@ "item": "minecraft:observer" }, "R": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" } }, "pattern": [ @@ -24,6 +24,7 @@ "IRI" ], "result": { - "item": "advancedperipherals:block_reader" + "count": 1, + "id": "advancedperipherals:block_reader" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/chat_box.json b/src/generated/resources/data/advancedperipherals/recipe/chat_box.json similarity index 77% rename from src/generated/resources/data/advancedperipherals/recipes/chat_box.json rename to src/generated/resources/data/advancedperipherals/recipe/chat_box.json index 832cb15db..d9ddff23c 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/chat_box.json +++ b/src/generated/resources/data/advancedperipherals/recipe/chat_box.json @@ -6,7 +6,7 @@ "item": "advancedperipherals:peripheral_casing" }, "G": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "P": { "tag": "minecraft:logs" @@ -18,6 +18,7 @@ "PGP" ], "result": { - "item": "advancedperipherals:chat_box" + "count": 1, + "id": "advancedperipherals:chat_box" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/chunk_controller.json b/src/generated/resources/data/advancedperipherals/recipe/chunk_controller.json similarity index 65% rename from src/generated/resources/data/advancedperipherals/recipes/chunk_controller.json rename to src/generated/resources/data/advancedperipherals/recipe/chunk_controller.json index 437a46c6c..a953b2d6a 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/chunk_controller.json +++ b/src/generated/resources/data/advancedperipherals/recipe/chunk_controller.json @@ -6,10 +6,10 @@ "item": "minecraft:ender_eye" }, "I": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "R": { - "tag": "forge:dusts/redstone" + "tag": "c:dusts/redstone" } }, "pattern": [ @@ -18,6 +18,7 @@ "IRI" ], "result": { - "item": "advancedperipherals:chunk_controller" + "count": 1, + "id": "advancedperipherals:chunk_controller" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipe/colony_integrator.json b/src/generated/resources/data/advancedperipherals/recipe/colony_integrator.json new file mode 100644 index 000000000..4a5e8e785 --- /dev/null +++ b/src/generated/resources/data/advancedperipherals/recipe/colony_integrator.json @@ -0,0 +1,36 @@ +{ + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "minecolonies" + } + ], + "type": "minecraft:crafting_shaped", + "category": "redstone", + "key": { + "A": { + "item": "advancedperipherals:peripheral_casing" + }, + "B": { + "item": "minecolonies:build_goggles" + }, + "O": { + "tag": "minecraft:logs" + }, + "R": { + "item": "minecolonies:blockminecoloniesrack" + }, + "S": { + "item": "structurize:sceptergold" + } + }, + "pattern": [ + "ORO", + "BAS", + "ORO" + ], + "result": { + "count": 1, + "id": "advancedperipherals:colony_integrator" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/computer_tool.json b/src/generated/resources/data/advancedperipherals/recipe/computer_tool.json similarity index 71% rename from src/generated/resources/data/advancedperipherals/recipes/computer_tool.json rename to src/generated/resources/data/advancedperipherals/recipe/computer_tool.json index 17ad1fb4b..f2c8f2783 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/computer_tool.json +++ b/src/generated/resources/data/advancedperipherals/recipe/computer_tool.json @@ -6,7 +6,7 @@ "item": "minecraft:blue_terracotta" }, "I": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" } }, "pattern": [ @@ -15,6 +15,7 @@ " B " ], "result": { - "item": "advancedperipherals:computer_tool" + "count": 1, + "id": "advancedperipherals:computer_tool" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/energy_detector.json b/src/generated/resources/data/advancedperipherals/recipe/energy_detector.json similarity index 73% rename from src/generated/resources/data/advancedperipherals/recipes/energy_detector.json rename to src/generated/resources/data/advancedperipherals/recipe/energy_detector.json index c5a2e3adb..2482ddcb2 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/energy_detector.json +++ b/src/generated/resources/data/advancedperipherals/recipe/energy_detector.json @@ -6,13 +6,13 @@ "item": "advancedperipherals:peripheral_casing" }, "B": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" }, "C": { "item": "minecraft:comparator" }, "G": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "R": { "item": "minecraft:redstone_torch" @@ -24,6 +24,7 @@ "BGB" ], "result": { - "item": "advancedperipherals:energy_detector" + "count": 1, + "id": "advancedperipherals:energy_detector" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/environment_detector.json b/src/generated/resources/data/advancedperipherals/recipe/environment_detector.json similarity index 81% rename from src/generated/resources/data/advancedperipherals/recipes/environment_detector.json rename to src/generated/resources/data/advancedperipherals/recipe/environment_detector.json index 819f1e9fe..b69f94aa4 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/environment_detector.json +++ b/src/generated/resources/data/advancedperipherals/recipe/environment_detector.json @@ -6,7 +6,7 @@ "item": "advancedperipherals:peripheral_casing" }, "C": { - "tag": "forge:crops" + "tag": "c:crops" }, "L": { "tag": "minecraft:leaves" @@ -24,6 +24,7 @@ "WCW" ], "result": { - "item": "advancedperipherals:environment_detector" + "count": 1, + "id": "advancedperipherals:environment_detector" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/geo_scanner.json b/src/generated/resources/data/advancedperipherals/recipe/geo_scanner.json similarity index 74% rename from src/generated/resources/data/advancedperipherals/recipes/geo_scanner.json rename to src/generated/resources/data/advancedperipherals/recipe/geo_scanner.json index 250c20e3d..d9467e1f6 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/geo_scanner.json +++ b/src/generated/resources/data/advancedperipherals/recipe/geo_scanner.json @@ -6,7 +6,7 @@ "item": "advancedperipherals:peripheral_casing" }, "D": { - "tag": "forge:gems/diamond" + "tag": "c:gems/diamond" }, "M": { "item": "computercraft:wired_modem_full" @@ -15,7 +15,7 @@ "item": "minecraft:observer" }, "R": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" } }, "pattern": [ @@ -24,6 +24,7 @@ "ROR" ], "result": { - "item": "advancedperipherals:geo_scanner" + "count": 1, + "id": "advancedperipherals:geo_scanner" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/inventory_manager.json b/src/generated/resources/data/advancedperipherals/recipe/inventory_manager.json similarity index 68% rename from src/generated/resources/data/advancedperipherals/recipes/inventory_manager.json rename to src/generated/resources/data/advancedperipherals/recipe/inventory_manager.json index e6f605ca9..bfe74ea3e 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/inventory_manager.json +++ b/src/generated/resources/data/advancedperipherals/recipe/inventory_manager.json @@ -6,10 +6,10 @@ "item": "advancedperipherals:peripheral_casing" }, "C": { - "tag": "forge:chests" + "tag": "c:chests" }, "I": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" } }, "pattern": [ @@ -18,6 +18,7 @@ "ICI" ], "result": { - "item": "advancedperipherals:inventory_manager" + "count": 1, + "id": "advancedperipherals:inventory_manager" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/me_bridge.json b/src/generated/resources/data/advancedperipherals/recipe/me_bridge.json similarity index 87% rename from src/generated/resources/data/advancedperipherals/recipes/me_bridge.json rename to src/generated/resources/data/advancedperipherals/recipe/me_bridge.json index 964ed8bb9..bebf8b637 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/me_bridge.json +++ b/src/generated/resources/data/advancedperipherals/recipe/me_bridge.json @@ -24,6 +24,7 @@ "FIF" ], "result": { - "item": "advancedperipherals:me_bridge" + "count": 1, + "id": "advancedperipherals:me_bridge" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/memory_card.json b/src/generated/resources/data/advancedperipherals/recipe/memory_card.json similarity index 62% rename from src/generated/resources/data/advancedperipherals/recipes/memory_card.json rename to src/generated/resources/data/advancedperipherals/recipe/memory_card.json index 65cae3b62..76c30627e 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/memory_card.json +++ b/src/generated/resources/data/advancedperipherals/recipe/memory_card.json @@ -3,16 +3,16 @@ "category": "redstone", "key": { "G": { - "tag": "forge:ingots/gold" + "tag": "c:ingots/gold" }, "I": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "O": { "item": "minecraft:observer" }, "W": { - "tag": "forge:glass/white" + "tag": "c:glass_blocks/cheap" } }, "pattern": [ @@ -21,6 +21,7 @@ " G " ], "result": { - "item": "advancedperipherals:memory_card" + "count": 1, + "id": "advancedperipherals:memory_card" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/nbt_storage.json b/src/generated/resources/data/advancedperipherals/recipe/nbt_storage.json similarity index 64% rename from src/generated/resources/data/advancedperipherals/recipes/nbt_storage.json rename to src/generated/resources/data/advancedperipherals/recipe/nbt_storage.json index b933398b0..381ea2dd9 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/nbt_storage.json +++ b/src/generated/resources/data/advancedperipherals/recipe/nbt_storage.json @@ -6,13 +6,13 @@ "item": "advancedperipherals:peripheral_casing" }, "C": { - "tag": "forge:chests" + "tag": "c:chests" }, "I": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "R": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" } }, "pattern": [ @@ -21,6 +21,7 @@ "RCR" ], "result": { - "item": "advancedperipherals:nbt_storage" + "count": 1, + "id": "advancedperipherals:nbt_storage" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/overpowered_end_automata_core.json b/src/generated/resources/data/advancedperipherals/recipe/overpowered_end_automata_core.json similarity index 74% rename from src/generated/resources/data/advancedperipherals/recipes/overpowered_end_automata_core.json rename to src/generated/resources/data/advancedperipherals/recipe/overpowered_end_automata_core.json index 2bcbba59c..7619ef1d6 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/overpowered_end_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/recipe/overpowered_end_automata_core.json @@ -10,6 +10,7 @@ } ], "result": { - "item": "advancedperipherals:overpowered_end_automata_core" + "count": 1, + "id": "advancedperipherals:overpowered_end_automata_core" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/overpowered_husbandry_automata_core.json b/src/generated/resources/data/advancedperipherals/recipe/overpowered_husbandry_automata_core.json similarity index 73% rename from src/generated/resources/data/advancedperipherals/recipes/overpowered_husbandry_automata_core.json rename to src/generated/resources/data/advancedperipherals/recipe/overpowered_husbandry_automata_core.json index 21d781502..7860851b9 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/overpowered_husbandry_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/recipe/overpowered_husbandry_automata_core.json @@ -10,6 +10,7 @@ } ], "result": { - "item": "advancedperipherals:overpowered_husbandry_automata_core" + "count": 1, + "id": "advancedperipherals:overpowered_husbandry_automata_core" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/overpowered_weak_automata_core.json b/src/generated/resources/data/advancedperipherals/recipe/overpowered_weak_automata_core.json similarity index 74% rename from src/generated/resources/data/advancedperipherals/recipes/overpowered_weak_automata_core.json rename to src/generated/resources/data/advancedperipherals/recipe/overpowered_weak_automata_core.json index 07bccaddd..32639f766 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/overpowered_weak_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/recipe/overpowered_weak_automata_core.json @@ -10,6 +10,7 @@ } ], "result": { - "item": "advancedperipherals:overpowered_weak_automata_core" + "count": 1, + "id": "advancedperipherals:overpowered_weak_automata_core" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/peripheral_casing.json b/src/generated/resources/data/advancedperipherals/recipe/peripheral_casing.json similarity index 64% rename from src/generated/resources/data/advancedperipherals/recipes/peripheral_casing.json rename to src/generated/resources/data/advancedperipherals/recipe/peripheral_casing.json index b2c43ded1..7b5ed4567 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/peripheral_casing.json +++ b/src/generated/resources/data/advancedperipherals/recipe/peripheral_casing.json @@ -3,10 +3,10 @@ "category": "redstone", "key": { "I": { - "tag": "forge:ingots/iron" + "tag": "c:ingots/iron" }, "R": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" }, "i": { "item": "minecraft:iron_bars" @@ -18,6 +18,7 @@ "IiI" ], "result": { - "item": "advancedperipherals:peripheral_casing" + "count": 1, + "id": "advancedperipherals:peripheral_casing" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/player_detector.json b/src/generated/resources/data/advancedperipherals/recipe/player_detector.json similarity index 74% rename from src/generated/resources/data/advancedperipherals/recipes/player_detector.json rename to src/generated/resources/data/advancedperipherals/recipe/player_detector.json index 6473313fc..3b29e8644 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/player_detector.json +++ b/src/generated/resources/data/advancedperipherals/recipe/player_detector.json @@ -6,7 +6,7 @@ "item": "advancedperipherals:peripheral_casing" }, "R": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" }, "S": { "item": "minecraft:smooth_stone" @@ -18,6 +18,7 @@ "SRS" ], "result": { - "item": "advancedperipherals:player_detector" + "count": 1, + "id": "advancedperipherals:player_detector" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/redstone_integrator.json b/src/generated/resources/data/advancedperipherals/recipe/redstone_integrator.json similarity index 73% rename from src/generated/resources/data/advancedperipherals/recipes/redstone_integrator.json rename to src/generated/resources/data/advancedperipherals/recipe/redstone_integrator.json index 2608082bd..bb1a98167 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/redstone_integrator.json +++ b/src/generated/resources/data/advancedperipherals/recipe/redstone_integrator.json @@ -9,7 +9,7 @@ "item": "minecraft:comparator" }, "R": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" } }, "pattern": [ @@ -18,6 +18,7 @@ "RCR" ], "result": { - "item": "advancedperipherals:redstone_integrator" + "count": 1, + "id": "advancedperipherals:redstone_integrator" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/weak_automata_core.json b/src/generated/resources/data/advancedperipherals/recipe/weak_automata_core.json similarity index 55% rename from src/generated/resources/data/advancedperipherals/recipes/weak_automata_core.json rename to src/generated/resources/data/advancedperipherals/recipe/weak_automata_core.json index 1b9646b21..ee9f59cb3 100644 --- a/src/generated/resources/data/advancedperipherals/recipes/weak_automata_core.json +++ b/src/generated/resources/data/advancedperipherals/recipe/weak_automata_core.json @@ -6,16 +6,13 @@ "item": "advancedperipherals:peripheral_casing" }, "D": { - "tag": "forge:gems/diamond" + "tag": "c:gems/diamond" }, "L": { - "type": "neoforge:nbt", - "item": "minecraft:potion", - "strict": true, - "tag": "{Potion:\"minecraft:long_regeneration\"}" + "item": "minecraft:potion" }, "R": { - "tag": "forge:storage_blocks/redstone" + "tag": "c:storage_blocks/redstone" }, "S": { "item": "minecraft:soul_lantern" @@ -27,6 +24,7 @@ "RLR" ], "result": { - "item": "advancedperipherals:weak_automata_core" + "count": 1, + "id": "advancedperipherals:weak_automata_core" } } \ No newline at end of file diff --git a/src/generated/resources/data/advancedperipherals/recipes/rs_bridge.json b/src/generated/resources/data/advancedperipherals/recipes/rs_bridge.json deleted file mode 100644 index 7a08c1400..000000000 --- a/src/generated/resources/data/advancedperipherals/recipes/rs_bridge.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "neoforge:conditions": [ - { - "type": "neoforge:mod_loaded", - "modid": "refinedstorage" - } - ], - "type": "minecraft:crafting_shaped", - "category": "redstone", - "key": { - "A": { - "item": "advancedperipherals:peripheral_casing" - }, - "I": { - "item": "refinedstorage:interface" - }, - "Q": { - "item": "refinedstorage:quartz_enriched_iron" - } - }, - "pattern": [ - "QIQ", - "IAI", - "QIQ" - ], - "result": { - "item": "advancedperipherals:rs_bridge" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index c1f24be18..7e45c1fe5 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -4,13 +4,13 @@ "advancedperipherals:chat_box", "advancedperipherals:player_detector", "advancedperipherals:me_bridge", - "advancedperipherals:rs_bridge", "advancedperipherals:energy_detector", "advancedperipherals:peripheral_casing", "advancedperipherals:inventory_manager", "advancedperipherals:redstone_integrator", "advancedperipherals:block_reader", "advancedperipherals:geo_scanner", - "advancedperipherals:nbt_storage" + "advancedperipherals:nbt_storage", + "advancedperipherals:colony_integrator" ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/needs_iron_tool.json b/src/generated/resources/data/minecraft/tags/blocks/needs_iron_tool.json index b3d6c2415..785a3def1 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/needs_iron_tool.json +++ b/src/generated/resources/data/minecraft/tags/blocks/needs_iron_tool.json @@ -4,12 +4,12 @@ "advancedperipherals:chat_box", "advancedperipherals:player_detector", "advancedperipherals:me_bridge", - "advancedperipherals:rs_bridge", "advancedperipherals:energy_detector", "advancedperipherals:inventory_manager", "advancedperipherals:redstone_integrator", "advancedperipherals:block_reader", "advancedperipherals:geo_scanner", - "advancedperipherals:nbt_storage" + "advancedperipherals:nbt_storage", + "advancedperipherals:colony_integrator" ] } \ No newline at end of file diff --git a/src/generated/resources/data/forge/tags/blocks/needs_wood_tool.json b/src/generated/resources/data/neoforge/tags/blocks/needs_wood_tool.json similarity index 100% rename from src/generated/resources/data/forge/tags/blocks/needs_wood_tool.json rename to src/generated/resources/data/neoforge/tags/blocks/needs_wood_tool.json diff --git a/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java b/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java index 7b923bc7a..5e1ac417b 100644 --- a/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java +++ b/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java @@ -1,55 +1,58 @@ package de.srendi.advancedperipherals; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.turtle.ITurtleUpgrade; +import dan200.computercraft.api.upgrades.UpgradeBase; +import dan200.computercraft.api.upgrades.UpgradeData; +import dan200.computercraft.shared.ModRegistry; +import dan200.computercraft.shared.pocket.items.PocketComputerItem; +import dan200.computercraft.shared.turtle.items.TurtleItem; +import dan200.computercraft.shared.util.DataComponentUtil; import de.srendi.advancedperipherals.common.setup.Blocks; -import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.common.setup.Registration; -import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.registries.DeferredHolder; -import java.util.Collection; -import java.util.Set; +import java.util.Objects; +import java.util.stream.Stream; public class APCreativeTab { public static void populateCreativeTabBuilder(CreativeModeTab.Builder builder) { builder.displayItems((set, out) -> { Registration.ITEMS.getEntries().stream().map(DeferredHolder::get).forEach(out::accept); - out.acceptAll(pocketUpgrade(CCRegistration.ID.COLONY_POCKET)); - out.acceptAll(pocketUpgrade(CCRegistration.ID.CHATTY_POCKET)); - out.acceptAll(pocketUpgrade(CCRegistration.ID.PLAYER_POCKET)); - out.acceptAll(pocketUpgrade(CCRegistration.ID.ENVIRONMENT_POCKET)); - out.acceptAll(pocketUpgrade(CCRegistration.ID.GEOSCANNER_POCKET)); - - out.acceptAll(turtleUpgrade(CCRegistration.ID.CHATTY_TURTLE)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.CHUNKY_TURTLE)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.COMPASS_TURTLE)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.PLAYER_TURTLE)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.ENVIRONMENT_TURTLE)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.GEOSCANNER_TURTLE)); - - out.acceptAll(turtleUpgrade(CCRegistration.ID.WEAK_AUTOMATA)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.OP_WEAK_AUTOMATA)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.HUSBANDRY_AUTOMATA)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.OP_HUSBANDRY_AUTOMATA)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.END_AUTOMATA)); - out.acceptAll(turtleUpgrade(CCRegistration.ID.OP_END_AUTOMATA)); + + addTurtle(out, ModRegistry.Items.TURTLE_NORMAL.get(), set.holders()); + addTurtle(out, ModRegistry.Items.TURTLE_ADVANCED.get(), set.holders()); + addPocket(out, ModRegistry.Items.POCKET_COMPUTER_NORMAL.get(), set.holders()); + addPocket(out, ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get(), set.holders()); }); builder.icon(() -> new ItemStack(Blocks.CHAT_BOX.get())); builder.title(Component.translatable("advancedperipherals.name")); } - private static Collection pocketUpgrade(ResourceLocation pocketId) { - return Set.of(ItemUtil.makePocket(ItemUtil.POCKET_NORMAL, pocketId.toString()), - ItemUtil.makePocket(ItemUtil.POCKET_ADVANCED, pocketId.toString())); + // Friendly stolen from CC:Tweaked ModRegistry.class + private static boolean isOurUpgrade(Holder.Reference upgrade) { + String namespace = upgrade.key().location().getNamespace(); + return namespace.equals(AdvancedPeripherals.MOD_ID); + } + + private static void addTurtle(CreativeModeTab.Output out, TurtleItem turtle, HolderLookup.Provider registries) { + out.accept(new ItemStack(turtle)); + Stream filteredItemStacks = registries.lookupOrThrow(ITurtleUpgrade.REGISTRY).listElements().filter(APCreativeTab::isOurUpgrade).map((x) -> DataComponentUtil.createStack(turtle, ModRegistry.DataComponents.RIGHT_TURTLE_UPGRADE.get(), UpgradeData.ofDefault(x))); + Objects.requireNonNull(out); + filteredItemStacks.forEach(out::accept); } - private static Collection turtleUpgrade(ResourceLocation pocketId) { - return Set.of(ItemUtil.makeTurtle(ItemUtil.TURTLE_NORMAL, pocketId.toString()), - ItemUtil.makeTurtle(ItemUtil.TURTLE_ADVANCED, pocketId.toString())); + private static void addPocket(CreativeModeTab.Output out, PocketComputerItem pocket, HolderLookup.Provider registries) { + out.accept(new ItemStack(pocket)); + Stream filteredItemStacks = registries.lookupOrThrow(IPocketUpgrade.REGISTRY).listElements().filter(APCreativeTab::isOurUpgrade).map((x) -> DataComponentUtil.createStack(pocket, ModRegistry.DataComponents.POCKET_UPGRADE.get(), UpgradeData.ofDefault(x))); + Objects.requireNonNull(out); + filteredItemStacks.forEach(out::accept); } } diff --git a/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java b/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java index b29cd9c27..95a2f8441 100644 --- a/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java +++ b/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java @@ -1,18 +1,16 @@ package de.srendi.advancedperipherals; -import appeng.api.AECapabilities; import dan200.computercraft.api.peripheral.PeripheralCapability; import de.srendi.advancedperipherals.common.addons.APAddons; +import de.srendi.advancedperipherals.common.addons.appliedenergistics.AppEngApi; import de.srendi.advancedperipherals.common.blocks.base.ICapabilityProvider; import de.srendi.advancedperipherals.common.configuration.APConfig; -import de.srendi.advancedperipherals.common.setup.BlockEntityTypes; import de.srendi.advancedperipherals.common.setup.Registration; import de.srendi.advancedperipherals.common.util.ChunkManager; import net.minecraft.resources.ResourceLocation; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.Mod; -import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import org.apache.logging.log4j.Level; @@ -31,10 +29,10 @@ public class AdvancedPeripherals { public AdvancedPeripherals(IEventBus modBus) { LOGGER.info("AdvancedPeripherals says hello!"); + APAddons.setup(); APConfig.register(ModLoadingContext.get()); - modBus.addListener(this::commonSetup); modBus.addListener(this::registerCapabilities); modBus.addListener(ChunkManager::registerTicketController); @@ -52,11 +50,7 @@ public static void debug(String message, Level level) { } public static ResourceLocation getRL(String resource) { - return new ResourceLocation(MOD_ID, resource); - } - - public void commonSetup(FMLCommonSetupEvent event) { - APAddons.commonSetup(); + return ResourceLocation.fromNamespaceAndPath(MOD_ID, resource); } public void registerCapabilities(RegisterCapabilitiesEvent event) { @@ -100,9 +94,6 @@ public void registerCapabilities(RegisterCapabilitiesEvent event) { }); if (APAddons.ae2Loaded) - event.registerBlockEntity( - AECapabilities.IN_WORLD_GRID_NODE_HOST, - BlockEntityTypes.ME_BRIDGE.get(), - (blockEntity, side) -> blockEntity); + AppEngApi.registerCapabilities(event); } } diff --git a/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java b/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java index 766009aa8..b98eded48 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java +++ b/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java @@ -6,17 +6,15 @@ import de.srendi.advancedperipherals.common.container.InventoryManagerScreen; import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.common.setup.ContainerTypes; -import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; -import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.client.event.ModelEvent; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) public class ClientRegistry { private static final String[] TURTLE_MODELS = new String[]{"turtle_chat_box_upgrade_left", "turtle_chat_box_upgrade_right", "turtle_environment_upgrade_left", "turtle_environment_upgrade_right", "turtle_player_upgrade_left", "turtle_player_upgrade_right", "turtle_geoscanner_upgrade_left", "turtle_geoscanner_upgrade_right"}; @@ -24,23 +22,23 @@ public class ClientRegistry { @SubscribeEvent public static void registerModels(ModelEvent.RegisterAdditional event) { for (String model : TURTLE_MODELS) { - event.register(new ModelResourceLocation(new ResourceLocation(AdvancedPeripherals.MOD_ID, model), "inventory")); + event.register(new ModelResourceLocation(AdvancedPeripherals.getRL(model), "standalone")); } } @SubscribeEvent - public static void onClientSetup(FMLClientSetupEvent event) { - MenuScreens.register(ContainerTypes.INVENTORY_MANAGER_CONTAINER.get(), InventoryManagerScreen::new); + public static void menuRegister(RegisterMenuScreensEvent event) { + event.register(ContainerTypes.INVENTORY_MANAGER_CONTAINER.get(), InventoryManagerScreen::new); } @SubscribeEvent public static void onUpgradeModeller(RegisterTurtleModellersEvent event) { event.register(CCRegistration.CHUNKY_TURTLE.get(), TurtleUpgradeModeller.flatItem()); event.register(CCRegistration.COMPASS_TURTLE.get(), TurtleUpgradeModeller.flatItem()); - event.register(CCRegistration.CHAT_BOX_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_right"), "inventory"))); - event.register(CCRegistration.ENVIRONMENT_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_right"), "inventory"))); - event.register(CCRegistration.GEO_SCANNER_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_right"), "inventory"))); - event.register(CCRegistration.PLAYER_DETECTOR_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_right"), "inventory"))); + event.register(CCRegistration.CHAT_BOX_TURTLE.get(), TurtleUpgradeModeller.sided(AdvancedPeripherals.getRL("block/turtle_chatty_left"), AdvancedPeripherals.getRL("block/turtle_chatty_right"))); + event.register(CCRegistration.ENVIRONMENT_TURTLE.get(), TurtleUpgradeModeller.sided(AdvancedPeripherals.getRL("block/turtle_environment_left"), AdvancedPeripherals.getRL("block/turtle_environment_right"))); + event.register(CCRegistration.GEO_SCANNER_TURTLE.get(), TurtleUpgradeModeller.sided(AdvancedPeripherals.getRL("block/turtle_geoscanner_left"), AdvancedPeripherals.getRL("block/turtle_geoscanner_right"))); + event.register(CCRegistration.PLAYER_DETECTOR_TURTLE.get(), TurtleUpgradeModeller.sided(AdvancedPeripherals.getRL("block/turtle_player_left"), AdvancedPeripherals.getRL("block/turtle_player_right"))); event.register(CCRegistration.OP_END_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); event.register(CCRegistration.OP_HUSBANDRY_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); event.register(CCRegistration.OP_WEAK_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); diff --git a/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java b/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java index fbf19a891..3dd235dad 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java +++ b/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java @@ -9,7 +9,7 @@ import dan200.computercraft.api.turtle.TurtleSide; import de.srendi.advancedperipherals.common.util.DataStorageUtil; import de.srendi.advancedperipherals.lib.turtle.ClockwiseAnimatedTurtleUpgrade; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponentPatch; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,7 +17,7 @@ public class MetaTurtleUpgradeModeller blockEntity); + } + public static Pair findAEStackFromStack(MEStorage monitor, @Nullable ICraftingService crafting, ItemStack item) { return findAEStackFromFilter(monitor, crafting, ItemFilter.fromStack(item)); } @@ -162,13 +175,13 @@ public static Map getObjectFromStack(Pair getObjectFromItemStack(Pair stack, @Nullable ICraftingService craftingService) { Map map = new HashMap<>(); String displayName = stack.getRight().getDisplayName().getString(); - CompoundTag nbt = stack.getRight().toTag(); + Tag nbt = DataComponentUtil.toNbt(stack.getRight().getReadOnlyStack().getComponentsPatch()); long amount = stack.getLeft(); map.put("fingerprint", ItemUtil.getFingerprint(stack.getRight().toStack())); map.put("name", ItemUtil.getRegistryKey(stack.getRight().getItem()).toString()); map.put("amount", amount); map.put("displayName", displayName); - map.put("nbt", NBTUtil.toLua(nbt)); + map.put("components", NBTUtil.toLua(nbt)); map.put("tags", LuaConverter.tagsToList(() -> stack.getRight().getItem().builtInRegistryHolder().tags())); map.put("isCraftable", craftingService != null && craftingService.isCraftable(stack.getRight())); @@ -193,7 +206,7 @@ private static Map getObjectFromGasStack(Pair map.put("name", stack.getRight().getStack().getTypeRegistryName().toString()); map.put("amount", amount); map.put("displayName", stack.getRight().getDisplayName().getString()); - map.put("tags", LuaConverter.tagsToList(() -> stack.getRight().getStack().getType().getTags())); + map.put("tags", LuaConverter.tagsToList(() -> stack.getRight().getStack().getTags())); return map; } @@ -418,15 +431,14 @@ public static long getUsedItemStorage(IGridNode node) { continue; if (stack.getItem() instanceof IBasicCellItem cell) { - int bytesPerType = cell.getBytesPerType(null); - if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.items().getClass())) { - if (stack.getTag() == null) + + BasicCellInventory cellInventory = BasicCellHandler.INSTANCE.getCellInventory(stack, null); + + if (cellInventory == null) continue; - int numOfType = stack.getTag().getLongArray("amts").length; - long numItemsInCell = stack.getTag().getLong("ic"); - used += ((int) Math.ceil(((double) numItemsInCell) / 8)) + ((long) bytesPerType * numOfType); + used += cellInventory.getUsedBytes(); } } } @@ -463,15 +475,13 @@ public static long getUsedFluidStorage(IGridNode node) { ItemStack stack = inventory.getStackInSlot(i); if (stack.getItem() instanceof IBasicCellItem cell) { - int bytesPerType = cell.getBytesPerType(null); - if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.fluids().getClass())) { - if (stack.getTag() == null) + BasicCellInventory cellInventory = BasicCellHandler.INSTANCE.getCellInventory(stack, null); + + if (cellInventory == null) continue; - int numOfType = stack.getTag().getLongArray("amts").length; - long numBucketsInCell = stack.getTag().getLong("ic") / 1000; - used += ((int) Math.ceil(((double) numBucketsInCell) / 8)) + ((long) bytesPerType * numOfType); + used += cellInventory.getUsedBytes(); } } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java index a3542cda3..ef7c6f71d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java @@ -30,7 +30,7 @@ public MeItemHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource a @NotNull @Override public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { - AEItemKey itemKey = AEItemKey.of(stack.getItem(), stack.getTag()); + AEItemKey itemKey = AEItemKey.of(stack); long inserted = storageMonitor.insert(itemKey, stack.getCount(), simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); ItemStack insertedStack = stack.copy(); // Safe to cast here, the amount will never be higher than 64 diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java index 0f8d5a28b..9a38fc263 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java @@ -2,7 +2,6 @@ import dan200.computercraft.api.lua.LuaFunction; import de.srendi.advancedperipherals.lib.peripherals.APGenericPeripheral; -import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.entity.BeaconBlockEntity; public class BeaconIntegration implements APGenericPeripheral { @@ -13,19 +12,17 @@ public String getPeripheralType() { @LuaFunction(mainThread = true) public final int getLevel(BeaconBlockEntity blockEntity) { - // because levels are now protected field .... why? - CompoundTag savedData = blockEntity.saveWithoutMetadata(); - return savedData.getInt("Levels"); + return blockEntity.levels; } @LuaFunction(mainThread = true) public final String getPrimaryEffect(BeaconBlockEntity blockEntity) { - return blockEntity.primaryPower == null ? "none" : blockEntity.primaryPower.getDescriptionId(); + return blockEntity.primaryPower == null ? "none" : blockEntity.primaryPower.getRegisteredName(); } @LuaFunction(mainThread = true) public final String getSecondaryEffect(BeaconBlockEntity blockEntity) { - return blockEntity.secondaryPower == null ? "none" : blockEntity.secondaryPower.getDescriptionId(); + return blockEntity.secondaryPower == null ? "none" : blockEntity.secondaryPower.getRegisteredName(); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java index c6d9895cb..abea3d3ab 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java @@ -1,6 +1,8 @@ package de.srendi.advancedperipherals.common.addons.computercraft.operations; +import de.srendi.advancedperipherals.common.setup.DataComponents; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; +import net.minecraft.core.component.DataComponentType; import net.neoforged.neoforge.common.ModConfigSpec; import java.util.HashMap; @@ -44,4 +46,9 @@ public Map computerDescription() { data.put("cooldown", cooldown.get()); return data; } + + @Override + public DataComponentType dataComponentType() { + return DataComponents.SIMPLE_FREE_OPERATION.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java index 5dc17a210..4c6f933e3 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java @@ -1,6 +1,8 @@ package de.srendi.advancedperipherals.common.addons.computercraft.operations; +import de.srendi.advancedperipherals.common.setup.DataComponents; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; +import net.minecraft.core.component.DataComponentType; import net.neoforged.neoforge.common.ModConfigSpec; import java.util.HashMap; @@ -73,6 +75,11 @@ public void addToConfig(ModConfigSpec.Builder builder) { cost = builder.defineInRange(settingsName() + "Cost", defaultCost, 0, Integer.MAX_VALUE); } + @Override + public DataComponentType dataComponentType() { + return DataComponents.SINGLE_OPERATION.get(); + } + public enum DistancePolicy { IGNORED(d -> 1), LINEAR(d -> d), diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java index 7e060f148..7d19b9fa5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java @@ -1,7 +1,9 @@ package de.srendi.advancedperipherals.common.addons.computercraft.operations; import com.google.common.math.IntMath; +import de.srendi.advancedperipherals.common.setup.DataComponents; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; +import net.minecraft.core.component.DataComponentType; import net.neoforged.neoforge.common.ModConfigSpec; import java.util.HashMap; @@ -80,4 +82,9 @@ public SphereOperationContext free() { public SphereOperationContext cost() { return new SphereOperationContext(getMaxCostRadius()); } + + @Override + public DataComponentType dataComponentType() { + return DataComponents.SPHERE_OPERATION.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java index a244c1073..274f58711 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java @@ -1,5 +1,6 @@ package de.srendi.advancedperipherals.common.addons.computercraft.owner; +import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.blocks.base.BaseBlock; import de.srendi.advancedperipherals.common.blocks.blockentities.InventoryManagerEntity; import de.srendi.advancedperipherals.common.util.DataStorageUtil; @@ -8,6 +9,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.FrontAndTop; +import net.minecraft.core.component.DataComponentPatch; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.Nameable; @@ -75,12 +77,22 @@ public Player getOwner() { return null; } - @NotNull @Override - public CompoundTag getDataStorage() { + public DataComponentPatch getDataStorage() { + AdvancedPeripherals.debug("Block Entity peripheral at " + getPos() + " tried to use data component storage but it should instead use nbt storage, report to github!", org.apache.logging.log4j.Level.WARN); + return DataComponentPatch.EMPTY; + } + + @Override + public CompoundTag getNbtStorage() { return DataStorageUtil.getDataStorage(tileEntity); } + @Override + public void putDataStorage(DataComponentPatch dataStorage) { + AdvancedPeripherals.debug("Block Entity peripheral at " + getPos() + " tried to use data component storage but it should instead use nbt storage, report to github!", org.apache.logging.log4j.Level.WARN); + } + @Override public void markDataStorageDirty() { tileEntity.setChanged(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java index 07245d648..391d637c1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java @@ -3,13 +3,16 @@ import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.lua.MethodResult; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralPlugin; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.component.PatchedDataComponentMap; import org.jetbrains.annotations.NotNull; import java.util.Map; +import static de.srendi.advancedperipherals.common.setup.DataComponents.FUEL_CONSUMPTION_RATE; + public abstract class FuelAbility implements IOwnerAbility, IPeripheralPlugin { - protected static final String FUEL_CONSUMING_RATE_SETTING = "FUEL_CONSUMING_RATE"; protected static final int DEFAULT_FUEL_CONSUMING_RATE = 1; protected @NotNull T owner; @@ -26,8 +29,8 @@ public FuelAbility(@NotNull T owner) { * @return the fuel consumption rate */ protected int getConsumptionRate() { - CompoundTag settings = owner.getDataStorage(); - int rate = settings.getInt(FUEL_CONSUMING_RATE_SETTING); + DataComponentPatch settings = owner.getDataStorage(); + int rate = settings.get(FUEL_CONSUMPTION_RATE.get()).get(); if (rate == 0) { setConsumptionRate(DEFAULT_FUEL_CONSUMING_RATE); return DEFAULT_FUEL_CONSUMING_RATE; @@ -44,7 +47,8 @@ protected void setConsumptionRate(int rate) { if (rate < DEFAULT_FUEL_CONSUMING_RATE) rate = DEFAULT_FUEL_CONSUMING_RATE; int maxFuelRate = getMaxFuelConsumptionRate(); if (rate > maxFuelRate) rate = maxFuelRate; - owner.getDataStorage().putInt(FUEL_CONSUMING_RATE_SETTING, rate); + PatchedDataComponentMap settings = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, owner.getDataStorage()); + settings.set(FUEL_CONSUMPTION_RATE.get(), rate); } public abstract boolean isFuelConsumptionDisable(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java index c99e9442b..d5b070074 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java @@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.FrontAndTop; +import net.minecraft.core.component.DataComponentPatch; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -29,7 +30,12 @@ public interface IPeripheralOwner { @Nullable Player getOwner(); - @NotNull CompoundTag getDataStorage(); + DataComponentPatch getDataStorage(); + + // Not everything from MC uses the new data component system, so we provide a nbt data storage too + CompoundTag getNbtStorage(); + + void putDataStorage(DataComponentPatch dataStorage); void markDataStorageDirty(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java index af5cf5718..f7f67940a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java @@ -8,6 +8,9 @@ import de.srendi.advancedperipherals.lib.peripherals.IPeripheralFunction; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralPlugin; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.nbt.CompoundTag; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,32 +23,61 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; -public class OperationAbility implements IOwnerAbility, IPeripheralPlugin { - private static final String COOLDOWNS_TAG = "cooldowns"; +import static de.srendi.advancedperipherals.common.setup.DataComponents.ABILITY_COOLDOWN; +public class OperationAbility implements IOwnerAbility, IPeripheralPlugin { private final Map> allowedOperations = new HashMap<>(); private final IPeripheralOwner owner; + private static final String COOLDOWNS_TAG = "cooldowns"; + public OperationAbility(IPeripheralOwner owner) { this.owner = owner; } protected void setCooldown(@NotNull IPeripheralOperation operation, int cooldown) { if (cooldown > 0) { - CompoundTag dataStorage = owner.getDataStorage(); - if (!dataStorage.contains(COOLDOWNS_TAG)) dataStorage.put(COOLDOWNS_TAG, new CompoundTag()); - dataStorage.getCompound(COOLDOWNS_TAG).putLong(operation.settingsName(), Timestamp.valueOf(LocalDateTime.now().plus(cooldown, ChronoUnit.MILLIS)).getTime()); + if (owner instanceof BlockEntityPeripheralOwner) { + CompoundTag dataStorage = owner.getNbtStorage(); + if (!dataStorage.contains(COOLDOWNS_TAG)) dataStorage.put(COOLDOWNS_TAG, new CompoundTag()); + dataStorage.getCompound(COOLDOWNS_TAG).putLong(operation.settingsName(), Timestamp.valueOf(LocalDateTime.now().plus(cooldown, ChronoUnit.MILLIS)).getTime()); + } + + PatchedDataComponentMap patch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, owner.getDataStorage()); + if (!patch.has(ABILITY_COOLDOWN.get())) patch.set(ABILITY_COOLDOWN.get(), DataComponentPatch.EMPTY); + + PatchedDataComponentMap operationPatch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, patch.get(ABILITY_COOLDOWN.get())); + operationPatch.set(operation.dataComponentType(), (long) cooldown); + + patch.set(ABILITY_COOLDOWN.get(), operationPatch.asPatch()); + owner.putDataStorage(patch.asPatch()); } } protected int getCooldown(@NotNull IPeripheralOperation operation) { - CompoundTag dataStorage = owner.getDataStorage(); - if (!dataStorage.contains(COOLDOWNS_TAG)) return 0; - CompoundTag cooldowns = dataStorage.getCompound(COOLDOWNS_TAG); - String operationName = operation.settingsName(); - if (!cooldowns.contains(operationName)) return 0; + if (owner instanceof BlockEntityPeripheralOwner) { + CompoundTag dataStorage = owner.getNbtStorage(); + if (!dataStorage.contains(COOLDOWNS_TAG)) return 0; + CompoundTag cooldowns = dataStorage.getCompound(COOLDOWNS_TAG); + String operationName = operation.settingsName(); + if (!cooldowns.contains(operationName)) return 0; + long currentTime = Timestamp.valueOf(LocalDateTime.now()).getTime(); + return (int) Math.max(0, cooldowns.getLong(operationName) - currentTime); + } + + PatchedDataComponentMap patch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, owner.getDataStorage()); + + if (!patch.has(ABILITY_COOLDOWN.get())) { + patch.set(ABILITY_COOLDOWN.get(), DataComponentPatch.EMPTY); + owner.putDataStorage(patch.asPatch()); + } + if (patch.get(ABILITY_COOLDOWN.get()).isEmpty()) return 0; + + DataComponentPatch cooldowns = patch.get(ABILITY_COOLDOWN.get()); + if (cooldowns.get(operation.dataComponentType()).isEmpty()) return 0; + long currentTime = Timestamp.valueOf(LocalDateTime.now()).getTime(); - return (int) Math.max(0, cooldowns.getLong(operationName) - currentTime); + return (int) Math.max(0, cooldowns.get(operation.dataComponentType()).get() - currentTime); } public void registerOperation(@NotNull IPeripheralOperation operation) { @@ -86,9 +118,11 @@ public void registerOperation(@NotNull IPeripheralOperation operation) { } cooldown = fuelAbility.reduceCooldownAccordingToConsumptionRate(cooldown); } + MethodResult result = method.apply(context); if (successCallback != null) successCallback.accept(context); + setCooldown(operation, cooldown); return result; } @@ -116,8 +150,6 @@ public final MethodResult getOperationCooldown(String name) { } public enum FailReason { - COOLDOWN, - NOT_ENOUGH_FUEL, - CHECK_FAILED + COOLDOWN, NOT_ENOUGH_FUEL, CHECK_FAILED } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java index 5cd8e588c..ab6d54d8a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java @@ -1,17 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import dan200.computercraft.api.pocket.IPocketAccess; +import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.util.DataStorageUtil; import de.srendi.advancedperipherals.common.util.fakeplayer.APFakePlayer; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.FrontAndTop; +import net.minecraft.core.component.DataComponentPatch; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,17 +39,14 @@ public String getCustomName() { @Nullable @Override public Level getLevel() { - Entity owner = pocket.getEntity(); - if (owner == null) return null; - return owner.getCommandSenderWorld(); + return pocket.getLevel(); } @NotNull @Override public BlockPos getPos() { - Entity owner = pocket.getEntity(); - if (owner == null) return new BlockPos(0, 0, 0); - return owner.blockPosition(); + Vec3 position = pocket.getPosition(); + return new BlockPos((int) position.x, (int) position.y, (int) position.z); } @NotNull @@ -75,15 +75,24 @@ public Player getOwner() { return null; } - @NotNull @Override - public CompoundTag getDataStorage() { + public DataComponentPatch getDataStorage() { return DataStorageUtil.getDataStorage(pocket); } + @Override + public CompoundTag getNbtStorage() { + AdvancedPeripherals.debug("Pocket peripheral at " + getPos() + " tried to use nbt storage but it should instead use data component storage, report to github!", org.apache.logging.log4j.Level.WARN); + return null; + } + + @Override + public void putDataStorage(DataComponentPatch dataStorage) { + DataStorageUtil.putDataStorage(pocket, dataStorage); + } + @Override public void markDataStorageDirty() { - pocket.updateUpgradeNBTData(); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java index 2d7446e1c..faaa446ee 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java @@ -4,12 +4,14 @@ import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.shared.util.InventoryUtil; +import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.util.DataStorageUtil; import de.srendi.advancedperipherals.common.util.fakeplayer.APFakePlayer; import de.srendi.advancedperipherals.common.util.fakeplayer.FakePlayerProviderTurtle; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.FrontAndTop; +import net.minecraft.core.component.DataComponentPatch; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -67,15 +69,24 @@ public Player getOwner() { return turtle.getLevel().getPlayerByUUID(owningPlayer.getId()); } - @NotNull @Override - public CompoundTag getDataStorage() { + public DataComponentPatch getDataStorage() { return DataStorageUtil.getDataStorage(turtle, side); } + @Override + public CompoundTag getNbtStorage() { + AdvancedPeripherals.debug("Turtle peripheral at " + getPos() + " tried to use nbt storage but it should instead use data component storage, report to github!", org.apache.logging.log4j.Level.WARN); + return null; + } + + @Override + public void putDataStorage(DataComponentPatch dataStorage) { + DataStorageUtil.putDataStorage(turtle, side, dataStorage); + } + @Override public void markDataStorageDirty() { - turtle.updateUpgradeNBTData(side); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java index 9ffa730e4..d9daf309d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java @@ -7,6 +7,7 @@ import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.util.LuaConverter; import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; @@ -42,7 +43,7 @@ public final Object getBlockData() { BlockEntity target = getLevel().getBlockEntity(getPos().relative(owner.getFacing())); if (target == null) return null; - return NBTUtil.toLua(target.saveWithoutMetadata()); + return NBTUtil.toLua(target.saveWithoutMetadata(RegistryAccess.EMPTY)); } @LuaFunction(mainThread = true) diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java index 18f134a59..cca72b69a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java @@ -23,6 +23,7 @@ import de.srendi.advancedperipherals.lib.peripherals.IPeripheralFunction; import de.srendi.advancedperipherals.network.APNetworking; import de.srendi.advancedperipherals.network.toclient.ToastToClientPacket; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceKey; @@ -74,7 +75,7 @@ private MutableComponent appendPrefix(String prefix, String brackets, String col if (!prefix.isEmpty()) { MutableComponent formattablePrefix; try { - formattablePrefix = MutableComponent.Serializer.fromJson(prefix); + formattablePrefix = MutableComponent.Serializer.fromJson(prefix, RegistryAccess.EMPTY); prefixComponent = formattablePrefix; } catch (JsonSyntaxException exception) { AdvancedPeripherals.debug("Non json prefix, using plain text instead."); @@ -113,7 +114,7 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get(); int range = arguments.optInt(4, -1); ResourceKey dimension = getLevel().dimension(); - MutableComponent component = Component.Serializer.fromJson(message); + MutableComponent component = Component.Serializer.fromJson(message, RegistryAccess.EMPTY); if (component == null) return MethodResult.of(null, "incorrect json"); @@ -172,7 +173,7 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum if (player == null) return MethodResult.of(null, "incorrect player name/uuid"); - MutableComponent component = Component.Serializer.fromJson(message); + MutableComponent component = Component.Serializer.fromJson(message, RegistryAccess.EMPTY); if (component == null) return MethodResult.of(null, "incorrect json"); @@ -207,11 +208,11 @@ public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments argumen if (player == null) return MethodResult.of(null, "incorrect player name/uuid"); - MutableComponent messageComponent = Component.Serializer.fromJson(message); + MutableComponent messageComponent = Component.Serializer.fromJson(message, RegistryAccess.EMPTY); if (messageComponent == null) return MethodResult.of(null, "incorrect json for message"); - MutableComponent titleComponent = Component.Serializer.fromJson(title); + MutableComponent titleComponent = Component.Serializer.fromJson(title, RegistryAccess.EMPTY); if (titleComponent == null) return MethodResult.of(null, "incorrect json for title"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java index 94829b12f..d21e6656d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java @@ -7,7 +7,8 @@ import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.util.ChunkManager; import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; import org.jetbrains.annotations.NotNull; @@ -16,6 +17,8 @@ import java.util.Objects; import java.util.UUID; +import static de.srendi.advancedperipherals.common.setup.DataComponents.CHUNKY_ID; + public class ChunkyPeripheral extends BasePeripheral { public static final String PERIPHERAL_TYPE = "chunky"; @@ -27,12 +30,12 @@ public ChunkyPeripheral(ITurtleAccess turtle, TurtleSide side) { } protected UUID getUUID() { - CompoundTag data = owner.getDataStorage(); - if (!data.contains(UUID_TAG)) { - data.putUUID(UUID_TAG, UUID.randomUUID()); - owner.markDataStorageDirty(); + PatchedDataComponentMap patch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, owner.getDataStorage()); + if (!patch.has(CHUNKY_ID.get())) { + patch.set(CHUNKY_ID.get(), UUID.randomUUID()); + owner.putDataStorage(patch.asPatch()); } - return data.getUUID(UUID_TAG); + return patch.get(CHUNKY_ID.get()); } public ChunkPos getChunkPos() { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ColonyPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ColonyPeripheral.java new file mode 100644 index 000000000..b89b82665 --- /dev/null +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ColonyPeripheral.java @@ -0,0 +1,298 @@ +package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; + +import com.minecolonies.api.IMinecoloniesAPI; +import com.minecolonies.api.colony.ICivilianData; +import com.minecolonies.api.colony.IColony; +import com.minecolonies.api.colony.IVisitorData; +import com.minecolonies.api.colony.buildings.IBuilding; +import com.minecolonies.api.colony.managers.interfaces.IRegisteredStructureManager; +import com.minecolonies.api.colony.requestsystem.manager.IRequestManager; +import com.minecolonies.api.colony.requestsystem.request.IRequest; +import com.minecolonies.api.colony.requestsystem.requestable.IDeliverable; +import com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver; +import com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver; +import com.minecolonies.api.colony.requestsystem.token.IToken; +import com.minecolonies.api.colony.workorders.IWorkOrder; +import com.minecolonies.api.research.IGlobalResearchTree; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import dan200.computercraft.api.lua.LuaException; +import dan200.computercraft.api.lua.LuaFunction; +import dan200.computercraft.api.pocket.IPocketAccess; +import de.srendi.advancedperipherals.AdvancedPeripherals; +import de.srendi.advancedperipherals.common.addons.APAddons; +import de.srendi.advancedperipherals.common.addons.computercraft.owner.BlockEntityPeripheralOwner; +import de.srendi.advancedperipherals.common.addons.computercraft.owner.IPeripheralOwner; +import de.srendi.advancedperipherals.common.addons.computercraft.owner.PocketPeripheralOwner; +import de.srendi.advancedperipherals.common.addons.minecolonies.MineColonies; +import de.srendi.advancedperipherals.common.blocks.base.PeripheralBlockEntity; +import de.srendi.advancedperipherals.common.configuration.APConfig; +import de.srendi.advancedperipherals.common.util.LuaConverter; +import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +public class ColonyPeripheral extends BasePeripheral { + + public static final String PERIPHERAL_TYPE = "colonyIntegrator"; + + protected boolean hasPermission = true; + + public ColonyPeripheral(PeripheralBlockEntity tileEntity) { + super(PERIPHERAL_TYPE, new BlockEntityPeripheralOwner<>(tileEntity)); + } + + public ColonyPeripheral(IPocketAccess access) { + super(PERIPHERAL_TYPE, new PocketPeripheralOwner(access)); + } + + @Override + public boolean isEnabled() { + return APAddons.minecoloniesLoaded && APConfig.PERIPHERALS_CONFIG.enableColonyIntegrator.get(); + } + + @LuaFunction(mainThread = true) + public final boolean isInColony() { + return getColonyWithoutPermission() != null; + } + + @LuaFunction(mainThread = true) + public final boolean isWithin(Map posTable) throws LuaException { + IColony colony = getColonyWithoutPermission(); + + if(colony == null) + return false; + + BlockPos pos = LuaConverter.convertToBlockPos(posTable); + + return colony.isCoordInColony(this.getLevel(), pos); + } + + @LuaFunction(mainThread = true) + public final Object getCitizens() throws LuaException { + IColony colony = getColony(); + + List list = new ArrayList<>(); + colony.getCitizenManager().getCitizens().forEach(citizen -> { + list.add(MineColonies.citizenToObject(citizen)); + }); + + return list; + } + + @LuaFunction(mainThread = true) + public final int amountOfConstructionSites() throws LuaException { + return MineColonies.getAmountOfConstructionSites(getColony()); + } + + @LuaFunction(mainThread = true) + public final int getColonyID() throws LuaException { + IColony colony = getColony(); + + return colony.getID(); + } + + @LuaFunction(mainThread = true) + public final String getColonyName() throws LuaException { + IColony colony = getColony(); + + return colony.getName(); + } + + @LuaFunction(mainThread = true) + public final String getColonyStyle() throws LuaException { + IColony colony = getColony(); + + return colony.getStructurePack(); + } + + @LuaFunction(mainThread = true) + public final boolean isActive() throws LuaException { + IColony colony = getColony(); + + return colony.isActive(); + } + + @LuaFunction(mainThread = true) + public final double getHappiness() throws LuaException { + IColony colony = getColony(); + + return colony.getOverallHappiness(); + } + + @LuaFunction(mainThread = true) + public final Object getLocation() throws LuaException { + IColony colony = getColony(); + + return LuaConverter.posToObject(colony.getCenter()); + } + + @LuaFunction(mainThread = true) + public final boolean isUnderAttack() throws LuaException { + IColony colony = getColony(); + + return colony.isColonyUnderAttack(); + } + + @LuaFunction(mainThread = true) + public final boolean isUnderRaid() throws LuaException { + IColony colony = getColony(); + + return colony.getRaiderManager().isRaided(); + } + + @LuaFunction(mainThread = true) + public final int amountOfCitizens() throws LuaException { + IColony colony = getColony(); + + return colony.getCitizenManager().getCurrentCitizenCount(); + } + + @LuaFunction(mainThread = true) + public final int maxOfCitizens() throws LuaException { + IColony colony = getColony(); + + return colony.getCitizenManager().getMaxCitizens(); + } + + @LuaFunction(mainThread = true) + public final int amountOfGraves() throws LuaException { + IColony colony = getColony(); + + return colony.getGraveManager().getGraves().size(); + } + + @LuaFunction(mainThread = true) + public final Object getVisitors() throws LuaException { + IColony colony = getColony(); + + List list = new ArrayList<>(); + for (ICivilianData civilian : colony.getVisitorManager().getCivilianDataMap().values()) { + if (!(civilian instanceof IVisitorData visitorData)) + continue; + list.add(MineColonies.visitorToObject(visitorData)); + } + return list; + } + + @LuaFunction(mainThread = true) + public final Object getBuildings() throws LuaException { + IColony colony = getColony(); + + IRegisteredStructureManager manager = colony.getBuildingManager(); + List buildingData = new ArrayList<>(); + for (Map.Entry building : manager.getBuildings().entrySet()) { + buildingData.add(MineColonies.buildingToObject(manager, building.getValue(), building.getKey())); + } + + return buildingData; + } + + @LuaFunction(mainThread = true) + public final Object getWorkOrders() throws LuaException { + IColony colony = getColony(); + + List worksData = new ArrayList<>(); + for (IWorkOrder workOrder : colony.getWorkManager().getWorkOrders().values()) + worksData.add(MineColonies.workOrderToObject(workOrder)); + + return worksData; + } + + @LuaFunction(mainThread = true) + public final Object getResearch() throws LuaException { + IColony colony = getColony(); + + IGlobalResearchTree globalTree = IGlobalResearchTree.getInstance(); + + Map result = new HashMap<>(); + for (ResourceLocation branch : globalTree.getBranches()) { + try { + result.put(branch.toString(), MineColonies.getResearch(branch, globalTree.getPrimaryResearch(branch), colony)); + } catch (CommandSyntaxException ex) { + AdvancedPeripherals.debug("Error getting research for branch " + branch + ": " + ex.getMessage(), org.apache.logging.log4j.Level.WARN); + ex.printStackTrace(); + } + } + + return result; + } + + @LuaFunction(mainThread = true) + public final Object getWorkOrderResources(int id) throws LuaException { + IColony colony = getColony(); + + IWorkOrder workOrder = colony.getWorkManager().getWorkOrder(id); + if (workOrder == null) return null; + + return MineColonies.builderResourcesToObject(colony, workOrder.getClaimedBy()); + } + + @LuaFunction(mainThread = true) + public final Object getBuilderResources(Map posTable) throws LuaException { + IColony colony = getColony(); + + BlockPos blockPos = LuaConverter.convertToBlockPos(posTable); + + return MineColonies.builderResourcesToObject(colony, blockPos); + } + + @LuaFunction(mainThread = true) + public final Object getRequests() throws LuaException { + IColony colony = getColony(); + + IRequestManager requestManager = colony.getRequestManager(); + //All requests assigned to players + IPlayerRequestResolver playerResolver = requestManager.getPlayerResolver(); + //All requests not assigned to players + IRetryingRequestResolver requestResolver = requestManager.getRetryingRequestResolver(); + + Set> tokens = new HashSet<>(); + tokens.addAll(playerResolver.getAllAssignedRequests()); + tokens.addAll(requestResolver.getAllAssignedRequests()); + + List> requests = new ArrayList<>(); + for (IToken token : tokens) { + IRequest request = requestManager.getRequestForToken(token); + if (request.getRequest() instanceof IDeliverable) + requests.add(request); + } + + List result = new ArrayList<>(); + requests.forEach(request -> { + IDeliverable deliverableRequest = (IDeliverable) request.getRequest(); + Map map = new HashMap<>(); + map.put("id", request.getId().getIdentifier().toString()); + map.put("name", ChatFormatting.stripFormatting(request.getShortDisplayString().getString())); + map.put("desc", ChatFormatting.stripFormatting(request.getLongDisplayString().getString())); + map.put("state", request.getState().toString()); + map.put("count", deliverableRequest.getCount()); + map.put("minCount", deliverableRequest.getMinimumCount()); + map.put("items", request.getDisplayStacks().stream().map(LuaConverter::stackToObject).collect(Collectors.toList())); + map.put("target", request.getRequester().getRequesterDisplayName(requestManager, request).getString()); + result.add(map); + }); + return result; + } + + private IColony getColony() throws LuaException { + IColony colony = getColonyWithoutPermission(); + this.hasPermission = !(owner instanceof PocketPeripheralOwner) || MineColonies.hasAccess(owner.getOwner(), colony); + if (colony == null || !this.hasPermission) + throw new LuaException("Here is no colony or you don't have the right permissions"); + return colony; + } + + private IColony getColonyWithoutPermission() { + IMinecoloniesAPI api = IMinecoloniesAPI.getInstance(); + return api.getColonyManager().getColonyByPosFromWorld(getLevel(), getPos()); + } +} diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java index 7113c7614..b475a3014 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java @@ -32,9 +32,8 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.levelgen.WorldgenRandom; import net.minecraft.world.phys.AABB; -import net.neoforged.bus.api.Event; import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.entity.player.SleepingTimeCheckEvent; +import net.neoforged.neoforge.event.entity.player.CanContinueSleepingEvent; import net.neoforged.neoforge.server.ServerLifecycleHooks; import org.jetbrains.annotations.NotNull; @@ -244,14 +243,13 @@ public final MethodResult canSleepPlayer(String playername) { if(!player.level().dimensionType().bedWorks()) return MethodResult.of(false, "not_allowed_in_dimension"); - SleepingTimeCheckEvent evt = new SleepingTimeCheckEvent(player, Optional.empty()); + CanContinueSleepingEvent evt = new CanContinueSleepingEvent(player, null); NeoForge.EVENT_BUS.post(evt); - Event.Result canContinueSleep = evt.getResult(); - if (canContinueSleep == Event.Result.DEFAULT) { + if (evt.mayContinueSleeping()) { return MethodResult.of(!player.level().isDay()); } else { - return MethodResult.of(canContinueSleep == Event.Result.ALLOW); + return MethodResult.of(true); } } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java deleted file mode 100644 index d5afa7248..000000000 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java +++ /dev/null @@ -1,390 +0,0 @@ -package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; - -import com.refinedmods.refinedstorage.api.autocrafting.task.CalculationResultType; -import com.refinedmods.refinedstorage.api.autocrafting.task.ICalculationResult; -import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTask; -import com.refinedmods.refinedstorage.api.network.INetwork; -import dan200.computercraft.api.lua.IArguments; -import dan200.computercraft.api.lua.LuaException; -import dan200.computercraft.api.lua.LuaFunction; -import dan200.computercraft.api.lua.MethodResult; -import dan200.computercraft.api.peripheral.IComputerAccess; -import de.srendi.advancedperipherals.AdvancedPeripherals; -import de.srendi.advancedperipherals.common.addons.computercraft.owner.BlockEntityPeripheralOwner; -import de.srendi.advancedperipherals.common.addons.refinedstorage.RefinedStorage; -import de.srendi.advancedperipherals.common.addons.refinedstorage.RefinedStorageNode; -import de.srendi.advancedperipherals.common.addons.refinedstorage.RsFluidHandler; -import de.srendi.advancedperipherals.common.addons.refinedstorage.RsItemHandler; -import de.srendi.advancedperipherals.common.blocks.blockentities.RsBridgeEntity; -import de.srendi.advancedperipherals.common.configuration.APConfig; -import de.srendi.advancedperipherals.common.util.Pair; -import de.srendi.advancedperipherals.common.util.inventory.FluidFilter; -import de.srendi.advancedperipherals.common.util.inventory.FluidUtil; -import de.srendi.advancedperipherals.common.util.inventory.InventoryUtil; -import de.srendi.advancedperipherals.common.util.inventory.ItemFilter; -import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; -import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; -import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.fluids.FluidStack; -import net.neoforged.neoforge.fluids.capability.IFluidHandler; -import net.neoforged.neoforge.items.IItemHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; - -public class RsBridgePeripheral extends BasePeripheral> { - - public static final String PERIPHERAL_TYPE = "rsBridge"; - - public RsBridgePeripheral(RsBridgeEntity tileEntity) { - super(PERIPHERAL_TYPE, new BlockEntityPeripheralOwner<>(tileEntity)); - } - - private RefinedStorageNode getNode() { - return owner.tileEntity.getNode(); - } - - private INetwork getNetwork() { - return getNode().getNetwork(); - } - - private MethodResult notConnected() { - return MethodResult.of(null, "NOT_CONNECTED"); - } - - @Override - public boolean isEnabled() { - return APConfig.PERIPHERALS_CONFIG.enableRSBridge.get(); - } - - @LuaFunction(mainThread = true) - public final boolean isConnected() { - return getNetwork() != null; - } - - @LuaFunction(mainThread = true) - public final MethodResult listItems() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(RefinedStorage.listItems(getNetwork())); - } - - @LuaFunction(mainThread = true) - public final MethodResult listCraftableItems() { - if (!isConnected()) - return notConnected(); - - List items = new ArrayList<>(); - RefinedStorage.getCraftableItems(getNetwork()).forEach(item -> items.add(RefinedStorage.getObjectFromStack(item, getNetwork()))); - return MethodResult.of(items); - } - - @LuaFunction(mainThread = true) - public final Object listCraftableFluids() { - if (!isConnected()) - return notConnected(); - - List fluids = new ArrayList<>(); - RefinedStorage.getCraftableFluids(getNetwork()).forEach(fluid -> fluids.add(RefinedStorage.getObjectFromFluid(fluid, getNetwork()))); - return MethodResult.of(fluids); - } - - @LuaFunction(mainThread = true) - public final MethodResult getMaxItemDiskStorage() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(RefinedStorage.getMaxItemDiskStorage(getNetwork())); - } - - @LuaFunction(mainThread = true) - public final MethodResult getMaxFluidDiskStorage() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(RefinedStorage.getMaxFluidDiskStorage(getNetwork())); - } - - @LuaFunction(mainThread = true) - public final MethodResult getMaxItemExternalStorage() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(RefinedStorage.getMaxItemExternalStorage(getNetwork())); - } - - @LuaFunction(mainThread = true) - public final MethodResult getMaxFluidExternalStorage() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(RefinedStorage.getMaxFluidExternalStorage(getNetwork())); - } - - @LuaFunction(mainThread = true) - public final MethodResult listFluids() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(RefinedStorage.listFluids(getNetwork())); - } - - @LuaFunction(mainThread = true) - public final MethodResult getEnergyUsage() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(getNetwork().getEnergyUsage()); - } - - @LuaFunction(mainThread = true) - public final MethodResult getMaxEnergyStorage() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(getNetwork().getEnergyStorage().getMaxEnergyStored()); - } - - @LuaFunction(mainThread = true) - public final MethodResult getEnergyStorage() { - if (!isConnected()) - return notConnected(); - - return MethodResult.of(getNetwork().getEnergyStorage().getEnergyStored()); - } - - @LuaFunction(mainThread = true) - public final MethodResult getPattern(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - Pair filter = ItemFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(false, filter.getRight()); - - ItemFilter parsedFilter = filter.getLeft(); - if (parsedFilter.isEmpty()) - return MethodResult.of(false, "EMPTY_FILTER"); - - ItemStack patternItem = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), parsedFilter); - - return MethodResult.of(RefinedStorage.getObjectFromPattern(getNetwork().getCraftingManager().getPattern(patternItem), getNetwork())); - } - - protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { - RsItemHandler itemHandler = new RsItemHandler(getNetwork()); - if (targetInventory == null) - return MethodResult.of(0, "INVALID_TARGET"); - - Pair filter = ItemFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(0, filter.getRight()); - - return MethodResult.of(InventoryUtil.moveItem(itemHandler, targetInventory, filter.getLeft()), null); - } - - protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { - RsItemHandler itemHandler = new RsItemHandler(getNetwork()); - if (targetInventory == null) - return MethodResult.of(0, "INVALID_TARGET"); - - Pair filter = ItemFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(0, filter.getRight()); - - return MethodResult.of(InventoryUtil.moveItem(targetInventory, itemHandler, filter.getLeft()), null); - } - - protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) throws LuaException { - RsFluidHandler itemHandler = new RsFluidHandler(getNetwork()); - if (targetInventory == null) - return MethodResult.of(0, "INVALID_TARGET"); - - Pair filter = FluidFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(0, filter.getRight()); - - return MethodResult.of(InventoryUtil.moveFluid(itemHandler, targetInventory, filter.getLeft()), null); - } - - protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) throws LuaException { - RsFluidHandler itemHandler = new RsFluidHandler(getNetwork()); - if (targetInventory == null) - return MethodResult.of(0, "INVALID_TARGET"); - - Pair filter = FluidFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(0, filter.getRight()); - - return MethodResult.of(InventoryUtil.moveFluid(targetInventory, itemHandler, filter.getLeft()), null); - } - - @LuaFunction(mainThread = true) - public final MethodResult exportItem(@NotNull IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IItemHandler inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner); - return exportToChest(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult exportItemToPeripheral(IComputerAccess computer, IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IItemHandler inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1)); - return exportToChest(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult importItem(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IItemHandler inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner); - return importToSystem(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult importItemFromPeripheral(IComputerAccess computer, IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IItemHandler inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1)); - return importToSystem(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult exportFluid(@NotNull IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IFluidHandler inventory = FluidUtil.getHandlerFromDirection(arguments.getString(1), owner); - return exportToTank(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult exportFluidToPeripheral(IComputerAccess computer, IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IFluidHandler inventory = FluidUtil.getHandlerFromName(computer, arguments.getString(1)); - return exportToTank(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult importFluid(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IFluidHandler inventory = FluidUtil.getHandlerFromDirection(arguments.getString(1), owner); - return importToSystem(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult importFluidFromPeripheral(IComputerAccess computer, IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - IFluidHandler inventory = FluidUtil.getHandlerFromName(computer, arguments.getString(1)); - return importToSystem(arguments, inventory); - } - - @LuaFunction(mainThread = true) - public final MethodResult getItem(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - Pair filter = ItemFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(null, filter.getRight()); - - ItemStack item = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); - if (item.isEmpty()) - return MethodResult.of(null, "NOT_FOUND"); - return MethodResult.of(RefinedStorage.getObjectFromStack(item, getNetwork())); - } - - @LuaFunction(mainThread = true) - public final MethodResult craftItem(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - - Pair filter = ItemFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(null, filter.getRight()); - - ItemStack stack = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); - if (stack.isEmpty()) - return MethodResult.of(null, "NOT_CRAFTABLE"); - - ICalculationResult result = getNetwork().getCraftingManager().create(stack, filter.getLeft().getCount()); - CalculationResultType type = result.getType(); - if (type == CalculationResultType.OK) - getNetwork().getCraftingManager().start(result.getTask()); - AdvancedPeripherals.debug("Crafting Result of '" + ItemUtil.getRegistryKey(stack).toString() + "':" + type); - return MethodResult.of(type == CalculationResultType.OK); - } - - @LuaFunction(mainThread = true) - public final MethodResult craftFluid(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - Pair filter = FluidFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(null, filter.getRight()); - - FluidStack stack = RefinedStorage.findFluidFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); - if (stack.isEmpty()) - return MethodResult.of(null, "NOT_CRAFTABLE"); - - ICalculationResult result = getNetwork().getCraftingManager().create(stack, filter.getLeft().getCount()); - getNetwork().getCraftingManager().getPatterns(); - CalculationResultType type = result.getType(); - if (type == CalculationResultType.OK) - getNetwork().getCraftingManager().start(result.getTask()); - AdvancedPeripherals.debug("Crafting Result of '" + FluidUtil.getRegistryKey(stack).toString() + "':" + type); - return MethodResult.of(type == CalculationResultType.OK); - } - - @LuaFunction(mainThread = true) - public final MethodResult isItemCrafting(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - Pair filter = ItemFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(null, filter.getRight()); - - ItemStack stack = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); - if (stack.isEmpty()) - return MethodResult.of(null, "NOT_CRAFTABLE"); - - for (ICraftingTask task : getNetwork().getCraftingManager().getTasks()) { - ItemStack taskStack = task.getRequested().getItem(); - if (taskStack != null && taskStack.is(stack.getItem())) - return MethodResult.of(true); - } - return MethodResult.of(false); - } - - @LuaFunction(mainThread = true) - public final MethodResult isItemCraftable(IArguments arguments) throws LuaException { - if (!isConnected()) - return notConnected(); - - Pair filter = ItemFilter.parse(arguments.getTable(0)); - if (filter.rightPresent()) - return MethodResult.of(false, filter.getRight()); - - ItemFilter parsedFilter = filter.getLeft(); - if (parsedFilter.isEmpty()) - return MethodResult.of(false, "EMPTY_FILTER"); - return MethodResult.of(RefinedStorage.isItemCraftable(getNetwork(), parsedFilter.toItemStack())); - } -} diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java index 27212e8e7..fd4df79df 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java @@ -11,6 +11,8 @@ import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; import net.minecraft.core.BlockPos; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -26,6 +28,7 @@ import java.util.function.Predicate; import static de.srendi.advancedperipherals.common.addons.computercraft.operations.SingleOperation.CAPTURE_ANIMAL; +import static de.srendi.advancedperipherals.common.setup.DataComponents.ENTITY_TRANSFER; public class AutomataEntityTransferPlugin extends AutomataCorePlugin { @@ -44,19 +47,23 @@ public AutomataEntityTransferPlugin(AutomataCorePeripheral automataCore, Predica } protected boolean isEntityInside() { - return !automataCore.getPeripheralOwner().getDataStorage().getCompound(ENTITY_NBT_KEY).isEmpty(); + return automataCore.getPeripheralOwner().getDataStorage().get(ENTITY_TRANSFER.get()).isPresent(); } protected void saveEntity(CompoundTag data) { - automataCore.getPeripheralOwner().getDataStorage().put(ENTITY_NBT_KEY, data); + PatchedDataComponentMap patch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, automataCore.getPeripheralOwner().getDataStorage()); + patch.set(ENTITY_TRANSFER.get(), data); + automataCore.getPeripheralOwner().putDataStorage(patch.asPatch()); } protected CompoundTag getEntity() { - return automataCore.getPeripheralOwner().getDataStorage().getCompound(ENTITY_NBT_KEY); + return automataCore.getPeripheralOwner().getDataStorage().get(ENTITY_TRANSFER.get()).get(); } protected void removeEntity() { - automataCore.getPeripheralOwner().getDataStorage().remove(ENTITY_NBT_KEY); + PatchedDataComponentMap patch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, automataCore.getPeripheralOwner().getDataStorage()); + patch.remove(ENTITY_TRANSFER.get()); + automataCore.getPeripheralOwner().putDataStorage(patch.asPatch()); } @Nullable diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java index 712ce2c29..012c9440d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java @@ -13,6 +13,8 @@ import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; import net.minecraft.core.BlockPos; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; @@ -21,12 +23,11 @@ import java.util.Objects; import static de.srendi.advancedperipherals.common.addons.computercraft.operations.SingleOperation.WARP; +import static de.srendi.advancedperipherals.common.setup.DataComponents.POINT_DATA_MARK; +import static de.srendi.advancedperipherals.common.setup.DataComponents.WORLD_DATA_MARK; public class AutomataWarpingPlugin extends AutomataCorePlugin { - private static final String POINT_DATA_MARK = "warp_points"; - private static final String WORLD_DATA_MARK = "warp_world"; - public AutomataWarpingPlugin(AutomataCorePeripheral automataCore) { super(automataCore); } @@ -39,18 +40,18 @@ public AutomataWarpingPlugin(AutomataCorePeripheral automataCore) { @NotNull protected Pair getPointData() { TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); - CompoundTag settings = owner.getDataStorage(); - if (!settings.contains(WORLD_DATA_MARK)) { - settings.putString(WORLD_DATA_MARK, owner.getLevel().dimension().location().toString()); + PatchedDataComponentMap settings = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, owner.getDataStorage()); + if (!settings.has(WORLD_DATA_MARK.get())) { + settings.set(WORLD_DATA_MARK.get(), owner.getLevel().dimension().location().toString()); } else { - String worldName = settings.getString(WORLD_DATA_MARK); + String worldName = settings.get(WORLD_DATA_MARK.get()); if (!owner.getLevel().dimension().location().toString().equals(worldName)) return Pair.onlyLeft(MethodResult.of(null, "Incorrect world for this upgrade")); } - if (!settings.contains(POINT_DATA_MARK)) - settings.put(POINT_DATA_MARK, new CompoundTag()); + if (!settings.has(POINT_DATA_MARK.get())) + settings.set(POINT_DATA_MARK.get(), new CompoundTag()); - return Pair.onlyRight(settings.getCompound(POINT_DATA_MARK)); + return Pair.onlyRight(settings.get(POINT_DATA_MARK.get())); } private int getWarpCost(SingleOperationContext context) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java index e0a17833b..4a2808520 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java @@ -1,16 +1,18 @@ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ChatBoxPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.pocket.BasePocketUpgrade; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; public class PocketChatBoxUpgrade extends BasePocketUpgrade { - public PocketChatBoxUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public PocketChatBoxUpgrade(ItemStack stack) { + super(CCRegistration.ID.CHATTY_POCKET, stack); } @Nullable @@ -19,4 +21,8 @@ public ChatBoxPeripheral getPeripheral(IPocketAccess access) { return new ChatBoxPeripheral(access); } + @Override + public UpgradeType getType() { + return CCRegistration.CHAT_BOX_POCKET.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketColonyIntegratorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketColonyIntegratorUpgrade.java new file mode 100644 index 000000000..1ac1f3f53 --- /dev/null +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketColonyIntegratorUpgrade.java @@ -0,0 +1,26 @@ +package de.srendi.advancedperipherals.common.addons.computercraft.pocket; + +import dan200.computercraft.api.pocket.IPocketAccess; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.upgrades.UpgradeType; +import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ColonyPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; +import de.srendi.advancedperipherals.lib.pocket.BasePocketUpgrade; +import net.minecraft.world.item.ItemStack; + +public class PocketColonyIntegratorUpgrade extends BasePocketUpgrade { + + public PocketColonyIntegratorUpgrade(ItemStack stack) { + super(CCRegistration.ID.COLONY_POCKET, stack); + } + + @Override + protected ColonyPeripheral getPeripheral(IPocketAccess access) { + return new ColonyPeripheral(access); + } + + @Override + public UpgradeType getType() { + return CCRegistration.COLONY_POCKET.get(); + } +} diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java index dc6719b17..0783b7b11 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java @@ -1,17 +1,19 @@ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.EnvironmentDetectorPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.pocket.BasePocketUpgrade; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class PocketEnvironmentUpgrade extends BasePocketUpgrade { - public PocketEnvironmentUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public PocketEnvironmentUpgrade(ItemStack stack) { + super(CCRegistration.ID.ENVIRONMENT_POCKET, stack); } @Nullable @@ -20,4 +22,8 @@ public EnvironmentDetectorPeripheral getPeripheral(@NotNull IPocketAccess iPocke return new EnvironmentDetectorPeripheral(iPocketAccess); } + @Override + public UpgradeType getType() { + return CCRegistration.ENVIRONMENT_POCKET.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java index 98823d94a..b28f3e9c1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java @@ -1,17 +1,19 @@ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.GeoScannerPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.pocket.BasePocketUpgrade; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class PocketGeoScannerUpgrade extends BasePocketUpgrade { - public PocketGeoScannerUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public PocketGeoScannerUpgrade(ItemStack stack) { + super(CCRegistration.ID.GEOSCANNER_POCKET, stack); } @Nullable @@ -20,4 +22,8 @@ public GeoScannerPeripheral getPeripheral(@NotNull IPocketAccess iPocketAccess) return new GeoScannerPeripheral(iPocketAccess); } + @Override + public UpgradeType getType() { + return CCRegistration.GEO_SCANNER_POCKET.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java index 1e2b6bb43..f35f9854d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java @@ -1,17 +1,19 @@ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.PlayerDetectorPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.pocket.BasePocketUpgrade; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class PocketPlayerDetectorUpgrade extends BasePocketUpgrade { - public PocketPlayerDetectorUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public PocketPlayerDetectorUpgrade(ItemStack stack) { + super(CCRegistration.ID.PLAYER_POCKET, stack); } @Nullable @@ -20,4 +22,8 @@ public PlayerDetectorPeripheral getPeripheral(@NotNull IPocketAccess iPocketAcce return new PlayerDetectorPeripheral(iPocketAccess); } + @Override + public UpgradeType getType() { + return CCRegistration.PLAYER_DETECTOR_POCKET.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java index b82aafab2..fb38c352d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java @@ -1,18 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ChatBoxPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.PeripheralTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class TurtleChatBoxUpgrade extends PeripheralTurtleUpgrade { - public TurtleChatBoxUpgrade(ResourceLocation id, ItemStack item) { - super(id, item); + public TurtleChatBoxUpgrade(ItemStack item) { + super(CCRegistration.ID.CHATTY_TURTLE, item); } @Override @@ -30,6 +32,11 @@ protected ChatBoxPeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotN return new ChatBoxPeripheral(turtle, side); } + @Override + public UpgradeType getType() { + return CCRegistration.CHAT_BOX_TURTLE.get(); + } + @Override public void update(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { super.update(turtle, side); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java index bed242638..3e92b8aa5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java @@ -2,20 +2,22 @@ import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ChunkyPeripheral; import de.srendi.advancedperipherals.common.configuration.APConfig; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.PeripheralTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class TurtleChunkyUpgrade extends PeripheralTurtleUpgrade { private int updateTick = 0; - public TurtleChunkyUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public TurtleChunkyUpgrade(ItemStack stack) { + super(CCRegistration.ID.CHUNKY_TURTLE, stack); } @Override @@ -33,6 +35,11 @@ protected ChunkyPeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNu return new ChunkyPeripheral(turtle, side); } + @Override + public UpgradeType getType() { + return CCRegistration.CHUNKY_TURTLE.get(); + } + @Override public void update(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { // Add a chunk to the Chunk Manager every 10 ticks, if it's not already forced. diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java index d7a1482d9..f763cc168 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java @@ -1,18 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.CompassPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.PeripheralTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class TurtleCompassUpgrade extends PeripheralTurtleUpgrade { - public TurtleCompassUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public TurtleCompassUpgrade(ItemStack stack) { + super(CCRegistration.ID.COMPASS_TURTLE, stack); } @Override @@ -30,4 +32,8 @@ protected CompassPeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotN return new CompassPeripheral(turtle, side); } + @Override + public UpgradeType getType() { + return CCRegistration.COMPASS_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java index f30886d5c..44d3ae3e9 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java @@ -1,19 +1,21 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.EnvironmentDetectorPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.PeripheralTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class TurtleEnvironmentDetectorUpgrade extends PeripheralTurtleUpgrade { - public TurtleEnvironmentDetectorUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public TurtleEnvironmentDetectorUpgrade(ItemStack stack) { + super(CCRegistration.ID.ENVIRONMENT_TURTLE, stack); } @Override @@ -30,4 +32,9 @@ public ModelResourceLocation getRightModel() { protected EnvironmentDetectorPeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new EnvironmentDetectorPeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.ENVIRONMENT_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java index f2f927f2e..c792f83d8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java @@ -1,19 +1,21 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.GeoScannerPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.PeripheralTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class TurtleGeoScannerUpgrade extends PeripheralTurtleUpgrade { - public TurtleGeoScannerUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public TurtleGeoScannerUpgrade(ItemStack stack) { + super(CCRegistration.ID.GEOSCANNER_TURTLE, stack); } @Override @@ -30,4 +32,9 @@ public ModelResourceLocation getRightModel() { protected GeoScannerPeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new GeoScannerPeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.GEO_SCANNER_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java index 135e19eb9..f82509e0b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java @@ -1,19 +1,21 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.PlayerDetectorPeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.PeripheralTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class TurtlePlayerDetectorUpgrade extends PeripheralTurtleUpgrade { - public TurtlePlayerDetectorUpgrade(ResourceLocation id, ItemStack stack) { - super(id, stack); + public TurtlePlayerDetectorUpgrade(ItemStack stack) { + super(CCRegistration.ID.PLAYER_TURTLE, stack); } @Override @@ -30,4 +32,9 @@ public ModelResourceLocation getRightModel() { protected PlayerDetectorPeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new PlayerDetectorPeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.PLAYER_DETECTOR_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java index 3d100360e..a39459f99 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java @@ -1,18 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics.EndAutomataCorePeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.ClockwiseAnimatedTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class EndAutomata extends ClockwiseAnimatedTurtleUpgrade { - public EndAutomata(ResourceLocation id, ItemStack stack) { - super(id, stack); + public EndAutomata(ItemStack stack) { + super(CCRegistration.ID.END_AUTOMATA, stack); } @Override @@ -29,4 +31,9 @@ public ModelResourceLocation getRightModel() { protected EndAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new EndAutomataCorePeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.END_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java index 898710cb9..b4d488267 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java @@ -1,17 +1,19 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics.HusbandryAutomataCorePeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.ClockwiseAnimatedTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class HusbandryAutomata extends ClockwiseAnimatedTurtleUpgrade { - public HusbandryAutomata(ResourceLocation id, ItemStack stack) { - super(id, stack); + public HusbandryAutomata(ItemStack stack) { + super(CCRegistration.ID.HUSBANDRY_AUTOMATA, stack); } @Override @@ -28,4 +30,9 @@ public ModelResourceLocation getRightModel() { protected HusbandryAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new HusbandryAutomataCorePeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.HUSBANDRY_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java index 408965f4e..453ab3671 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java @@ -1,18 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics.OverpoweredEndAutomataCorePeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.ClockwiseAnimatedTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class OverpoweredEndAutomata extends ClockwiseAnimatedTurtleUpgrade { - public OverpoweredEndAutomata(ResourceLocation id, ItemStack stack) { - super(id, stack); + public OverpoweredEndAutomata(ItemStack stack) { + super(CCRegistration.ID.OP_END_AUTOMATA, stack); } @Override @@ -29,4 +31,9 @@ public ModelResourceLocation getRightModel() { protected OverpoweredEndAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new OverpoweredEndAutomataCorePeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.OP_END_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java index 83f1e27d8..005254867 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java @@ -1,18 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics.OverpoweredHusbandryAutomataCorePeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.ClockwiseAnimatedTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class OverpoweredHusbandryAutomata extends ClockwiseAnimatedTurtleUpgrade { - public OverpoweredHusbandryAutomata(ResourceLocation id, ItemStack stack) { - super(id, stack); + public OverpoweredHusbandryAutomata(ItemStack stack) { + super(CCRegistration.ID.HUSBANDRY_AUTOMATA, stack); } @Override @@ -29,4 +31,9 @@ public ModelResourceLocation getRightModel() { protected OverpoweredHusbandryAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new OverpoweredHusbandryAutomataCorePeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.OP_HUSBANDRY_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java index 4ed87f62c..9e049137a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java @@ -1,18 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics.OverpoweredWeakAutomataCorePeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.ClockwiseAnimatedTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class OverpoweredWeakAutomata extends ClockwiseAnimatedTurtleUpgrade { - public OverpoweredWeakAutomata(ResourceLocation id, ItemStack stack) { - super(id, stack); + public OverpoweredWeakAutomata(ItemStack stack) { + super(CCRegistration.ID.OP_WEAK_AUTOMATA, stack); } @Override @@ -29,4 +31,9 @@ public ModelResourceLocation getRightModel() { protected OverpoweredWeakAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new OverpoweredWeakAutomataCorePeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.OP_WEAK_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java index 3d35bfa0c..a1d067935 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java @@ -1,18 +1,20 @@ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics.WeakAutomataCorePeripheral; +import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.lib.turtle.ClockwiseAnimatedTurtleUpgrade; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; public class WeakAutomata extends ClockwiseAnimatedTurtleUpgrade { - public WeakAutomata(ResourceLocation id, ItemStack stack) { - super(id, stack); + public WeakAutomata(ItemStack stack) { + super(CCRegistration.ID.WEAK_AUTOMATA, stack); } @Override @@ -29,4 +31,9 @@ public ModelResourceLocation getRightModel() { protected WeakAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { return new WeakAutomataCorePeripheral(turtle, side); } + + @Override + public UpgradeType getType() { + return CCRegistration.WEAK_TURTLE.get(); + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/minecolonies/MineColonies.java b/src/main/java/de/srendi/advancedperipherals/common/addons/minecolonies/MineColonies.java new file mode 100644 index 000000000..536643b85 --- /dev/null +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/minecolonies/MineColonies.java @@ -0,0 +1,368 @@ +package de.srendi.advancedperipherals.common.addons.minecolonies; + +import com.minecolonies.api.colony.ICitizenData; +import com.minecolonies.api.colony.IColony; +import com.minecolonies.api.colony.IVisitorData; +import com.minecolonies.api.colony.buildings.IBuilding; +import com.minecolonies.api.colony.jobs.IJob; +import com.minecolonies.api.colony.managers.interfaces.IRegisteredStructureManager; +import com.minecolonies.api.colony.permissions.Action; +import com.minecolonies.api.colony.workorders.IWorkOrder; +import com.minecolonies.api.entity.citizen.Skill; +import com.minecolonies.api.entity.citizen.VisibleCitizenStatus; +import com.minecolonies.api.research.IGlobalResearch; +import com.minecolonies.api.research.IGlobalResearchTree; +import com.minecolonies.api.research.ILocalResearch; +import com.minecolonies.api.research.ILocalResearchTree; +import com.minecolonies.api.research.IResearchRequirement; +import com.minecolonies.api.research.effects.IResearchEffect; +import com.minecolonies.api.research.util.ResearchState; +import com.minecolonies.core.colony.buildings.AbstractBuildingStructureBuilder; +import com.minecolonies.core.colony.buildings.utils.BuildingBuilderResource; +import com.minecolonies.core.entity.citizen.citizenhandlers.CitizenSkillHandler; +import com.minecolonies.core.research.BuildingResearchRequirement; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import de.srendi.advancedperipherals.common.util.LuaConverter; +import io.netty.buffer.Unpooled; +import net.minecraft.core.BlockPos; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.common.crafting.SizedIngredient; +import net.neoforged.neoforge.items.IItemHandler; +import net.neoforged.neoforge.network.connection.ConnectionType; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MineColonies { + + /** + * To ensure that the user of a pocket computer has the appropriate rights. + * + * @param entity the user of the pocket computer + * @param colony the colony where the user is in it + * @return true if the user has the appropriate rights + */ + public static boolean hasAccess(Entity entity, IColony colony) { + if (entity instanceof Player player) { + if (colony != null) { + return colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS); + } + } + return false; + } + + /** + * Converts a citizen to a map + * + * @param citizen the citizen + * @return a map with information about the citizen + */ + public static Object citizenToObject(ICitizenData citizen) { + Map map = new HashMap<>(); + map.put("id", citizen.getId()); + map.put("name", citizen.getName()); + map.put("bedPos", LuaConverter.posToObject(citizen.getBedPos())); + map.put("children", citizen.getChildren()); + map.put("location", LuaConverter.posToObject(citizen.getLastPosition())); + map.put("state", citizen.getStatus() == null ? "Idle" : Component.translatable(citizen.getStatus().getTranslationKey()).getString()); + map.put("isChild", citizen.isChild() ? "child" : "adult"); + map.put("gender", citizen.isFemale() ? "female" : "male"); + map.put("saturation", citizen.getSaturation()); + map.put("happiness", citizen.getCitizenHappinessHandler().getHappiness(citizen.getColony(), citizen)); + map.put("skills", skillsToObject(citizen.getCitizenSkillHandler().getSkills())); + map.put("work", citizen.getWorkBuilding() == null ? null : jobToObject(citizen.getWorkBuilding(), citizen.getJob())); + map.put("home", citizen.getHomeBuilding() == null ? null : homeToObject(citizen.getHomeBuilding())); + map.put("betterFood", citizen.needsBetterFood()); + map.put("isAsleep", citizen.getStatus().equals(VisibleCitizenStatus.SLEEP)); + map.put("isIdle", citizen.getStatus().equals(VisibleCitizenStatus.HOUSE)); + citizen.getEntity().ifPresent(entity -> { + map.put("health", entity.getHealth()); + map.put("maxHealth", entity.getMaxHealth()); + map.put("armor", entity.getAttributeValue(Attributes.ARMOR)); + map.put("toughness", entity.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); + }); + + return map; + } + + /** + * Converts a visitor {@link IVisitorData} to a map + * + * @param visitor the visitor + * @return a map with information about the visitor + */ + public static Object visitorToObject(IVisitorData visitor) { + Map map = new HashMap<>(); + map.put("id", visitor.getId()); + map.put("name", visitor.getName()); + map.put("location", LuaConverter.posToObject(visitor.getSittingPosition())); + map.put("isChild", visitor.isChild() ? "child" : "adult"); + map.put("gender", visitor.isFemale() ? "female" : "male"); + map.put("saturation", visitor.getSaturation()); + map.put("happiness", visitor.getCitizenHappinessHandler().getHappiness(visitor.getColony(), visitor)); + map.put("skills", skillsToObject(visitor.getCitizenSkillHandler().getSkills())); + map.put("recruitCost", LuaConverter.stackToObject(visitor.getRecruitCost())); + + return map; + } + + /** + * Converts a building {@link IBuilding} and job {@link IJob} to a map + * + * @param work the home building + * @param job the job + * @return a map with information about the building and job + */ + public static Object jobToObject(IBuilding work, IJob job) { + Map map = new HashMap<>(); + map.put("location", LuaConverter.posToObject(work.getLocation().getInDimensionLocation())); + map.put("type", work.getSchematicName()); + map.put("level", work.getBuildingLevel()); + map.put("name", work.getBuildingDisplayName()); + map.put("job", job.getJobRegistryEntry().getTranslationKey()); + + return map; + } + + /** + * Converts a home {@link IBuilding} to a map + * + * @param home the home building + * @return a map with information about the home building + */ + public static Object homeToObject(IBuilding home) { + Map map = new HashMap<>(); + map.put("location", LuaConverter.posToObject(home.getLocation().getInDimensionLocation())); + map.put("type", home.getSchematicName()); + map.put("level", home.getBuildingLevel()); + + return map; + } + + /** + * Converts a skill {@link Skill} into a map + * + * @param skills skills as list. Can be obtained via {@link ICitizenData#getCitizenSkillHandler} + * @return a map with information about the skill + */ + public static Object skillsToObject(Map skills) { + Map map = new HashMap<>(); + for (Map.Entry skill : skills.entrySet()) { + Map skillData = new HashMap<>(); + skillData.put("level", skill.getValue().getLevel()); + skillData.put("xp", skill.getValue().getExperience()); + map.put(skill.getKey().name(), skillData); + } + + return map; + } + + /** + * Returns information about the building like structure data, the citizens and some other values + * + * @param buildingManager The building manager of the colony + * @param building The building as instance + * @param pos The location of the buildings block + * @return information about the building + */ + public static Object buildingToObject(IRegisteredStructureManager buildingManager, IBuilding building, BlockPos pos) { + Map structureData = new HashMap<>(); + structureData.put("cornerA", LuaConverter.posToObject(building.getCorners().getA())); + structureData.put("cornerB", LuaConverter.posToObject(building.getCorners().getB())); + structureData.put("rotation", building.getRotationMirror().toString()); + structureData.put("mirror", building.getRotationMirror().isMirrored()); + + List citizensData = new ArrayList<>(); + for (ICitizenData citizen : building.getAllAssignedCitizen()) { + Map citizenData = new HashMap<>(); + citizenData.put("id", citizen.getId()); + citizenData.put("name", citizen.getName()); + citizensData.add(citizenData); + } + + Map map = new HashMap<>(); + map.put("location", LuaConverter.posToObject(pos)); + map.put("type", building.getSchematicName()); + map.put("style", building.getStructurePack()); + map.put("level", building.getBuildingLevel()); + map.put("maxLevel", building.getMaxBuildingLevel()); + map.put("name", building.getBuildingDisplayName()); + map.put("built", building.isBuilt()); + map.put("isWorking", building.hasWorkOrder()); + map.put("priority", building.getPickUpPriority()); + map.put("structure", structureData); + map.put("citizens", citizensData); + map.put("storageBlocks", building.getContainers().size()); + map.put("storageSlots", getStorageSize(building)); + map.put("guarded", buildingManager.hasGuardBuildingNear(building)); + + return map; + } + + /** + * Returns the size of all inventories in this building + * + * @param building the proper building with racks(Or other inventories) + * @return the size of all inventories in this building + */ + public static int getStorageSize(IBuilding building) { + int size = 0; + + for (IItemHandler itemHandler : building.getHandlers()) { + size += itemHandler.getSlots(); + } + + return size; + } + + public static int getAmountOfConstructionSites(IColony colony) { + int constructionSites = 0; + for (IBuilding building : colony.getBuildingManager().getBuildings().values()) { + if (building.hasWorkOrder()) + constructionSites++; + } + + return constructionSites; + } + + public static Object workOrderToObject(IWorkOrder workOrder) { + Map map = new HashMap<>(); + + map.put("builder", LuaConverter.posToObject(workOrder.getClaimedBy())); + map.put("changed", workOrder.isDirty()); + map.put("id", workOrder.getID()); + map.put("priority", workOrder.getPriority()); + map.put("isClaimed", workOrder.isClaimed()); + map.put("location", LuaConverter.posToObject(workOrder.getLocation())); + map.put("type", workOrder.getClass().getSimpleName()); + map.put("buildingName", workOrder.getDisplayName().getString()); + map.put("targetLevel", workOrder.getTargetLevel()); + map.put("workOrderType", workOrder.getWorkOrderType().toString()); + + return map; + } + + /** + * Returns a list with all possible researches + * + * @param branch The branch, there are only a few branches + * @param researches The primary researches of the branch + * @param colony The colony + * @return a list including maps with all possible researches + */ + public static List getResearch(ResourceLocation branch, List researches, IColony colony) throws CommandSyntaxException { + List result = new ArrayList<>(); + if (researches != null) { + for (ResourceLocation researchName : researches) { + //All global possible researches + IGlobalResearchTree globalTree = IGlobalResearchTree.getInstance(); + //The research tree of the colony + ILocalResearchTree colonyTree = colony.getResearchManager().getResearchTree(); + + IGlobalResearch research = globalTree.getResearch(branch, researchName); + if (research == null) + continue; + if (research.isHidden()) + continue; + ILocalResearch colonyResearch = colonyTree.getResearch(branch, researchName); + + List effects = new ArrayList<>(); + for (IResearchEffect researchEffect : research.getEffects()) + effects.add(Component.translatable(researchEffect.getDesc().getKey(), researchEffect.getDesc().getArgs()).getString()); + + List> cost = new ArrayList<>(); + for (SizedIngredient item : research.getCostList()) { + Map researchCost = new HashMap<>(); + List> researchCostItems = new ArrayList<>(); + + for (ItemStack costItem : item.getItems()) + researchCostItems.add(LuaConverter.stackToObject(costItem)); + + researchCost.put("validItems", researchCostItems); + researchCost.put("count", item.count()); + //researchCost.put("", item.getType().getId().toString()); + + cost.add(researchCost); + } + + List> requirements = new ArrayList<>(); + for (IResearchRequirement requirement : research.getResearchRequirement()) { + Map requirementItem = new HashMap<>(); + requirementItem.put("fulfilled", requirement.isFulfilled(colony)); + if (requirement instanceof BuildingResearchRequirement buildingRequirement) { + requirementItem.put("type", "building"); + requirementItem.put("building", buildingRequirement.getBuilding()); + requirementItem.put("level", buildingRequirement.getBuildingLevel()); + } else { + requirementItem.put("type", requirement.getClass().getCanonicalName()); + } + requirementItem.put("desc", requirement.getDesc().getString()); + requirements.add(requirementItem); + } + + Map map = new HashMap<>(); + map.put("id", researchName.toString()); + map.put("name", Component.translatable(research.getName().getKey(), research.getName().getArgs()).getString()); + map.put("requirements", requirements); + map.put("cost", cost); + map.put("researchEffects", effects); + map.put("status", colonyResearch == null ? ResearchState.NOT_STARTED.toString() : colonyResearch.getState().toString()); + map.put("requiredTime", colonyResearch == null ? 0 : IGlobalResearchTree.getInstance().getBranchData(colonyResearch.getBranch()).getBaseTime(colonyResearch.getDepth())); + map.put("progress", colonyResearch == null ? 0 : colonyResearch.getProgress()); + + List childrenResearch = getResearch(branch, research.getChildren(), colony); + if (!childrenResearch.isEmpty()) + map.put("children", childrenResearch); + + result.add(map); + } + } + return result; + } + + /** + * Returns the resources(As items) which the builder needs + * + * @param colony The colony + * @param pos The position of the builder's hut block + * @return a map with all needed resources + */ + public static Object builderResourcesToObject(IColony colony, BlockPos pos) { + IBuilding building = colony.getBuildingManager().getBuilding(pos); + if (!(building instanceof AbstractBuildingStructureBuilder builderBuilding)) + return null; + + //We need to tell the building that we want information about it + RegistryFriendlyByteBuf buffer = new RegistryFriendlyByteBuf(Unpooled.buffer(), colony.getWorld().registryAccess(), ConnectionType.OTHER); + builderBuilding.serializeToView(buffer, false); + buffer.release(); + + List resources = new ArrayList<>(builderBuilding.getNeededResources().values()); + resources.sort(new BuildingBuilderResource.ResourceComparator()); + + List result = new ArrayList<>(); + for (BuildingBuilderResource resource : resources) { + Map map = new HashMap<>(); + ItemStack stack = resource.getItemStack().copy(); + + map.put("item", LuaConverter.stackToObject(stack)); + map.put("displayName", resource.getName()); + map.put("available", resource.getAvailable()); + map.put("delivering", resource.getAmountInDelivery()); + map.put("status", resource.getAvailabilityStatus().toString()); + map.put("needs", resource.getAmount()); + result.add(map); + } + + return result; + } + +} diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorage.java b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorage.java deleted file mode 100644 index 3889a3edf..000000000 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorage.java +++ /dev/null @@ -1,295 +0,0 @@ -package de.srendi.advancedperipherals.common.addons.refinedstorage; - -import com.refinedmods.refinedstorage.api.IRSAPI; -import com.refinedmods.refinedstorage.api.autocrafting.ICraftingManager; -import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern; -import com.refinedmods.refinedstorage.api.network.INetwork; -import com.refinedmods.refinedstorage.api.network.node.INetworkNode; -import com.refinedmods.refinedstorage.api.storage.IStorage; -import com.refinedmods.refinedstorage.api.storage.cache.IStorageCache; -import com.refinedmods.refinedstorage.api.storage.disk.IStorageDisk; -import com.refinedmods.refinedstorage.api.storage.externalstorage.IExternalStorage; -import com.refinedmods.refinedstorage.api.util.StackListEntry; -import com.refinedmods.refinedstorage.apiimpl.API; -import com.refinedmods.refinedstorage.apiimpl.network.node.NetworkNode; -import dan200.computercraft.shared.util.NBTUtil; -import de.srendi.advancedperipherals.AdvancedPeripherals; -import de.srendi.advancedperipherals.common.util.LuaConverter; -import de.srendi.advancedperipherals.common.util.inventory.FluidFilter; -import de.srendi.advancedperipherals.common.util.inventory.ItemFilter; -import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; -import net.minecraft.core.NonNullList; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.material.Fluid; -import net.neoforged.neoforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; -import java.util.stream.Stream; - -public class RefinedStorage { - - public static RefinedStorage instance; - - private final IRSAPI api; - - public RefinedStorage() { - api = API.instance(); - initiate(); - } - - private static INetworkNode read(CompoundTag tag, NetworkNode node) { - node.read(tag); - return node; - } - - public static ItemStack findStackFromStack(INetwork network, @Nullable ICraftingManager crafting, ItemStack item) { - return findStackFromFilter(network, crafting, ItemFilter.fromStack(item)); - } - - public static ItemStack findStackFromFilter(INetwork network, @Nullable ICraftingManager crafting, ItemFilter filter) { - for (StackListEntry temp : network.getItemStorageCache().getList().getStacks()) { - if (filter.test(temp.getStack())) - return temp.getStack().copy(); - } - - if (crafting == null) - return ItemStack.EMPTY; - - for (ICraftingPattern pattern : crafting.getPatterns()) { - for(ItemStack stack : pattern.getOutputs()) { - if (filter.test(stack)) - return stack.copy(); - } - } - - return ItemStack.EMPTY; - } - - public static FluidStack findFluidFromStack(INetwork network, @Nullable ICraftingManager crafting, FluidStack stack) { - return findFluidFromFilter(network, crafting, FluidFilter.fromStack(stack)); - } - - public static FluidStack findFluidFromFilter(INetwork network, @Nullable ICraftingManager crafting, FluidFilter filter) { - for (StackListEntry temp : network.getFluidStorageCache().getList().getStacks()) { - if (filter.test(temp.getStack())) - return temp.getStack().copy(); - } - - if (crafting == null) - return FluidStack.EMPTY; - - for (ICraftingPattern pattern : crafting.getPatterns()) { - if (pattern.getFluidOutputs().stream().anyMatch(filter::test)) - return pattern.getFluidOutputs().stream().filter(filter::test).findFirst().orElse(FluidStack.EMPTY).copy(); - } - - return FluidStack.EMPTY; - } - - public static Object listFluids(INetwork network) { - List fluids = new ArrayList<>(); - getFluids(network).forEach(item -> fluids.add(getObjectFromFluid(item, network))); - return fluids; - } - - public static Object listItems(INetwork network) { - List items = new ArrayList<>(); - getItems(network).forEach(item -> items.add(getObjectFromStack(item, network))); - return items; - } - - public static boolean isItemCraftable(INetwork network, ItemStack stack) { - return network.getCraftingManager().getPattern(stack) != null; - } - - public static boolean isFluidCraftable(INetwork network, FluidStack stack) { - return network.getCraftingManager().getPattern(stack) != null; - } - - public static long getMaxItemDiskStorage(INetwork network) { - long total = 0; - boolean creative = false; - for (IStorage store : network.getItemStorageCache().getStorages()) { - if (store instanceof IStorageDisk storageDisk) { - int cap = storageDisk.getCapacity(); - if (cap > 0) total += cap; - else creative = true; - } - } - return creative ? -1 : total; - } - - public static long getMaxFluidDiskStorage(INetwork network) { - long total = 0; - boolean creative = false; - for (IStorage store : network.getFluidStorageCache().getStorages()) { - if (store instanceof IStorageDisk storageDisk) { - int cap = storageDisk.getCapacity(); - if (cap > 0) total += cap; - else creative = true; - } - } - return creative ? -1 : total; - } - - public static long getMaxItemExternalStorage(INetwork network) { - long total = 0; - for (IStorage store : network.getItemStorageCache().getStorages()) { - if (store instanceof IExternalStorage externalStorage) { - total += externalStorage.getCapacity(); - } - } - return total; - } - - public static long getMaxFluidExternalStorage(INetwork network) { - long total = 0; - for (IStorage store : network.getFluidStorageCache().getStorages()) { - if (store instanceof IExternalStorage externalStorage) { - total += externalStorage.getCapacity(); - } - } - return total; - } - - public static Object getObjectFromPattern(ICraftingPattern pattern, INetwork network) { - if (pattern == null) return null; - Map map = new HashMap<>(); - List outputsList = pattern.getOutputs(); - List outputs = new ArrayList<>(); - for (ItemStack itemStack : outputsList) - outputs.add(getObjectFromStack(itemStack, network)); - - map.put("outputs", outputs); - - List> inputList = pattern.getInputs(); - List inputs = new ArrayList<>(); - for (List singleInputList : inputList) { - List inputs1 = new ArrayList<>(); - for (ItemStack stack : singleInputList) - inputs1.add(getObjectFromStack(stack, network)); - inputs.add(inputs1); - } - - List byproducts = new ArrayList<>(); - if (!pattern.isProcessing()) { - List byproductsList = pattern.getByproducts(); - for (ItemStack stack : byproductsList) - byproducts.add(getObjectFromStack(stack, network)); - } - - map.put("inputs", inputs); - map.put("outputs", outputs); - map.put("byproducts", byproducts); - map.put("processing", pattern.isProcessing()); - return map; - } - - public static Map getObjectFromStack(@Nullable ItemStack itemStack, INetwork network) { - if (itemStack == null) - return Collections.emptyMap(); - - Map map = new HashMap<>(); - CompoundTag nbt = itemStack.getTag(); - Supplier>> tags = () -> itemStack.getItem().builtInRegistryHolder().tags(); - map.put("fingerprint", ItemUtil.getFingerprint(itemStack)); - map.put("name", ItemUtil.getRegistryKey(itemStack.getItem()).toString()); - map.put("amount", itemStack.getCount()); - map.put("displayName", itemStack.getDisplayName().getString()); - map.put("isCraftable", isItemCraftable(network, itemStack)); - map.put("nbt", nbt == null ? null : NBTUtil.toLua(nbt)); - map.put("tags", tags.get().findAny().isEmpty() ? null : LuaConverter.tagsToList(tags)); - - return map; - } - - public static Map getObjectFromFluid(@Nullable FluidStack fluidStack, INetwork network) { - if (fluidStack == null) - return Collections.emptyMap(); - - Map map = new HashMap<>(); - Supplier>> tags = () -> fluidStack.getFluid().builtInRegistryHolder().tags(); - map.put("name", BuiltInRegistries.FLUID.getKey(fluidStack.getFluid()).toString()); - map.put("amount", fluidStack.getAmount()); - map.put("displayName", fluidStack.getDisplayName().getString()); - map.put("isCraftable", isFluidCraftable(network, fluidStack)); - map.put("tags", tags.get().findAny().isEmpty() ? null : LuaConverter.tagsToList(tags)); - - return map; - } - - public static Object getItem(INetwork network, ItemStack item) { - for (ItemStack itemStack : getItems(network)) { - if (itemStack.is(item.getItem()) && Objects.equals(itemStack.getTag(), item.getTag())) - return getObjectFromStack(itemStack, network); - } - return null; - } - - public static List getCraftableItems(INetwork network) { - IStorageCache cache = network.getItemStorageCache(); - Collection> craftableEntries = cache.getCraftablesList().getStacks(); - List result = new ArrayList<>(craftableEntries.size()); - - for (StackListEntry entry : craftableEntries) { - result.add(entry.getStack().copy()); - } - - return result; - } - - public static List getCraftableFluids(INetwork network) { - IStorageCache cache = network.getFluidStorageCache(); - Collection> craftableEntries = cache.getCraftablesList().getStacks(); - List result = new ArrayList<>(craftableEntries.size()); - - for (StackListEntry entry : craftableEntries) - result.add(entry.getStack().copy()); - - return result; - } - - public static List getItems(INetwork network) { - IStorageCache cache = network.getItemStorageCache(); - Collection> entries = cache.getList().getStacks(); - List result = new ArrayList<>(entries.size()); - - for (StackListEntry entry : entries) - result.add(entry.getStack().copy()); - - return result; - } - - public static List getFluids(INetwork network) { - IStorageCache cache = network.getFluidStorageCache(); - Collection> entries = cache.getList().getStacks(); - List result = new ArrayList<>(entries.size()); - - for (StackListEntry entry : entries) - result.add(entry.getStack().copy()); - - return result; - } - - public void initiate() { - api.getNetworkNodeRegistry().add(new ResourceLocation(AdvancedPeripherals.MOD_ID, "rs_bridge"), (tag, world, pos) -> read(tag, new RefinedStorageNode(world, pos))); - } - - public IRSAPI getApi() { - return api; - } - -} diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorageNode.java b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorageNode.java deleted file mode 100644 index 6c19489de..000000000 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorageNode.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.srendi.advancedperipherals.common.addons.refinedstorage; - - -import com.refinedmods.refinedstorage.apiimpl.network.node.NetworkNode; -import de.srendi.advancedperipherals.AdvancedPeripherals; -import de.srendi.advancedperipherals.common.configuration.APConfig; -import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class RefinedStorageNode extends NetworkNode { - - public RefinedStorageNode(Level level, BlockPos pos) { - super(level, pos); - } - - @Override - public int getEnergyUsage() { - return APConfig.PERIPHERALS_CONFIG.rsConsumption.get(); - } - - @Override - public ResourceLocation getId() { - return new ResourceLocation(AdvancedPeripherals.MOD_ID, "rs_bridge"); - } - - @NotNull - @Override - public ItemStack getItemStack() { - return super.getItemStack(); - } -} diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsFluidHandler.java b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsFluidHandler.java deleted file mode 100644 index b099b9f6a..000000000 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsFluidHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.srendi.advancedperipherals.common.addons.refinedstorage; - -import com.refinedmods.refinedstorage.api.network.INetwork; -import com.refinedmods.refinedstorage.api.util.Action; -import com.refinedmods.refinedstorage.api.util.IComparer; -import de.srendi.advancedperipherals.common.util.inventory.FluidFilter; -import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemFluidHandler; -import net.neoforged.neoforge.fluids.FluidStack; -import org.jetbrains.annotations.NotNull; - -public class RsFluidHandler implements IStorageSystemFluidHandler { - - @NotNull - private final INetwork network; - - public RsFluidHandler(@NotNull INetwork network) { - this.network = network; - } - - @Override - public int fill(FluidStack resource, FluidAction action) { - if(resource.isEmpty()) - return 0; - return resource.getAmount() - network.insertFluid(resource, resource.getAmount(), action == FluidAction.SIMULATE ? Action.SIMULATE : Action.PERFORM).getAmount(); - } - - @NotNull - @Override - public FluidStack drain(FluidFilter filter, FluidAction simulate) { - FluidStack fluid = RefinedStorage.findFluidFromFilter(network, null, filter); - if(fluid == null) - return FluidStack.EMPTY; - return network.extractFluid(fluid, filter.getCount(), IComparer.COMPARE_QUANTITY, simulate == FluidAction.SIMULATE ? Action.SIMULATE : Action.PERFORM); - } -} diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsItemHandler.java b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsItemHandler.java deleted file mode 100644 index a95035903..000000000 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsItemHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.srendi.advancedperipherals.common.addons.refinedstorage; - -import com.refinedmods.refinedstorage.api.network.INetwork; -import com.refinedmods.refinedstorage.api.util.Action; -import com.refinedmods.refinedstorage.api.util.IComparer; -import de.srendi.advancedperipherals.AdvancedPeripherals; -import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemItemHandler; -import de.srendi.advancedperipherals.common.util.inventory.ItemFilter; -import net.minecraft.world.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -/** - * Used to transfer item between an inventory and the RS system. - * @see de.srendi.advancedperipherals.common.addons.computercraft.peripheral.RsBridgePeripheral - */ -public class RsItemHandler implements IStorageSystemItemHandler { - - @NotNull - private final INetwork network; - - public RsItemHandler(@NotNull INetwork network) { - this.network = network; - } - - @NotNull - @Override - public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { - return network.insertItem(stack, stack.getCount(), simulate ? Action.SIMULATE : Action.PERFORM); - } - - @Override - public ItemStack extractItem(ItemFilter filter, int count, boolean simulate) { - ItemStack item = RefinedStorage.findStackFromFilter(network, network.getCraftingManager(), filter); - AdvancedPeripherals.debug("Trying to extract item: " + item + " from filter: " + filter); - if(item == null) - return ItemStack.EMPTY; - ItemStack extracted = network.extractItem(item, count, IComparer.COMPARE_NBT, simulate ? Action.SIMULATE : Action.PERFORM); - AdvancedPeripherals.debug("Extracted item: " + extracted + " from filter: " + filter); - return extracted; - } - -} diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java index 5da7a86ff..b6b329096 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java @@ -6,7 +6,6 @@ import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.setup.BlockEntityTypes; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; @@ -29,9 +28,9 @@ public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState sta } @Override - public @NotNull InteractionResult use(@NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) { + public @NotNull InteractionResult useWithoutItem(@NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull BlockHitResult hit) { if (!APConfig.PERIPHERALS_CONFIG.enablePlayerDetector.get()) - return super.use(state, levelIn, pos, player, handIn, hit); + return super.useWithoutItem(state, levelIn, pos, player, hit); BlockEntity tileEntity = levelIn.getBlockEntity(pos); if (tileEntity instanceof PlayerDetectorEntity entity) { for (IComputerAccess computer : entity.getConnectedComputers()) { @@ -39,7 +38,7 @@ public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState sta } } - return super.use(state, levelIn, pos, player, handIn, hit); + return super.useWithoutItem(state, levelIn, pos, player, hit); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java index 5b54d510c..955424eac 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java @@ -7,7 +7,7 @@ import net.minecraft.world.Container; import net.minecraft.world.Containers; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; @@ -41,16 +41,16 @@ public BaseBlockEntityBlock(boolean belongToTickingEntity, Properties properties @NotNull @Override - public InteractionResult use(@NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) { - if (levelIn.isClientSide) return InteractionResult.SUCCESS; + public ItemInteractionResult useItemOn(@NotNull ItemStack stack, @NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) { + if (levelIn.isClientSide) return ItemInteractionResult.SUCCESS; BlockEntity tileEntity = levelIn.getBlockEntity(pos); - if (tileEntity != null && !(tileEntity instanceof IInventoryBlock)) return InteractionResult.PASS; + if (tileEntity != null && !(tileEntity instanceof IInventoryBlock)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; MenuProvider namedContainerProvider = this.getMenuProvider(state, levelIn, pos); if (namedContainerProvider != null) { - if (!(player instanceof ServerPlayer serverPlayerEntity)) return InteractionResult.PASS; + if (!(player instanceof ServerPlayer serverPlayerEntity)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; serverPlayerEntity.openMenu(namedContainerProvider, pos); } - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } @Override @@ -68,8 +68,8 @@ public void setPlacedBy(@NotNull Level worldIn, @NotNull BlockPos pos, @NotNull if (worldIn.getBlockEntity(pos) == null) return; //Used for the lua function getName() - if (stack.hasCustomHoverName() && worldIn.getBlockEntity(pos) instanceof BaseContainerBlockEntity blockEntity) { - blockEntity.setCustomName(stack.getHoverName()); + if (worldIn.getBlockEntity(pos) instanceof BaseContainerBlockEntity blockEntity) { + blockEntity.name = stack.getHoverName(); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java index d2cb59e16..90d9f0620 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java @@ -7,6 +7,7 @@ import de.srendi.advancedperipherals.lib.peripherals.IPeripheralTileEntity; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -95,17 +96,17 @@ public ITextComponent getDisplayName() { }*/ @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); - ContainerHelper.saveAllItems(compound, items); - if (!peripheralSettings.isEmpty()) compound.put(PERIPHERAL_SETTINGS_KEY, peripheralSettings); + protected void saveAdditional(@NotNull CompoundTag tag, @NotNull HolderLookup.Provider provider) { + super.saveAdditional(tag, provider); + ContainerHelper.saveAllItems(tag, items, provider); + if (!peripheralSettings.isEmpty()) tag.put(PERIPHERAL_SETTINGS_KEY, peripheralSettings); } @Override - public void load(@NotNull CompoundTag compound) { - ContainerHelper.loadAllItems(compound, items); - peripheralSettings = compound.getCompound(PERIPHERAL_SETTINGS_KEY); - super.load(compound); + protected void loadAdditional(@NotNull CompoundTag tag, @NotNull HolderLookup.Provider provider) { + ContainerHelper.loadAllItems(tag, items, provider); + peripheralSettings = tag.getCompound(PERIPHERAL_SETTINGS_KEY); + super.loadAdditional(tag, provider); } @Override @@ -125,7 +126,7 @@ protected AbstractContainerMenu createMenu(int id, @NotNull Inventory player) { } @Override - public int[] getSlotsForFace(@NotNull Direction side) { + public int @NotNull [] getSlotsForFace(@NotNull Direction side) { return new int[]{0}; } @@ -182,6 +183,17 @@ public void setItem(int index, @NotNull ItemStack stack) { } } + @NotNull + @Override + public NonNullList getItems() { + return items; + } + + @Override + public void setItems(@NotNull NonNullList items) { + this.items = items; + } + @Override public boolean stillValid(@NotNull Player player) { return true; diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java index e39242118..82ff21ba0 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java @@ -4,6 +4,7 @@ import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -28,15 +29,15 @@ public PoweredPeripheralBlockEntity(BlockEntityType tileEntityTypeIn, BlockPo protected abstract int getMaxEnergyStored(); @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); + public void saveAdditional(@NotNull CompoundTag compound, @NotNull HolderLookup.Provider provider) { + super.saveAdditional(compound, provider); if (energyStorage != null) compound.putInt("energy", energyStorage.getEnergyStored()); } @Override - public void load(@NotNull CompoundTag compound) { - super.load(compound); + public void loadAdditional(@NotNull CompoundTag compound, @NotNull HolderLookup.Provider provider) { + super.loadAdditional(compound, provider); if (energyStorage != null) energyStorage.receiveEnergy(compound.getInt("energy") - energyStorage.getEnergyStored(), false); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ColonyIntegratorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ColonyIntegratorEntity.java new file mode 100644 index 000000000..8c6504791 --- /dev/null +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ColonyIntegratorEntity.java @@ -0,0 +1,21 @@ +package de.srendi.advancedperipherals.common.blocks.blockentities; + +import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ColonyPeripheral; +import de.srendi.advancedperipherals.common.blocks.base.PeripheralBlockEntity; +import de.srendi.advancedperipherals.common.setup.BlockEntityTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; + +public class ColonyIntegratorEntity extends PeripheralBlockEntity { + + public ColonyIntegratorEntity(BlockPos pos, BlockState state) { + super(BlockEntityTypes.COLONY_INTEGRATOR.get(), pos, state); + } + + @NotNull + @Override + protected ColonyPeripheral createPeripheral() { + return new ColonyPeripheral(this); + } +} diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java index a523f7561..2e50c9252 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java @@ -7,6 +7,7 @@ import de.srendi.advancedperipherals.common.util.EnergyStorageProxy; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.JigsawBlock; @@ -57,9 +58,15 @@ public IEnergyStorage createEnergyStorageCap(@Nullable Direction direction) { } @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); - compound.putInt("rateLimit", storageProxy.getMaxTransferRate()); + protected void saveAdditional(@NotNull CompoundTag tag, @NotNull HolderLookup.Provider provider) { + tag.putInt("transferRate", transferRate); + super.saveAdditional(tag, provider); + } + + @Override + protected void loadAdditional(@NotNull CompoundTag tag, @NotNull HolderLookup.Provider provider) { + transferRate = tag.getInt("transferRate"); + super.loadAdditional(tag, provider); } @Override @@ -71,12 +78,6 @@ public void handleTick(Level level, BlockState state, Bl } } - @Override - public void deserializeNBT(CompoundTag nbt) { - storageProxy.setMaxTransferRate(nbt.getInt("rateLimit")); - super.deserializeNBT(nbt); - } - public void invalidateStorages() { outReceivingStorage = null; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java index 315745535..06f7b25cd 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java @@ -8,6 +8,7 @@ import de.srendi.advancedperipherals.common.setup.BlockEntityTypes; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; @@ -21,7 +22,7 @@ import java.util.UUID; -import static de.srendi.advancedperipherals.common.items.MemoryCardItem.OWNER_NBT_KEY; +import static de.srendi.advancedperipherals.common.setup.DataComponents.OWNER; public class InventoryManagerEntity extends PeripheralBlockEntity implements IInventoryBlock { @@ -55,9 +56,9 @@ public boolean canPlaceItemThroughFace(int index, @NotNull ItemStack itemStackIn @Override public void setItem(int index, @NotNull ItemStack stack) { if (stack.getItem() instanceof MemoryCardItem) { - if (stack.hasTag() && stack.getTag().contains(OWNER_NBT_KEY)) { - this.owner = stack.getTag().getUUID(OWNER_NBT_KEY); - stack.getTag().remove(OWNER_NBT_KEY); + if (stack.has(OWNER)) { + this.owner = stack.get(OWNER); + stack.remove(OWNER); } else if (stack != this.getItem(index)) { // Only clear owner when the new card item is not the current item this.owner = null; @@ -75,18 +76,16 @@ public Component getDisplayName() { } @Override - public void load(CompoundTag data) { + public void loadAdditional(CompoundTag data, @NotNull HolderLookup.Provider provider) { if (data.contains("ownerId")) { this.owner = data.getUUID("ownerId"); } - super.load(data); - // Fresh the memory card for backward compatibility - this.setItem(0, this.getItem(0)); + super.loadAdditional(data, provider); } @Override - public void saveAdditional(CompoundTag data) { - super.saveAdditional(data); + public void saveAdditional(@NotNull CompoundTag data, @NotNull HolderLookup.Provider provider) { + super.saveAdditional(data, provider); if (this.owner != null) { data.putUUID("ownerId", this.owner); } @@ -96,7 +95,6 @@ public Player getOwnerPlayer() { if (this.owner == null) { return null; } - Player player = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayer(this.owner); - return player; + return ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayer(this.owner); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java index 707fec188..758520d95 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java @@ -4,6 +4,7 @@ import de.srendi.advancedperipherals.common.blocks.base.PeripheralBlockEntity; import de.srendi.advancedperipherals.common.setup.BlockEntityTypes; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.NotNull; @@ -32,15 +33,15 @@ public void setStored(CompoundTag newStored) { } @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); + public void saveAdditional(@NotNull CompoundTag compound, HolderLookup.@NotNull Provider provider) { + super.saveAdditional(compound, provider); compound.put("storedData", stored); } @Override - public void load(@NotNull CompoundTag compound) { + public void loadAdditional(@NotNull CompoundTag compound, HolderLookup.@NotNull Provider provider) { stored = compound.getCompound("storedData"); - super.load(compound); + super.loadAdditional(compound, provider); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java index 1987a1bf0..2d8e9f829 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java @@ -7,6 +7,7 @@ import de.srendi.advancedperipherals.common.util.ServerWorker; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RedStoneWireBlock; @@ -62,16 +63,16 @@ public void setOutput(Direction direction, int power) { } @Override - public void load(@NotNull CompoundTag compound) { + public void loadAdditional(@NotNull CompoundTag compound, @NotNull HolderLookup.Provider provider) { for (Direction direction : Direction.values()) { setRedstoneOutput(direction, compound.getInt(direction.name() + "Power")); } - super.load(compound); + super.loadAdditional(compound, provider); } @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); + public void saveAdditional(@NotNull CompoundTag compound, @NotNull HolderLookup.Provider provider) { + super.saveAdditional(compound, provider); int i = 0; for (Direction direction : Direction.values()) { compound.putInt(direction.name() + "Power", power[i]); diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RsBridgeEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RsBridgeEntity.java deleted file mode 100644 index c0733ce7f..000000000 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RsBridgeEntity.java +++ /dev/null @@ -1,72 +0,0 @@ -package de.srendi.advancedperipherals.common.blocks.blockentities; - -import com.refinedmods.refinedstorage.api.network.node.INetworkNodeProxy; -import com.refinedmods.refinedstorage.blockentity.NetworkNodeBlockEntity; -import com.refinedmods.refinedstorage.blockentity.config.IRedstoneConfigurable; -import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec; -import dan200.computercraft.api.peripheral.IPeripheral; -import de.srendi.advancedperipherals.AdvancedPeripherals; -import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.RsBridgePeripheral; -import de.srendi.advancedperipherals.common.addons.refinedstorage.RefinedStorageNode; -import de.srendi.advancedperipherals.common.blocks.base.ICapabilityProvider; -import de.srendi.advancedperipherals.common.setup.BlockEntityTypes; -import de.srendi.advancedperipherals.lib.peripherals.IPeripheralTileEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class RsBridgeEntity extends NetworkNodeBlockEntity implements INetworkNodeProxy, IRedstoneConfigurable, IPeripheralTileEntity, ICapabilityProvider { - - private static final String PERIPHERAL_SETTINGS = "AP_SETTINGS"; - //I have no clue what this does, but it works - private static final BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder().build(); - protected CompoundTag peripheralSettings; - protected RsBridgePeripheral peripheral = new RsBridgePeripheral(this); - - public RsBridgeEntity(BlockPos pos, BlockState state) { - super(BlockEntityTypes.RS_BRIDGE.get(), pos, state, SPEC, null); - peripheralSettings = new CompoundTag(); - } - - @Nullable - @Override - public IPeripheral createPeripheralCap(@Nullable Direction side) { - if (peripheral.isEnabled()) { - return peripheral; - } else { - AdvancedPeripherals.debug(peripheral.getType() + " is disabled, you can enable it in the Configuration."); - return null; - } - } - - public RefinedStorageNode createNode(Level level, BlockPos blockPos) { - return new RefinedStorageNode(level, blockPos); - } - - @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); - if (!peripheralSettings.isEmpty()) compound.put(PERIPHERAL_SETTINGS, peripheralSettings); - } - - @Override - public void load(@NotNull CompoundTag compound) { - peripheralSettings = compound.getCompound(PERIPHERAL_SETTINGS); - super.load(compound); - } - - @Override - public CompoundTag getPeripheralSettings() { - return peripheralSettings; - } - - @Override - public void markSettingsChanged() { - setChanged(); - } - -} diff --git a/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java b/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java index 83db97245..b2ccf352f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java +++ b/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java @@ -5,7 +5,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.tree.LiteralCommandNode; import dan200.computercraft.core.computer.ComputerSide; -import dan200.computercraft.core.computer.Environment; import dan200.computercraft.shared.ModRegistry; import dan200.computercraft.shared.command.text.ChatHelpers; import dan200.computercraft.shared.command.text.TableBuilder; @@ -23,13 +22,13 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.server.level.ServerPlayer; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.RegisterCommandsEvent; import java.util.Comparator; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID) public class APCommands { public static final String ROOT_LITERAL = "advancedperipherals"; public static final String FORCELOAD_LITERAL = "forceload"; @@ -89,9 +88,8 @@ private static int forceloadDump(CommandSourceStack source) throws CommandSyntax TableBuilder table = new TableBuilder("ChunkyTurtles", "Computer", "Position"); ServerComputer[] computers = ServerContext.get(source.getServer()).registry().getComputers().stream().filter((computer) -> { - Environment env = computer.getComputer().getEnvironment(); for (ComputerSide side : ComputerSide.values()) { - if (env.getPeripheral(side) instanceof ChunkyPeripheral) { + if (computer.getPeripheral(side) instanceof ChunkyPeripheral) { return true; } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java b/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java index 5dab5ee3a..3ae818259 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java @@ -1,26 +1,23 @@ package de.srendi.advancedperipherals.common.configuration; -import com.electronwill.nightconfig.core.file.CommentedFileConfig; import net.neoforged.fml.ModContainer; import net.neoforged.fml.ModLoadingContext; -import net.neoforged.fml.config.ConfigFileTypeHandler; -import net.neoforged.fml.config.ModConfig; +import net.neoforged.fml.config.IConfigSpec; import net.neoforged.fml.loading.FMLPaths; -import java.nio.file.Path; -import java.util.function.Function; +import java.util.HashMap; +import java.util.Map; -public class APConfig extends ModConfig { +public class APConfig { - public static final ConfigFileHandler CONFIG_FILE_HANDLER = new ConfigFileHandler(); + private static final Map KNOWN_CONFIGS = new HashMap<>(); public static final GeneralConfig GENERAL_CONFIG = new GeneralConfig(); public static final PeripheralsConfig PERIPHERALS_CONFIG = new PeripheralsConfig(); public static final MetaphysicsConfig METAPHYSICS_CONFIG = new MetaphysicsConfig(); public static final WorldConfig WORLD_CONFIG = new WorldConfig(); - public APConfig(IAPConfig config, ModContainer container) { - super(config.getType(), config.getConfigSpec(), container, "Advancedperipherals/" + config.getFileName() + ".toml"); + public APConfig() { } public static void register(ModLoadingContext context) { @@ -28,34 +25,20 @@ public static void register(ModLoadingContext context) { FMLPaths.getOrCreateGameRelativePath(FMLPaths.CONFIGDIR.get().resolve("Advancedperipherals")); ModContainer modContainer = context.getActiveContainer(); - modContainer.addConfig(new APConfig(GENERAL_CONFIG, modContainer)); - modContainer.addConfig(new APConfig(PERIPHERALS_CONFIG, modContainer)); - modContainer.addConfig(new APConfig(METAPHYSICS_CONFIG, modContainer)); - modContainer.addConfig(new APConfig(WORLD_CONFIG, modContainer)); + APConfigHelper.registerConfig(KNOWN_CONFIGS, modContainer, GENERAL_CONFIG); + APConfigHelper.registerConfig(KNOWN_CONFIGS, modContainer, PERIPHERALS_CONFIG); + APConfigHelper.registerConfig(KNOWN_CONFIGS, modContainer, METAPHYSICS_CONFIG); + APConfigHelper.registerConfig(KNOWN_CONFIGS, modContainer, WORLD_CONFIG); } - /*@Override - public ConfigFileTypeHandler getHandler() { - return CONFIG_FILE_HANDLER; - }*/ - - public static class ConfigFileHandler extends ConfigFileTypeHandler { - - public static Path getPath(Path path) { - if (path.endsWith("serverconfig")) - return FMLPaths.CONFIGDIR.get(); - - return path; - } - - @Override - public Function reader(Path configBasePath) { - return super.reader(getPath(configBasePath)); + public static class APConfigHelper { + public static String getAPConfigFilePath(IAPConfig config) { + return "Advancedperipherals/" + config.getFileName() + ".toml"; } - @Override - public void unload(ModConfig config) { - super.unload(config); + public static void registerConfig(Map knownConfigs, ModContainer modContainer, IAPConfig config) { + modContainer.registerConfig(config.getType(), config.getConfigSpec(), APConfigHelper.getAPConfigFilePath(config)); + knownConfigs.put(config.getConfigSpec(), config); } } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerScreen.java b/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerScreen.java index e4d88e29c..12842db5a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerScreen.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerScreen.java @@ -24,6 +24,6 @@ public int getSizeY() { @Override public ResourceLocation getTexture() { - return new ResourceLocation(AdvancedPeripherals.MOD_ID, "textures/gui/inventory_manager_gui.png"); + return AdvancedPeripherals.getRL("textures/gui/inventory_manager_gui.png"); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java index 73eea6265..858040054 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java @@ -1,6 +1,7 @@ package de.srendi.advancedperipherals.common.data; import de.srendi.advancedperipherals.common.setup.Registration; +import net.minecraft.core.HolderLookup; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.level.block.Block; @@ -11,8 +12,8 @@ public class BlockLootTables extends BlockLootSubProvider { - protected BlockLootTables() { - super(Set.of(), FeatureFlags.REGISTRY.allFlags()); + protected BlockLootTables(HolderLookup.Provider provider) { + super(Set.of(), FeatureFlags.REGISTRY.allFlags(), provider); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java index d7ca829da..c64a6142a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java @@ -1,22 +1,24 @@ package de.srendi.advancedperipherals.common.data; import com.google.common.collect.ImmutableList; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.WritableRegistry; import net.minecraft.data.PackOutput; import net.minecraft.data.loot.LootTableProvider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ProblemReporter; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.ValidationContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import org.jetbrains.annotations.NotNull; import java.util.List; -import java.util.Map; import java.util.Set; +import java.util.concurrent.CompletableFuture; public class BlockLootTablesProvider extends LootTableProvider { - public BlockLootTablesProvider(PackOutput output) { - super(output, Set.of(), ImmutableList.of(new SubProviderEntry(BlockLootTables::new, LootContextParamSets.BLOCK))); + public BlockLootTablesProvider(PackOutput output, CompletableFuture lookupProvider) { + super(output, Set.of(), ImmutableList.of(new SubProviderEntry(BlockLootTables::new, LootContextParamSets.BLOCK)), lookupProvider); } @Override @@ -25,7 +27,7 @@ public BlockLootTablesProvider(PackOutput output) { } @Override - protected void validate(Map map, @NotNull ValidationContext validationtracker) { - map.forEach((id, table) -> table.validate(validationtracker)); + protected void validate(@NotNull WritableRegistry writableregistry, @NotNull ValidationContext validationcontext, ProblemReporter.@NotNull Collector collector) { + super.validate(writableregistry, validationcontext, collector); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java index 465c1fb84..abb69071b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java @@ -24,18 +24,23 @@ public BlockStatesAndModelsProvider(PackOutput packOutput, ExistingFileHelper ex @Override protected void registerStatesAndModels() { - peripheralBlock(Blocks.ENVIRONMENT_DETECTOR.get(), "front"); - peripheralBlock(Blocks.CHAT_BOX.get(), "front"); - peripheralBlock(Blocks.PLAYER_DETECTOR.get(), "side", "front"); - peripheralBlock(Blocks.ME_BRIDGE.get(), "front"); - peripheralBlock(Blocks.RS_BRIDGE.get(), "front"); - peripheralBlock(Blocks.ENERGY_DETECTOR.get(), "front", "back"); - peripheralBlock(Blocks.PERIPHERAL_CASING.get()); - peripheralBlock(Blocks.INVENTORY_MANAGER.get(), "front"); - peripheralBlock(Blocks.REDSTONE_INTEGRATOR.get(), "front"); + // Define blocks with specific sides and orientations + peripheralBlock(Blocks.ENVIRONMENT_DETECTOR.get(), "front", "top"); + peripheralBlock(Blocks.CHAT_BOX.get(), "front", "top"); + peripheralBlock(Blocks.ME_BRIDGE.get(), "front", "top"); + peripheralBlock(Blocks.ENERGY_DETECTOR.get(), "front", "back", "top", "east"); + peripheralBlock(Blocks.INVENTORY_MANAGER.get(), "front", "top"); + peripheralBlock(Blocks.GEO_SCANNER.get(), "front", "top"); + peripheralBlock(Blocks.COLONY_INTEGRATOR.get(), "front", "top"); + peripheralBlock(Blocks.NBT_STORAGE.get(), "front", "top"); + + // Define blocks with custom model generation + peripheralBlock(Blocks.PLAYER_DETECTOR.get(), generateModel(Blocks.PLAYER_DETECTOR.get(), false, "side", "front", "top")); + peripheralBlock(Blocks.REDSTONE_INTEGRATOR.get(), generateModel(Blocks.REDSTONE_INTEGRATOR.get(), false, "side", "front", "top", "bottom")); peripheralBlock(Blocks.BLOCK_READER.get(), generateModel(Blocks.BLOCK_READER.get(), false, "north", "south", "east", "west", "up", "down")); - peripheralBlock(Blocks.GEO_SCANNER.get(), "front"); - peripheralBlock(Blocks.NBT_STORAGE.get(), "front"); + + // Define a simple block with all sides having the same texture + peripheralBlock(Blocks.PERIPHERAL_CASING.get()); } private void peripheralBlock(Block block, ModelFile file) { @@ -80,6 +85,8 @@ private BlockModelBuilder generateModel(Block block, boolean hasNormalSide, Stri side = "north"; particleTexture = blockTexture(block, "front"); } + if (side.equals("top")) side = "up"; + if (side.equals("bottom")) side = "down"; if (side.equals("back")) side = "south"; builder.texture(side, blockTexture(block, sideTexture)); @@ -95,7 +102,7 @@ private BlockModelBuilder generateModel(Block block) { private ResourceLocation blockTexture(Block block, String offset) { ResourceLocation name = key(block); - return new ResourceLocation(name.getNamespace(), ModelProvider.BLOCK_FOLDER + "/" + name.getPath() + "_" + offset); + return ResourceLocation.fromNamespaceAndPath(name.getNamespace(), ModelProvider.BLOCK_FOLDER + "/" + name.getPath() + "_" + offset); } private ResourceLocation key(Block block) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java b/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java index 6999d3c71..fbbc3f82a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java @@ -1,20 +1,25 @@ package de.srendi.advancedperipherals.common.data; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.turtle.ITurtleUpgrade; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.setup.Registration; import net.minecraft.Util; import net.minecraft.core.HolderLookup; +import net.minecraft.core.RegistrySetBuilder; import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; +import net.minecraft.data.registries.RegistryPatchGenerator; import net.minecraft.data.registries.VanillaRegistries; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; import net.neoforged.neoforge.data.event.GatherDataEvent; import java.util.concurrent.CompletableFuture; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = EventBusSubscriber.Bus.MOD) public class DataGenerators { private DataGenerators() { @@ -25,13 +30,17 @@ public static void genData(GatherDataEvent event) { DataGenerator generator = event.getGenerator(); PackOutput packOutput = event.getGenerator().getPackOutput(); ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); + CompletableFuture lookupProvider = event.getLookupProvider(); CompletableFuture completablefuture = CompletableFuture.supplyAsync(VanillaRegistries::createLookup, Util.backgroundExecutor()); generator.addProvider(event.includeServer(), new BlockTagsProvider(packOutput, completablefuture, existingFileHelper, Registration.BLOCKS)); - generator.addProvider(event.includeServer(), new RecipesProvider(packOutput)); - generator.addProvider(event.includeServer(), new BlockLootTablesProvider(packOutput)); - generator.addProvider(event.includeServer(), new TurtleUpgradesProvider(packOutput)); - generator.addProvider(event.includeServer(), new PocketUpgradesProvider(packOutput)); + generator.addProvider(event.includeServer(), new RecipesProvider(packOutput, lookupProvider)); + generator.addProvider(event.includeServer(), new BlockLootTablesProvider(packOutput, lookupProvider)); + CompletableFuture fullRegistryPatch = RegistryPatchGenerator.createLookup(event.getLookupProvider(), Util.make(new RegistrySetBuilder(), (builder) -> { + builder.add(ITurtleUpgrade.REGISTRY, TurtleUpgradesProvider::addUpgrades); + builder.add(IPocketUpgrade.REGISTRY, PocketUpgradesProvider::addUpgrades); + })); + generator.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(packOutput, fullRegistryPatch, null)); generator.addProvider(event.includeServer(), new PoiTypeProvider(packOutput, completablefuture, existingFileHelper)); generator.addProvider(event.includeServer(), new BlockStatesAndModelsProvider(packOutput, existingFileHelper)); diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java index d54d04f2b..ed91f98d8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java @@ -54,12 +54,12 @@ private void addItems() { private void addBlocks() { addBlock(Blocks.BLOCK_READER, "Block Reader"); addBlock(Blocks.CHAT_BOX, "Chat Box"); + addBlock(Blocks.COLONY_INTEGRATOR, "Colony Integrator"); addBlock(Blocks.ENERGY_DETECTOR, "Energy Detector"); addBlock(Blocks.ENVIRONMENT_DETECTOR, "Environment Detector"); addBlock(Blocks.GEO_SCANNER, "Geo Scanner"); addBlock(Blocks.INVENTORY_MANAGER, "Inventory Manager"); addBlock(Blocks.ME_BRIDGE, "ME Bridge"); - addBlock(Blocks.RS_BRIDGE, "RS Bridge"); addBlock(Blocks.NBT_STORAGE, "NBT Storage"); addBlock(Blocks.PERIPHERAL_CASING, "Peripheral Casing"); addBlock(Blocks.PLAYER_DETECTOR, "Player Detector"); @@ -108,7 +108,6 @@ private void addTooltips() { addTooltip(Items.CHUNK_CONTROLLER.get(), "&7A crafting ingredient for the Chunky Turtle."); addTooltip(Blocks.ENVIRONMENT_DETECTOR.get(), "&7This peripheral interacts with the minecraft world."); addTooltip(Blocks.PLAYER_DETECTOR.get(), "&7This peripheral can be used to interact with players, but don't be a stalker."); - addTooltip(Blocks.RS_BRIDGE.get(), "&7The RS Bridge interacts with Refined Storage to manage your items."); addTooltip(Blocks.ME_BRIDGE.get(), "&7The ME Bridge interacts with Applied Energistics to manage your items."); addTooltip(Blocks.CHAT_BOX.get(), "&7Interacts with the ingame chat, can read and write messages."); addTooltip(Blocks.PERIPHERAL_CASING.get(), "&7An empty hull without the love it deserves. Used as a crafting ingredient"); @@ -118,6 +117,7 @@ private void addTooltips() { addTooltip(Blocks.REDSTONE_INTEGRATOR.get(), "&7This block is able to interact with redstone. Works exactly like the redstone api of an computer."); addTooltip(Blocks.BLOCK_READER.get(), "&7Reads nbt data of blocks to interact with blocks which do not have computer support."); addTooltip(Blocks.GEO_SCANNER.get(), "&7Scans the area around it to find some shiny ores."); + addTooltip(Blocks.COLONY_INTEGRATOR.get(), "&7Interacts with Minecolonies to read data about your colony and citizens."); addTooltip(Blocks.NBT_STORAGE.get(), "&7Acts like a storage disk. Can store nbt based data."); addTooltip(Items.WEAK_AUTOMATA_CORE.get(), "&7Upgrade for turtles, which makes turtles more useful."); addTooltip(Items.OVERPOWERED_WEAK_AUTOMATA_CORE.get(), "&7Improved version of the weak automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile."); diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java index 8e01dd26c..13d7e35f7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java @@ -1,25 +1,29 @@ package de.srendi.advancedperipherals.common.data; import dan200.computercraft.api.pocket.IPocketUpgrade; -import dan200.computercraft.api.pocket.PocketUpgradeDataProvider; -import dan200.computercraft.api.upgrades.UpgradeSerialiser; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketChatBoxUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketColonyIntegratorUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketEnvironmentUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketGeoScannerUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketPlayerDetectorUpgrade; import de.srendi.advancedperipherals.common.setup.Blocks; import de.srendi.advancedperipherals.common.setup.CCRegistration; -import net.minecraft.data.PackOutput; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; -import java.util.function.Consumer; +public class PocketUpgradesProvider { -public class PocketUpgradesProvider extends PocketUpgradeDataProvider { - - public PocketUpgradesProvider(PackOutput output) { - super(output); + public static void addUpgrades(BootstrapContext upgrades) { + upgrades.register(id(CCRegistration.ID.CHATTY_POCKET), new PocketChatBoxUpgrade(new ItemStack(Blocks.CHAT_BOX.get()))); + upgrades.register(id(CCRegistration.ID.PLAYER_POCKET), new PocketPlayerDetectorUpgrade(new ItemStack(Blocks.PLAYER_DETECTOR.get()))); + upgrades.register(id(CCRegistration.ID.ENVIRONMENT_POCKET), new PocketEnvironmentUpgrade(new ItemStack(Blocks.ENVIRONMENT_DETECTOR.get()))); + upgrades.register(id(CCRegistration.ID.GEOSCANNER_POCKET), new PocketGeoScannerUpgrade(new ItemStack(Blocks.GEO_SCANNER.get()))); + upgrades.register(id(CCRegistration.ID.COLONY_POCKET), new PocketColonyIntegratorUpgrade(new ItemStack(Blocks.COLONY_INTEGRATOR.get()))); } - @Override - protected void addUpgrades(Consumer>> consumer) { - simpleWithCustomItem(CCRegistration.ID.CHATTY_POCKET, CCRegistration.CHAT_BOX_POCKET.get(), Blocks.CHAT_BOX.get().asItem()).add(consumer); - simpleWithCustomItem(CCRegistration.ID.PLAYER_POCKET, CCRegistration.PLAYER_DETECTOR_POCKET.get(), Blocks.PLAYER_DETECTOR.get().asItem()).add(consumer); - simpleWithCustomItem(CCRegistration.ID.ENVIRONMENT_POCKET, CCRegistration.ENVIRONMENT_POCKET.get(), Blocks.ENVIRONMENT_DETECTOR.get().asItem()).add(consumer); - simpleWithCustomItem(CCRegistration.ID.GEOSCANNER_POCKET, CCRegistration.GEO_SCANNER_POCKET.get(), Blocks.GEO_SCANNER.get().asItem()).add(consumer); + public static ResourceKey id(ResourceLocation id) { + return ResourceKey.create(IPocketUpgrade.REGISTRY, id); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java index 8faf507c4..42af11920 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java @@ -1,11 +1,13 @@ package de.srendi.advancedperipherals.common.data; import appeng.core.definitions.AEBlocks; -import com.refinedmods.refinedstorage.RSBlocks; -import com.refinedmods.refinedstorage.RSItems; +import com.minecolonies.api.blocks.ModBlocks; +import com.minecolonies.api.items.ModItems; import dan200.computercraft.shared.ModRegistry; import de.srendi.advancedperipherals.common.addons.APAddons; import de.srendi.advancedperipherals.common.setup.Blocks; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; @@ -15,21 +17,22 @@ import net.minecraft.tags.ItemTags; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.PotionContents; import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.level.block.Block; import net.neoforged.neoforge.common.Tags; import net.neoforged.neoforge.common.conditions.IConditionBuilder; import net.neoforged.neoforge.common.conditions.ModLoadedCondition; -import net.neoforged.neoforge.common.crafting.NBTIngredient; + +import java.util.concurrent.CompletableFuture; public class RecipesProvider extends RecipeProvider implements IConditionBuilder { private static final Block CASING = Blocks.PERIPHERAL_CASING.get(); private static final String HAS_ITEM = "has_item"; - public RecipesProvider(PackOutput pGenerator) { - super(pGenerator); + public RecipesProvider(PackOutput pGenerator, CompletableFuture lookupProvider) { + super(pGenerator, lookupProvider); } @@ -49,7 +52,7 @@ protected void buildRecipes(RecipeOutput recipeOutput) { ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, Blocks.INVENTORY_MANAGER.get()).define('I', Tags.Items.INGOTS_IRON).define('C', Tags.Items.CHESTS).define('A', CASING).pattern("ICI").pattern("CAC").pattern("ICI").unlockedBy(HAS_ITEM, has(CASING)).save(recipeOutput); - ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, de.srendi.advancedperipherals.common.setup.Items.MEMORY_CARD.get()).define('I', Tags.Items.INGOTS_IRON).define('W', Tags.Items.GLASS_WHITE).define('O', Items.OBSERVER).define('G', Tags.Items.INGOTS_GOLD).pattern("IWI").pattern("IOI").pattern(" G ").unlockedBy(HAS_ITEM, has(Items.OBSERVER)).save(recipeOutput); + ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, de.srendi.advancedperipherals.common.setup.Items.MEMORY_CARD.get()).define('I', Tags.Items.INGOTS_IRON).define('W', Tags.Items.GLASS_BLOCKS_CHEAP).define('O', Items.OBSERVER).define('G', Tags.Items.INGOTS_GOLD).pattern("IWI").pattern("IOI").pattern(" G ").unlockedBy(HAS_ITEM, has(Items.OBSERVER)).save(recipeOutput); ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, Blocks.PERIPHERAL_CASING.get()).define('I', Tags.Items.INGOTS_IRON).define('i', Items.IRON_BARS).define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).pattern("IiI").pattern("iRi").pattern("IiI").unlockedBy(HAS_ITEM, has(Items.REDSTONE_BLOCK)).save(recipeOutput); @@ -65,9 +68,23 @@ protected void buildRecipes(RecipeOutput recipeOutput) { ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, Blocks.ME_BRIDGE.get()).define('F', AEBlocks.FLUIX_BLOCK.asItem()).define('A', CASING).define('I', AEBlocks.INTERFACE.asItem()).pattern("FIF").pattern("IAI").pattern("FIF").unlockedBy(HAS_ITEM, has(CASING)).save(recipeOutput.withConditions(new ModLoadedCondition(APAddons.AE2_MODID))); - ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, Blocks.RS_BRIDGE.get()).define('Q', RSItems.QUARTZ_ENRICHED_IRON.get()).define('A', CASING).define('I', RSBlocks.INTERFACE.get()).pattern("QIQ").pattern("IAI").pattern("QIQ").unlockedBy(HAS_ITEM, has(CASING)).save(recipeOutput.withConditions(new ModLoadedCondition(APAddons.REFINEDSTORAGE_MODID))); - - ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, de.srendi.advancedperipherals.common.setup.Items.WEAK_AUTOMATA_CORE.get()).define('A', CASING).define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).define('S', Items.SOUL_LANTERN).define('D', Tags.Items.GEMS_DIAMOND).define('L', NBTIngredient.of(true, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.LONG_REGENERATION))).pattern("RAR").pattern("DSD").pattern("RLR").unlockedBy(HAS_ITEM, has(CASING)).save(recipeOutput); + ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, Blocks.COLONY_INTEGRATOR.get()).define('O', ItemTags.LOGS).define('A', CASING).define('B', ModItems.buildGoggles).define('S', com.ldtteam.structurize.items.ModItems.buildTool).define('R', ModBlocks.blockRack).pattern("ORO").pattern("BAS").pattern("ORO").unlockedBy(HAS_ITEM, has(CASING)).save(recipeOutput.withConditions(new ModLoadedCondition(APAddons.MINECOLONIES_MODID))); + + ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, de.srendi.advancedperipherals.common.setup.Items.WEAK_AUTOMATA_CORE.get()) + .define('A', CASING) + .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) + .define('S', Items.SOUL_LANTERN) + .define('D', Tags.Items.GEMS_DIAMOND) + .define('L', () -> { + ItemStack potion = Items.POTION.getDefaultInstance(); + potion.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, Potions.LONG_REGENERATION, PotionContents::withPotion); + return potion.getItem(); + }) + .pattern("RAR") + .pattern("DSD") + .pattern("RLR") + .unlockedBy(HAS_ITEM, has(CASING)) + .save(recipeOutput); ShapelessRecipeBuilder.shapeless(RecipeCategory.REDSTONE, de.srendi.advancedperipherals.common.setup.Items.OVERPOWERED_WEAK_AUTOMATA_CORE.get()).requires(de.srendi.advancedperipherals.common.setup.Items.WEAK_AUTOMATA_CORE.get()).requires(Items.NETHER_STAR).unlockedBy(HAS_ITEM, has(de.srendi.advancedperipherals.common.setup.Items.WEAK_AUTOMATA_CORE.get())).save(recipeOutput); diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java index 7db008935..0366f9dea 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java @@ -1,37 +1,45 @@ package de.srendi.advancedperipherals.common.data; import dan200.computercraft.api.turtle.ITurtleUpgrade; -import dan200.computercraft.api.turtle.TurtleUpgradeDataProvider; -import dan200.computercraft.api.upgrades.UpgradeSerialiser; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleChatBoxUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleChunkyUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleCompassUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleEnvironmentDetectorUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleGeoScannerUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtlePlayerDetectorUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.EndAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.HusbandryAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.OverpoweredEndAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.OverpoweredHusbandryAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.OverpoweredWeakAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.WeakAutomata; import de.srendi.advancedperipherals.common.setup.Blocks; import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.common.setup.Items; -import net.minecraft.data.PackOutput; -import org.jetbrains.annotations.NotNull; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; -import java.util.function.Consumer; +public class TurtleUpgradesProvider { -public class TurtleUpgradesProvider extends TurtleUpgradeDataProvider { - - public TurtleUpgradesProvider(PackOutput generator) { - super(generator); + public static void addUpgrades(BootstrapContext upgrades) { + upgrades.register(id(CCRegistration.ID.CHATTY_TURTLE), new TurtleChatBoxUpgrade(new ItemStack(Blocks.CHAT_BOX.get()))); + upgrades.register(id(CCRegistration.ID.PLAYER_TURTLE), new TurtlePlayerDetectorUpgrade(new ItemStack(Blocks.PLAYER_DETECTOR.get()))); + upgrades.register(id(CCRegistration.ID.ENVIRONMENT_TURTLE), new TurtleEnvironmentDetectorUpgrade(new ItemStack(Blocks.ENVIRONMENT_DETECTOR.get()))); + upgrades.register(id(CCRegistration.ID.CHUNKY_TURTLE), new TurtleChunkyUpgrade(new ItemStack(Items.CHUNK_CONTROLLER))); + upgrades.register(id(CCRegistration.ID.GEOSCANNER_TURTLE), new TurtleGeoScannerUpgrade(new ItemStack(Blocks.GEO_SCANNER.get()))); + upgrades.register(id(CCRegistration.ID.COMPASS_TURTLE), new TurtleCompassUpgrade(new ItemStack(net.minecraft.world.item.Items.COMPASS))); + upgrades.register(id(CCRegistration.ID.WEAK_AUTOMATA), new WeakAutomata(new ItemStack(Items.WEAK_AUTOMATA_CORE.get()))); + upgrades.register(id(CCRegistration.ID.END_AUTOMATA), new EndAutomata(new ItemStack(Items.END_AUTOMATA_CORE.get()))); + upgrades.register(id(CCRegistration.ID.HUSBANDRY_AUTOMATA), new HusbandryAutomata(new ItemStack(Items.HUSBANDRY_AUTOMATA_CORE.get()))); + upgrades.register(id(CCRegistration.ID.OP_WEAK_AUTOMATA), new OverpoweredWeakAutomata(new ItemStack(Items.OVERPOWERED_WEAK_AUTOMATA_CORE.get()))); + upgrades.register(id(CCRegistration.ID.OP_END_AUTOMATA), new OverpoweredEndAutomata(new ItemStack(Items.OVERPOWERED_END_AUTOMATA_CORE.get()))); + upgrades.register(id(CCRegistration.ID.OP_HUSBANDRY_AUTOMATA), new OverpoweredHusbandryAutomata(new ItemStack(Items.OVERPOWERED_HUSBANDRY_AUTOMATA_CORE.get()))); } - @Override - protected void addUpgrades(@NotNull Consumer>> addUpgrade) { - simpleWithCustomItem(CCRegistration.ID.CHATTY_TURTLE, CCRegistration.CHAT_BOX_TURTLE.get(), Blocks.CHAT_BOX.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.PLAYER_TURTLE, CCRegistration.PLAYER_DETECTOR_TURTLE.get(), Blocks.PLAYER_DETECTOR.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.ENVIRONMENT_TURTLE, CCRegistration.ENVIRONMENT_TURTLE.get(), Blocks.ENVIRONMENT_DETECTOR.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.CHUNKY_TURTLE, CCRegistration.CHUNKY_TURTLE.get(), Items.CHUNK_CONTROLLER.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.GEOSCANNER_TURTLE, CCRegistration.GEO_SCANNER_TURTLE.get(), Blocks.GEO_SCANNER.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.COMPASS_TURTLE, CCRegistration.COMPASS_TURTLE.get(), net.minecraft.world.item.Items.COMPASS).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.WEAK_AUTOMATA, CCRegistration.WEAK_TURTLE.get(), Items.WEAK_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.END_AUTOMATA, CCRegistration.END_TURTLE.get(), Items.END_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.HUSBANDRY_AUTOMATA, CCRegistration.HUSBANDRY_TURTLE.get(), Items.HUSBANDRY_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.OP_WEAK_AUTOMATA, CCRegistration.OP_WEAK_TURTLE.get(), Items.OVERPOWERED_WEAK_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.OP_END_AUTOMATA, CCRegistration.OP_END_TURTLE.get(), Items.OVERPOWERED_END_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.OP_HUSBANDRY_AUTOMATA, CCRegistration.OP_HUSBANDRY_TURTLE.get(), Items.OVERPOWERED_HUSBANDRY_AUTOMATA_CORE.get()).add(addUpgrade); - + public static ResourceKey id(ResourceLocation id) { + return ITurtleUpgrade.createKey(id); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/events/Events.java b/src/main/java/de/srendi/advancedperipherals/common/events/Events.java index 68f90cd45..af8d1a6da 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/events/Events.java +++ b/src/main/java/de/srendi/advancedperipherals/common/events/Events.java @@ -4,26 +4,23 @@ import com.mojang.brigadier.context.CommandContextBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; import de.srendi.advancedperipherals.AdvancedPeripherals; -import de.srendi.advancedperipherals.common.addons.APAddons; import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.util.Pair; -import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.MessageArgument; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; +import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.CommandEvent; import net.neoforged.neoforge.event.ServerChatEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent; import java.util.function.Consumer; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.GAME) public class Events { private static final String PLAYED_BEFORE = "ap_played_before"; @@ -41,15 +38,14 @@ public static void onWorldJoin(PlayerEvent.PlayerLoggedInEvent event) { // We could switch to the advancement way to give new players the book. However, that would not allow us to create // a config option for that. So we will stick with the custom solution here. // See https://vazkiimods.github.io/Patchouli/docs/patchouli-basics/giving-new - if (APConfig.WORLD_CONFIG.givePlayerBookOnJoin.get() && APAddons.patchouliLoaded) { + //TODO + /*if (APConfig.WORLD_CONFIG.givePlayerBookOnJoin.get() && APAddons.patchouliLoaded) { if (!hasPlayedBefore(player)) { - ItemStack book = new ItemStack(ItemUtil.getRegistryEntry("patchouli:guide_book", BuiltInRegistries.ITEM)); - CompoundTag nbt = new CompoundTag(); - nbt.putString("patchouli:book", "advancedperipherals:manual"); - book.setTag(nbt); + PatchouliAPI.IPatchouliAPI patchouli = new PatchouliAPIImpl(); + ItemStack book = patchouli.getBookStack(AdvancedPeripherals.getRL("manual")); player.addItem(book); } - } + }*/ putPlayerMessage(Pair.of(getLastPlayerMessageID(), new PlayerMessageObject("playerJoin", player.getName().getString(), player.level().dimension().location().toString(), ""))); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java index 55ae94e96..e8df77656 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java @@ -5,7 +5,6 @@ import de.srendi.advancedperipherals.common.items.base.BaseItem; import de.srendi.advancedperipherals.common.util.EnumColor; import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; @@ -13,13 +12,13 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.List; -public class MemoryCardItem extends BaseItem { +import static de.srendi.advancedperipherals.common.setup.DataComponents.OWNER; - public static final String OWNER_NBT_KEY = "ownerId"; +public class MemoryCardItem extends BaseItem { public MemoryCardItem() { super(new Properties().stacksTo(1)); @@ -31,29 +30,27 @@ public boolean isEnabled() { } @Override - public void appendHoverText(ItemStack stack, @Nullable Level levelIn, List tooltip, TooltipFlag flagIn) { - super.appendHoverText(stack, levelIn, tooltip, flagIn); - CompoundTag data = stack.getOrCreateTag(); + public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext context, @NotNull List tooltip, @NotNull TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); Minecraft minecraft = Minecraft.getInstance(); - if (data.contains(OWNER_NBT_KEY)) { - String username = ClientUUIDCache.getUsername(data.getUUID(OWNER_NBT_KEY), minecraft.player.getUUID()); + if (stack.has(OWNER)) { + String username = ClientUUIDCache.getUsername(stack.get(OWNER), minecraft.player.getUUID()); if (username == null) - username = data.getUUID(OWNER_NBT_KEY).toString(); + username = stack.get(OWNER).toString(); tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.memory_card.bound", username))); } } @Override - public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { + public @NotNull InteractionResultHolder use(Level worldIn, @NotNull Player playerIn, @NotNull InteractionHand handIn) { if (!worldIn.isClientSide) { ItemStack stack = playerIn.getItemInHand(handIn); - CompoundTag data = stack.getOrCreateTag(); - if (data.contains(OWNER_NBT_KEY)) { + if (stack.has(OWNER)) { playerIn.displayClientMessage(Component.translatable("text.advancedperipherals.removed_player"), true); - data.remove(OWNER_NBT_KEY); + stack.remove(OWNER); } else { playerIn.displayClientMessage(Component.translatable("text.advancedperipherals.added_player"), true); - data.putUUID(OWNER_NBT_KEY, playerIn.getUUID()); + stack.set(OWNER, playerIn.getUUID()); } } return super.use(worldIn, playerIn, handIn); diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java b/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java index 15c11c67b..78bf97b1d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java @@ -16,21 +16,20 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import net.neoforged.neoforge.common.util.FakePlayer; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import static de.srendi.advancedperipherals.common.setup.DataComponents.CONSUMED_ENTITY_COMPOUND; + public class WeakAutomataCore extends APItem implements IFeedableAutomataCore { private static final String CONSUMED_ENTITY_COUNT = "consumed_entity_count"; private static final String CONSUMED_ENTITY_NAME = "consumed_entity_name"; - private static final String CONSUMER_ENTITY_COMPOUND = "consumed_entity_compound"; private static final Map AUTOMATA_CORE_REGISTRY = new HashMap<>(); static { @@ -57,15 +56,16 @@ public WeakAutomataCore() { } @Override - public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { - super.appendHoverText(stack, worldIn, tooltip, flagIn); - CompoundTag tag = stack.getOrCreateTag(); - CompoundTag consumedData = tag.getCompound(CONSUMER_ENTITY_COMPOUND); - consumedData.getAllKeys().forEach(key -> { - WeakAutomataCoreRecord record = AUTOMATA_CORE_REGISTRY.get(key); - CompoundTag recordData = consumedData.getCompound(key); - tooltip.add(EnumColor.buildTextComponent(Component.literal(String.format("Consumed: %d/%d %s", recordData.getInt(CONSUMED_ENTITY_COUNT), record.getRequiredCount(key), recordData.getString(CONSUMED_ENTITY_NAME))))); - }); + public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext context, @NotNull List tooltip, @NotNull TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); + + CompoundTag consumedData = stack.get(CONSUMED_ENTITY_COMPOUND.get()); + if (consumedData != null) + consumedData.getAllKeys().forEach(key -> { + WeakAutomataCoreRecord record = AUTOMATA_CORE_REGISTRY.get(key); + CompoundTag recordData = consumedData.getCompound(key); + tooltip.add(EnumColor.buildTextComponent(Component.literal(String.format("Consumed: %d/%d %s", recordData.getInt(CONSUMED_ENTITY_COUNT), record.getRequiredCount(key), recordData.getString(CONSUMED_ENTITY_NAME))))); + }); } @Override @@ -76,9 +76,11 @@ public InteractionResult interactLivingEntity(@NotNull ItemStack stack, @NotNull return InteractionResult.FAIL; } String entityType = EntityType.getKey(entity.getType()).toString(); + if (AUTOMATA_CORE_REGISTRY.containsKey(entityType)) { - CompoundTag tag = stack.getOrCreateTag(); - CompoundTag consumedData = tag.getCompound(CONSUMER_ENTITY_COMPOUND); + CompoundTag consumedData = stack.get(CONSUMED_ENTITY_COMPOUND) == null ? new CompoundTag() : stack.get(CONSUMED_ENTITY_COMPOUND); + if (consumedData == null) + return InteractionResult.PASS; WeakAutomataCoreRecord record; if (consumedData.isEmpty()) { record = AUTOMATA_CORE_REGISTRY.get(entityType); @@ -96,7 +98,7 @@ record = AUTOMATA_CORE_REGISTRY.get(anyKey.get()); if (record.isFinished(consumedData)) { player.setItemInHand(hand, new ItemStack(record.resultSoul)); } - tag.put(CONSUMER_ENTITY_COMPOUND, consumedData); + stack.set(CONSUMED_ENTITY_COMPOUND.get(), consumedData); return InteractionResult.SUCCESS; } return InteractionResult.PASS; diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java index 9f639ea1e..813d1eeff 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java @@ -8,10 +8,8 @@ import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.List; @@ -27,8 +25,8 @@ public BaseBlockItem(Block blockIn) { } @Override - public void appendHoverText(ItemStack stack, @Nullable Level levelIn, List tooltip, TooltipFlag flagIn) { - super.appendHoverText(stack, levelIn, tooltip, flagIn); + public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext context, @NotNull List tooltip, @NotNull TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); if (!KeybindUtil.isKeyPressed(KeyBindings.DESCRIPTION_KEYBINDING)) { tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.show_desc", KeyBindings.DESCRIPTION_KEYBINDING.getTranslatedKeyMessage()))); } else { diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java index 6f5c0afd8..2ee66dcff 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java @@ -15,7 +15,6 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.List; @@ -30,21 +29,24 @@ public BaseItem() { super(new Properties()); } + @NotNull @Override - public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { + public InteractionResultHolder use(Level worldIn, @NotNull Player playerIn, @NotNull InteractionHand handIn) { if (worldIn.isClientSide) return new InteractionResultHolder<>(InteractionResult.PASS, playerIn.getItemInHand(handIn)); if (this instanceof IInventoryItem inventoryItem) { ServerPlayer serverPlayerEntity = (ServerPlayer) playerIn; ItemStack stack = playerIn.getItemInHand(handIn); - serverPlayerEntity.openMenu(inventoryItem.createContainer(playerIn, stack), buf -> buf.writeItem(stack)); + serverPlayerEntity.openMenu(inventoryItem.createContainer(playerIn, stack), buf -> { + ItemStack.STREAM_CODEC.encode(buf, stack); + }); } return super.use(worldIn, playerIn, handIn); } @Override - public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { - super.appendHoverText(stack, worldIn, tooltip, flagIn); + public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext context, @NotNull List tooltip, @NotNull TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); if (!KeybindUtil.isKeyPressed(KeyBindings.DESCRIPTION_KEYBINDING)) { tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.show_desc", KeyBindings.DESCRIPTION_KEYBINDING.getTranslatedKeyMessage()))); } else { @@ -54,8 +56,8 @@ public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List, BlockEntityType> ENVIRONMENT_DETECTOR = Registration.BLOCK_ENTITIES.register("environment_detector", () -> new BlockEntityType<>(EnvironmentDetectorEntity::new, Sets.newHashSet(Blocks.ENVIRONMENT_DETECTOR.get()), null)); public static final DeferredHolder, BlockEntityType> PLAYER_DETECTOR = Registration.BLOCK_ENTITIES.register("player_detector", () -> new BlockEntityType<>(PlayerDetectorEntity::new, Sets.newHashSet(Blocks.PLAYER_DETECTOR.get()), null)); public static final DeferredHolder, BlockEntityType> ME_BRIDGE = APAddons.ae2Loaded ? Registration.BLOCK_ENTITIES.register("me_bridge", () -> new BlockEntityType<>(MeBridgeEntity::new, Sets.newHashSet(Blocks.ME_BRIDGE.get()), null)) : null; - public static final DeferredHolder, BlockEntityType> RS_BRIDGE = APAddons.refinedStorageLoaded ? Registration.BLOCK_ENTITIES.register("rs_bridge", () -> new BlockEntityType<>(RsBridgeEntity::new, Sets.newHashSet(Blocks.RS_BRIDGE.get()), null)) : null; public static final DeferredHolder, BlockEntityType> ENERGY_DETECTOR = Registration.BLOCK_ENTITIES.register("energy_detector", () -> new BlockEntityType<>(EnergyDetectorEntity::new, Sets.newHashSet(Blocks.ENERGY_DETECTOR.get()), null)); public static final DeferredHolder, BlockEntityType> INVENTORY_MANAGER = Registration.BLOCK_ENTITIES.register("inventory_manager", () -> new BlockEntityType<>(InventoryManagerEntity::new, Sets.newHashSet(Blocks.INVENTORY_MANAGER.get()), null)); public static final DeferredHolder, BlockEntityType> REDSTONE_INTEGRATOR = Registration.BLOCK_ENTITIES.register("redstone_integrator", () -> new BlockEntityType<>(RedstoneIntegratorEntity::new, Sets.newHashSet(Blocks.REDSTONE_INTEGRATOR.get()), null)); + public static final DeferredHolder, BlockEntityType> COLONY_INTEGRATOR = Registration.BLOCK_ENTITIES.register("colony_integrator", () -> new BlockEntityType<>(ColonyIntegratorEntity::new, Sets.newHashSet(Blocks.COLONY_INTEGRATOR.get()), null)); public static final DeferredHolder, BlockEntityType> BLOCK_READER = Registration.BLOCK_ENTITIES.register("block_reader", () -> new BlockEntityType<>(BlockReaderEntity::new, Sets.newHashSet(Blocks.BLOCK_READER.get()), null)); public static final DeferredHolder, BlockEntityType> GEO_SCANNER = Registration.BLOCK_ENTITIES.register("geo_scanner", () -> new BlockEntityType<>(GeoScannerEntity::new, Sets.newHashSet(Blocks.GEO_SCANNER.get()), null)); public static final DeferredHolder, BlockEntityType> NBT_STORAGE = Registration.BLOCK_ENTITIES.register("nbt_storage", () -> new BlockEntityType<>(NBTStorageEntity::new, Sets.newHashSet(Blocks.NBT_STORAGE.get()), null)); diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/Blocks.java b/src/main/java/de/srendi/advancedperipherals/common/setup/Blocks.java index c00fb2a3d..52de7d557 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/Blocks.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/Blocks.java @@ -23,7 +23,6 @@ public class Blocks { public static final DeferredHolder> CHAT_BOX = register("chat_box", () -> new APBlockEntityBlock<>(BlockEntityTypes.CHAT_BOX, true), () -> new APBlockItem(Blocks.CHAT_BOX.get(), APConfig.PERIPHERALS_CONFIG.enableChatBox::get)); public static final DeferredHolder> PLAYER_DETECTOR = register("player_detector", PlayerDetectorBlock::new, () -> new APBlockItem(Blocks.PLAYER_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enablePlayerDetector::get)); public static final DeferredHolder> ME_BRIDGE = register("me_bridge", () -> new APBlockEntityBlock<>(APAddons.ae2Loaded ? BlockEntityTypes.ME_BRIDGE : null, APAddons.ae2Loaded), () -> new APBlockItem(Blocks.ME_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableMEBridge::get)); - public static final DeferredHolder> RS_BRIDGE = register("rs_bridge", () -> new APBlockEntityBlock<>(APAddons.refinedStorageLoaded ? BlockEntityTypes.RS_BRIDGE : null, false), () -> new APBlockItem(Blocks.RS_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableRSBridge::get)); public static final DeferredHolder> ENERGY_DETECTOR = register("energy_detector", () -> new APBlockEntityBlock<>(BlockEntityTypes.ENERGY_DETECTOR, true), () -> new APBlockItem(Blocks.ENERGY_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableEnergyDetector::get)); public static final DeferredHolder PERIPHERAL_CASING = register("peripheral_casing", BaseBlock::new, () -> new APBlockItem(Blocks.PERIPHERAL_CASING.get(), new Item.Properties().stacksTo(16), () -> true)); public static final DeferredHolder> INVENTORY_MANAGER = register("inventory_manager", () -> new APBlockEntityBlock<>(BlockEntityTypes.INVENTORY_MANAGER, false), () -> new APBlockItem(Blocks.INVENTORY_MANAGER.get(), APConfig.PERIPHERALS_CONFIG.enableInventoryManager::get)); @@ -31,6 +30,7 @@ public class Blocks { public static final DeferredHolder> BLOCK_READER = register("block_reader", () -> new APBlockEntityBlock<>(BlockEntityTypes.BLOCK_READER, true), () -> new APBlockItem(Blocks.BLOCK_READER.get(), APConfig.PERIPHERALS_CONFIG.enableBlockReader::get)); public static final DeferredHolder> GEO_SCANNER = register("geo_scanner", () -> new APBlockEntityBlock<>(BlockEntityTypes.GEO_SCANNER, false), () -> new APBlockItem(Blocks.GEO_SCANNER.get(), APConfig.PERIPHERALS_CONFIG.enableGeoScanner::get)); public static final DeferredHolder> NBT_STORAGE = register("nbt_storage", () -> new APBlockEntityBlock<>(BlockEntityTypes.NBT_STORAGE, false), () -> new APBlockItem(Blocks.NBT_STORAGE.get(), APConfig.PERIPHERALS_CONFIG.enableNBTStorage::get)); + public static final DeferredHolder> COLONY_INTEGRATOR = register("colony_integrator", () -> new APBlockEntityBlock<>(BlockEntityTypes.COLONY_INTEGRATOR, false), () -> new APBlockItem(Blocks.COLONY_INTEGRATOR.get(), APConfig.PERIPHERALS_CONFIG.enableColonyIntegrator::get)); public static void register() { } diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java b/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java index 0b5a89c89..6fb2bb3f1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java @@ -2,10 +2,11 @@ import dan200.computercraft.api.pocket.IPocketUpgrade; import dan200.computercraft.api.turtle.ITurtleUpgrade; -import dan200.computercraft.api.upgrades.UpgradeSerialiser; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.integrations.IntegrationPeripheralProvider; import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketChatBoxUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketColonyIntegratorUpgrade; import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketEnvironmentUpgrade; import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketGeoScannerUpgrade; import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketPlayerDetectorUpgrade; @@ -26,23 +27,24 @@ public class CCRegistration { - public static final DeferredHolder, UpgradeSerialiser> CHAT_BOX_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.CHATTY_TURTLE.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(TurtleChatBoxUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> PLAYER_DETECTOR_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.PLAYER_TURTLE.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(TurtlePlayerDetectorUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> ENVIRONMENT_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.ENVIRONMENT_TURTLE.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(TurtleEnvironmentDetectorUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> CHUNKY_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.CHUNKY_TURTLE.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(TurtleChunkyUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> GEO_SCANNER_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.GEOSCANNER_TURTLE.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(TurtleGeoScannerUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> COMPASS_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.COMPASS_TURTLE.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(TurtleCompassUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> WEAK_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.WEAK_AUTOMATA.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(WeakAutomata::new)); - public static final DeferredHolder, UpgradeSerialiser> END_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.END_AUTOMATA.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(EndAutomata::new)); - public static final DeferredHolder, UpgradeSerialiser> HUSBANDRY_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.HUSBANDRY_AUTOMATA.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(HusbandryAutomata::new)); - public static final DeferredHolder, UpgradeSerialiser> OP_WEAK_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.OP_WEAK_AUTOMATA.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(OverpoweredWeakAutomata::new)); - public static final DeferredHolder, UpgradeSerialiser> OP_END_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.OP_END_AUTOMATA.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(OverpoweredEndAutomata::new)); - public static final DeferredHolder, UpgradeSerialiser> OP_HUSBANDRY_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.OP_HUSBANDRY_AUTOMATA.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(OverpoweredHusbandryAutomata::new)); + public static final DeferredHolder, UpgradeType> CHAT_BOX_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.CHATTY_TURTLE.getPath(), () -> UpgradeType.simpleWithCustomItem(TurtleChatBoxUpgrade::new)); + public static final DeferredHolder, UpgradeType> PLAYER_DETECTOR_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.PLAYER_TURTLE.getPath(), () -> UpgradeType.simpleWithCustomItem(TurtlePlayerDetectorUpgrade::new)); + public static final DeferredHolder, UpgradeType> ENVIRONMENT_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.ENVIRONMENT_TURTLE.getPath(), () -> UpgradeType.simpleWithCustomItem(TurtleEnvironmentDetectorUpgrade::new)); + public static final DeferredHolder, UpgradeType> CHUNKY_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.CHUNKY_TURTLE.getPath(), () -> UpgradeType.simpleWithCustomItem(TurtleChunkyUpgrade::new)); + public static final DeferredHolder, UpgradeType> GEO_SCANNER_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.GEOSCANNER_TURTLE.getPath(), () -> UpgradeType.simpleWithCustomItem(TurtleGeoScannerUpgrade::new)); + public static final DeferredHolder, UpgradeType> COMPASS_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.COMPASS_TURTLE.getPath(), () -> UpgradeType.simpleWithCustomItem(TurtleCompassUpgrade::new)); + public static final DeferredHolder, UpgradeType> WEAK_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.WEAK_AUTOMATA.getPath(), () -> UpgradeType.simpleWithCustomItem(WeakAutomata::new)); + public static final DeferredHolder, UpgradeType> END_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.END_AUTOMATA.getPath(), () -> UpgradeType.simpleWithCustomItem(EndAutomata::new)); + public static final DeferredHolder, UpgradeType> HUSBANDRY_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.HUSBANDRY_AUTOMATA.getPath(), () -> UpgradeType.simpleWithCustomItem(HusbandryAutomata::new)); + public static final DeferredHolder, UpgradeType> OP_WEAK_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.OP_WEAK_AUTOMATA.getPath(), () -> UpgradeType.simpleWithCustomItem(OverpoweredWeakAutomata::new)); + public static final DeferredHolder, UpgradeType> OP_END_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.OP_END_AUTOMATA.getPath(), () -> UpgradeType.simpleWithCustomItem(OverpoweredEndAutomata::new)); + public static final DeferredHolder, UpgradeType> OP_HUSBANDRY_TURTLE = Registration.TURTLE_SERIALIZER.register(ID.OP_HUSBANDRY_AUTOMATA.getPath(), () -> UpgradeType.simpleWithCustomItem(OverpoweredHusbandryAutomata::new)); - public static final DeferredHolder, UpgradeSerialiser> CHAT_BOX_POCKET = Registration.POCKET_SERIALIZER.register(ID.CHATTY_POCKET.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(PocketChatBoxUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> PLAYER_DETECTOR_POCKET = Registration.POCKET_SERIALIZER.register(ID.PLAYER_POCKET.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(PocketPlayerDetectorUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> ENVIRONMENT_POCKET = Registration.POCKET_SERIALIZER.register(ID.ENVIRONMENT_POCKET.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(PocketEnvironmentUpgrade::new)); - public static final DeferredHolder, UpgradeSerialiser> GEO_SCANNER_POCKET = Registration.POCKET_SERIALIZER.register(ID.GEOSCANNER_POCKET.getPath(), () -> UpgradeSerialiser.simpleWithCustomItem(PocketGeoScannerUpgrade::new)); + public static final DeferredHolder, UpgradeType> CHAT_BOX_POCKET = Registration.POCKET_SERIALIZER.register(ID.CHATTY_POCKET.getPath(), () -> UpgradeType.simpleWithCustomItem(PocketChatBoxUpgrade::new)); + public static final DeferredHolder, UpgradeType> PLAYER_DETECTOR_POCKET = Registration.POCKET_SERIALIZER.register(ID.PLAYER_POCKET.getPath(), () -> UpgradeType.simpleWithCustomItem(PocketPlayerDetectorUpgrade::new)); + public static final DeferredHolder, UpgradeType> ENVIRONMENT_POCKET = Registration.POCKET_SERIALIZER.register(ID.ENVIRONMENT_POCKET.getPath(), () -> UpgradeType.simpleWithCustomItem(PocketEnvironmentUpgrade::new)); + public static final DeferredHolder, UpgradeType> GEO_SCANNER_POCKET = Registration.POCKET_SERIALIZER.register(ID.GEOSCANNER_POCKET.getPath(), () -> UpgradeType.simpleWithCustomItem(PocketGeoScannerUpgrade::new)); + public static final DeferredHolder, UpgradeType> COLONY_POCKET = Registration.POCKET_SERIALIZER.register(ID.COLONY_POCKET.getPath(), () -> UpgradeType.simpleWithCustomItem(PocketColonyIntegratorUpgrade::new)); public static IntegrationPeripheralProvider integrationPeripheralProvider; @@ -54,24 +56,24 @@ public static void register() { public static class ID { - public static final ResourceLocation CHATTY_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "chatty_turtle"); - public static final ResourceLocation PLAYER_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "player_turtle"); - public static final ResourceLocation ENVIRONMENT_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "environment_turtle"); - public static final ResourceLocation CHUNKY_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "chunky_turtle"); - public static final ResourceLocation GEOSCANNER_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "geoscanner_turtle"); - public static final ResourceLocation COMPASS_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "compass_turtle"); - public static final ResourceLocation WEAK_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "weak_automata"); - public static final ResourceLocation END_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "end_automata"); - public static final ResourceLocation HUSBANDRY_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "husbandry_automata"); - public static final ResourceLocation OP_WEAK_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "overpowered_weak_automata"); - public static final ResourceLocation OP_END_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "overpowered_end_automata"); - public static final ResourceLocation OP_HUSBANDRY_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "overpowered_husbandry_automata"); + public static final ResourceLocation CHATTY_TURTLE = AdvancedPeripherals.getRL("chatty_turtle"); + public static final ResourceLocation PLAYER_TURTLE = AdvancedPeripherals.getRL("player_turtle"); + public static final ResourceLocation ENVIRONMENT_TURTLE = AdvancedPeripherals.getRL("environment_turtle"); + public static final ResourceLocation CHUNKY_TURTLE = AdvancedPeripherals.getRL("chunky_turtle"); + public static final ResourceLocation GEOSCANNER_TURTLE = AdvancedPeripherals.getRL("geoscanner_turtle"); + public static final ResourceLocation COMPASS_TURTLE = AdvancedPeripherals.getRL("compass_turtle"); + public static final ResourceLocation WEAK_AUTOMATA = AdvancedPeripherals.getRL("weak_automata"); + public static final ResourceLocation END_AUTOMATA = AdvancedPeripherals.getRL("end_automata"); + public static final ResourceLocation HUSBANDRY_AUTOMATA = AdvancedPeripherals.getRL("husbandry_automata"); + public static final ResourceLocation OP_WEAK_AUTOMATA = AdvancedPeripherals.getRL("overpowered_weak_automata"); + public static final ResourceLocation OP_END_AUTOMATA = AdvancedPeripherals.getRL("overpowered_end_automata"); + public static final ResourceLocation OP_HUSBANDRY_AUTOMATA = AdvancedPeripherals.getRL("overpowered_husbandry_automata"); - public static final ResourceLocation CHATTY_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "chatty_pocket"); - public static final ResourceLocation PLAYER_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "player_pocket"); - public static final ResourceLocation ENVIRONMENT_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "environment_pocket"); - public static final ResourceLocation GEOSCANNER_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "geoscanner_pocket"); - public static final ResourceLocation COLONY_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "colony_pocket"); + public static final ResourceLocation CHATTY_POCKET = AdvancedPeripherals.getRL("chatty_pocket"); + public static final ResourceLocation PLAYER_POCKET = AdvancedPeripherals.getRL("player_pocket"); + public static final ResourceLocation ENVIRONMENT_POCKET = AdvancedPeripherals.getRL("environment_pocket"); + public static final ResourceLocation GEOSCANNER_POCKET = AdvancedPeripherals.getRL("geoscanner_pocket"); + public static final ResourceLocation COLONY_POCKET = AdvancedPeripherals.getRL("colony_pocket"); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/DataComponents.java b/src/main/java/de/srendi/advancedperipherals/common/setup/DataComponents.java new file mode 100644 index 000000000..ef612b4bb --- /dev/null +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/DataComponents.java @@ -0,0 +1,92 @@ +package de.srendi.advancedperipherals.common.setup; + +import com.mojang.serialization.Codec; +import net.minecraft.core.Registry; +import net.minecraft.core.UUIDUtil; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentSerialization; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.ExtraCodecs; +import net.neoforged.neoforge.registries.DeferredHolder; + +import java.util.UUID; +import java.util.function.UnaryOperator; + +public class DataComponents { + + public static final DeferredHolder, DataComponentType> TURTLE_UPGRADE_STORED_DATA = registerDataComponent("stored_data"); + public static final DeferredHolder, DataComponentType> ABILITY_COOLDOWN = registerDataComponent("cooldowns"); + public static final DeferredHolder, DataComponentType> OWNER = registerUUID("owner_id"); + public static final DeferredHolder, DataComponentType> CHUNKY_ID = registerUUID("chunky_id"); + public static final DeferredHolder, DataComponentType> ROTATION_CHARGE_SETTING = registerInt("rotation_charge_setting"); + public static final DeferredHolder, DataComponentType> FUEL_CONSUMPTION_RATE = registerInt("fuel_consumption_rate"); + public static final DeferredHolder, DataComponentType> ENTITY_TRANSFER = registerNBT("entity_transfer"); + public static final DeferredHolder, DataComponentType> WORLD_DATA_MARK = registerString("world_data_mark"); + public static final DeferredHolder, DataComponentType> POINT_DATA_MARK = registerNBT("point_data_mark"); + public static final DeferredHolder, DataComponentType> CONSUMED_ENTITY_COMPOUND = registerNBT("consumed_entity_compound"); + + public static final DeferredHolder, DataComponentType> SIMPLE_FREE_OPERATION = registerLong("free_operation_cooldown"); + public static final DeferredHolder, DataComponentType> SINGLE_OPERATION = registerLong("single_operation"); + public static final DeferredHolder, DataComponentType> SPHERE_OPERATION = registerLong("sphere_operation"); + + public static void register() { + } + + private static DeferredHolder, DataComponentType> simple(String name, UnaryOperator> operator) { + return Registration.DATA_COMPONENT_TYPES.register(name, () -> operator.apply(DataComponentType.builder()).build()); + } + + private static DeferredHolder, DataComponentType> registerBoolean(String name) { + return simple(name, builder -> builder.persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL)); + } + + private static DeferredHolder, DataComponentType> registerString(String name) { + return simple(name, builder -> builder.persistent(Codec.STRING) + .networkSynchronized(ByteBufCodecs.STRING_UTF8)); + } + + private static DeferredHolder, DataComponentType> registerDataComponent(String name) { + return simple(name, builder -> builder.persistent(DataComponentPatch.CODEC) + .networkSynchronized(DataComponentPatch.STREAM_CODEC)); + } + + private static DeferredHolder, DataComponentType> registerNonNegativeInt(String name) { + return simple(name, builder -> builder.persistent(ExtraCodecs.POSITIVE_INT) + .networkSynchronized(ByteBufCodecs.VAR_INT)); + } + + private static DeferredHolder, DataComponentType> registerInt(String name) { + return simple(name, builder -> builder.persistent(Codec.INT) + .networkSynchronized(ByteBufCodecs.VAR_INT)); + } + + private static DeferredHolder, DataComponentType> registerLong(String name) { + return simple(name, builder -> builder.persistent(Codec.LONG) + .networkSynchronized(ByteBufCodecs.VAR_LONG)); + } + + private static DeferredHolder, DataComponentType> registerUUID(String name) { + return simple(name, builder -> builder.persistent(UUIDUtil.CODEC) + .networkSynchronized(UUIDUtil.STREAM_CODEC)); + } + + private static DeferredHolder, DataComponentType> registerNBT(String name) { + return simple(name, builder -> builder.persistent(CompoundTag.CODEC)); + } + + private static DeferredHolder, DataComponentType> registerComponent(String name) { + return simple(name, builder -> builder.persistent(ComponentSerialization.FLAT_CODEC) + .networkSynchronized(ComponentSerialization.STREAM_CODEC) + .cacheEncoding()); + } + + private static DeferredHolder, DataComponentType>> registerResourceKey(String name, ResourceKey> registryKey) { + return simple(name, builder -> builder.persistent(ResourceKey.codec(registryKey)) + .networkSynchronized(ResourceKey.streamCodec(registryKey))); + } +} diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/Registration.java b/src/main/java/de/srendi/advancedperipherals/common/setup/Registration.java index 80c8e0a63..ede366592 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/Registration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/Registration.java @@ -2,8 +2,9 @@ import dan200.computercraft.api.pocket.IPocketUpgrade; import dan200.computercraft.api.turtle.ITurtleUpgrade; -import dan200.computercraft.api.upgrades.UpgradeSerialiser; +import dan200.computercraft.api.upgrades.UpgradeType; import de.srendi.advancedperipherals.AdvancedPeripherals; +import net.minecraft.core.component.DataComponentType; import net.minecraft.core.registries.Registries; import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.entity.npc.VillagerProfession; @@ -21,9 +22,10 @@ public class Registration { public static final DeferredRegister> CONTAINER_TYPES = DeferredRegister.create(Registries.MENU, AdvancedPeripherals.MOD_ID); public static final DeferredRegister POI_TYPES = DeferredRegister.create(Registries.POINT_OF_INTEREST_TYPE, AdvancedPeripherals.MOD_ID); public static final DeferredRegister VILLAGER_PROFESSIONS = DeferredRegister.create(Registries.VILLAGER_PROFESSION, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister> TURTLE_SERIALIZER = DeferredRegister.create(ITurtleUpgrade.serialiserRegistryKey(), AdvancedPeripherals.MOD_ID); - public static final DeferredRegister> POCKET_SERIALIZER = DeferredRegister.create(IPocketUpgrade.serialiserRegistryKey(), AdvancedPeripherals.MOD_ID); + public static final DeferredRegister> TURTLE_SERIALIZER = DeferredRegister.create(ITurtleUpgrade.typeRegistry(), AdvancedPeripherals.MOD_ID); + public static final DeferredRegister> POCKET_SERIALIZER = DeferredRegister.create(IPocketUpgrade.typeRegistry(), AdvancedPeripherals.MOD_ID); public static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, AdvancedPeripherals.MOD_ID); + public static final DeferredRegister> DATA_COMPONENT_TYPES = DeferredRegister.create(Registries.DATA_COMPONENT_TYPE, AdvancedPeripherals.MOD_ID); public static void register(IEventBus modEventBus) { BLOCKS.register(modEventBus); @@ -35,6 +37,7 @@ public static void register(IEventBus modEventBus) { TURTLE_SERIALIZER.register(modEventBus); POCKET_SERIALIZER.register(modEventBus); CREATIVE_MODE_TABS.register(modEventBus); + DATA_COMPONENT_TYPES.register(modEventBus); Blocks.register(); BlockEntityTypes.register(); @@ -43,5 +46,6 @@ public static void register(IEventBus modEventBus) { Villagers.register(); CCRegistration.register(); CreativeTabs.register(); + DataComponents.register(); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java b/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java index c199ae736..1d1a265d8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java @@ -2,6 +2,7 @@ import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.configuration.APConfig; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; @@ -10,11 +11,11 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.saveddata.SavedData; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.common.world.chunk.RegisterTicketControllersEvent; import net.neoforged.neoforge.common.world.chunk.TicketController; -import net.neoforged.neoforge.event.TickEvent; import net.neoforged.neoforge.event.server.ServerStartedEvent; +import net.neoforged.neoforge.event.tick.ServerTickEvent; import net.neoforged.neoforge.server.ServerLifecycleHooks; import org.apache.logging.log4j.Level; import org.jetbrains.annotations.NotNull; @@ -25,7 +26,7 @@ import java.util.Set; import java.util.UUID; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID) public class ChunkManager extends SavedData { private static final String DATA_NAME = AdvancedPeripherals.MOD_ID + "_ForcedChunks"; @@ -44,7 +45,7 @@ public ChunkManager() { return level.getDataStorage().computeIfAbsent(new SavedData.Factory<>(ChunkManager::new, ChunkManager::load, null), DATA_NAME); } - public static ChunkManager load(@NotNull CompoundTag data) { + public static ChunkManager load(@NotNull CompoundTag data, HolderLookup.Provider provider) { ChunkManager manager = new ChunkManager(); CompoundTag forcedData = data.getCompound(FORCED_CHUNKS_TAG); AdvancedPeripherals.debug("Loading chunk manager from NBT " + data, Level.WARN); @@ -65,12 +66,10 @@ public static void afterServerStarted(ServerStartedEvent event) { } @SubscribeEvent - public static void serverTick(TickEvent.ServerTickEvent event) { - if (event.phase == TickEvent.Phase.END) { + public static void serverTick(ServerTickEvent.Post event) { + if (event.hasTime()) { tickCounter++; - // run cleanup per chunkLoadValidTime / 10 - final int checkIntervalInTick = APConfig.PERIPHERALS_CONFIG.chunkLoadValidTime.get() * 20 / 10; - if (tickCounter % checkIntervalInTick == 0) { + if (tickCounter % (APConfig.PERIPHERALS_CONFIG.chunkLoadValidTime.get() * 20 / 10) == 0) { ChunkManager.get(ServerLifecycleHooks.getCurrentServer().overworld()).cleanup(); } } @@ -221,7 +220,7 @@ public synchronized void cleanup() { } @Override - public synchronized @NotNull CompoundTag save(@NotNull CompoundTag data) { + public synchronized @NotNull CompoundTag save(@NotNull CompoundTag data, HolderLookup.@NotNull Provider registries) { AdvancedPeripherals.debug("Schedule chunk manager save, forcedChunks = " + forcedChunks.size(), Level.WARN); CompoundTag forcedChunksTag = new CompoundTag(); forcedChunks.forEach((key, value) -> forcedChunksTag.put(key.toString(), value.serialize())); @@ -241,7 +240,7 @@ private static Map getServerLevels() { } private static ServerLevel getServerLevel(String name) { - ResourceKey key = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(name)); + ResourceKey key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(name)); return ServerLifecycleHooks.getCurrentServer().getLevel(key); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/DataComponentUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/DataComponentUtil.java new file mode 100644 index 000000000..7931d037c --- /dev/null +++ b/src/main/java/de/srendi/advancedperipherals/common/util/DataComponentUtil.java @@ -0,0 +1,15 @@ +package de.srendi.advancedperipherals.common.util; + +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.Tag; +import net.minecraft.resources.RegistryOps; +import net.neoforged.neoforge.server.ServerLifecycleHooks; + +public class DataComponentUtil { + + public static Tag toNbt(DataComponentPatch patch) { + return DataComponentPatch.CODEC.encodeStart(RegistryOps.create(NbtOps.INSTANCE, ServerLifecycleHooks.getCurrentServer().registryAccess()), patch).getOrThrow(); + } + +} diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java index 0499427cc..b0639b3ae 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java @@ -5,21 +5,36 @@ import dan200.computercraft.api.turtle.TurtleSide; import de.srendi.advancedperipherals.common.addons.computercraft.owner.IPeripheralOwner; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralTileEntity; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.nbt.CompoundTag; import org.jetbrains.annotations.NotNull; +import java.util.Optional; + +import static de.srendi.advancedperipherals.common.setup.DataComponents.ROTATION_CHARGE_SETTING; + public class DataStorageUtil { - public static CompoundTag getDataStorage(@NotNull ITurtleAccess access, @NotNull TurtleSide side) { - return access.getUpgradeNBTData(side); + public static DataComponentPatch getDataStorage(@NotNull ITurtleAccess access, @NotNull TurtleSide side) { + return access.getUpgradeData(side); + } + + public static void putDataStorage(@NotNull ITurtleAccess access, @NotNull TurtleSide side, DataComponentPatch dataComponent) { + access.setUpgradeData(side, dataComponent); } public static CompoundTag getDataStorage(@NotNull IPeripheralTileEntity tileEntity) { return tileEntity.getPeripheralSettings(); } - public static CompoundTag getDataStorage(@NotNull IPocketAccess pocket) { - return pocket.getUpgradeNBTData(); + public static DataComponentPatch getDataStorage(@NotNull IPocketAccess pocket) { + return pocket.getUpgradeData(); + } + + public static void putDataStorage(@NotNull IPocketAccess pocket, DataComponentPatch dataComponent) { + pocket.setUpgradeData(dataComponent); } /** @@ -33,27 +48,29 @@ public static class RotationCharge { /** * Used for gear rotation animation */ - private static final String ROTATION_CHARGE_SETTING = "rotationCharge"; - public static int get(@NotNull ITurtleAccess access, @NotNull TurtleSide side) { - return getDataStorage(access, side).getInt(ROTATION_CHARGE_SETTING); + Optional rotationCharge = getDataStorage(access, side).get(ROTATION_CHARGE_SETTING.get()); + return rotationCharge != null && rotationCharge.isPresent() ? rotationCharge.get() : 0; } public static boolean consume(@NotNull ITurtleAccess access, @NotNull TurtleSide side) { - CompoundTag data = getDataStorage(access, side); - int currentCharge = data.getInt(ROTATION_CHARGE_SETTING); + PatchedDataComponentMap patch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, getDataStorage(access, side)); + int currentCharge = get(access, side); if (currentCharge > 0) { - data.putInt(ROTATION_CHARGE_SETTING, Math.max(0, data.getInt(ROTATION_CHARGE_SETTING) - 1)); - access.updateUpgradeNBTData(side); + patch.set(ROTATION_CHARGE_SETTING.get(), Math.max(0, get(access, side) - 1)); + putDataStorage(access, side, patch.asPatch()); return true; } return false; } public static void addCycles(IPeripheralOwner owner, int count) { - CompoundTag data = owner.getDataStorage(); - data.putInt(ROTATION_CHARGE_SETTING, Math.max(0, data.getInt(ROTATION_CHARGE_SETTING)) + count * ROTATION_STEPS); - owner.markDataStorageDirty(); + PatchedDataComponentMap patch = PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, owner.getDataStorage()); + Integer currentCharge = patch.get(ROTATION_CHARGE_SETTING.get()); + if (currentCharge == null || currentCharge < 0) + currentCharge = 0; + patch.set(ROTATION_CHARGE_SETTING.get(), currentCharge + count * ROTATION_STEPS); + owner.putDataStorage(patch.asPatch()); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java b/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java index 4bad04579..a0f56863d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java @@ -5,7 +5,7 @@ import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.InventoryManagerPeripheral; import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponentPatch; import net.minecraft.tags.TagKey; import net.minecraft.util.StringRepresentable; import net.minecraft.world.entity.Entity; @@ -52,7 +52,7 @@ public static Map animalToLua(Animal animal, ItemStack itemInHan data.put("inLove", animal.isInLove()); data.put("aggressive", animal.isAggressive()); if (animal instanceof IShearable shareable && !itemInHand.isEmpty()) { - data.put("shareable", shareable.isShearable(itemInHand, animal.level(), animal.blockPosition())); + data.put("shareable", shareable.isShearable(null, itemInHand, animal.level(), animal.blockPosition())); } return data; } @@ -103,11 +103,11 @@ public static Object posToObject(BlockPos pos) { public static Map stackToObject(@NotNull ItemStack stack) { if (stack.isEmpty()) return new HashMap<>(); Map map = itemToObject(stack.getItem()); - CompoundTag nbt = stack.copy().getOrCreateTag(); + DataComponentPatch components = stack.getComponentsPatch(); map.put("count", stack.getCount()); map.put("displayName", stack.getDisplayName().getString()); map.put("maxStackSize", stack.getMaxStackSize()); - map.put("nbt", NBTUtil.toLua(nbt)); + map.put("nbt", NBTUtil.toLua(DataComponentUtil.toNbt(components))); map.put("fingerprint", ItemUtil.getFingerprint(stack)); return map; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java b/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java index a39487b29..bfb8a9d49 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java @@ -2,13 +2,13 @@ import de.srendi.advancedperipherals.AdvancedPeripherals; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.event.TickEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.event.tick.ServerTickEvent; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID) public class ServerWorker { private static final Queue callQueue = new ConcurrentLinkedQueue<>(); @@ -20,8 +20,8 @@ public static void add(final Runnable call) { } @SubscribeEvent - public static void serverTick(TickEvent.ServerTickEvent event) { - if (event.phase == TickEvent.Phase.END) { + public static void serverTick(ServerTickEvent.Post event) { + if (event.hasTime()) { while (true) { final Runnable runnable = callQueue.poll(); if (runnable == null) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java index 009b2d521..38757be4f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java @@ -19,6 +19,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; @@ -37,10 +38,9 @@ import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import net.neoforged.bus.api.Event; import net.neoforged.neoforge.common.CommonHooks; -import net.neoforged.neoforge.common.NeoForgeMod; import net.neoforged.neoforge.common.util.FakePlayer; +import net.neoforged.neoforge.common.util.TriState; import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import org.apache.commons.lang3.StringUtils; @@ -242,8 +242,8 @@ public InteractionResult use(boolean skipEntity, boolean skipBlock, @Nullable Pr if (event.isCanceled()) { return event.getCancellationResult(); } - boolean usedItem = event.getUseItem() != Event.Result.DENY; - boolean usedOnBlock = event.getUseBlock() != Event.Result.DENY; + boolean usedItem = event.getUseItem() != TriState.FALSE; + boolean usedOnBlock = event.getUseBlock() != TriState.FALSE; if (usedItem) { InteractionResult result = stack.onItemUseFirst(new UseOnContext(level(), this, InteractionHand.MAIN_HAND, stack, blockHit)); if (result != InteractionResult.PASS) { @@ -292,7 +292,7 @@ public HitResult findHit(boolean skipEntity, boolean skipBlock) { @NotNull public HitResult findHit(boolean skipEntity, boolean skipBlock, @Nullable Predicate entityFilter) { - AttributeInstance reachAttribute = getAttribute(NeoForgeMod.BLOCK_REACH.value()); + AttributeInstance reachAttribute = getAttribute(Attributes.BLOCK_INTERACTION_RANGE); if (reachAttribute == null) throw new IllegalArgumentException("How did this happened?"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java index f174a62e5..24a882719 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java @@ -10,6 +10,7 @@ import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; @@ -32,7 +33,7 @@ public static APFakePlayer getPlayer(ITurtleAccess turtle, GameProfile profile) public static void load(APFakePlayer player, ITurtleAccess turtle) { Direction direction = turtle.getDirection(); - player.setLevel((ServerLevel) turtle.getLevel()); + player.setLevel(turtle.getLevel()); // Player position BlockPos position = turtle.getPosition(); player.moveTo(position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5, direction.toYRot(), 0); @@ -55,7 +56,12 @@ public static void load(APFakePlayer player, ITurtleAccess turtle) { // Add properties ItemStack activeStack = player.getItemInHand(InteractionHand.MAIN_HAND); if (!activeStack.isEmpty()) { - player.getAttributes().addTransientAttributeModifiers(activeStack.getAttributeModifiers(EquipmentSlot.MAINHAND)); + activeStack.getAttributeModifiers().forEach(EquipmentSlot.MAINHAND, (attr, modif) -> { + AttributeInstance inst = player.getAttribute(attr); + if (inst != null) { + inst.addOrUpdateTransientModifier(modif); + } + }); } } @@ -66,7 +72,12 @@ public static void unload(APFakePlayer player, ITurtleAccess turtle) { // Remove properties ItemStack activeStack = player.getItemInHand(InteractionHand.MAIN_HAND); if (!activeStack.isEmpty()) { - player.getAttributes().removeAttributeModifiers(activeStack.getAttributeModifiers(EquipmentSlot.MAINHAND)); + activeStack.getAttributeModifiers().forEach(EquipmentSlot.MAINHAND, (attr, modif) -> { + AttributeInstance inst = player.getAttribute(attr); + if (inst != null) { + inst.addOrUpdateTransientModifier(modif); + } + }); } // Copy primary items into turtle inventory and then insert/drop the rest diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java index 6b38034d6..43e3dfb86 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java @@ -3,11 +3,12 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.core.apis.TableHelper; import de.srendi.advancedperipherals.AdvancedPeripherals; +import de.srendi.advancedperipherals.common.util.DataComponentUtil; import de.srendi.advancedperipherals.common.util.NBTUtil; import de.srendi.advancedperipherals.common.util.Pair; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; -import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; @@ -17,11 +18,13 @@ import java.util.Map; +//TODO tag public class FluidFilter { private Fluid fluid = Fluids.EMPTY; private TagKey tag = null; - private CompoundTag nbt = null; + private Tag componentsAsNbt = null; + private PatchedDataComponentMap components; private int count = 1000; private String fingerprint = ""; @@ -37,7 +40,7 @@ public static Pair parse(Map item) { try { String name = TableHelper.getStringField(item, "name"); if (name.startsWith("#")) { - fluidFilter.tag = TagKey.create(Registries.FLUID, new ResourceLocation(name.substring(1))); + fluidFilter.tag = TagKey.create(Registries.FLUID, ResourceLocation.parse(name.substring(1))); } else if ((fluidFilter.fluid = ItemUtil.getRegistryEntry(name, BuiltInRegistries.FLUID)) == null) { return Pair.of(null, "FLUID_NOT_FOUND"); } @@ -45,11 +48,15 @@ public static Pair parse(Map item) { return Pair.of(null, "NO_VALID_FLUID"); } } - if (item.containsKey("nbt")) { + if (item.containsKey("components")) { try { - fluidFilter.nbt = NBTUtil.fromText(TableHelper.getStringField(item, "nbt")); + fluidFilter.componentsAsNbt = NBTUtil.fromText(TableHelper.getStringField(item, "components")); } catch (LuaException luaException) { - return Pair.of(null, "NO_VALID_NBT"); + try { + fluidFilter.componentsAsNbt = NBTUtil.fromText(TableHelper.getTableField(item, "components").toString()); + } catch (LuaException e) { + return Pair.of(null, "NO_VALID_COMPONENTS"); + } } } if (item.containsKey("fingerprint")) { @@ -74,7 +81,8 @@ public static Pair parse(Map item) { public static FluidFilter fromStack(FluidStack stack) { FluidFilter filter = empty(); filter.fluid = stack.getFluid(); - filter.nbt = stack.hasTag() ? stack.getTag() : null; + filter.componentsAsNbt = DataComponentUtil.toNbt(stack.getComponentsPatch()); + filter.components = stack.getComponents(); return filter; } @@ -83,12 +91,12 @@ public static FluidFilter empty() { } public boolean isEmpty() { - return fingerprint.isEmpty() && fluid == Fluids.EMPTY && tag == null && nbt == null; + return fingerprint.isEmpty() && fluid == Fluids.EMPTY && tag == null && componentsAsNbt == null; } public FluidStack toFluidStack() { var result = new FluidStack(fluid, count); - result.setTag(nbt != null ? nbt.copy() : null); + result.applyComponents(components); return result; } @@ -109,7 +117,7 @@ public boolean test(FluidStack stack) { if (tag != null && !stack.getFluid().is(tag)) { return false; } - if (nbt != null && !stack.getOrCreateTag().equals(nbt)) { + if (componentsAsNbt != null && !DataComponentUtil.toNbt(stack.getComponentsPatch()).equals(componentsAsNbt)) { return false; } return true; @@ -123,8 +131,8 @@ public Fluid getFluid() { return fluid; } - public Tag getNbt() { - return nbt; + public Tag getComponentsAsNbt() { + return componentsAsNbt; } @Override @@ -132,7 +140,7 @@ public String toString() { return "FluidFilter{" + "fluid=" + FluidUtil.getRegistryKey(fluid) + ", tag=" + tag + - ", nbt=" + nbt + + ", components=" + componentsAsNbt + ", count=" + count + ", fingerprint='" + fingerprint + '\'' + '}'; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java index e7476d15f..548584de8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java @@ -73,7 +73,7 @@ public static IFluidHandler getHandlerFromName(@NotNull IComputerAccess access, @NotNull public static String getFingerprint(@NotNull FluidStack stack) { - String fingerprint = stack.getOrCreateTag() + getRegistryKey(stack).toString() + stack.getDisplayName().getString(); + String fingerprint = stack.getComponents() + getRegistryKey(stack).toString() + stack.getDisplayName().getString(); try { byte[] bytesOfHash = fingerprint.getBytes(StandardCharsets.UTF_8); MessageDigest md = MessageDigest.getInstance("MD5"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java index 5c2776d60..9f4a1819a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java @@ -5,11 +5,13 @@ import dan200.computercraft.api.peripheral.IPeripheral; import de.srendi.advancedperipherals.common.addons.computercraft.owner.IPeripheralOwner; import de.srendi.advancedperipherals.common.util.CoordUtil; +import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; +import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.capability.IFluidHandler; import net.neoforged.neoforge.items.IItemHandler; @@ -25,11 +27,18 @@ public class InventoryUtil { private InventoryUtil() { } - public static IItemHandler extractHandler(@Nullable Object object) { + public static IItemHandler extractHandler(@Nullable Object object, @Nullable Level level, @Nullable BlockPos pos, @Nullable Direction direction) { if (object instanceof IItemHandler itemHandler) return itemHandler; if (object instanceof Container container) return new InvWrapper(container); + if (object instanceof BlockEntity blockEntity && level == null && pos == null) { + pos = blockEntity.getBlockPos(); + level = blockEntity.getLevel(); + } + if (level != null && pos != null) { + return level.getCapability(Capabilities.ItemHandler.BLOCK, pos, direction != null ? direction : Direction.NORTH); + } return null; } @@ -141,7 +150,7 @@ public static IItemHandler getHandlerFromName(@NotNull IComputerAccess access, S if (location == null) return null; - return extractHandler(location.getTarget()); + return extractHandler(location.getTarget(), null, null, null); } @Nullable @@ -153,6 +162,6 @@ public static IItemHandler getHandlerFromDirection(@NotNull String direction, @N if (target == null) return null; - return extractHandler(target); + return extractHandler(target, level, target.getBlockPos(), relativeDirection.getOpposite()); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java index 6f44b63c1..3a2cca625 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java @@ -3,11 +3,12 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.core.apis.TableHelper; import de.srendi.advancedperipherals.AdvancedPeripherals; +import de.srendi.advancedperipherals.common.util.DataComponentUtil; import de.srendi.advancedperipherals.common.util.NBTUtil; import de.srendi.advancedperipherals.common.util.Pair; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; -import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; @@ -17,11 +18,13 @@ import java.util.Map; +//TODO tag public class ItemFilter { private Item item = Items.AIR; private TagKey tag = null; - private CompoundTag nbt = null; + private Tag componentsAsNbt = null; + private PatchedDataComponentMap components; private int count = 64; private String fingerprint = ""; public int fromSlot = -1; @@ -39,7 +42,7 @@ public static Pair parse(Map item) { try { String name = TableHelper.getStringField(item, "name"); if (name.startsWith("#")) { - itemFilter.tag = TagKey.create(Registries.ITEM, new ResourceLocation(name.substring(1))); + itemFilter.tag = TagKey.create(Registries.ITEM, ResourceLocation.parse(name.substring(1))); } else if ((itemFilter.item = ItemUtil.getRegistryEntry(name, BuiltInRegistries.ITEM)) == null) { return Pair.of(null, "ITEM_NOT_FOUND"); } @@ -47,14 +50,14 @@ public static Pair parse(Map item) { return Pair.of(null, "NO_VALID_ITEM"); } } - if (item.containsKey("nbt")) { + if (item.containsKey("components")) { try { - itemFilter.nbt = NBTUtil.fromText(TableHelper.getStringField(item, "nbt")); + itemFilter.componentsAsNbt = NBTUtil.fromText(TableHelper.getStringField(item, "components")); } catch (LuaException luaException) { try { - itemFilter.nbt = NBTUtil.fromText(TableHelper.getTableField(item, "nbt").toString()); + itemFilter.componentsAsNbt = NBTUtil.fromText(TableHelper.getTableField(item, "components").toString()); } catch (LuaException e) { - return Pair.of(null, "NO_VALID_NBT"); + return Pair.of(null, "NO_VALID_COMPONENTS"); } } } @@ -94,7 +97,8 @@ public static Pair parse(Map item) { public static ItemFilter fromStack(ItemStack stack) { ItemFilter filter = empty(); filter.item = stack.getItem(); - filter.nbt = stack.hasTag() ? stack.getTag() : null; + filter.componentsAsNbt = DataComponentUtil.toNbt(stack.getComponentsPatch()); + filter.components = (PatchedDataComponentMap) stack.getComponents(); return filter; } @@ -103,12 +107,12 @@ public static ItemFilter empty() { } public boolean isEmpty() { - return fingerprint.isEmpty() && item == Items.AIR && tag == null && nbt == null; + return fingerprint.isEmpty() && item == Items.AIR && tag == null && componentsAsNbt == null; } public ItemStack toItemStack() { var result = new ItemStack(item, count); - result.setTag(nbt != null ? nbt.copy() : null); + result.applyComponents(components); return result; } @@ -124,7 +128,7 @@ public boolean test(ItemStack stack) { if (tag != null && !stack.is(tag)) { return false; } - if (nbt != null && !stack.getOrCreateTag().equals(nbt)) { + if (componentsAsNbt != null && !DataComponentUtil.toNbt(stack.getComponentsPatch()).equals(componentsAsNbt)) { return false; } return true; @@ -146,8 +150,8 @@ public int getToSlot() { return toSlot; } - public Tag getNbt() { - return nbt; + public Tag getComponentsAsNbt() { + return componentsAsNbt; } @Override @@ -155,7 +159,7 @@ public String toString() { return "ItemFilter{" + "item=" + ItemUtil.getRegistryKey(item) + ", tag=" + tag + - ", nbt=" + nbt + + ", components=" + componentsAsNbt + ", count=" + count + ", fingerprint='" + fingerprint + '\'' + ", fromSlot=" + fromSlot + diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java index 06805ce18..498766805 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java @@ -4,7 +4,6 @@ import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.util.StringUtil; import net.minecraft.ResourceLocationException; -import net.minecraft.core.NonNullList; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; @@ -33,7 +32,7 @@ private ItemUtil() { public static T getRegistryEntry(String name, Registry forgeRegistry) { ResourceLocation location; try { - location = new ResourceLocation(name); + location = ResourceLocation.parse(name); } catch (ResourceLocationException ex) { location = null; } @@ -53,7 +52,7 @@ public static T getRegistryEntry(String name, Registry forgeRegistry) { * @return A generated MD5 hash from the item stack */ public static String getFingerprint(ItemStack stack) { - String fingerprint = stack.getOrCreateTag() + getRegistryKey(stack).toString() + stack.getDisplayName().getString(); + String fingerprint = stack.getComponents() + getRegistryKey(stack).toString() + stack.getDisplayName().getString(); try { byte[] bytesOfHash = fingerprint.getBytes(StandardCharsets.UTF_8); MessageDigest md = MessageDigest.getInstance("MD5"); @@ -65,18 +64,6 @@ public static String getFingerprint(ItemStack stack) { return ""; } - public static ItemStack makeTurtle(Item turtle, String upgrade) { - ItemStack stack = new ItemStack(turtle); - stack.getOrCreateTag().putString("RightUpgrade", upgrade); - return stack; - } - - public static ItemStack makePocket(Item turtle, String upgrade) { - ItemStack stack = new ItemStack(turtle); - stack.getOrCreateTag().putString("Upgrade", upgrade); - return stack; - } - //Gathers all items in handler and returns them public static List getItemsFromItemHandler(IItemHandler handler) { List items = new ArrayList<>(handler.getSlots()); @@ -87,17 +74,6 @@ public static List getItemsFromItemHandler(IItemHandler handler) { return items; } - public static void addComputerItemToTab(ResourceLocation turtleID, ResourceLocation pocketID, NonNullList items) { - if (turtleID != null) { - items.add(makeTurtle(TURTLE_ADVANCED, turtleID.toString())); - items.add(makeTurtle(TURTLE_NORMAL, turtleID.toString())); - } - if (pocketID != null) { - items.add(makePocket(POCKET_ADVANCED, pocketID.toString())); - items.add(makePocket(POCKET_NORMAL, pocketID.toString())); - } - } - public static ResourceLocation getRegistryKey(Item item) { return BuiltInRegistries.ITEM.getKey(item); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java b/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java index 33d7135d2..5324ab75a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java +++ b/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java @@ -12,14 +12,15 @@ import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement; import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList; +import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.server.ServerAboutToStartEvent; import java.util.ArrayList; import java.util.List; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.GAME) public class VillageStructures { // Adapted from Pneumaticcraft @@ -54,13 +55,13 @@ public static void addStructures(ServerAboutToStartEvent event) { return; Holder emptyProcessor = event.getServer().registryAccess().registryOrThrow(Registries.PROCESSOR_LIST) - .getHolderOrThrow(ResourceKey.create(Registries.PROCESSOR_LIST, new ResourceLocation("minecraft:empty"))); + .getHolderOrThrow(ResourceKey.create(Registries.PROCESSOR_LIST, ResourceLocation.parse("minecraft:empty"))); Registry templatePoolRegistry = event.getServer().registryAccess().registryOrThrow(Registries.TEMPLATE_POOL); for (String biome : new String[]{"desert", "snowy", "plains", "savanna", "taiga"}) { AdvancedPeripherals.debug("Register generating scientist_" + biome + " village house"); - addPieceToPool(templatePoolRegistry, emptyProcessor, new ResourceLocation("village/" + biome + "/houses"), AdvancedPeripherals.MOD_ID + ":villages/scientist_" + biome, StructureTemplatePool.Projection.RIGID, APConfig.WORLD_CONFIG.villagerStructureWeight.get()); + addPieceToPool(templatePoolRegistry, emptyProcessor, ResourceLocation.parse("village/" + biome + "/houses"), AdvancedPeripherals.MOD_ID + ":villages/scientist_" + biome, StructureTemplatePool.Projection.RIGID, APConfig.WORLD_CONFIG.villagerStructureWeight.get()); } } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java index 527931701..ec9947ee4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java @@ -1,10 +1,20 @@ package de.srendi.advancedperipherals.common.village; +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.turtle.ITurtleUpgrade; +import dan200.computercraft.api.upgrades.UpgradeData; +import dan200.computercraft.shared.ModRegistry; +import dan200.computercraft.shared.util.DataComponentUtil; +import de.srendi.advancedperipherals.AdvancedPeripherals; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.npc.VillagerTrades; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.ItemCost; import net.minecraft.world.item.trading.MerchantOffer; import net.minecraft.world.level.ItemLike; import net.neoforged.neoforge.event.village.VillagerTradesEvent; @@ -39,16 +49,16 @@ private VillagerTrade(@NotNull Type type, int emeraldAmount, int itemAmount, int public MerchantOffer getOffer(@NotNull Entity trader, @NotNull RandomSource rand) { if (type == Type.EMERALD_FOR_ITEM) { if (itemStack != null) - return new MerchantOffer(itemStack, new ItemStack(Items.EMERALD, emeraldAmount), maxUses, xp, 1); + return new MerchantOffer(new ItemCost(itemStack.getItem()), new ItemStack(Items.EMERALD, emeraldAmount), maxUses, xp, 1); if (item != null) - return new MerchantOffer(new ItemStack(item, itemAmount), new ItemStack(Items.EMERALD, emeraldAmount), maxUses, xp, 1); + return new MerchantOffer(new ItemCost(new ItemStack(item, itemAmount).getItem()), new ItemStack(Items.EMERALD, emeraldAmount), maxUses, xp, 1); } if (type == Type.ITEM_FOR_EMERALD) { if (itemStack != null) - return new MerchantOffer(new ItemStack(Items.EMERALD, emeraldAmount), itemStack, maxUses, xp, 1); + return new MerchantOffer(new ItemCost(new ItemStack(Items.EMERALD, emeraldAmount).getItem()), itemStack, maxUses, xp, 1); if (item != null) - return new MerchantOffer(new ItemStack(Items.EMERALD, emeraldAmount), new ItemStack(item, itemAmount), maxUses, xp, 1); + return new MerchantOffer(new ItemCost(new ItemStack(Items.EMERALD, emeraldAmount).getItem()), new ItemStack(item, itemAmount), maxUses, xp, 1); } return null; } @@ -71,40 +81,18 @@ public static class TradeBuilder { private int maxUses = 10; private int xp = 2; - private final ItemLike item; - private final ItemStack itemStack; + private ItemLike item; + private ItemStack itemStack; - private TradeBuilder(VillagerTradesEvent event, ItemLike item, Type type, int emeraldAmount, int professionLevel) { + private TradeBuilder(VillagerTradesEvent event, Type type, int emeraldAmount, int professionLevel) { this.villagerEvent = event; - this.item = item; - this.itemStack = null; this.type = type; this.emeraldAmount = emeraldAmount; this.professionLevel = professionLevel; } - private TradeBuilder(VillagerTradesEvent event, ItemStack stack, Type type, int emeraldAmount, int professionLevel) { - this.villagerEvent = event; - this.itemStack = stack; - this.item = null; - this.type = type; - this.emeraldAmount = emeraldAmount; - this.professionLevel = professionLevel; - } - - private TradeBuilder(WandererTradesEvent event, ItemLike item, Type type, int emeraldAmount, int professionLevel) { + private TradeBuilder(WandererTradesEvent event, Type type, int emeraldAmount, int professionLevel) { this.wandererEvent = event; - this.item = item; - this.itemStack = null; - this.type = type; - this.emeraldAmount = emeraldAmount; - this.professionLevel = professionLevel; - } - - private TradeBuilder(WandererTradesEvent event, ItemStack stack, Type type, int emeraldAmount, int professionLevel) { - this.wandererEvent = event; - this.itemStack = stack; - this.item = null; this.type = type; this.emeraldAmount = emeraldAmount; this.professionLevel = professionLevel; @@ -123,22 +111,20 @@ private TradeBuilder(WandererTradesEvent event, ItemStack stack, Type type, int * @return a builder instance */ public static TradeBuilder createTrade(VillagerTradesEvent event, ItemLike itemLike, Type type, int emeraldAmount, int professionLevel) { - return new TradeBuilder(event, itemLike, type, emeraldAmount, professionLevel); + return new TradeBuilder(event, type, emeraldAmount, professionLevel).withItem(itemLike); } /** * Creates a new TradeBuilder instance. Can be used to create villager trades for normal villagers - * This one is for normal villagers with item stacks * * @param event this should be executed in an event - pass the villager trade event here - * @param itemStack the item for trade * @param type the trade type * @param emeraldAmount the emerald amount of the trade * @param professionLevel the profession level of the villager. 1 to 5 * @return a builder instance */ - public static TradeBuilder createTrade(VillagerTradesEvent event, ItemStack itemStack, Type type, int emeraldAmount, int professionLevel) { - return new TradeBuilder(event, itemStack, type, emeraldAmount, professionLevel); + public static TradeBuilder createTrade(VillagerTradesEvent event, Type type, int emeraldAmount, int professionLevel) { + return new TradeBuilder(event, type, emeraldAmount, professionLevel); } /** @@ -154,22 +140,77 @@ public static TradeBuilder createTrade(VillagerTradesEvent event, ItemStack item * @return a builder instance */ public static TradeBuilder createTrade(WandererTradesEvent event, ItemLike itemLike, Type type, int emeraldAmount, int professionLevel) { - return new TradeBuilder(event, itemLike, type, emeraldAmount, professionLevel); + return new TradeBuilder(event, type, emeraldAmount, professionLevel).withItem(itemLike); } /** * Creates a new TradeBuilder instance. Can be used to create villager trades for wandering traders. - * This one is for normal villagers with item stacks * * @param event this should be executed in an event - pass the villager trade event here - * @param itemStack the item for trade * @param type the trade type * @param emeraldAmount the emerald amount of the trade * @param professionLevel the profession level of the villager. 1 to 5 * @return a builder instance */ - public static TradeBuilder createTrade(WandererTradesEvent event, ItemStack itemStack, Type type, int emeraldAmount, int professionLevel) { - return new TradeBuilder(event, itemStack, type, emeraldAmount, professionLevel); + public static TradeBuilder createTrade(WandererTradesEvent event, Type type, int emeraldAmount, int professionLevel) { + return new TradeBuilder(event, type, emeraldAmount, professionLevel); + } + + public TradeBuilder withItem(ItemLike item) { + this.item = item; + return this; + } + + public TradeBuilder withItemStack(ItemStack itemStack) { + this.itemStack = itemStack; + return this; + } + + /** + * Sets a pocket upgrade as the item stack + * + * @param advanced should it be an advanced pocket computer + * @param id the id of the upgrade + * @return the current instance of the builder + */ + public TradeBuilder withPocketUpgrade(boolean advanced, ResourceLocation id) { + RegistryAccess access = wandererEvent != null ? wandererEvent.getRegistryAccess() : villagerEvent.getRegistryAccess(); + + Holder.Reference pocketUpgrade = access.registryOrThrow(IPocketUpgrade.REGISTRY) + .getHolder(id) + .orElse(null); + if (pocketUpgrade == null) { + AdvancedPeripherals.debug("Pocket upgrade " + id + " does not exist or was removed by a datapack, skipping villager trade"); + return this; + } + + ItemStack pocketStack = DataComponentUtil.createStack(advanced ? ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get() : ModRegistry.Items.POCKET_COMPUTER_NORMAL.get(), ModRegistry.DataComponents.POCKET_UPGRADE.get(), UpgradeData.ofDefault(pocketUpgrade)); + + return withItemStack(pocketStack); + } + + /** + * Sets a turtle upgrade as the item stack + * + * @param advanced should it be an advanced turtle + * @param id the id of the upgrade + * @return the current instance of the builder + */ + public TradeBuilder withTurtleUpgrade(boolean advanced, ResourceLocation id) { + RegistryAccess access = wandererEvent != null ? wandererEvent.getRegistryAccess() : villagerEvent.getRegistryAccess(); + + Holder.Reference turtleUpgrade = access.registryOrThrow(ITurtleUpgrade.REGISTRY) + .getHolder(id) + .orElse(null); + + if (turtleUpgrade == null) { + AdvancedPeripherals.debug("Pocket upgrade " + id + " does not exist or was removed by a datapack, skipping villager trade"); + return this; + } + + ItemStack turtleStack = DataComponentUtil.createStack(advanced ? ModRegistry.Items.TURTLE_ADVANCED.get() : ModRegistry.Items.TURTLE_NORMAL.get(), ModRegistry.DataComponents.RIGHT_TURTLE_UPGRADE.get(), UpgradeData.ofDefault(turtleUpgrade)); + + return withItemStack(turtleStack); } /** diff --git a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java index 7fff06d20..89cd3e5d4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java +++ b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java @@ -7,15 +7,15 @@ import de.srendi.advancedperipherals.common.setup.CCRegistration; import de.srendi.advancedperipherals.common.setup.Items; import de.srendi.advancedperipherals.common.setup.Villagers; -import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; +import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.village.VillagerTradesEvent; import net.neoforged.neoforge.event.village.WandererTradesEvent; import static de.srendi.advancedperipherals.common.village.VillagerTrade.TradeBuilder; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.GAME) public class VillagerTrades { @SubscribeEvent @@ -55,15 +55,17 @@ public static void registerVillagerTrades(VillagerTradesEvent event) { TradeBuilder.createTrade(event, ModRegistry.Blocks.COMPUTER_ADVANCED.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 3, 2) .setXp(4) .build(); - - TradeBuilder.createTrade(event, ItemUtil.makeTurtle(ItemUtil.TURTLE_NORMAL, CCRegistration.ID.ENVIRONMENT_TURTLE.toString()), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3) + TradeBuilder.createTrade(event, VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3) + .withTurtleUpgrade(false, CCRegistration.ID.ENVIRONMENT_TURTLE) .setMaxUses(4) .setXp(5) .build(); - TradeBuilder.createTrade(event, ItemUtil.makePocket(ItemUtil.POCKET_ADVANCED, CCRegistration.ID.PLAYER_POCKET.toString()), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3) + TradeBuilder.createTrade(event, VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3) + .withPocketUpgrade(true, CCRegistration.ID.PLAYER_POCKET) .setMaxUses(4) .setXp(7) .build(); + TradeBuilder.createTrade(event, Items.CHUNK_CONTROLLER.get(), VillagerTrade.Type.EMERALD_FOR_ITEM, 5, 3) .setMaxUses(6) .setXp(8) @@ -87,7 +89,8 @@ public static void registerVillagerTrades(VillagerTradesEvent event) { TradeBuilder.createTrade(event, Items.MEMORY_CARD.get(), VillagerTrade.Type.EMERALD_FOR_ITEM, 2, 4) .setXp(4) .build(); - TradeBuilder.createTrade(event, ItemUtil.makeTurtle(ItemUtil.TURTLE_ADVANCED, CCRegistration.ID.CHUNKY_TURTLE.toString()), VillagerTrade.Type.ITEM_FOR_EMERALD, 8, 4) + TradeBuilder.createTrade(event, VillagerTrade.Type.ITEM_FOR_EMERALD, 8, 4) + .withTurtleUpgrade(true, CCRegistration.ID.CHUNKY_TURTLE) .setXp(7) .build(); TradeBuilder.createTrade(event, Items.CHUNK_CONTROLLER.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 6, 4) diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IDataComponentProvider.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IDataComponentProvider.java new file mode 100644 index 000000000..370e7c0cc --- /dev/null +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IDataComponentProvider.java @@ -0,0 +1,9 @@ +package de.srendi.advancedperipherals.lib.peripherals; + +import net.minecraft.core.component.DataComponentType; + +public interface IDataComponentProvider { + + DataComponentType dataComponentType(); + +} diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java index 4dfe11fea..37f74a45e 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java @@ -4,7 +4,7 @@ import java.util.Map; -public interface IPeripheralOperation extends IConfigHandler { +public interface IPeripheralOperation extends IConfigHandler, IDataComponentProvider { int getInitialCooldown(); int getCooldown(T context); diff --git a/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java b/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java index 291a333de..8dbfa33f3 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java @@ -16,7 +16,7 @@ public abstract class BasePocketUpgrade> extends Ab protected T peripheral; protected BasePocketUpgrade(ResourceLocation id, ItemStack stack) { - super(id, TranslationUtil.pocket(id.getPath()), stack); + super(TranslationUtil.pocket(id.getPath()), stack); } protected abstract T getPeripheral(IPocketAccess access); diff --git a/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java b/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java index cd04a8976..58602e465 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java @@ -4,68 +4,47 @@ import dan200.computercraft.api.turtle.TurtleSide; import de.srendi.advancedperipherals.common.util.DataStorageUtil; import de.srendi.advancedperipherals.lib.peripherals.IBasePeripheral; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponentPatch; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; +import static de.srendi.advancedperipherals.common.setup.DataComponents.TURTLE_UPGRADE_STORED_DATA; + public abstract class ClockwiseAnimatedTurtleUpgrade> extends PeripheralTurtleUpgrade { - public static final String STORED_DATA_TAG = "storedData"; protected ClockwiseAnimatedTurtleUpgrade(ResourceLocation id, ItemStack item) { super(id, item); } - /*@NotNull - @Override - public TransformedModel getModel(@Nullable ITurtleAccess turtle, @NotNull TurtleSide side) { - if (getLeftModel() == null) { - PoseStack stack = new PoseStack(); - stack.pushPose(); - stack.translate(0.0f, 0.5f, 0.5f); - if (turtle != null) { - int rotationStep = DataStorageUtil.RotationCharge.get(turtle, side); - stack.mulPose(Vector3f.XN.rotationDegrees(-10 * rotationStep)); - } - stack.translate(0.0f, -0.5f, -0.5f); - stack.mulPose(Vector3f.YN.rotationDegrees(90)); - if (side == TurtleSide.LEFT) { - stack.translate(0, 0, -0.6); - } else { - stack.translate(0, 0, -1.4); - } - return TransformedModel.of(getCraftingItem(), new Transformation(stack.last().pose())); - } - return TransformedModel.of(side == TurtleSide.LEFT ? getLeftModel() : getRightModel()); - }*/ - // Optional callbacks for addons based on AP public void chargeConsumingCallback() { } @Override - public ItemStack getUpgradeItem(CompoundTag upgradeData) { + public ItemStack getUpgradeItem(DataComponentPatch upgradeData) { if (upgradeData.isEmpty()) return getCraftingItem(); - var baseItem = getCraftingItem().copy(); - baseItem.addTagElement(STORED_DATA_TAG, upgradeData); + ItemStack baseItem = getCraftingItem().copy(); + baseItem.applyComponents(upgradeData); return baseItem; } @Override - public CompoundTag getUpgradeData(ItemStack stack) { - var storedData = stack.getTagElement(STORED_DATA_TAG); + public DataComponentPatch getUpgradeData(ItemStack stack) { + var storedData = stack.get(TURTLE_UPGRADE_STORED_DATA); if (storedData == null) - return new CompoundTag(); + return DataComponentPatch.EMPTY; return storedData; } @Override - public boolean isItemSuitable(ItemStack stack) { - if (stack.getTagElement(STORED_DATA_TAG) == null) return super.isItemSuitable(stack); + public boolean isItemSuitable(@NotNull ItemStack stack) { + if (!stack.has(TURTLE_UPGRADE_STORED_DATA)) + return super.isItemSuitable(stack); var tweakedStack = stack.copy(); - tweakedStack.getOrCreateTag().remove(STORED_DATA_TAG); + tweakedStack.remove(TURTLE_UPGRADE_STORED_DATA); return super.isItemSuitable(tweakedStack); } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java b/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java index cfc08b134..be5ab7de2 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java @@ -19,7 +19,7 @@ public abstract class PeripheralTurtleUpgrade> exte protected int tick; protected PeripheralTurtleUpgrade(ResourceLocation id, ItemStack item) { - super(id, TurtleUpgradeType.PERIPHERAL, TranslationUtil.turtle(id.getPath()), item); + super(TurtleUpgradeType.PERIPHERAL, TranslationUtil.turtle(id.getPath()), item); } public abstract ModelResourceLocation getLeftModel(); diff --git a/src/main/java/de/srendi/advancedperipherals/network/APNetworking.java b/src/main/java/de/srendi/advancedperipherals/network/APNetworking.java index f9479d38c..765843697 100644 --- a/src/main/java/de/srendi/advancedperipherals/network/APNetworking.java +++ b/src/main/java/de/srendi/advancedperipherals/network/APNetworking.java @@ -8,37 +8,36 @@ import net.minecraft.server.level.ServerPlayer; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.ModLoadingContext; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.common.util.FakePlayer; import net.neoforged.neoforge.network.PacketDistributor; -import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent; -import net.neoforged.neoforge.network.registration.IPayloadRegistrar; +import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; +import net.neoforged.neoforge.network.registration.PayloadRegistrar; -@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = EventBusSubscriber.Bus.MOD) public class APNetworking { private static final String PROTOCOL_VERSION = ModLoadingContext.get().getActiveContainer().getModInfo().getVersion().toString(); - public static void init(IPayloadRegistrar registrar) { - registrar.common(ToastToClientPacket.ID, ToastToClientPacket::decode, handler -> handler.client(IAPPacket::handlePacket)); - registrar.common(UsernameToCachePacket.ID, UsernameToCachePacket::decode, handler -> handler.client(IAPPacket::handlePacket)); + public static void init(PayloadRegistrar registrar) { + registrar.playToClient(ToastToClientPacket.TYPE, ToastToClientPacket.CODEC, ToastToClientPacket::handle); + registrar.playToClient(UsernameToCachePacket.TYPE, UsernameToCachePacket.CODEC, UsernameToCachePacket::handle); - registrar.common(RetrieveUsernamePacket.ID, RetrieveUsernamePacket::decode, handler -> handler.server(IAPPacket::handlePacket)); + registrar.playToServer(RetrieveUsernamePacket.TYPE, RetrieveUsernamePacket.CODEC, RetrieveUsernamePacket::handle); } - @SubscribeEvent - public static void register(final RegisterPayloadHandlerEvent event) { - final IPayloadRegistrar registrar = event.registrar(AdvancedPeripherals.MOD_ID) + public static void register(final RegisterPayloadHandlersEvent event) { + final PayloadRegistrar registrar = event.registrar(AdvancedPeripherals.MOD_ID) .versioned(PROTOCOL_VERSION); init(registrar); } public static void sendTo(ServerPlayer player, CustomPacketPayload message) { if (!(player instanceof FakePlayer)) { - PacketDistributor.PLAYER.with(player).send(message); + PacketDistributor.sendToPlayer(player, message); } } public static void sendToServer(CustomPacketPayload message) { - PacketDistributor.SERVER.noArg().send(message); + PacketDistributor.sendToServer(message); } } diff --git a/src/main/java/de/srendi/advancedperipherals/network/toclient/ToastToClientPacket.java b/src/main/java/de/srendi/advancedperipherals/network/toclient/ToastToClientPacket.java index 2fd684528..6b6fbd0e4 100644 --- a/src/main/java/de/srendi/advancedperipherals/network/toclient/ToastToClientPacket.java +++ b/src/main/java/de/srendi/advancedperipherals/network/toclient/ToastToClientPacket.java @@ -3,16 +3,21 @@ import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.util.ToastUtil; import de.srendi.advancedperipherals.network.IAPPacket; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.ComponentSerialization; +import net.minecraft.network.codec.StreamCodec; import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.network.handling.IPayloadContext; import org.jetbrains.annotations.NotNull; public class ToastToClientPacket implements IAPPacket { + public static final StreamCodec CODEC = StreamCodec.composite( + ComponentSerialization.STREAM_CODEC, packet -> packet.title, + ComponentSerialization.STREAM_CODEC, packet -> packet.component, + ToastToClientPacket::new); - public static final ResourceLocation ID = AdvancedPeripherals.getRL("toasttoclient"); + public static final Type TYPE = new Type<>(AdvancedPeripherals.getRL("toasttoclient")); private final Component title; private final Component component; @@ -22,10 +27,6 @@ public ToastToClientPacket(Component title, Component component) { this.component = component; } - public static ToastToClientPacket decode(FriendlyByteBuf buffer) { - return new ToastToClientPacket(buffer.readComponent(), buffer.readComponent()); - } - @Override public void handle(@NotNull IPayloadContext context) { // Should in the theory not happen, but safe is safe. @@ -36,16 +37,9 @@ public void handle(@NotNull IPayloadContext context) { ToastUtil.displayToast(title, component); } - @Override - public void write(@NotNull FriendlyByteBuf buffer) { - buffer.writeComponent(this.title); - buffer.writeComponent(this.component); - } - @NotNull @Override - public ResourceLocation id() { - return ID; + public Type type() { + return TYPE; } - } diff --git a/src/main/java/de/srendi/advancedperipherals/network/toclient/UsernameToCachePacket.java b/src/main/java/de/srendi/advancedperipherals/network/toclient/UsernameToCachePacket.java index 81aa27e23..d0b722e93 100644 --- a/src/main/java/de/srendi/advancedperipherals/network/toclient/UsernameToCachePacket.java +++ b/src/main/java/de/srendi/advancedperipherals/network/toclient/UsernameToCachePacket.java @@ -4,15 +4,18 @@ import de.srendi.advancedperipherals.client.ClientUUIDCache; import de.srendi.advancedperipherals.network.IAPPacket; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.neoforged.neoforge.network.handling.IPayloadContext; import org.jetbrains.annotations.NotNull; import java.util.UUID; public class UsernameToCachePacket implements IAPPacket { + public static final StreamCodec CODEC = StreamCodec.of((buffer, value) -> value.write(buffer), UsernameToCachePacket::decode); - public static final ResourceLocation ID = AdvancedPeripherals.getRL("usernametocache"); + public static final Type TYPE = new Type<>(AdvancedPeripherals.getRL("usernametocache")); public UUID uuid; public String username; @@ -31,7 +34,6 @@ public void handle(IPayloadContext context) { ClientUUIDCache.putUsername(uuid, username); } - @Override public void write(FriendlyByteBuf buffer) { buffer.writeUUID(uuid); buffer.writeUtf(username); @@ -39,7 +41,7 @@ public void write(FriendlyByteBuf buffer) { @NotNull @Override - public ResourceLocation id() { - return ID; + public Type type() { + return TYPE; } } diff --git a/src/main/java/de/srendi/advancedperipherals/network/toserver/RetrieveUsernamePacket.java b/src/main/java/de/srendi/advancedperipherals/network/toserver/RetrieveUsernamePacket.java index 63200bc1e..7a3bfe40a 100644 --- a/src/main/java/de/srendi/advancedperipherals/network/toserver/RetrieveUsernamePacket.java +++ b/src/main/java/de/srendi/advancedperipherals/network/toserver/RetrieveUsernamePacket.java @@ -6,7 +6,9 @@ import de.srendi.advancedperipherals.network.IAPPacket; import de.srendi.advancedperipherals.network.toclient.UsernameToCachePacket; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.server.level.ServerPlayer; import net.neoforged.neoforge.network.handling.IPayloadContext; import net.neoforged.neoforge.server.ServerLifecycleHooks; @@ -16,8 +18,9 @@ import java.util.UUID; public class RetrieveUsernamePacket implements IAPPacket { + public static final StreamCodec CODEC = StreamCodec.of((buffer, value) -> value.write(buffer), RetrieveUsernamePacket::decode); - public static final ResourceLocation ID = AdvancedPeripherals.getRL("retrieveusername"); + public static final Type TYPE = new Type<>(AdvancedPeripherals.getRL("retrieveusername")); public UUID uuid; public UUID requester; @@ -42,11 +45,9 @@ public void handle(IPayloadContext context) { if (gameProfile.isEmpty()) return; - APNetworking.sendTo(player, new UsernameToCachePacket(gameProfile.get().getId(), gameProfile.get().getName())); } - @Override public void write(FriendlyByteBuf buffer) { buffer.writeUUID(uuid); buffer.writeUUID(requester); @@ -54,7 +55,7 @@ public void write(FriendlyByteBuf buffer) { @NotNull @Override - public ResourceLocation id() { - return ID; + public Type type() { + return TYPE; } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index f1fbe1461..da4147bc4 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,5 +1,7 @@ public net.minecraft.world.level.block.entity.BeaconBlockEntity primaryPower # primaryPower public net.minecraft.world.level.block.entity.BeaconBlockEntity secondaryPower # secondaryPower +public net.minecraft.world.level.block.entity.BeaconBlockEntity levels # levels +public net.minecraft.world.level.block.entity.BaseContainerBlockEntity name # name public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool rawTemplates # rawTemplates public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool templates # templates -public net.minecraft.world.level.block.Blocks m_50805_(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Z # never \ No newline at end of file +public-f net.minecraft.world.entity.Entity getEyeHeight(Lnet/minecraft/world/entity/Pose;)F # getEyeHeight \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/neoforge.mods.toml similarity index 64% rename from src/main/resources/META-INF/mods.toml rename to src/main/resources/META-INF/neoforge.mods.toml index 4221c8416..25ce0f826 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -1,8 +1,9 @@ modLoader = "javafml" -loaderVersion = "[2,)" +loaderVersion="${loader_version}" license = "All rights reserved" issueTrackerURL = "/~https://github.com/Seniorendi/AdvancedPeripherals/issues" logoFile = "pack.png" + [[mods]] modId = "${mod_id}" version = "${version}" @@ -15,69 +16,45 @@ It also integrates with multiple third party mods. ''' [[accessTransformers]] -file="META-INF/accesstransformer.cfg" +file = "META-INF/accesstransformer.cfg" -[[dependencies.${mod_id}]] +[[dependencies.${ mod_id }]] modId = "neoforge" type = "required" versionRange = "[${neo_version},)" ordering = "NONE" side = "BOTH" -[[dependencies.${mod_id}]] +[[dependencies.${ mod_id }]] modId = "minecraft" type = "required" versionRange = "[${minecraft_version},)" ordering = "NONE" side = "BOTH" -[[dependencies.${mod_id}]] +[[dependencies.${ mod_id }]] modId = "computercraft" type = "required" versionRange = "[${cc_version},)" ordering = "NONE" side = "BOTH" [[dependencies.${mod_id}]] -modId = "curios" -type = "optional" -versionRange = "[${curios_version},)" -ordering = "NONE" -side = "BOTH" -[[dependencies.${mod_id}]] modId = "ae2" type = "optional" versionRange = "[${appliedenergistics_version},)" ordering = "NONE" side = "BOTH" -[[dependencies.${mod_id}]] -modId = "refinedstorage" -type = "optional" -versionRange = "[1.13.0-beta4,)" -ordnering = "NONE" -side = "BOTH" -[[dependencies.${mod_id}]] +[[dependencies.${ mod_id }]] modId = "minecolonies" type = "optional" versionRange = "[${minecolonies_version},)" ordering = "NONE" side = "BOTH" -[[dependencies.${mod_id}]] +[[dependencies.${ mod_id }]] modId = "patchouli" type = "optional" versionRange = "[${patchouli_version},)" ordering = "NONE" side = "BOTH" -[[dependencies.${mod_id}]] -modId = "create" -type = "optional" -versionRange = "[0.5.1,)" -ordering = "NONE" -side = "BOTH" -[[dependencies.${mod_id}]] -modId = "botania" -type = "optional" -versionRange = "[${botania_version},)" -ordering = "NONE" -side = "BOTH" -[[dependencies.${mod_id}]] +[[dependencies.${ mod_id }]] modId = "mekanism" type = "optional" versionRange = "[${mekanism_version},)" diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_chatty_left.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_chatty_left.json new file mode 100644 index 000000000..ff49ae618 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_chatty_left.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": {"texture": "advancedperipherals:block/chat_box_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_chatty_right.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_chatty_right.json new file mode 100644 index 000000000..9c5de71bd --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_chatty_right.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": {"texture": "advancedperipherals:block/chat_box_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_environment_left.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_environment_left.json new file mode 100644 index 000000000..f144c9175 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_environment_left.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": {"texture": "advancedperipherals:block/environment_detector_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_environment_right.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_environment_right.json new file mode 100644 index 000000000..a86301e57 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_environment_right.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": {"texture": "advancedperipherals:block/environment_detector_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_geoscanner_left.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_geoscanner_left.json new file mode 100644 index 000000000..03466103f --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_geoscanner_left.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": {"texture": "advancedperipherals:block/geo_scanner_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_geoscanner_right.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_geoscanner_right.json new file mode 100644 index 000000000..b79935bae --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_geoscanner_right.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": {"texture": "advancedperipherals:block/geo_scanner_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_player_left.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_player_left.json new file mode 100644 index 000000000..0c38ff073 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_player_left.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": {"texture": "advancedperipherals:block/player_detector_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/models/block/turtle_player_right.json b/src/main/resources/assets/advancedperipherals/models/block/turtle_player_right.json new file mode 100644 index 000000000..542305903 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/models/block/turtle_player_right.json @@ -0,0 +1,4 @@ +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": {"texture": "advancedperipherals:block/player_detector_front"} +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedperipherals/textures/block/ar_controller.png b/src/main/resources/assets/advancedperipherals/textures/block/ar_controller.png deleted file mode 100644 index 2fe546d82..000000000 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/ar_controller.png and /dev/null differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/ar_controller_front.png b/src/main/resources/assets/advancedperipherals/textures/block/ar_controller_front.png deleted file mode 100644 index a12c37923..000000000 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/ar_controller_front.png and /dev/null differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_down.png b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_down.png index c42740fa5..4e039835c 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_down.png and b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_down.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_east.png b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_east.png index a6d3a2147..b2fac00a7 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_east.png and b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_east.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_north.png b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_north.png index b7d47a1c5..7a6bc401d 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_north.png and b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_north.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_north.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_north.png.mcmeta new file mode 100644 index 000000000..3d932eea7 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_north.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 2 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_south.png b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_south.png index b7963a0f9..f832cce92 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_south.png and b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_south.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_up.png b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_up.png index 753304160..300540c6e 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_up.png and b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_up.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_west.png b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_west.png index 7dc2aa101..3523ec91e 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/block_reader_west.png and b/src/main/resources/assets/advancedperipherals/textures/block/block_reader_west.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/bottom.png b/src/main/resources/assets/advancedperipherals/textures/block/bottom.png new file mode 100644 index 000000000..604ecb267 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/bottom.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/chat_box.png b/src/main/resources/assets/advancedperipherals/textures/block/chat_box.png index 1fc9a3ce9..134492be4 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/chat_box.png and b/src/main/resources/assets/advancedperipherals/textures/block/chat_box.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/chat_box_front.png b/src/main/resources/assets/advancedperipherals/textures/block/chat_box_front.png index 0eca0ed3c..39868fc90 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/chat_box_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/chat_box_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/chat_box_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/chat_box_front.png.mcmeta new file mode 100644 index 000000000..9559c00e4 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/chat_box_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 2 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/chat_box_top.png b/src/main/resources/assets/advancedperipherals/textures/block/chat_box_top.png new file mode 100644 index 000000000..093f9a493 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/chat_box_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator.png b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator.png index e2e6b3ecd..eec100570 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator.png and b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_front.png b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_front.png new file mode 100644 index 000000000..408810795 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_front.png.mcmeta new file mode 100644 index 000000000..09eaec921 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 4 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_top.png b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_top.png new file mode 100644 index 000000000..3791355cb Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/colony_integrator_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector.png b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector.png index 3d23b2e88..5b994935b 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector.png and b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_back.png b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_back.png index 231a2e1e5..044eef38b 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_back.png and b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_back.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_east.png b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_east.png new file mode 100644 index 000000000..f1609811f Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_east.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_east.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_east.png.mcmeta new file mode 100644 index 000000000..9559c00e4 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_east.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 2 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_front.png b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_front.png index eed36711f..b08e24afc 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_top.png b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_top.png new file mode 100644 index 000000000..a0c133c96 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/energy_detector_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/environment_detector.png b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector.png index 3fc5af452..3f9a235c7 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/environment_detector.png and b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_front.png b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_front.png index 9b8a97a4f..2d3a1748a 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_front.png.mcmeta new file mode 100644 index 000000000..09eaec921 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 4 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_top.png b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_top.png new file mode 100644 index 000000000..12bc33d06 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/environment_detector_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner.png b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner.png index c3be1ef20..6c37614cb 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner.png and b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_front.png b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_front.png index 6252d7513..51c005da3 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_front.png.mcmeta new file mode 100644 index 000000000..d6331b7cf --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 4 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_top.png b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_top.png new file mode 100644 index 000000000..c4e38cc3b Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/geo_scanner_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager.png b/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager.png index f928023f2..e4d76f393 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager.png and b/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager_front.png b/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager_front.png index 9d26f1f0e..932fbf477 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager_top.png b/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager_top.png new file mode 100644 index 000000000..f6c8a30b2 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/inventory_manager_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/me_bridge.png b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge.png index aad32c54b..0f33f12f0 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/me_bridge.png and b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_front.png b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_front.png index d9ee04417..72745ec1b 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_front.png.mcmeta new file mode 100644 index 000000000..9559c00e4 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 2 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_top.png b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_top.png new file mode 100644 index 000000000..cdc50a6a8 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/me_bridge_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage.png b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage.png index fb9f580b9..339272ef8 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage.png and b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_front.png b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_front.png index e84078a3c..ebd09c27a 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_front.png.mcmeta new file mode 100644 index 000000000..9559c00e4 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 2 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_top.png b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_top.png new file mode 100644 index 000000000..78f6c6d3a Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/nbt_storage_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/peripheral_casing.png b/src/main/resources/assets/advancedperipherals/textures/block/peripheral_casing.png index 20aa776ea..258a10387 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/peripheral_casing.png and b/src/main/resources/assets/advancedperipherals/textures/block/peripheral_casing.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/player_detector.png b/src/main/resources/assets/advancedperipherals/textures/block/player_detector.png deleted file mode 100644 index 0ee0bb55b..000000000 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/player_detector.png and /dev/null differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/player_detector_front.png b/src/main/resources/assets/advancedperipherals/textures/block/player_detector_front.png index a2ee80d43..cb29846f2 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/player_detector_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/player_detector_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/player_detector_side.png b/src/main/resources/assets/advancedperipherals/textures/block/player_detector_side.png index 19dc3a6e8..adb368100 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/player_detector_side.png and b/src/main/resources/assets/advancedperipherals/textures/block/player_detector_side.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/player_detector_top.png b/src/main/resources/assets/advancedperipherals/textures/block/player_detector_top.png new file mode 100644 index 000000000..e2cb43a5d Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/player_detector_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator.png b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator.png deleted file mode 100644 index f3c6599cc..000000000 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator.png and /dev/null differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_bottom.png b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_bottom.png new file mode 100644 index 000000000..9401704ad Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_bottom.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_front.png b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_front.png index 8458ee4c2..a5ab834f7 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_front.png.mcmeta new file mode 100644 index 000000000..9559c00e4 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 2 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_side.png b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_side.png new file mode 100644 index 000000000..dee7029f0 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_side.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_top.png b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_top.png new file mode 100644 index 000000000..4d3238964 Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/redstone_integrator_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge.png b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge.png index e1b45deb4..1018593f5 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge.png and b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_front.png b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_front.png index 45b15f398..e94fa1d59 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_front.png and b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_front.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_front.png.mcmeta b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_front.png.mcmeta new file mode 100644 index 000000000..9559c00e4 --- /dev/null +++ b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 2 + } +} diff --git a/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_top.png b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_top.png new file mode 100644 index 000000000..38c98a90f Binary files /dev/null and b/src/main/resources/assets/advancedperipherals/textures/block/rs_bridge_top.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/entity/villager/profession/computer_scientist.png b/src/main/resources/assets/advancedperipherals/textures/entity/villager/profession/computer_scientist.png index c42e1afbe..732775fc5 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/entity/villager/profession/computer_scientist.png and b/src/main/resources/assets/advancedperipherals/textures/entity/villager/profession/computer_scientist.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/entity/zombie_villager/profession/computer_scientist.png b/src/main/resources/assets/advancedperipherals/textures/entity/zombie_villager/profession/computer_scientist.png index d5e7a619c..e1acca553 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/entity/zombie_villager/profession/computer_scientist.png and b/src/main/resources/assets/advancedperipherals/textures/entity/zombie_villager/profession/computer_scientist.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/gui/inventory_manager_gui.png b/src/main/resources/assets/advancedperipherals/textures/gui/inventory_manager_gui.png index dffcdff01..89175818d 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/gui/inventory_manager_gui.png and b/src/main/resources/assets/advancedperipherals/textures/gui/inventory_manager_gui.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/ar_goggles.png b/src/main/resources/assets/advancedperipherals/textures/item/ar_goggles.png deleted file mode 100644 index 2fc985a12..000000000 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/ar_goggles.png and /dev/null differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/book.png b/src/main/resources/assets/advancedperipherals/textures/item/book.png index 6d5971d6d..bf4aae4be 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/book.png and b/src/main/resources/assets/advancedperipherals/textures/item/book.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/chunk_controller.png b/src/main/resources/assets/advancedperipherals/textures/item/chunk_controller.png index 11577536f..618db58d5 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/chunk_controller.png and b/src/main/resources/assets/advancedperipherals/textures/item/chunk_controller.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/computer_tool.png b/src/main/resources/assets/advancedperipherals/textures/item/computer_tool.png index 6e5491733..ecfe966c9 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/computer_tool.png and b/src/main/resources/assets/advancedperipherals/textures/item/computer_tool.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/empty_glasses_slot.png b/src/main/resources/assets/advancedperipherals/textures/item/empty_glasses_slot.png deleted file mode 100644 index 2f5d24e17..000000000 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/empty_glasses_slot.png and /dev/null differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/memory_card.png b/src/main/resources/assets/advancedperipherals/textures/item/memory_card.png index 6da07f35e..5bd876fe5 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/memory_card.png and b/src/main/resources/assets/advancedperipherals/textures/item/memory_card.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/base_gear.png b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/base_gear.png index 062ce0b12..a12585f2b 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/base_gear.png and b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/base_gear.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire.png b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire.png index f93c7193c..38b4ee20a 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire.png and b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_green.png b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_green.png index 10531427a..5e20e64b7 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_green.png and b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_green.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_purple.png b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_purple.png index 824e63d55..3fdccd14d 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_purple.png and b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/big_fire_purple.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire.png b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire.png index 65690e8d4..8986741f1 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire.png and b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_green.png b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_green.png index ee4af9c9b..d5c2475e6 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_green.png and b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_green.png differ diff --git a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_purple.png b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_purple.png index 97d2f2da2..5492c65e8 100644 Binary files a/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_purple.png and b/src/main/resources/assets/advancedperipherals/textures/item/metaphysics/fire_purple.png differ