Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always enable the Guide hotkey #8084

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import appeng.client.guidebook.PageAnchor;
import appeng.client.guidebook.indices.ItemIndex;
import appeng.client.guidebook.screen.GuideScreen;
import appeng.core.AEConfig;
import appeng.core.AppEngClient;

/**
Expand Down Expand Up @@ -58,13 +57,9 @@ private OpenGuideHotkey() {
}

public static void init() {
if (AEConfig.instance().isGuideHotkeyEnabled()) {
NeoForge.EVENT_BUS.addListener(
(ItemTooltipEvent evt) -> handleTooltip(evt.getItemStack(), evt.getFlags(), evt.getToolTip()));
NeoForge.EVENT_BUS.addListener((ClientTickEvent.Post evt) -> newTick = true);
} else {
LOG.info("AE2 guide hotkey is disabled via config.");
}
NeoForge.EVENT_BUS.addListener(
(ItemTooltipEvent evt) -> handleTooltip(evt.getItemStack(), evt.getFlags(), evt.getToolTip()));
NeoForge.EVENT_BUS.addListener((ClientTickEvent.Post evt) -> newTick = true);
}

private static void handleTooltip(ItemStack itemStack, TooltipFlag tooltipFlag, List<Component> lines) {
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/appeng/core/AEConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

public final class AEConfig {

private final StartupConfig startup = new StartupConfig();
private final ClientConfig client = new ClientConfig();
private final CommonConfig common = new CommonConfig();

Expand All @@ -53,7 +52,6 @@ public final class AEConfig {
private static AEConfig instance;

private AEConfig(ModContainer container) {
container.registerConfig(ModConfig.Type.STARTUP, startup.spec);
container.registerConfig(ModConfig.Type.CLIENT, client.spec);
container.registerConfig(ModConfig.Type.COMMON, common.spec);
container.getEventBus().addListener((ModConfigEvent.Loading evt) -> {
Expand Down Expand Up @@ -160,10 +158,6 @@ public void setTerminalStyle(TerminalStyle setting) {
client.spec.save();
}

public boolean isGuideHotkeyEnabled() {
return startup.enableGuideHotkey.get();
}

public double getGridEnergyStoragePerNode() {
return common.gridEnergyStoragePerNode.get();
}
Expand Down Expand Up @@ -408,19 +402,6 @@ public void save() {
client.spec.save();
}

private static class StartupConfig {
private final ModConfigSpec spec;

public final BooleanValue enableGuideHotkey;

public StartupConfig() {
var builder = new ModConfigSpec.Builder();
this.enableGuideHotkey = define(builder, "enableGuideHotkey", true,
"Enables the 'hold key to show guide' functionality in tooltips");
this.spec = builder.build();
}
}

private static class ClientConfig {
private final ModConfigSpec spec;

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/appeng/core/AppEngClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import net.neoforged.neoforge.client.event.RegisterDimensionSpecialEffectsEvent;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.client.settings.KeyConflictContext;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.server.ServerStartingEvent;
Expand Down Expand Up @@ -189,6 +191,9 @@ public AppEngClient(IEventBus modEventBus, ModContainer container) {
tickPinnedKeys(Minecraft.getInstance());
Hotkeys.checkHotkeys();
});

container.registerExtensionPoint(IConfigScreenFactory.class,
(mc, parent) -> new ConfigurationScreen(container, parent));
}

private void enqueueImcMessages(InterModEnqueueEvent event) {
Expand Down Expand Up @@ -247,9 +252,7 @@ public void registerHotkey(String id) {
}

private void registerHotkeys(RegisterKeyMappingsEvent e) {
if (AEConfig.instance().isGuideHotkeyEnabled()) {
e.register(OpenGuideHotkey.getHotkey());
}
e.register(OpenGuideHotkey.getHotkey());
e.register(MOUSE_WHEEL_ITEM_MODIFIER);
Hotkeys.finalizeRegistration(e::register);
}
Expand Down