Skip to content

Commit

Permalink
Fix "open guide" hotkey not working for items in Emi because they wer…
Browse files Browse the repository at this point in the history
…e changing each frame (#7965) (#8062)

Fixes #7877

(cherry picked from commit 40583e4)
  • Loading branch information
shartte authored Jul 27, 2024
1 parent 719a8a2 commit 485ca12
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/java/appeng/client/guidebook/hotkey/OpenGuideHotkey.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package appeng.client.guidebook.hotkey;

import java.util.List;
import java.util.Objects;

import com.google.common.base.Strings;
import com.mojang.blaze3d.platform.InputConstants;
Expand Down Expand Up @@ -46,8 +47,8 @@ public final class OpenGuideHotkey {

private static boolean newTick = true;

// The last itemstack the tooltip was being shown for
private static ItemStack lastStack;
// The previous item the tooltip was being shown for
private static ResourceLocation previousItemId;
@Nullable
private static PageAnchor guidebookPage;
// Full ticks since the button was held (reduces slowly when not held)
Expand Down Expand Up @@ -137,15 +138,16 @@ private static Component makeProgressBar(float progress) {
}

private static void update(ItemStack itemStack) {
if (itemStack != lastStack) {
lastStack = itemStack;
var itemId = itemStack.getItemHolder()
.unwrapKey()
.map(ResourceKey::location)
.orElse(null);

if (!Objects.equals(itemId, previousItemId)) {
previousItemId = itemId;
guidebookPage = null;
ticksKeyHeld = 0;

var itemId = itemStack.getItemHolder()
.unwrapKey()
.map(ResourceKey::location)
.orElse(null);
if (itemId == null) {
return;
}
Expand Down

0 comments on commit 485ca12

Please sign in to comment.