generated from MrSphay/codex-agent-repository-kit
92 lines
4.0 KiB
Java
92 lines
4.0 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.vinlanx.explosionoverhaul;
|
|
|
|
import com.mojang.blaze3d.platform.InputConstants;
|
|
import com.vinlanx.explosionoverhaul.PacketHandler;
|
|
import com.vinlanx.explosionoverhaul.ScanControlPacket;
|
|
import com.vinlanx.explosionoverhaul.ScanInfoHUD;
|
|
import com.vinlanx.explosionoverhaul.ScanLoadControlPacket;
|
|
import com.vinlanx.explosionoverhaul.ScanLoadInfoHUD;
|
|
import com.vinlanx.explosionoverhaul.ScanLoadPromptHUD;
|
|
import com.vinlanx.explosionoverhaul.ScanPromptHUD;
|
|
import com.vinlanx.explosionoverhaul.client.ModKeyMappings;
|
|
import net.minecraft.client.KeyMapping;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.client.event.InputEvent;
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
@Mod.EventBusSubscriber(value={Dist.CLIENT})
|
|
public class ScanKeyHandler {
|
|
@SubscribeEvent
|
|
public static void onKeyInput(InputEvent.Key event) {
|
|
Minecraft mc = Minecraft.m_91087_();
|
|
if (mc.f_91074_ == null || mc.f_91080_ != null) {
|
|
return;
|
|
}
|
|
if (!mc.f_91074_.m_20310_(2) && !mc.m_91091_()) {
|
|
return;
|
|
}
|
|
if (event.getAction() != 1) {
|
|
return;
|
|
}
|
|
InputConstants.Key key = InputConstants.m_84827_((int)event.getKey(), (int)event.getScanCode());
|
|
if (ScanLoadPromptHUD.isVisible()) {
|
|
if (key.equals((Object)ModKeyMappings.ACCEPT_SCAN.getKey())) {
|
|
PacketHandler.INSTANCE.sendToServer((Object)new ScanLoadControlPacket(true));
|
|
ScanLoadPromptHUD.setVisible(false);
|
|
ScanLoadInfoHUD.setVisible(false);
|
|
if (event.getKey() != 49 && event.getKey() != 50) {
|
|
ScanKeyHandler.consumeKey(event.getKey());
|
|
}
|
|
} else if (key.equals((Object)ModKeyMappings.DECLINE_SCAN.getKey())) {
|
|
PacketHandler.INSTANCE.sendToServer((Object)new ScanLoadControlPacket(false));
|
|
ScanLoadPromptHUD.setVisible(false);
|
|
ScanLoadInfoHUD.setVisible(false);
|
|
if (event.getKey() != 49 && event.getKey() != 50) {
|
|
ScanKeyHandler.consumeKey(event.getKey());
|
|
}
|
|
} else if (key.equals((Object)ModKeyMappings.INFO_SCAN.getKey())) {
|
|
boolean currentlyVisible = ScanLoadInfoHUD.isVisible();
|
|
ScanLoadInfoHUD.setVisible(!currentlyVisible);
|
|
ScanKeyHandler.consumeKey(event.getKey());
|
|
}
|
|
return;
|
|
}
|
|
if (ScanPromptHUD.isVisible()) {
|
|
if (key.equals((Object)ModKeyMappings.ACCEPT_SCAN.getKey())) {
|
|
PacketHandler.INSTANCE.sendToServer((Object)new ScanControlPacket(true));
|
|
ScanPromptHUD.setVisible(false);
|
|
ScanInfoHUD.setVisible(false);
|
|
if (event.getKey() != 49 && event.getKey() != 50) {
|
|
ScanKeyHandler.consumeKey(event.getKey());
|
|
}
|
|
} else if (key.equals((Object)ModKeyMappings.DECLINE_SCAN.getKey())) {
|
|
PacketHandler.INSTANCE.sendToServer((Object)new ScanControlPacket(false));
|
|
ScanPromptHUD.setVisible(false);
|
|
ScanInfoHUD.setVisible(false);
|
|
if (event.getKey() != 49 && event.getKey() != 50) {
|
|
ScanKeyHandler.consumeKey(event.getKey());
|
|
}
|
|
} else if (key.equals((Object)ModKeyMappings.INFO_SCAN.getKey())) {
|
|
boolean currentlyVisible = ScanInfoHUD.isVisible();
|
|
ScanInfoHUD.setVisible(!currentlyVisible);
|
|
ScanKeyHandler.consumeKey(event.getKey());
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void consumeKey(int keyCode) {
|
|
Minecraft mc = Minecraft.m_91087_();
|
|
for (KeyMapping mapping : mc.f_91066_.f_92059_) {
|
|
if (mapping.getKey().m_84873_() != keyCode) continue;
|
|
while (mapping.m_90859_()) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|