From 1fd45fed2da163ed633432bcda82228084ce2153 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Sat, 2 Apr 2022 18:27:04 -0500 Subject: [PATCH 01/13] make spell circles warm up slower but have a faster top speed --- .../hexcasting/api/circle/BlockEntityAbstractImpetus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/petrak/hexcasting/api/circle/BlockEntityAbstractImpetus.java b/src/main/java/at/petrak/hexcasting/api/circle/BlockEntityAbstractImpetus.java index 85e76a30..169499ed 100644 --- a/src/main/java/at/petrak/hexcasting/api/circle/BlockEntityAbstractImpetus.java +++ b/src/main/java/at/petrak/hexcasting/api/circle/BlockEntityAbstractImpetus.java @@ -436,7 +436,7 @@ public abstract class BlockEntityAbstractImpetus extends PaucalBlockEntity imple if (this.trackedBlocks == null) { return 10; } else { - return Math.max(4, 10 - trackedBlocks.size() / 2); + return Math.max(2, 10 - trackedBlocks.size() / 3); } } From f084208f305f538e9e231ab47a1841488cf0db0a Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Sat, 2 Apr 2022 20:44:33 -0500 Subject: [PATCH 02/13] are you happy guru --- .../common/casting/RegisterPatterns.java | 2 ++ .../common/casting/operators/OpDuplicateN.kt | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/main/java/at/petrak/hexcasting/common/casting/operators/OpDuplicateN.kt diff --git a/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java b/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java index 5cd0444f..3ad9145c 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java +++ b/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java @@ -75,6 +75,8 @@ public class RegisterPatterns { PatternRegistry.mapPattern(HexPattern.FromAnglesSig("d", HexDir.EAST), prefix("const/null"), Widget.NULL); PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaa", HexDir.EAST), prefix("duplicate"), OpDuplicate.INSTANCE); + PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaadaa", HexDir.EAST), prefix("duplicate_n"), + OpDuplicateN.INSTANCE); PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawdd", HexDir.EAST), prefix("swap"), OpSwap.INSTANCE); PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddad", HexDir.WEST), prefix("fisherman"), OpFisherman.INSTANCE); diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/OpDuplicateN.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpDuplicateN.kt new file mode 100644 index 00000000..c3d4ea10 --- /dev/null +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpDuplicateN.kt @@ -0,0 +1,34 @@ +package at.petrak.hexcasting.common.casting.operators + +import at.petrak.hexcasting.api.spell.ConstManaOperator +import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked +import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.common.casting.CastingContext +import at.petrak.hexcasting.common.casting.mishaps.MishapInvalidIota +import net.minecraft.network.chat.TranslatableComponent +import kotlin.math.abs +import kotlin.math.roundToInt + +object OpDuplicateN : ConstManaOperator { + override val argc: Int + get() = 2 + + override fun execute(args: List>, ctx: CastingContext): List> { + val countDouble = args.getChecked(1) + + if (abs(countDouble.toInt() - countDouble) >= 0.05f) + throw MishapInvalidIota( + args[1], + 0, + TranslatableComponent("hexcasting.mishap.invalid_value.fisherman", args.size) + ) + + val count = countDouble.roundToInt() + // there's gotta be a better way to do this + val out = mutableListOf>() + for (n in 0 until count) + out.add(args[0]) + + return out + } +} \ No newline at end of file From 36037206d392eb2aba8807e48d7f889897b8febf Mon Sep 17 00:00:00 2001 From: Jared Date: Mon, 4 Apr 2022 22:01:07 +0200 Subject: [PATCH 03/13] Add Jenkinsfile and maven info --- Jenkinsfile | 38 ++++++++++++++++++++++++ build.gradle | 83 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..acf1c2b6 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,38 @@ +#!/usr/bin/env groovy + +pipeline { + agent any + tools { + jdk "jdk-17.0.1" + } + + environment { + discordWebhook = credentials('discord_webhook') + } + stages { + stage('Clean') { + steps { + echo 'Cleaning Project' + sh 'chmod +x gradlew' + sh './gradlew clean' + } + } + stage('Build') { + steps { + echo 'Building' + sh './gradlew build' + } + } + stage('Publish') { + steps { + echo 'Deploying to Maven' + sh './gradlew publish sendWebhook' + } + } + } + post { + always { + archive 'build/libs/**.jar' + } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index ae1b9bcb..6b48d72a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,14 +4,20 @@ buildscript { maven { url = 'https://maven.minecraftforge.net' } maven { url = 'https://maven.parchmentmc.org' } maven { url = 'https://repo.spongepowered.org/maven' } + maven { url = 'https://maven.blamejared.com' } mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true classpath 'org.parchmentmc:librarian:1.+' classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT' + classpath group: 'com.diluv.schoomp', name: 'Schoomp', version: '1.1.0' } } + +import com.diluv.schoomp.Webhook +import com.diluv.schoomp.message.Message + apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' @@ -22,9 +28,11 @@ apply plugin: 'org.spongepowered.mixin' version = '0.7.1' group = 'at.petra-k.hexcasting' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = 'hexcasting' +archivesBaseName = 'hexcasting-1.18.2' -if (System.getenv('TAG_NAME') != null) { +if (System.getenv('BUILD_NUMBER') != null) { + version += "-prerelease-" + System.getenv('BUILD_NUMBER') +} else if (System.getenv('TAG_NAME') != null) { version = System.getenv('TAG_NAME').substring(1) println 'Version overridden to tag version ' + version } @@ -209,6 +217,11 @@ mixin { dumpTargetOnFailure true } +java { + withJavadocJar() + withSourcesJar() +} + // Example for how to get properties into the manifest for reading at runtime. jar { manifest { @@ -230,15 +243,35 @@ jar.finalizedBy('reobfJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing // publish.dependsOn('reobfJar') + +// Disables Gradle's custom module metadata from being published to maven. The +// metadata includes mapped dependencies which are not reasonably consumable by +// other mod developers. +tasks.withType(GenerateModuleMetadata) { + + enabled = false +} + publishing { publications { mavenJava(MavenPublication) { - artifact jar + groupId project.group + artifactId project.archivesBaseName + version project.version + from components.java + + pom.withXml { + + asNode().dependencies.dependency.each { dep -> + + assert dep.parent().remove(dep) + } + } } } repositories { maven { - url "file://${project.projectDir}/mcmodsrepo" + url "file://" + System.getenv("local_maven") } } } @@ -250,3 +283,45 @@ compileTestKotlin { kotlinOptions { } } + +def getGitChangelog = { -> + try { + def stdout = new ByteArrayOutputStream() + def gitHash = System.getenv('GIT_COMMIT') + def gitPrevHash = System.getenv('GIT_PREVIOUS_COMMIT') + def travisRange = System.getenv('TRAVIS_COMMIT_RANGE') + if (gitHash && gitPrevHash) { + exec { + commandLine 'git', 'log', '--pretty=tformat:- %s', '' + gitPrevHash + '...' + gitHash + standardOutput = stdout + } + return stdout.toString().trim() + } else if (travisRange) { + exec { + commandLine 'git', 'log', '--pretty=tformat:- %s', '' + travisRange + standardOutput = stdout + } + return stdout.toString().trim() + } else { + return ""; + } + } catch (ignored) { + return ""; + } +} + +task sendWebhook { + + if (System.getenv('discordWebhook') == null || System.getenv("BUILD_URL") == null) { + println "Cannot send the webhook without the webhook url or the build url" + return + } + def webhook = new Webhook(System.getenv('discordWebhook'), 'HexMod Patreon Gradle') + + def message = new Message() + message.setUsername("Patreon early access") + message.setContent("New HexMod release! Download it here: ${System.getenv("BUILD_URL")}\nChangelog:\n${getGitChangelog()}") + + webhook.sendMessage(message) +} + From a4a9f2160255056c14a69218200709e89d8610c1 Mon Sep 17 00:00:00 2001 From: Jared Date: Mon, 4 Apr 2022 22:09:20 +0200 Subject: [PATCH 04/13] Fix discord webhook credential --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index acf1c2b6..e28ba668 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,9 +5,8 @@ pipeline { tools { jdk "jdk-17.0.1" } - environment { - discordWebhook = credentials('discord_webhook') + discordWebhook = credentials('discordWebhook') } stages { stage('Clean') { @@ -32,7 +31,7 @@ pipeline { } post { always { - archive 'build/libs/**.jar' + archiveArtifacts 'build/libs/**.jar' } } } \ No newline at end of file From ef40b86ede2687b7e3342b9ec1e86920ad87d40c Mon Sep 17 00:00:00 2001 From: Jared Date: Mon, 4 Apr 2022 22:13:25 +0200 Subject: [PATCH 05/13] Only post the webhook once --- build.gradle | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 6b48d72a..6dd780d0 100644 --- a/build.gradle +++ b/build.gradle @@ -312,16 +312,22 @@ def getGitChangelog = { -> task sendWebhook { - if (System.getenv('discordWebhook') == null || System.getenv("BUILD_URL") == null) { - println "Cannot send the webhook without the webhook url or the build url" - return + doLast { + try { + if (System.getenv('discordWebhook') == null || System.getenv("BUILD_URL") == null) { + println "Cannot send the webhook without the webhook url or the build url" + return + } + def webhook = new Webhook(System.getenv('discordWebhook'), 'HexMod Patreon Gradle') + + def message = new Message() + message.setUsername("Patreon early access") + message.setContent("New HexMod release! Download it here: ${System.getenv("BUILD_URL")}\nChangelog:\n${getGitChangelog()}") + + webhook.sendMessage(message) + } catch (ignored) { + project.logger.error("Failed to push Discord webhook.") + } } - def webhook = new Webhook(System.getenv('discordWebhook'), 'HexMod Patreon Gradle') - - def message = new Message() - message.setUsername("Patreon early access") - message.setContent("New HexMod release! Download it here: ${System.getenv("BUILD_URL")}\nChangelog:\n${getGitChangelog()}") - - webhook.sendMessage(message) } From 8e6be116601054a23f2436445a1784f19d4e84c9 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Mon, 4 Apr 2022 17:37:07 -0500 Subject: [PATCH 06/13] <3 you @jaredlll08 --- .github/workflows/gradle.yml | 24 ------------------------ .github/workflows/publish.yml | 25 ------------------------- build.gradle | 2 +- 3 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 .github/workflows/gradle.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 5b24ecae..00000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Java CI with Gradle -on: - push: - tags: 'v*' - branches: 'main' -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@v2 - with: - arguments: build - - uses: actions/upload-artifact@v2 - if: github.event_name != 'pull_request' - with: - name: Package - path: build/libs diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 084817ca..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Publish tag -on: - push: - tags: - - 'v*' -jobs: - build: - runs-on: ubuntu-latest - env: - TAG_NAME: ${{ github.ref_name }} - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@v2 - with: - arguments: build - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: build/libs/* diff --git a/build.gradle b/build.gradle index 6dd780d0..c42e302d 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.parchmentmc.librarian.forgegradle' apply plugin: 'org.spongepowered.mixin' -version = '0.7.1' +version = '0.8.0' group = 'at.petra-k.hexcasting' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'hexcasting-1.18.2' From 7fed08890b1d48e13c802b7ace834f3cef7de70b Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Mon, 4 Apr 2022 17:48:19 -0500 Subject: [PATCH 07/13] move to different folder in jenkins and update formatting --- build.gradle | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index c42e302d..677b4f15 100644 --- a/build.gradle +++ b/build.gradle @@ -292,21 +292,21 @@ def getGitChangelog = { -> def travisRange = System.getenv('TRAVIS_COMMIT_RANGE') if (gitHash && gitPrevHash) { exec { - commandLine 'git', 'log', '--pretty=tformat:- %s', '' + gitPrevHash + '...' + gitHash + commandLine 'git', 'log', '--pretty=tformat:> %s', '' + gitPrevHash + '...' + gitHash standardOutput = stdout } return stdout.toString().trim() } else if (travisRange) { exec { - commandLine 'git', 'log', '--pretty=tformat:- %s', '' + travisRange + commandLine 'git', 'log', '--pretty=tformat:> %s', '' + travisRange standardOutput = stdout } return stdout.toString().trim() } else { - return ""; + return "" } } catch (ignored) { - return ""; + return "" } } @@ -318,11 +318,11 @@ task sendWebhook { println "Cannot send the webhook without the webhook url or the build url" return } - def webhook = new Webhook(System.getenv('discordWebhook'), 'HexMod Patreon Gradle') + def webhook = new Webhook(System.getenv('discordWebhook'), 'Petrak@ Patreon Gradle') def message = new Message() - message.setUsername("Patreon early access") - message.setContent("New HexMod release! Download it here: ${System.getenv("BUILD_URL")}\nChangelog:\n${getGitChangelog()}") + message.setUsername("Patreon Early Access") + message.setContent("New Hexcasting release! Download it here: ${System.getenv("BUILD_URL")}\nChangelog:\n${getGitChangelog()}") webhook.sendMessage(message) } catch (ignored) { From 76f492e2607569611d712b0c460cbce0309d9e33 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:25:17 -0500 Subject: [PATCH 08/13] finally free from the tyranny of curse maven --- build.gradle | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 677b4f15..e9669e6f 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,33 @@ version = '0.8.0' group = 'at.petra-k.hexcasting' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'hexcasting-1.18.2' -if (System.getenv('BUILD_NUMBER') != null) { +def isRelease = { -> + try { + def stdout = new ByteArrayOutputStream() + def gitHash = System.getenv('GIT_COMMIT') + def gitPrevHash = System.getenv('GIT_PREVIOUS_COMMIT') + def travisRange = System.getenv('TRAVIS_COMMIT_RANGE') + if (gitHash && gitPrevHash) { + exec { + commandLine 'git', 'log', '--pretty=tformat:- %s', '' + gitPrevHash + '...' + gitHash + standardOutput = stdout + } + return stdout.toString().toLowerCase().contains("[release") + } else if (travisRange) { + exec { + commandLine 'git', 'log', '--pretty=tformat:- %s', '' + travisRange + standardOutput = stdout + } + return stdout.toString().toLowerCase().contains("[release") + } else { + return false + } + } catch (ignored) { + return false + } +} + +if (!isRelease && System.getenv('BUILD_NUMBER') != null) { version += "-prerelease-" + System.getenv('BUILD_NUMBER') } else if (System.getenv('TAG_NAME') != null) { version = System.getenv('TAG_NAME').substring(1) @@ -207,8 +233,8 @@ dependencies { // at runtime, use the full JEI jar runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.3.143") - compileOnly fg.deobf("curse.maven:paucal-597824:3724029") - runtimeOnly fg.deobf("curse.maven:paucal-597824:3724029") + compileOnly fg.deobf("at.petra-k.paucal:paucal-1.18.2:0.3.2") + runtimeOnly fg.deobf("at.petra-k.paucal:paucal-1.18.2:0.3.2") } mixin { @@ -311,7 +337,6 @@ def getGitChangelog = { -> } task sendWebhook { - doLast { try { if (System.getenv('discordWebhook') == null || System.getenv("BUILD_URL") == null) { From 3726c275ee74ce0d79d006bd0968eed7698c9358 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:32:47 -0500 Subject: [PATCH 09/13] test: jenkins shouldn't build this one --- .../hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java index 24805d26..7a5e704e 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java @@ -29,6 +29,8 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En .setValue(DATUM_TYPE, DatumType.EMPTY)); } + // aa + @Override public @Nullable BlockPos getRecordPosition(BlockPos herePos, BlockState state, Level world) { if (world.getBlockEntity(herePos) instanceof BlockEntityAkashicBookshelf tile && From 9c232a4d0cff4a001b34a92ee7aa85ff94cc7fa3 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:25:17 -0500 Subject: [PATCH 10/13] finally free from the tyranny of curse maven and jenkins should build this? --- build.gradle | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 677b4f15..e9669e6f 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,33 @@ version = '0.8.0' group = 'at.petra-k.hexcasting' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'hexcasting-1.18.2' -if (System.getenv('BUILD_NUMBER') != null) { +def isRelease = { -> + try { + def stdout = new ByteArrayOutputStream() + def gitHash = System.getenv('GIT_COMMIT') + def gitPrevHash = System.getenv('GIT_PREVIOUS_COMMIT') + def travisRange = System.getenv('TRAVIS_COMMIT_RANGE') + if (gitHash && gitPrevHash) { + exec { + commandLine 'git', 'log', '--pretty=tformat:- %s', '' + gitPrevHash + '...' + gitHash + standardOutput = stdout + } + return stdout.toString().toLowerCase().contains("[release") + } else if (travisRange) { + exec { + commandLine 'git', 'log', '--pretty=tformat:- %s', '' + travisRange + standardOutput = stdout + } + return stdout.toString().toLowerCase().contains("[release") + } else { + return false + } + } catch (ignored) { + return false + } +} + +if (!isRelease && System.getenv('BUILD_NUMBER') != null) { version += "-prerelease-" + System.getenv('BUILD_NUMBER') } else if (System.getenv('TAG_NAME') != null) { version = System.getenv('TAG_NAME').substring(1) @@ -207,8 +233,8 @@ dependencies { // at runtime, use the full JEI jar runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.3.143") - compileOnly fg.deobf("curse.maven:paucal-597824:3724029") - runtimeOnly fg.deobf("curse.maven:paucal-597824:3724029") + compileOnly fg.deobf("at.petra-k.paucal:paucal-1.18.2:0.3.2") + runtimeOnly fg.deobf("at.petra-k.paucal:paucal-1.18.2:0.3.2") } mixin { @@ -311,7 +337,6 @@ def getGitChangelog = { -> } task sendWebhook { - doLast { try { if (System.getenv('discordWebhook') == null || System.getenv("BUILD_URL") == null) { From fe5d799ef06b61887ba23189f06af55c5e0fab59 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:37:12 -0500 Subject: [PATCH 11/13] hopefully only publish to maven on main branch? --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index e28ba668..d1f09880 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,6 +23,7 @@ pipeline { } } stage('Publish') { + when { branch 'main' } steps { echo 'Deploying to Maven' sh './gradlew publish sendWebhook' From f672da34855de3934ec9f5497629b9adff906fd2 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:37:49 -0500 Subject: [PATCH 12/13] and this should NOT build --- .../hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java index 7a5e704e..24805d26 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java @@ -29,8 +29,6 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En .setValue(DATUM_TYPE, DatumType.EMPTY)); } - // aa - @Override public @Nullable BlockPos getRecordPosition(BlockPos herePos, BlockState state, Level world) { if (world.getBlockEntity(herePos) instanceof BlockEntityAkashicBookshelf tile && From 5d97c7390b86d6e24f5f6c82ee9e62883739dfd2 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Thu, 7 Apr 2022 10:38:48 -0500 Subject: [PATCH 13/13] backend changes to scrolls and slates, and akashic libraries still dont work --- build.gradle | 7 --- src/generated/resources/.cache/cache | 58 +++++++++---------- .../block/akashic_bookshelf_double0.json | 4 +- .../block/akashic_bookshelf_double1.json | 4 +- .../block/akashic_bookshelf_double2.json | 4 +- .../block/akashic_bookshelf_double3.json | 4 +- .../block/akashic_bookshelf_empty0.json | 4 +- .../block/akashic_bookshelf_entity0.json | 4 +- .../block/akashic_bookshelf_entity1.json | 4 +- .../block/akashic_bookshelf_entity2.json | 4 +- .../block/akashic_bookshelf_entity3.json | 4 +- .../models/block/akashic_bookshelf_list0.json | 4 +- .../models/block/akashic_bookshelf_list1.json | 4 +- .../models/block/akashic_bookshelf_list2.json | 4 +- .../models/block/akashic_bookshelf_list3.json | 4 +- .../block/akashic_bookshelf_other0.json | 4 +- .../block/akashic_bookshelf_other1.json | 4 +- .../block/akashic_bookshelf_other2.json | 4 +- .../block/akashic_bookshelf_other3.json | 4 +- .../block/akashic_bookshelf_pattern0.json | 4 +- .../block/akashic_bookshelf_pattern1.json | 4 +- .../block/akashic_bookshelf_pattern2.json | 4 +- .../block/akashic_bookshelf_pattern3.json | 4 +- .../models/block/akashic_bookshelf_vec0.json | 4 +- .../models/block/akashic_bookshelf_vec1.json | 4 +- .../models/block/akashic_bookshelf_vec2.json | 4 +- .../models/block/akashic_bookshelf_vec3.json | 4 +- .../block/akashic_bookshelf_widget0.json | 4 +- .../block/akashic_bookshelf_widget1.json | 4 +- .../block/akashic_bookshelf_widget2.json | 4 +- .../block/akashic_bookshelf_widget3.json | 4 +- .../item/DataHolder.java} | 33 ++++------- .../client/RegisterClientStuff.java | 12 ++-- .../blocks/akashic/BlockAkashicBookshelf.java | 48 +++++++++++++-- .../blocks/akashic/BlockAkashicRecord.java | 32 ++++++++++ .../akashic/BlockEntityAkashicBookshelf.java | 27 +++++++-- .../akashic/BlockEntityAkashicRecord.java | 9 +-- .../impetuses/BlockStoredPlayerImpetus.java | 4 +- .../common/casting/CastingContext.kt | 4 +- .../common/casting/operators/OpRead.kt | 6 +- .../casting/operators/OpTheCoolerRead.kt | 6 +- .../common/casting/operators/OpWrite.kt | 34 ++--------- .../operators/akashic/OpAkashicWrite.kt | 47 +++++++++++---- .../common/entities/EntityWallScroll.java | 2 +- .../hexcasting/common/items/ItemAbacus.java | 14 ++++- .../hexcasting/common/items/ItemFocus.java | 15 ++++- .../hexcasting/common/items/ItemScroll.java | 34 ++++++++++- .../hexcasting/common/items/ItemSlate.java | 46 ++++++++++++++- .../common/items/ItemSpellbook.java | 4 +- .../hexcasting/common/lib/HexSounds.java | 3 +- .../assets/hexcasting/lang/en_us.json | 1 + .../resources/assets/hexcasting/sounds.json | 8 +++ 52 files changed, 376 insertions(+), 194 deletions(-) rename src/main/java/at/petrak/hexcasting/{common/items/ItemDataHolder.java => api/item/DataHolder.java} (53%) diff --git a/build.gradle b/build.gradle index e9669e6f..41bb2f81 100644 --- a/build.gradle +++ b/build.gradle @@ -207,13 +207,6 @@ repositories { name = "ModMaven" url = "https://modmaven.dev" } - - maven { - url "https://cursemaven.com" - content { - includeGroup "curse.maven" - } - } } dependencies { diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 8e267182..166c300d 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -28,35 +28,35 @@ aed50918bad8a7b00cd26e45d67eb509a04c9f6c assets/hexcasting/blockstates/amethyst_ 77e723163f415795437b810fe87c348c96a989be assets/hexcasting/blockstates/scroll_paper_lantern.json 5cb63493ae07f5ab5d8f686e3553c97a85105931 assets/hexcasting/blockstates/slate.json 043abd5bbfd1186415049d24d185d4e4395320f9 assets/hexcasting/blockstates/slate_block.json -866dc8bd766571aec33394b4af1e6b28ceef36cb assets/hexcasting/models/block/akashic_bookshelf_double0.json -b582e7eb88a4e7cf258b903d2ba282bfa5770deb assets/hexcasting/models/block/akashic_bookshelf_double1.json -06ec37e0e3edc576713e60ea3670f208ddef8335 assets/hexcasting/models/block/akashic_bookshelf_double2.json -fa7df33096483b43d2fd5e663576d0ed6c77fd00 assets/hexcasting/models/block/akashic_bookshelf_double3.json -2fb789e8f932dff33b9dffef66a6c570cd09e593 assets/hexcasting/models/block/akashic_bookshelf_empty0.json -1bf1773a6224537b0d1cdb5ed98300094763b35e assets/hexcasting/models/block/akashic_bookshelf_entity0.json -fb06e1af5d79feae6f8826bba0fc6c57f95f32eb assets/hexcasting/models/block/akashic_bookshelf_entity1.json -cc2a9bb3c959ad313431c1476f6f3a4410aaf4d5 assets/hexcasting/models/block/akashic_bookshelf_entity2.json -339d944a1604a0949e836a412b192ef5f18a31de assets/hexcasting/models/block/akashic_bookshelf_entity3.json -609195285d8672221f3bf5d6196e2536a29e3a36 assets/hexcasting/models/block/akashic_bookshelf_list0.json -66bb6f23b7d5fdcd1bfd45cbba00c082bf328d6d assets/hexcasting/models/block/akashic_bookshelf_list1.json -8e9fabc624bd4a9171f326d1b116ddce0ac03936 assets/hexcasting/models/block/akashic_bookshelf_list2.json -b6722e6b1ed5bae988152579f925562e05c0e7ce assets/hexcasting/models/block/akashic_bookshelf_list3.json -450c52b84d0ce8db6bca9bcb0f401e4c0f64d56e assets/hexcasting/models/block/akashic_bookshelf_other0.json -c45373e6acfe8e02b892cf79b0ab90b20505a403 assets/hexcasting/models/block/akashic_bookshelf_other1.json -0bd6a902d935c54f95c403fe987d6d1d8fd4b037 assets/hexcasting/models/block/akashic_bookshelf_other2.json -df0eff5d064b1344c16a25b1f61ed8e0d1d9e93d assets/hexcasting/models/block/akashic_bookshelf_other3.json -f012cc73e966263135581f6b5559573d7027d161 assets/hexcasting/models/block/akashic_bookshelf_pattern0.json -1b0fa714816106bf800346a47558f808b614f20e assets/hexcasting/models/block/akashic_bookshelf_pattern1.json -c87db8396d3aff9de54bceaaf7005e99bc11e941 assets/hexcasting/models/block/akashic_bookshelf_pattern2.json -c97f68bfea418fc1e71e801ddb408456aaf2709b assets/hexcasting/models/block/akashic_bookshelf_pattern3.json -daa7c03501b6c416e292ee81a1086777374fb65f assets/hexcasting/models/block/akashic_bookshelf_vec0.json -77a385aef36d9ff1b8ee8c3257cf0a131c7a00bc assets/hexcasting/models/block/akashic_bookshelf_vec1.json -088749fa83b9eab81e572b93833ab31166cf54aa assets/hexcasting/models/block/akashic_bookshelf_vec2.json -2d9880c0a28e90e030b920426443e69e4bbda3d1 assets/hexcasting/models/block/akashic_bookshelf_vec3.json -2d66d2d958325c5e8afd8ded4e413a0a29d004cf assets/hexcasting/models/block/akashic_bookshelf_widget0.json -8eb8b14eb801739687ac4cdf29b959dce0b206f3 assets/hexcasting/models/block/akashic_bookshelf_widget1.json -2ceccf7ebfad7517a476978b7110875f05569506 assets/hexcasting/models/block/akashic_bookshelf_widget2.json -4511f440c9f25f6daa2bf352f192beef3088faf2 assets/hexcasting/models/block/akashic_bookshelf_widget3.json +2d15e34158cece647d497ef88e463487359f75eb assets/hexcasting/models/block/akashic_bookshelf_double0.json +632d2cddba9c17b1580d50e1995de3c44d31f542 assets/hexcasting/models/block/akashic_bookshelf_double1.json +c96c914adc33e0aede5e65c157b86d712c93fe3c assets/hexcasting/models/block/akashic_bookshelf_double2.json +d450489f48e120d19ace98d6419c30bf6d2abf57 assets/hexcasting/models/block/akashic_bookshelf_double3.json +7f0443e9859e339695dc51a17999ba464cfafd10 assets/hexcasting/models/block/akashic_bookshelf_empty0.json +697e3e12fad2fa3cbcaf65ec9e8730796762d761 assets/hexcasting/models/block/akashic_bookshelf_entity0.json +4afa26f463c514c93a7faa86834515769d14fae3 assets/hexcasting/models/block/akashic_bookshelf_entity1.json +726d6db36ec79c44c21bcb9e726ccd45d3f7603c assets/hexcasting/models/block/akashic_bookshelf_entity2.json +4eb78401ba6018230d7f2f15a4604f7f82e10288 assets/hexcasting/models/block/akashic_bookshelf_entity3.json +4160204476c68c89f49862b1239feaab7efc82af assets/hexcasting/models/block/akashic_bookshelf_list0.json +30b2da2b25229646729fc6a60bca939b17a301cb assets/hexcasting/models/block/akashic_bookshelf_list1.json +d820a4698ed10673f83fd5d3d2ba51831eed1719 assets/hexcasting/models/block/akashic_bookshelf_list2.json +16a4ac20b3342fc0551c7819f4b588f834b05240 assets/hexcasting/models/block/akashic_bookshelf_list3.json +a2c05476f6876e1d3933fbf24c7ebee6a817e4e7 assets/hexcasting/models/block/akashic_bookshelf_other0.json +e4f5dd9d9c18e8864bdb8089c5c027b961840c71 assets/hexcasting/models/block/akashic_bookshelf_other1.json +a0648b0b707cb71302c0b4c5c1d1850700049f0b assets/hexcasting/models/block/akashic_bookshelf_other2.json +da0b58413ccbe244395e576374eabf9f7f77cff5 assets/hexcasting/models/block/akashic_bookshelf_other3.json +46f14c543f573d17ce88586994b5190d49aa82e0 assets/hexcasting/models/block/akashic_bookshelf_pattern0.json +d35301dcfa6113bf18d93e3390e4f41ba82fc496 assets/hexcasting/models/block/akashic_bookshelf_pattern1.json +4fcce7cb268762cefc7aeb23857f4a8f9dd27cea assets/hexcasting/models/block/akashic_bookshelf_pattern2.json +05a5db451083e351663a3e8543de96387ccb0019 assets/hexcasting/models/block/akashic_bookshelf_pattern3.json +b40c007e6445c3651fb862a717ffcae71fa5b134 assets/hexcasting/models/block/akashic_bookshelf_vec0.json +0e5e5980be796fed69121b5afbb345a7e7f5e232 assets/hexcasting/models/block/akashic_bookshelf_vec1.json +cbda1ba469c679566ad913d02a2aa6b82d581469 assets/hexcasting/models/block/akashic_bookshelf_vec2.json +4ecb317c7f0844878ef3e507ea40fb5c02ad9325 assets/hexcasting/models/block/akashic_bookshelf_vec3.json +2430f9dcaf51c86d3413ebfc6834e3ca91e5f4aa assets/hexcasting/models/block/akashic_bookshelf_widget0.json +94e79ebb6e73ef89ec6a20d11b7ea242e6f387c3 assets/hexcasting/models/block/akashic_bookshelf_widget1.json +3b411abf79de1e2bed972a40c3338e4584719b54 assets/hexcasting/models/block/akashic_bookshelf_widget2.json +6363ddafca13522e33c94656f05d381d8cdf286f assets/hexcasting/models/block/akashic_bookshelf_widget3.json a38a867ae86bc5da5e7abb668e6a92a7e2628279 assets/hexcasting/models/block/akashic_connector.json f3a7403c673a4816d421f22e69a5458670694aac assets/hexcasting/models/block/akashic_door_bottom.json 8e33c5d50ab94c4996522cce88b70e5c317a3635 assets/hexcasting/models/block/akashic_door_bottom_hinge.json diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double0.json index dec5342b..eb4d5110 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/double1", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double1.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double1.json index f618f9c1..ca8f6cfa 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double1.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double1.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/double2", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double2.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double2.json index 1bc167a7..2aea1933 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double2.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double2.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/double3", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double3.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double3.json index fbee5842..6a10e5ec 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double3.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_double3.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/double4", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_empty0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_empty0.json index 37917acf..604cacdf 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_empty0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_empty0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/empty", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity0.json index bab7986a..5a429bac 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/entity1", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity1.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity1.json index 4a0ba9b1..e478c719 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity1.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity1.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/entity2", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity2.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity2.json index 51505f94..caad1590 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity2.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity2.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/entity3", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity3.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity3.json index 6b74b216..53a353f3 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity3.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_entity3.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/entity4", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list0.json index 7673301f..4c3896c0 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/list1", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list1.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list1.json index ba169dff..40dc9956 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list1.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list1.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/list2", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list2.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list2.json index 91f65a6d..8bc26865 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list2.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list2.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/list3", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list3.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list3.json index 08e4594d..f37fd6be 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list3.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_list3.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/list4", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other0.json index 881f5fa8..7d0687b5 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/other1", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other1.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other1.json index 32fc84ba..07354172 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other1.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other1.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/other2", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other2.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other2.json index 212c6033..06a6ab8a 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other2.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other2.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/other3", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other3.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other3.json index 7c5e6ba0..a6480e7c 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other3.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_other3.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/other4", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern0.json index 230eca16..49d2df4c 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/pattern1", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern1.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern1.json index 20b0b6a2..4dea8d09 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern1.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern1.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/pattern2", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern2.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern2.json index 820248f8..8f81975c 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern2.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern2.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/pattern3", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern3.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern3.json index fc81de56..c30a3dc0 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern3.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_pattern3.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/pattern4", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec0.json index aa5572b2..dc248492 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/vec1", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec1.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec1.json index 03ccaa1c..210cc820 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec1.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec1.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/vec2", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec2.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec2.json index 7e628c0a..33f37499 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec2.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec2.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/vec3", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec3.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec3.json index a465e59d..0ae396e2 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec3.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_vec3.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/vec4", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget0.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget0.json index 7595f522..0f2f7e9b 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget0.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget0.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/widget1", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget1.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget1.json index fc99c1bf..57604fc5 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget1.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget1.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/widget2", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget2.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget2.json index 9c6eb31f..16ef90fd 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget2.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget2.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/widget3", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget3.json b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget3.json index d6da2361..b0b686f6 100644 --- a/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget3.json +++ b/src/generated/resources/assets/hexcasting/models/block/akashic_bookshelf_widget3.json @@ -1,8 +1,8 @@ { "parent": "minecraft:block/orientable", "textures": { - "side": "hexcasting:block/akashic/planks1", + "side": "hexcasting:block/akashic/bookshelf/side", "front": "hexcasting:block/akashic/bookshelf/widget4", - "top": "hexcasting:block/akashic/tile" + "top": "hexcasting:block/akashic/bookshelf/end" } } \ No newline at end of file diff --git a/src/main/java/at/petrak/hexcasting/common/items/ItemDataHolder.java b/src/main/java/at/petrak/hexcasting/api/item/DataHolder.java similarity index 53% rename from src/main/java/at/petrak/hexcasting/common/items/ItemDataHolder.java rename to src/main/java/at/petrak/hexcasting/api/item/DataHolder.java index be6c4e1a..29728c6b 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/ItemDataHolder.java +++ b/src/main/java/at/petrak/hexcasting/api/item/DataHolder.java @@ -1,51 +1,42 @@ -package at.petrak.hexcasting.common.items; +package at.petrak.hexcasting.api.item; import at.petrak.hexcasting.api.spell.SpellDatum; -import at.petrak.hexcasting.common.casting.CastingContext; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.world.item.Item; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; import java.util.List; -abstract public class ItemDataHolder extends Item { - public ItemDataHolder(Properties pProperties) { - super(pProperties); - } +public interface DataHolder { + @Nullable CompoundTag readDatumTag(ItemStack stack); @Nullable - public abstract CompoundTag readDatumTag(ItemStack stack); - - @Nullable - public SpellDatum readDatum(ItemStack stack, CastingContext ctx) { - if (!(stack.getItem() instanceof ItemDataHolder dh)) { + default SpellDatum readDatum(ItemStack stack, ServerLevel world) { + if (!(stack.getItem() instanceof DataHolder dh)) { + // this should be checked via mishap beforehand throw new IllegalArgumentException("stack's item must be an ItemDataholder but was " + stack.getItem()); } var tag = dh.readDatumTag(stack); if (tag != null) { - return SpellDatum.DeserializeFromNBT(tag, ctx); + return SpellDatum.DeserializeFromNBT(tag, world); } else { return null; } } + boolean canWrite(CompoundTag tag, SpellDatum datum); - public abstract boolean canWrite(CompoundTag tag, SpellDatum datum); + void writeDatum(CompoundTag tag, SpellDatum datum); - public abstract void writeDatum(CompoundTag tag, SpellDatum datum); - - - @Override - public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltipComponents, + static void appendHoverText(DataHolder self, ItemStack pStack, List pTooltipComponents, TooltipFlag pIsAdvanced) { - var datumTag = this.readDatumTag(pStack); + var datumTag = self.readDatumTag(pStack); if (datumTag != null) { var component = SpellDatum.DisplayFromTag(datumTag); pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component)); diff --git a/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java b/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java index 3c4be97f..798f85a0 100644 --- a/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java +++ b/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java @@ -146,15 +146,15 @@ public class RegisterClientStuff { var out = new ArrayList>(); - if (tile.recordPos != null) { + var recordPos = tile.getRecordPos(); + var pattern = tile.getPattern(); + if (recordPos != null && pattern != null) { out.add(new Pair<>(new ItemStack(HexBlocks.AKASHIC_RECORD.get()), new TranslatableComponent( "hexcasting.tooltip.lens.akashic.bookshelf.location", - tile.recordPos.toShortString() + recordPos.toShortString() ))); - if (tile.pattern != null) { - if (world.getBlockEntity(tile.recordPos) instanceof BlockEntityAkashicRecord record) { - out.add(new Pair<>(new ItemStack(Items.BOOK), record.getDisplayAt(tile.pattern))); - } + if (world.getBlockEntity(recordPos) instanceof BlockEntityAkashicRecord record) { + out.add(new Pair<>(new ItemStack(Items.BOOK), record.getDisplayAt(pattern))); } } diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java index 24805d26..5ca783a6 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java @@ -1,9 +1,16 @@ package at.petrak.hexcasting.common.blocks.akashic; import at.petrak.hexcasting.api.spell.DatumType; +import at.petrak.hexcasting.api.spell.SpellDatum; import at.petrak.hexcasting.common.blocks.HexBlocks; +import at.petrak.hexcasting.common.items.ItemScroll; +import at.petrak.hexcasting.common.lib.HexSounds; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -16,6 +23,7 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.phys.BlockHitResult; import org.jetbrains.annotations.Nullable; public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements EntityBlock { @@ -31,21 +39,53 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En @Override public @Nullable BlockPos getRecordPosition(BlockPos herePos, BlockState state, Level world) { + // time saving measure? if (world.getBlockEntity(herePos) instanceof BlockEntityAkashicBookshelf tile && - tile.recordPos != null && world.getBlockEntity(tile.recordPos) instanceof BlockEntityAkashicRecord) { - return tile.recordPos; + tile.getRecordPos() != null && world.getBlockEntity( + tile.getRecordPos()) instanceof BlockEntityAkashicRecord) { + return tile.getRecordPos(); } return super.getRecordPosition(herePos, state, world); } + @Override + public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, + BlockHitResult pHit) { + if (pLevel.getBlockEntity(pPos) instanceof BlockEntityAkashicBookshelf shelf) { + var stack = pPlayer.getItemInHand(pHand); + if (stack.getItem() instanceof ItemScroll scroll) { + if (!pLevel.isClientSide()) { + scroll.writeDatum(stack.getOrCreateTag(), SpellDatum.make(shelf.getPattern())); + } + pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE.get(), SoundSource.BLOCKS, 1f, 1f); + return InteractionResult.sidedSuccess(pLevel.isClientSide); + } else if (pPlayer.isDiscrete() && pHand == InteractionHand.MAIN_HAND && stack.isEmpty()) { + if (!pLevel.isClientSide()) { + shelf.setNewData(null, null, DatumType.EMPTY); + + var recordPos = HexBlocks.AKASHIC_BOOKSHELF.get().getRecordPosition(pPos, pState, pLevel); + if (recordPos != null && + pLevel.getBlockEntity(recordPos) instanceof BlockEntityAkashicRecord record) { + record.revalidateAllBookshelves(); + } + } + + pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE.get(), SoundSource.BLOCKS, + 1f, 0.8f); + return InteractionResult.sidedSuccess(pLevel.isClientSide); + } + } + + return InteractionResult.PASS; + } + @Override public void onPlace(BlockState pState, Level world, BlockPos pos, BlockState pOldState, boolean pIsMoving) { if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) { var recordPos = BlockAkashicFloodfiller.floodFillFor(pos, world, (here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get())); if (recordPos != null) { - tile.recordPos = recordPos; - tile.setChanged(); + tile.setNewData(recordPos, tile.getPattern(), DatumType.EMPTY); } } } diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java index 1e67555e..760a0b74 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java @@ -1,12 +1,18 @@ package at.petrak.hexcasting.common.blocks.akashic; +import at.petrak.hexcasting.api.spell.DatumType; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Nullable; +import java.util.ArrayDeque; +import java.util.HashSet; + public class BlockAkashicRecord extends Block implements EntityBlock { public BlockAkashicRecord(Properties p_49795_) { super(p_49795_); @@ -17,4 +23,30 @@ public class BlockAkashicRecord extends Block implements EntityBlock { public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { return new BlockEntityAkashicRecord(pPos, pState); } + + @Override + public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) { + var seen = new HashSet(); + var todo = new ArrayDeque(); + todo.add(pPos); + // we do NOT add this position to the valid positions, because the record + // isn't flood-fillable through. + while (!todo.isEmpty()) { + var here = todo.remove(); + + for (var dir : Direction.values()) { + var neighbor = here.relative(dir); + if (seen.add(neighbor)) { + var bs = pLevel.getBlockState(neighbor); + if (BlockAkashicFloodfiller.canItBeFloodedThrough(neighbor, bs, pLevel)) { + todo.add(neighbor); + } + if (pLevel.getBlockEntity(pPos) instanceof BlockEntityAkashicBookshelf shelf) { + shelf.setNewData(null, null, DatumType.EMPTY); + } + } + } + } + super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving); + } } diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java index a793c6bb..089cc7e8 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java @@ -20,28 +20,40 @@ import net.minecraft.nbt.NbtUtils; import net.minecraft.util.Mth; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec2; +import org.jetbrains.annotations.Nullable; public class BlockEntityAkashicBookshelf extends PaucalBlockEntity { public static final String TAG_RECORD_POS = "record_pos"; public static final String TAG_PATTERN = "pattern"; - // This might actually be innacurate! It's a best-guess - public BlockPos recordPos = null; + // This might actually be inaccurate! It's a best-guess + private BlockPos recordPos = null; // This is only not null if this stores any data. - public HexPattern pattern = null; + private HexPattern pattern = null; public BlockEntityAkashicBookshelf(BlockPos pWorldPosition, BlockState pBlockState) { super(HexBlockEntities.AKASHIC_BOOKSHELF_TILE.get(), pWorldPosition, pBlockState); } - public void setNewDatum(BlockPos recordPos, HexPattern pattern, DatumType type) { + @Nullable + public BlockPos getRecordPos() { + return recordPos; + } + + @Nullable + public HexPattern getPattern() { + return pattern; + } + + + public void setNewData(BlockPos recordPos, HexPattern pattern, DatumType type) { this.recordPos = recordPos; this.pattern = pattern; this.setChanged(); var oldBs = this.getBlockState(); var newBs = oldBs.setValue(BlockAkashicBookshelf.DATUM_TYPE, type); - this.level.setBlockAndUpdate(this.getBlockPos(), newBs); + this.level.setBlock(this.getBlockPos(), newBs, 3); this.level.sendBlockUpdated(this.getBlockPos(), oldBs, newBs, 3); } @@ -49,7 +61,6 @@ public class BlockEntityAkashicBookshelf extends PaucalBlockEntity { protected void saveModData(CompoundTag compoundTag) { if (this.recordPos != null) { compoundTag.put(TAG_RECORD_POS, NbtUtils.writeBlockPos(this.recordPos)); - } if (this.pattern != null) { compoundTag.put(TAG_PATTERN, this.pattern.serializeToNBT()); @@ -60,9 +71,13 @@ public class BlockEntityAkashicBookshelf extends PaucalBlockEntity { protected void loadModData(CompoundTag compoundTag) { if (compoundTag.contains(TAG_RECORD_POS)) { this.recordPos = NbtUtils.readBlockPos(compoundTag.getCompound(TAG_RECORD_POS)); + } else { + this.recordPos = null; } if (compoundTag.contains(TAG_PATTERN)) { this.pattern = HexPattern.DeserializeFromNBT(compoundTag.getCompound(TAG_PATTERN)); + } else { + this.pattern = null; } } diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java index 98169e92..172624ef 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java @@ -51,10 +51,10 @@ public class BlockEntityAkashicRecord extends PaucalBlockEntity { var openPos = BlockAkashicFloodfiller.floodFillFor(this.worldPosition, this.level, (pos, bs, world) -> world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile - && tile.pattern == null); + && tile.getPattern() == null); if (openPos != null) { var tile = (BlockEntityAkashicBookshelf) this.level.getBlockEntity(openPos); - tile.setNewDatum(this.getBlockPos(), key, datum.getType()); + tile.setNewData(this.getBlockPos(), key, datum.getType()); this.entries.put(key.anglesSignature(), new Entry(openPos, key.startDir(), datum.serializeToNBT())); this.sync(); @@ -87,7 +87,7 @@ public class BlockEntityAkashicRecord extends PaucalBlockEntity { return this.entries.size(); } - private void revalidateAllBookshelves() { + public void revalidateAllBookshelves() { // floodfill for all known positions var validPoses = new HashSet(); { @@ -120,7 +120,7 @@ public class BlockEntityAkashicRecord extends PaucalBlockEntity { this.entries.remove(sig); if (this.level.getBlockEntity(entry.pos) instanceof BlockEntityAkashicBookshelf shelf) { - shelf.setNewDatum(null, null, DatumType.EMPTY); + shelf.setNewData(null, null, DatumType.EMPTY); } } } @@ -146,6 +146,7 @@ public class BlockEntityAkashicRecord extends PaucalBlockEntity { protected void loadModData(CompoundTag compoundTag) { var lookupTag = compoundTag.getCompound(TAG_LOOKUP); + this.entries.clear(); var sigs = lookupTag.getAllKeys(); for (var sig : sigs) { var entryTag = lookupTag.getCompound(sig); diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java b/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java index a6122367..bc91a417 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java @@ -1,8 +1,8 @@ package at.petrak.hexcasting.common.blocks.circles.impetuses; import at.petrak.hexcasting.api.circle.BlockAbstractImpetus; +import at.petrak.hexcasting.api.item.DataHolder; import at.petrak.hexcasting.api.spell.SpellDatum; -import at.petrak.hexcasting.common.items.ItemDataHolder; import at.petrak.hexcasting.common.lib.HexSounds; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; @@ -33,7 +33,7 @@ public class BlockStoredPlayerImpetus extends BlockAbstractImpetus { BlockHitResult pHit) { if (pLevel.getBlockEntity(pPos) instanceof BlockEntityStoredPlayerImpetus tile) { var usedStack = pPlayer.getItemInHand(pHand); - if (usedStack.getItem() instanceof ItemDataHolder dataer) { + if (usedStack.getItem() instanceof DataHolder dataer) { var stored = dataer.readDatumTag(usedStack); if (stored != null && stored.contains(SpellDatum.TAG_ENTITY)) { var uuid = stored.getCompound(SpellDatum.TAG_ENTITY).getUUID(SpellDatum.TAG_ENTITY_UUID); diff --git a/src/main/java/at/petrak/hexcasting/common/casting/CastingContext.kt b/src/main/java/at/petrak/hexcasting/common/casting/CastingContext.kt index 7495735d..f06df87e 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/CastingContext.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/CastingContext.kt @@ -2,12 +2,12 @@ package at.petrak.hexcasting.common.casting import at.petrak.hexcasting.HexConfig import at.petrak.hexcasting.HexUtils +import at.petrak.hexcasting.api.item.DataHolder import at.petrak.hexcasting.api.spell.Operator import at.petrak.hexcasting.common.casting.mishaps.MishapBadOffhandItem import at.petrak.hexcasting.common.casting.mishaps.MishapEntityTooFarAway import at.petrak.hexcasting.common.casting.mishaps.MishapEvalTooDeep import at.petrak.hexcasting.common.casting.mishaps.MishapLocationTooFarAway -import at.petrak.hexcasting.common.items.ItemDataHolder import at.petrak.hexcasting.common.lib.HexCapabilities import at.petrak.hexcasting.common.lib.RegisterHelper.prefix import net.minecraft.server.level.ServerLevel @@ -40,7 +40,7 @@ data class CastingContext( fun getDataHolder(): ItemStack { val handItem = caster.getItemInHand(this.otherHand) - return if (handItem.item is ItemDataHolder) { + return if (handItem.item is DataHolder) { handItem } else { throw MishapBadOffhandItem.of(handItem, "iota") diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt index 87b9ee69..5b06ea16 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt @@ -1,10 +1,10 @@ package at.petrak.hexcasting.common.casting.operators +import at.petrak.hexcasting.api.item.DataHolder import at.petrak.hexcasting.api.spell.ConstManaOperator import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.common.casting.CastingContext import at.petrak.hexcasting.common.casting.mishaps.MishapBadOffhandItem -import at.petrak.hexcasting.common.items.ItemDataHolder object OpRead : ConstManaOperator { override val argc = 0 @@ -13,10 +13,10 @@ object OpRead : ConstManaOperator { val handStack = ctx.caster.getItemInHand(ctx.otherHand) val handItem = handStack.item - if (handItem !is ItemDataHolder) { + if (handItem !is DataHolder) { throw MishapBadOffhandItem.of(handStack, "iota.read") } - val datum = handItem.readDatum(handStack, ctx) ?: throw MishapBadOffhandItem.of(handStack, "iota.read") + val datum = handItem.readDatum(handStack, ctx.world) ?: throw MishapBadOffhandItem.of(handStack, "iota.read") return listOf(datum) } } \ No newline at end of file diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt index 2d4177f8..b733d51e 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt @@ -1,11 +1,11 @@ package at.petrak.hexcasting.common.casting.operators +import at.petrak.hexcasting.api.item.DataHolder import at.petrak.hexcasting.api.spell.ConstManaOperator import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.common.casting.CastingContext import at.petrak.hexcasting.common.casting.mishaps.MishapBadOffhandItem -import at.petrak.hexcasting.common.items.ItemDataHolder import net.minecraft.world.entity.item.ItemEntity object OpTheCoolerRead : ConstManaOperator { @@ -18,13 +18,13 @@ object OpTheCoolerRead : ConstManaOperator { val target = args.getChecked(0) val stack = target.item val item = stack.item - if (item !is ItemDataHolder) { + if (item !is DataHolder) { throw MishapBadOffhandItem.of(stack, "iota.read") } ctx.assertEntityInRange(target) - val datum = item.readDatum(stack, ctx) ?: throw MishapBadOffhandItem.of(stack, "iota.read") + val datum = item.readDatum(stack, ctx.world) ?: throw MishapBadOffhandItem.of(stack, "iota.read") return listOf(datum) } } \ No newline at end of file diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt index bdaef182..7ee74290 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt @@ -1,17 +1,13 @@ package at.petrak.hexcasting.common.casting.operators +import at.petrak.hexcasting.api.item.DataHolder import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.api.spell.SpellOperator -import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate import at.petrak.hexcasting.common.casting.CastingContext import at.petrak.hexcasting.common.casting.mishaps.MishapBadOffhandItem import at.petrak.hexcasting.common.casting.mishaps.MishapOthersName -import at.petrak.hexcasting.common.items.HexItems -import at.petrak.hexcasting.common.items.ItemDataHolder -import at.petrak.hexcasting.common.items.ItemScroll -import at.petrak.hexcasting.hexmath.HexPattern import net.minecraft.world.entity.player.Player // we make this a spell cause imo it's a little ... anticlimactic for it to just make no noise @@ -26,21 +22,8 @@ object OpWrite : SpellOperator { val tag = handStack.orCreateTag val datum = args[0] - val canWrite = if (handItem is ItemDataHolder) { + val canWrite = if (handItem is DataHolder) { handItem.canWrite(tag, datum) - } else if (datum.payload is HexPattern) { - if (handStack.`is`(HexItems.SCROLL.get()) && !tag.contains(ItemScroll.TAG_PATTERN)) { - true - } else if (handStack.`is`(HexItems.SLATE.get())) { - val hasBET = tag.contains("BlockEntityTag") - if (hasBET) { - tag.getCompound("BlockEntityTag").contains(BlockEntitySlate.TAG_PATTERN) - } else { - true - } - } else { - false - } } else { false } @@ -62,18 +45,9 @@ object OpWrite : SpellOperator { val handStack = ctx.caster.getItemInHand(ctx.otherHand) val handItem = handStack.item val tag = handStack.orCreateTag - if (handItem is ItemDataHolder) { + if (handItem is DataHolder) { handItem.writeDatum(tag, datum) - } else if (handItem == HexItems.SCROLL.get() && !tag.contains(ItemScroll.TAG_PATTERN) && datum.payload is HexPattern) { - tag.put(ItemScroll.TAG_PATTERN, datum.payload.serializeToNBT()) - } else if (handItem == HexItems.SLATE.get() && datum.payload is HexPattern) { - val bet = tag.getCompound("BlockEntityTag") - bet.put(BlockEntitySlate.TAG_PATTERN, datum.payload.serializeToNBT()) - // Just in case it's brand new - tag.put("BlockEntityTag", bet) - } else { - // Fuck - } + } // else fuck } } diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt index c240ef26..aeb9c500 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt @@ -1,22 +1,27 @@ package at.petrak.hexcasting.common.casting.operators.akashic -import at.petrak.hexcasting.api.spell.ConstManaOperator import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked -import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf +import at.petrak.hexcasting.api.spell.ParticleSpray +import at.petrak.hexcasting.api.spell.RenderedSpell import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord import at.petrak.hexcasting.common.casting.CastingContext -import at.petrak.hexcasting.common.casting.Widget import at.petrak.hexcasting.common.casting.mishaps.MishapNoAkashicRecord +import at.petrak.hexcasting.common.lib.HexCapabilities +import at.petrak.hexcasting.common.lib.HexSounds import at.petrak.hexcasting.hexmath.HexPattern import net.minecraft.core.BlockPos +import net.minecraft.sounds.SoundSource import net.minecraft.world.phys.Vec3 -object OpAkashicWrite : ConstManaOperator { +object OpAkashicWrite : SpellOperator { override val argc = 3 - override val manaCost = 10_000 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute( + args: List>, + ctx: CastingContext + ): Triple> { val pos = args.getChecked(0) val key = args.getChecked(1) val datum = args[2] @@ -27,12 +32,30 @@ object OpAkashicWrite : ConstManaOperator { throw MishapNoAkashicRecord(bpos) } - val newPos = tile.addNewDatum(key, datum) - return spellListOf( - if (newPos == null) - Widget.NULL - else - Vec3.atCenterOf(newPos) + return Triple( + Spell(tile, key, datum), + 10_000, + listOf() ) } + + private data class Spell(val record: BlockEntityAkashicRecord, val key: HexPattern, val datum: SpellDatum<*>) : + RenderedSpell { + override fun cast(ctx: CastingContext) { + record.addNewDatum(key, datum) + + ctx.world.playSound( + null, record.blockPos, HexSounds.SCROLL_SCRIBBLE.get(), SoundSource.BLOCKS, + 1f, 0.8f + ) + + ctx.caster.getCapability(HexCapabilities.PREFERRED_COLORIZER).ifPresent { + // val normal = record.blockState.getValue(BlockAkashicBookshelf.FACING).normal + // ParticleSpray( + // Vec3.atCenterOf(record.blockPos), Vec3.atBottomCenterOf(normal), + // 0.5, Math.PI / 4, 10 + // ).sprayParticles(ctx.world, it.colorizer) + } + } + } } \ No newline at end of file diff --git a/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java b/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java index 1e3320c7..705032a0 100644 --- a/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java +++ b/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java @@ -121,7 +121,7 @@ public class EntityWallScroll extends HangingEntity implements IEntityAdditional } this.setShowsStrokeOrder(true); - pPlayer.level.playSound(pPlayer, this, HexSounds.DUST_SCROLL.get(), SoundSource.PLAYERS, 1f, 1f); + pPlayer.level.playSound(pPlayer, this, HexSounds.SCROLL_DUST.get(), SoundSource.PLAYERS, 1f, 1f); return InteractionResult.SUCCESS; } return super.interactAt(pPlayer, pVec, pHand); diff --git a/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java b/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java index d477a241..525c0ba4 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java +++ b/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java @@ -1,18 +1,24 @@ package at.petrak.hexcasting.common.items; +import at.petrak.hexcasting.api.item.DataHolder; import at.petrak.hexcasting.api.spell.SpellDatum; import at.petrak.hexcasting.common.lib.HexSounds; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; +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 org.jetbrains.annotations.Nullable; -public class ItemAbacus extends ItemDataHolder { +import java.util.List; + +public class ItemAbacus extends Item implements DataHolder { public static final String TAG_VALUE = "value"; public ItemAbacus(Properties pProperties) { @@ -67,4 +73,10 @@ public class ItemAbacus extends ItemDataHolder { return InteractionResultHolder.pass(stack); } } + + @Override + public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltipComponents, + TooltipFlag pIsAdvanced) { + DataHolder.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced); + } } diff --git a/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java b/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java index b7f19544..d86491ab 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java +++ b/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java @@ -1,13 +1,20 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.HexMod; +import at.petrak.hexcasting.api.item.DataHolder; import at.petrak.hexcasting.api.spell.SpellDatum; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +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 org.jetbrains.annotations.Nullable; -public class ItemFocus extends ItemDataHolder { +import java.util.List; + +public class ItemFocus extends Item implements DataHolder { public static final ResourceLocation DATATYPE_PRED = new ResourceLocation(HexMod.MOD_ID, "datatype"); public static final String TAG_DATA = "data"; public static final String TAG_SEALED = "sealed"; @@ -40,4 +47,10 @@ public class ItemFocus extends ItemDataHolder { tag.put(TAG_DATA, datum.serializeToNBT()); } } + + @Override + public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltipComponents, + TooltipFlag pIsAdvanced) { + DataHolder.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced); + } } diff --git a/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java b/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java index 37ce6c36..a80cfafa 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java +++ b/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java @@ -1,9 +1,14 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.HexMod; +import at.petrak.hexcasting.api.item.DataHolder; +import at.petrak.hexcasting.api.spell.DatumType; +import at.petrak.hexcasting.api.spell.SpellDatum; import at.petrak.hexcasting.common.entities.EntityWallScroll; +import at.petrak.hexcasting.hexmath.HexPattern; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; @@ -14,6 +19,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.gameevent.GameEvent; +import org.jetbrains.annotations.Nullable; /** * TAG_OP_ID and TAG_PATTERN: "Ancient Scroll of %s" (Great Spells) @@ -24,7 +30,7 @@ import net.minecraft.world.level.gameevent.GameEvent; *
* TAG_OP_ID: invalid */ -public class ItemScroll extends Item { +public class ItemScroll extends Item implements DataHolder { public static final String TAG_OP_ID = "op_id"; public static final String TAG_PATTERN = "pattern"; public static final ResourceLocation ANCIENT_PREDICATE = new ResourceLocation(HexMod.MOD_ID, "ancient"); @@ -33,6 +39,31 @@ public class ItemScroll extends Item { super(pProperties); } + @Override + public @Nullable CompoundTag readDatumTag(ItemStack stack) { + var stackTag = stack.getTag(); + if (stackTag == null || !stackTag.contains(TAG_PATTERN)) { + return null; + } + + var patTag = stackTag.getCompound(TAG_PATTERN); + var out = new CompoundTag(); + out.put(SpellDatum.TAG_PATTERN, patTag); + return out; + } + + @Override + public boolean canWrite(CompoundTag tag, SpellDatum datum) { + return datum.getType() == DatumType.PATTERN && !tag.contains(TAG_PATTERN); + } + + @Override + public void writeDatum(CompoundTag tag, SpellDatum datum) { + if (this.canWrite(tag, datum) && datum.getPayload() instanceof HexPattern pat) { + tag.put(TAG_PATTERN, pat.serializeToNBT()); + } + } + @Override public InteractionResult useOn(UseOnContext ctx) { var posClicked = ctx.getClickedPos(); @@ -85,4 +116,5 @@ public class ItemScroll extends Item { } } + // purposely no hover text } diff --git a/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java b/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java index 383c9ddb..ae14a08b 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java +++ b/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java @@ -1,15 +1,21 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.HexMod; +import at.petrak.hexcasting.api.item.DataHolder; +import at.petrak.hexcasting.api.spell.DatumType; +import at.petrak.hexcasting.api.spell.SpellDatum; import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate; +import at.petrak.hexcasting.hexmath.HexPattern; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; +import org.jetbrains.annotations.Nullable; -public class ItemSlate extends BlockItem { +public class ItemSlate extends BlockItem implements DataHolder { public static final ResourceLocation WRITTEN_PRED = new ResourceLocation(HexMod.MOD_ID, "written"); public ItemSlate(Block pBlock, Properties pProperties) { @@ -30,4 +36,42 @@ public class ItemSlate extends BlockItem { } return false; } + + @Override + public @Nullable CompoundTag readDatumTag(ItemStack stack) { + var stackTag = stack.getTag(); + if (stackTag == null || !stackTag.contains("BlockEntityTag")) { + return null; + } + var beTag = stackTag.getCompound("BlockEntityTag"); + if (!beTag.contains(BlockEntitySlate.TAG_PATTERN)) { + return null; + } + + var patTag = beTag.getCompound(BlockEntitySlate.TAG_PATTERN); + var out = new CompoundTag(); + out.put(SpellDatum.TAG_PATTERN, patTag); + return out; + } + + @Override + public boolean canWrite(CompoundTag tag, SpellDatum datum) { + if (datum.getType() != DatumType.PATTERN) { + return false; + } + + if (!tag.contains("BlockEntityTag")) { + return false; + } + var beTag = tag.getCompound("BlockEntityTag"); + return !beTag.contains(BlockEntitySlate.TAG_PATTERN); + } + + @Override + public void writeDatum(CompoundTag tag, SpellDatum datum) { + if (this.canWrite(tag, datum) && datum.getPayload() instanceof HexPattern pat) { + var beTag = tag.getCompound("BlockEntityTag"); + beTag.put(BlockEntitySlate.TAG_PATTERN, pat.serializeToNBT()); + } + } } diff --git a/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java b/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java index b26ffb13..dcb6042c 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java +++ b/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java @@ -1,10 +1,12 @@ package at.petrak.hexcasting.common.items; +import at.petrak.hexcasting.api.item.DataHolder; import at.petrak.hexcasting.api.spell.SpellDatum; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; @@ -13,7 +15,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.stream.Stream; -public class ItemSpellbook extends ItemDataHolder { +public class ItemSpellbook extends Item implements DataHolder { public static String TAG_SELECTED_PAGE = "page_idx"; // this is a CompoundTag of string numerical keys to SpellData // it is 1-indexed, so that 0/0 can be the special case of "it is empty" diff --git a/src/main/java/at/petrak/hexcasting/common/lib/HexSounds.java b/src/main/java/at/petrak/hexcasting/common/lib/HexSounds.java index ca93d8c5..a859f7f0 100644 --- a/src/main/java/at/petrak/hexcasting/common/lib/HexSounds.java +++ b/src/main/java/at/petrak/hexcasting/common/lib/HexSounds.java @@ -27,7 +27,8 @@ public class HexSounds { public static final RegistryObject SPELL_CIRCLE_FAIL = sound("spellcircle.fail"); public static final RegistryObject SPELL_CIRCLE_CAST = sound("spellcircle.cast"); - public static final RegistryObject DUST_SCROLL = sound("scroll.dust"); + public static final RegistryObject SCROLL_DUST = sound("scroll.dust"); + public static final RegistryObject SCROLL_SCRIBBLE = sound("scroll.scribble"); public static final RegistryObject IMPETUS_LOOK_TICK = sound("impetus.fletcher.tick"); public static final RegistryObject IMPETUS_STOREDPLAYER_DING = sound("impetus.cleric.register"); diff --git a/src/main/resources/assets/hexcasting/lang/en_us.json b/src/main/resources/assets/hexcasting/lang/en_us.json index 63b3f1fd..8aeb2e2d 100644 --- a/src/main/resources/assets/hexcasting/lang/en_us.json +++ b/src/main/resources/assets/hexcasting/lang/en_us.json @@ -146,6 +146,7 @@ "hexcasting.subtitles.spellcircle.fail": "Spell circle fizzles out", "hexcasting.subtitles.spellcircle.cast": "Spell circle casts", "hexcasting.subtitles.scroll.dust": "Scroll covers with dust", + "hexcasting.subtitles.scroll.dust": "Scribble on Scroll", "hexcasting.subtitles.impetus.fletcher.tick": "Fletcher Impetus ticks", "hexcasting.subtitles.impetus.cleric.register": "Cleric Impetus dings", diff --git a/src/main/resources/assets/hexcasting/sounds.json b/src/main/resources/assets/hexcasting/sounds.json index 0557c5a4..d11481c7 100644 --- a/src/main/resources/assets/hexcasting/sounds.json +++ b/src/main/resources/assets/hexcasting/sounds.json @@ -93,6 +93,14 @@ ], "subtitle": "hexcasting.subtitles.scroll.dust" }, + "scroll.scribble": { + "sounds": [ + "minecraft:item/book/open_flip1", + "minecraft:item/book/open_flip2", + "minecraft:item/book/open_flip3" + ], + "subtitle": "hexcasting.subtitles.scroll.scribble" + }, "impetus.fletcher.tick": { "sounds": [