Skip to content

Commit

Permalink
Tweak impl. of modify_item_cooldown item action type
Browse files Browse the repository at this point in the history
Now uses the item's old cooldown entry end tick value as the base value for the modifiers instead of the cooldown progress, which was a float clamped from 0.0 to 1.0
  • Loading branch information
eggohito committed Feb 13, 2024
1 parent e70bd2e commit ba6b5b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ public static void action(SerializableData.Instance data, Pair<World, ItemStack>
ItemCooldownManager cooldownManager = player.getItemCooldownManager();
Item item = stack.getItem();

double newCooldown = ModifierUtil.applyModifiers(player, modifiers, cooldownManager.getCooldownProgress(item, 0.0f));
cooldownManager.set(item, (int) Math.floor(newCooldown));
ItemCooldownManager.Entry cooldownEntry = cooldownManager.entries.get(item);

int oldCooldown = cooldownEntry != null ? cooldownEntry.endTick : 0;
int newCooldown = (int) ModifierUtil.applyModifiers(player, modifiers, oldCooldown);

cooldownManager.set(item, newCooldown);

}

Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/eggolib.accesswidener
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessWidener v1 named
accessWidener v2 named

extendable class net/minecraft/item/ItemStack
mutable field net/minecraft/item/ItemStack item Lnet/minecraft/item/Item;
Expand All @@ -12,3 +12,6 @@ accessible class net/minecraft/server/command/AdvancementCommand$Selection
accessible method net/minecraft/server/command/AdvancementCommand$Operation processEach (Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/advancement/Advancement;)Z
accessible method net/minecraft/server/command/AdvancementCommand$Operation processEachCriterion (Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/advancement/Advancement;Ljava/lang/String;)Z
extendable class net/minecraft/world/event/Vibrations$ListenerData
accessible field net/minecraft/entity/player/ItemCooldownManager entries Ljava/util/Map;
accessible class net/minecraft/entity/player/ItemCooldownManager$Entry
accessible field net/minecraft/entity/player/ItemCooldownManager$Entry endTick I

0 comments on commit ba6b5b5

Please sign in to comment.