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)

Fixes #7877
  • Loading branch information
shartte committed Jun 24, 2024
1 parent 28727a2 commit 40583e4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 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 All @@ -14,6 +15,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
Expand Down Expand Up @@ -43,8 +45,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 @@ -133,15 +135,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 40583e4

Please sign in to comment.