From 3e122816ab8021e6a20ba1675fdf72bd033153f1 Mon Sep 17 00:00:00 2001 From: B1n_ry Date: Sat, 23 Mar 2024 18:28:23 +0100 Subject: [PATCH] Fixed duplication of numismatic overhaul coins --- build.gradle | 2 +- gradle.properties | 2 +- .../yigd/compat/NumismaticOverhaulCompat.java | 29 +++++++++++++++---- .../yigd/events/YigdServerEventHandler.java | 1 + 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index a3c1edb..8939d5a 100644 --- a/build.gradle +++ b/build.gradle @@ -106,7 +106,7 @@ dependencies { modCompileOnly "dev.emi:trinkets:${project.trinkets_version}" modCompileOnly "curse.maven:inventorio-${project.inventorio_version}" modCompileOnly "curse.maven:travelersbackpack-${project.travelers_backpack_version}" - modCompileOnly "curse.maven:numismaticoverhaul-${project.numismatic_version}" + modCompileOnly "maven.modrinth:numismatic-overhaul:${project.numismatic_version}" modCompileOnly "com.github.apace100:apoli:${project.apoli_version}" modCompileOnly "curse.maven:levelz-${project.levelz_version}" modCompileOnly "maven.modrinth:beans-backpacks:${project.beans_backpacks_version}" diff --git a/gradle.properties b/gradle.properties index cfefb1b..65c7a1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -31,7 +31,7 @@ org.gradle.parallel=true trinkets_version=3.7.1 inventorio_version=491073:4619078 travelers_backpack_version=541171:4989864 - numismatic_version=568316:4996365 + numismatic_version=0.2.14+1.20 apoli_version=v2.9.0 levelz_version=517130:5024636 beans_backpacks_version=H4JcgrtM diff --git a/src/main/java/com/b1n_ry/yigd/compat/NumismaticOverhaulCompat.java b/src/main/java/com/b1n_ry/yigd/compat/NumismaticOverhaulCompat.java index d6fb0db..77e983f 100644 --- a/src/main/java/com/b1n_ry/yigd/compat/NumismaticOverhaulCompat.java +++ b/src/main/java/com/b1n_ry/yigd/compat/NumismaticOverhaulCompat.java @@ -28,7 +28,7 @@ public String getModName() { public void clear(ServerPlayerEntity player) { CurrencyComponent component = ModComponents.CURRENCY.get(player); long value = component.getValue(); - component.modify(-value); + component.silentModify(-value); } @Override @@ -120,6 +120,10 @@ public void handleDropRules(DeathContext context) { this.inventory -= itemValue; this.keepValue += itemValue; } + case PUT_IN_GRAVE -> { + this.inventory -= itemValue; + this.graveValue += itemValue; + } } } } @@ -154,16 +158,29 @@ public DefaultedList> getAsStackDropList() { @Override public CompatComponent filterInv(Predicate predicate) { long totalValue = 0; - if (predicate.test(DropRule.DROP)) + long dropValue = 0; + long keepValue = 0; + long destroyValue = 0; + long graveValue = 0; + + if (predicate.test(DropRule.DROP)) { totalValue += this.dropValue; - if (predicate.test(DropRule.KEEP)) + dropValue = this.dropValue; + } + if (predicate.test(DropRule.KEEP)) { totalValue += this.keepValue; - if (predicate.test(DropRule.DESTROY)) + keepValue = this.keepValue; + } + if (predicate.test(DropRule.DESTROY)) { totalValue += this.destroyValue; - if (predicate.test(DropRule.PUT_IN_GRAVE)) + destroyValue = this.destroyValue; + } + if (predicate.test(DropRule.PUT_IN_GRAVE)) { totalValue += this.graveValue; + graveValue = this.graveValue; + } - return new NumismaticCompatComponent(totalValue, this.dropValue, this.keepValue, this.destroyValue, this.graveValue); + return new NumismaticCompatComponent(totalValue, dropValue, keepValue, destroyValue, graveValue); } @Override diff --git a/src/main/java/com/b1n_ry/yigd/events/YigdServerEventHandler.java b/src/main/java/com/b1n_ry/yigd/events/YigdServerEventHandler.java index bf3516f..b03beb8 100644 --- a/src/main/java/com/b1n_ry/yigd/events/YigdServerEventHandler.java +++ b/src/main/java/com/b1n_ry/yigd/events/YigdServerEventHandler.java @@ -215,6 +215,7 @@ public static void registerEventCallbacks() { } return true; }); + DropItemEvent.EVENT.register((stack, x, y, z, world) -> !stack.isEmpty()); } /**