Skip to content

Commit

Permalink
Port to 1.17.X
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Fireplace committed Jul 21, 2021
1 parent aeeac41 commit 10fff48
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
25 changes: 6 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,7 +52,7 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 8
it.options.release = 16
}

java {
Expand All @@ -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"
Expand All @@ -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')
}
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/main/java/the_fireplace/audiobook/Audiobook.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 14 additions & 4 deletions src/main/java/the_fireplace/audiobook/AudiobookLogic.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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<String> readPages(NbtCompound nbt) {
ImmutableList.Builder<String> builder = ImmutableList.builder();
Objects.requireNonNull(builder);
BookScreen.filterPages(nbt, builder::add);
return builder.build();
}

private static boolean isBook(ItemStack stack) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"fabricloader": ">=0.7.4",
"fabric": "*",
"fabric-key-binding-api-v1": "*",
"minecraft": ">=1.14.4 <1.17"
"minecraft": ">=1.17"
},

"custom": {
Expand Down

0 comments on commit 10fff48

Please sign in to comment.