Skip to content

Commit

Permalink
Fixed duplication of numismatic overhaul coins
Browse files Browse the repository at this point in the history
  • Loading branch information
B1n-ry committed Mar 23, 2024
1 parent 4203cd7 commit 3e12281
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 23 additions & 6 deletions src/main/java/com/b1n_ry/yigd/compat/NumismaticOverhaulCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down Expand Up @@ -154,16 +158,29 @@ public DefaultedList<Pair<ItemStack, DropRule>> getAsStackDropList() {
@Override
public CompatComponent<Long> filterInv(Predicate<DropRule> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public static void registerEventCallbacks() {
}
return true;
});
DropItemEvent.EVENT.register((stack, x, y, z, world) -> !stack.isEmpty());
}

/**
Expand Down

0 comments on commit 3e12281

Please sign in to comment.