From 1baf8f3d6afcd95dbb2e2212bc1bcfad5c97fbcb Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Sat, 2 Apr 2022 16:59:30 +0200 Subject: [PATCH] Fix switching pages not working --- build.gradle | 34 +++++++++---------- gradle.properties | 2 +- .../waystones/gui/UniversalWaystoneGui.java | 11 ++++-- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 0b8ed5e..56a2c98 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,9 @@ plugins { id 'fabric-loom' version '0.11-SNAPSHOT' id 'maven-publish' - id "com.modrinth.minotaur" version "1.2.1" + id "com.modrinth.minotaur" version "2.+" //id 'com.matthewprenger.cursegradle' version '1.4.0' } -import com.modrinth.minotaur.TaskModrinthUpload -import com.modrinth.minotaur.request.VersionType sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 @@ -30,9 +28,9 @@ dependencies { modCompileOnly 'curse.maven:repurposed-structures-fabric-391366:3542863' - modImplementation include("eu.pb4:sgui:1.0.0+1.18.1") + modImplementation include("eu.pb4:sgui:1.0.1+1.18.2") modImplementation include("eu.pb4:hologram-api:0.2.1+1.18-pre5") - modImplementation include("eu.pb4:polymer:0.2.0-beta.29+1.18.2") + modImplementation include("eu.pb4:polymer:0.2.0-beta.36+1.18.2") modImplementation include("fr.catcore:server-translations-api:1.4.9+1.18.2-rc1") } @@ -98,18 +96,20 @@ publishing { } }*/ -task publishModrinth (type: TaskModrinthUpload){ - onlyIf { - System.getenv("MODRINTH") +if (System.getenv("MODRINTH")) { + modrinth { + token = System.getenv("MODRINTH") + projectId = 'gU9Ao8K2' + versionNumber = version + versionType = "release" + changelog = System.getenv("CHANGELOG") + // On fabric, use 'remapJar' instead of 'jar' + uploadFile = remapJar + gameVersions = [((String) project.minecraft_version)] + loaders = ["fabric"] } - token = System.getenv("MODRINTH") - projectId = 'gU9Ao8K2' - versionNumber = version - versionType = VersionType.RELEASE - changelog = System.getenv("CHANGELOG") - // On fabric, use 'remapJar' instead of 'jar' - uploadFile = remapJar - addGameVersion((String) project.minecraft_version) - addLoader('fabric') + remapJar { + finalizedBy project.tasks.modrinth + } } diff --git a/gradle.properties b/gradle.properties index cb7f012..2a0057c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,5 +13,5 @@ archives_base_name=wraith-waystones # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api fabric_version=0.47.8+1.18.2 -sub_version=0 +sub_version=1 diff --git a/src/main/java/wraith/waystones/gui/UniversalWaystoneGui.java b/src/main/java/wraith/waystones/gui/UniversalWaystoneGui.java index f20c95a..74553fb 100644 --- a/src/main/java/wraith/waystones/gui/UniversalWaystoneGui.java +++ b/src/main/java/wraith/waystones/gui/UniversalWaystoneGui.java @@ -13,6 +13,7 @@ import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Hand; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.Nullable; import wraith.waystones.Waystones; @@ -27,6 +28,7 @@ import java.util.ArrayList; import java.util.Comparator; +import java.util.Objects; import java.util.function.Consumer; import java.util.function.Predicate; @@ -129,7 +131,7 @@ protected void updateDisplay() { private void updateWaystones() { this.sortedWaystones = new ArrayList<>(); if (((PlayerEntityMixinAccess) player).shouldViewDiscoveredWaystones()) { - this.sortedWaystones.addAll(((PlayerAccess) player).getHashesSorted()); + this.sortedWaystones.addAll(((PlayerEntityMixinAccess) player).getDiscoveredWaystones()); } if (((PlayerEntityMixinAccess) player).shouldViewGlobalWaystones()) { for (String waystone : Waystones.WAYSTONE_STORAGE.getGlobals()) { @@ -138,12 +140,15 @@ private void updateWaystones() { } } } - this.sortedWaystones.sort(Comparator.comparing(a -> Waystones.WAYSTONE_STORAGE.getWaystoneData(a).getWaystoneName())); + this.sortedWaystones.sort(Comparator.comparing(a -> { + var data = Waystones.WAYSTONE_STORAGE.getWaystoneData(a); + return data != null ? data.getWaystoneName() : ""; + })); } @Override protected int getPageAmount() { - return this.sortedWaystones.size() / PAGE_SIZE; + return MathHelper.ceil(this.sortedWaystones.size() / (double) PAGE_SIZE); } @Override