diff --git a/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAdvancementCondition.java b/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAdvancementCondition.java index cf6c0cc5..24af91be 100644 --- a/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAdvancementCondition.java +++ b/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAdvancementCondition.java @@ -89,6 +89,7 @@ public List getTooltip(Player player, BookConditionContext context) { } public static class DistHelper { + public static long lastRequestTime = 0; public static Component getAdvancementTitle(Player player, ResourceLocation advancementId) { if (player instanceof LocalPlayer localPlayer) { //Problem: Advancements are not syncted to the client by vanilla if they are visible - and actively removed if they are not. @@ -101,7 +102,11 @@ public static Component getAdvancementTitle(Player player, ResourceLocation adva //if not available locally, request from server for our local cache if (adv == null) { - Services.NETWORK.sendToServer(new RequestAdvancementMessage(advancementId)); + //only request every second + if(System.currentTimeMillis() - lastRequestTime < 1000) { + lastRequestTime = System.currentTimeMillis(); + Services.NETWORK.sendToServer(new RequestAdvancementMessage(advancementId)); + } return Component.translatable(Tooltips.CONDITION_ADVANCEMENT_LOADING); } diff --git a/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAndCondition.java b/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAndCondition.java index 7688290c..d91ebf67 100644 --- a/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAndCondition.java +++ b/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAndCondition.java @@ -104,14 +104,15 @@ public boolean testOnLoad() { public List getTooltip(Player player, BookConditionContext context) { if (this.tooltips == null) { this.tooltips = new ArrayList<>(); - if (this.tooltip != null) - this.tooltips.add(this.tooltip); - for (var child : this.children) { - this.tooltips.addAll(child.getTooltip(player, context)); - } } + this.tooltips.clear(); //should not cache because e.g. advancement condition tooltips can change + if (this.tooltip != null) + this.tooltips.add(this.tooltip); + for (var child : this.children) { + this.tooltips.addAll(child.getTooltip(player, context)); + } - return this.tooltips != null ? this.tooltips : List.of(); + return this.tooltips; } } diff --git a/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookOrCondition.java b/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookOrCondition.java index 09bae543..9efae79b 100644 --- a/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookOrCondition.java +++ b/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookOrCondition.java @@ -105,14 +105,15 @@ public boolean testOnLoad() { public List getTooltip(Player player, BookConditionContext context) { if (this.tooltips == null) { this.tooltips = new ArrayList<>(); - if (this.tooltip != null) - this.tooltips.add(this.tooltip); - for (var child : this.children) { - this.tooltips.addAll(child.getTooltip(player, context)); - } } + this.tooltips.clear(); //should not cache because e.g. advancement condition tooltips can change + if (this.tooltip != null) + this.tooltips.add(this.tooltip); + for (var child : this.children) { + this.tooltips.addAll(child.getTooltip(player, context)); + } - return this.tooltips != null ? this.tooltips : List.of(); + return this.tooltips; } }