From 10fff481fa1350bd36f12d62ddf29bfcbf45f32d Mon Sep 17 00:00:00 2001 From: The_Fireplace Date: Wed, 21 Jul 2021 17:25:09 -0500 Subject: [PATCH] Port to 1.17.X --- build.gradle | 25 +++++-------------- gradle.properties | 10 ++++---- .../the_fireplace/audiobook/Audiobook.java | 2 +- .../audiobook/AudiobookLogic.java | 18 ++++++++++--- src/main/resources/fabric.mod.json | 2 +- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index 208b0ad..2288107 100644 --- a/build.gradle +++ b/build.gradle @@ -11,8 +11,8 @@ plugins { id 'io.codearte.nexus-staging' version '0.30.0' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.mod_version @@ -52,7 +52,7 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - it.options.release = 8 + it.options.release = 16 } java { @@ -74,15 +74,8 @@ if (hasProperty('curseForgeApiKey')) { changelog = file('changelog.txt') releaseType = project.release_type addGameVersion project.minecraft_version - addGameVersion '1.16.4' - addGameVersion '1.16.3' - addGameVersion '1.16.2' - addGameVersion '1.16.1' - addGameVersion '1.16' - addGameVersion '1.16-Snapshot' - addGameVersion '1.15.2' - addGameVersion '1.14.4' - addGameVersion 'Java 8' + addGameVersion '1.17' + addGameVersion 'Java 16' addGameVersion 'Fabric' mainArtifact(new File(new File(buildDir, "libs"), "$archivesBaseName-${version}.jar")) { displayName = "$archivesBaseName-$version" @@ -109,13 +102,7 @@ if (hasProperty('modrinthApiKey')) { changelog = file('changelog.txt').getText() releaseType = project.release_type addGameVersion(project.minecraft_version as String) - addGameVersion('1.16.4') - addGameVersion('1.16.3') - addGameVersion('1.16.2') - addGameVersion('1.16.1') - addGameVersion('1.16') - addGameVersion('1.15.2') - addGameVersion('1.14.4') + addGameVersion('1.17') addLoader('fabric') } } diff --git a/gradle.properties b/gradle.properties index 26d7bf2..3dea566 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx3G # Fabric Properties -minecraft_version=1.16.5 -yarn_mappings=1.16.5+build.9 -loader_version=0.11.3 +minecraft_version=1.17.1 +yarn_mappings=1.17.1+build.24 +loader_version=0.11.6 # Mod Properties maven_group = dev.the-fireplace @@ -14,5 +14,5 @@ mod_version = 1.1.0 release_type = release # Dependencies -fabric_version=0.35.0+1.16 -fireplacelib_version=5.0.0+1.16.5 +fabric_version=0.37.0+1.17 +fireplacelib_version=5.0.0+1.17.1 diff --git a/src/main/java/the_fireplace/audiobook/Audiobook.java b/src/main/java/the_fireplace/audiobook/Audiobook.java index bd14fdc..7b3132b 100644 --- a/src/main/java/the_fireplace/audiobook/Audiobook.java +++ b/src/main/java/the_fireplace/audiobook/Audiobook.java @@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.minecraft.client.options.KeyBinding; +import net.minecraft.client.option.KeyBinding; import java.awt.event.KeyEvent; diff --git a/src/main/java/the_fireplace/audiobook/AudiobookLogic.java b/src/main/java/the_fireplace/audiobook/AudiobookLogic.java index cc25c03..97a262e 100644 --- a/src/main/java/the_fireplace/audiobook/AudiobookLogic.java +++ b/src/main/java/the_fireplace/audiobook/AudiobookLogic.java @@ -1,5 +1,6 @@ package the_fireplace.audiobook; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.mojang.text2speech.Narrator; import net.fabricmc.api.EnvType; @@ -8,14 +9,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.WritableBookItem; import net.minecraft.item.WrittenBookItem; +import net.minecraft.nbt.NbtCompound; import javax.annotation.Nullable; import java.util.List; +import java.util.Objects; @Environment(EnvType.CLIENT) public final class AudiobookLogic { public static void playBook(ItemStack stack) { - playBook(stack.hasTag() && stack.getTag() != null ? BookScreen.Contents.create(stack) : null); + playBook(stack.hasNbt() && stack.getNbt() != null ? BookScreen.Contents.create(stack) : null); } public static void playBook(@Nullable BookScreen.Contents contents) { @@ -45,12 +48,19 @@ public static boolean isReadableBook(ItemStack stack) { } private static boolean isReadable(ItemStack stack) { - if (!stack.hasTag()) { + if (!stack.hasNbt()) { return false; } - assert stack.getTag() != null; + assert stack.getNbt() != null; - return !BookScreen.readPages(stack.getTag()).isEmpty(); + return !readPages(stack.getNbt()).isEmpty(); + } + + private static List readPages(NbtCompound nbt) { + ImmutableList.Builder builder = ImmutableList.builder(); + Objects.requireNonNull(builder); + BookScreen.filterPages(nbt, builder::add); + return builder.build(); } private static boolean isBook(ItemStack stack) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d223486..491a830 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ "fabricloader": ">=0.7.4", "fabric": "*", "fabric-key-binding-api-v1": "*", - "minecraft": ">=1.14.4 <1.17" + "minecraft": ">=1.17" }, "custom": {