Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Advancement: fix 1.20.3+ support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Dec 26, 2023
1 parent f6dff1e commit 44cf784
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Optional;

// Thanks, @CroaBeast, for these methods
// Source https://github.com/CroaBeast/AdvancementInfo
// Source https://github.com /CroaBeast/AdvancementInfo

public class FAdvancement {
private static final String COMP_CLASS = "IChatBaseComponent";
Expand All @@ -23,11 +23,13 @@ public class FAdvancement {

private static final boolean IS_19_4;
private static final boolean IS_20_2;
private static final boolean IS_20_3;

static {
double value = NMSUtil.getVersion();
IS_19_4 = value >= 19.4;
IS_20_2 = value >= 20.2;
IS_20_3 = value >= 20.3;
}

public FAdvancement(@NotNull Advancement adv) {
Expand All @@ -38,7 +40,7 @@ public FAdvancement(@NotNull Advancement adv) {
Object nmsAdv = NMSUtil.getObject(craftClass, craftClass.cast(adv), "getHandle");
if (IS_20_2) nmsAdv = NMSUtil.getObject(nmsAdv, "b");

Object display = NMSUtil.getObject(nmsAdv, IS_19_4 ? "d" : "c");
Object display = NMSUtil.getObject(nmsAdv, IS_19_4 && !IS_20_3 ? "d" : "c");
if (display == null) return;

if (IS_20_2) {
Expand Down

0 comments on commit 44cf784

Please sign in to comment.