Skip to content

Commit

Permalink
fix: 🐛 Fixed mob charms notification icon to not stay stuck in gui ov…
Browse files Browse the repository at this point in the history
…erlay when it gets very low in durability
  • Loading branch information
P3pp3rF1y committed Feb 11, 2025
1 parent 22c21ce commit 97d66df
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ loader_version_range=[4,)
mod_id=reliquary
mod_name=Reliquary Reincarnations
mod_license=All Rights Reserved
mod_version=2.0.45
mod_version=2.0.46
mod_group_id=reliquary
mod_authors=P3pp3rF1y
mod_description=Two words: magical swag. Oh, and a gun.
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/reliquary/client/gui/hud/CharmPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ private static void removeExpiredMobCharms() {
for (Iterator<Map.Entry<Integer, CharmToDraw>> iterator = charmsToDraw.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<Integer, CharmToDraw> entry = iterator.next();
CharmToDraw charmToDraw = entry.getValue();
if (Boolean.TRUE.equals(Config.COMMON.items.mobCharm.keepAlmostDestroyedDisplayed.get()) && charmToDraw.getCharm().getDamageValue() >= (charmToDraw.getCharm().getMaxDamage() * 0.9)) {
continue;
float percentToMaxDamage = 1 - (float) charmToDraw.getCharm().getDamageValue() / charmToDraw.getCharm().getMaxDamage();

int expirationDuration = secondsToExpire * 1000;
if (percentToMaxDamage < 0.1f) {
expirationDuration = (int) (expirationDuration + (expirationDuration * 2 * (1 - percentToMaxDamage * 10)));
}

if (charmToDraw.time + secondsToExpire * 1000 < System.currentTimeMillis()) {
if (charmToDraw.time + expirationDuration < System.currentTimeMillis()) {
iterator.remove();
changed = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reliquary/network/MobCharmDamagePayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public record MobCharmDamagePayload(ItemStack mobCharm, int slot) implements CustomPacketPayload {
public static final Type<MobCharmDamagePayload> TYPE = new Type<>(Reliquary.getRL("mob_charm_damage"));
public static final StreamCodec<RegistryFriendlyByteBuf, MobCharmDamagePayload> STREAM_CODEC = StreamCodec.composite(
ItemStack.STREAM_CODEC,
ItemStack.OPTIONAL_STREAM_CODEC,
MobCharmDamagePayload::mobCharm,
ByteBufCodecs.INT,
MobCharmDamagePayload::slot,
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/reliquary/reference/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ public static class MobCharmSettings {
public final IntValue dropDurabilityRepair;
public final IntValue maxCharmsToDisplay;
public final IntValue pedestalRange;
public final BooleanValue keepAlmostDestroyedDisplayed;
@SuppressWarnings("java:S4968")
// ? extends String is the type parameter returned from defineList so it can't be just String here
public final ConfigValue<List<? extends String>> entityBlockList;
Expand Down Expand Up @@ -911,9 +910,6 @@ public static class MobCharmSettings {
.comment("Range in which mob charm or belt in pedestals will keep monsters from attacking players")
.defineInRange("pedestalRange", 21, 10, 100);

keepAlmostDestroyedDisplayed = builder
.comment("Determines if almost destroyed charms stay displayed in the hud")
.define("keepAlmostDestroyedDisplayed", true);
entityBlockList = builder
.comment("List of hostile entities that are not supposed to have mob charms registered for them")
.defineList("entityBlockList", this::getDefaultEntityBlockList, () -> BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.ZOMBIE).toString() , entityName -> ((String) entityName).matches(REGISTRY_NAME_MATCHER));
Expand Down

0 comments on commit 97d66df

Please sign in to comment.