优化按键方法
This commit is contained in:
parent
eecf61168a
commit
d70edf6967
2 changed files with 12 additions and 40 deletions
|
@ -167,6 +167,9 @@ public class ClickHandler {
|
||||||
if (key == ModKeyMappings.CONFIG.getKey().getValue()) {
|
if (key == ModKeyMappings.CONFIG.getKey().getValue()) {
|
||||||
handleConfigScreen(player);
|
handleConfigScreen(player);
|
||||||
}
|
}
|
||||||
|
if (key == ModKeyMappings.RELOAD.getKey().getValue()) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
||||||
|
}
|
||||||
if (key == ModKeyMappings.EDIT_MODE.getKey().getValue()) {
|
if (key == ModKeyMappings.EDIT_MODE.getKey().getValue()) {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new EditModeMessage(0));
|
ModUtils.PACKET_HANDLER.sendToServer(new EditModeMessage(0));
|
||||||
}
|
}
|
||||||
|
@ -182,6 +185,12 @@ public class ClickHandler {
|
||||||
if (key == ModKeyMappings.EDIT_STOCK.getKey().getValue()) {
|
if (key == ModKeyMappings.EDIT_STOCK.getKey().getValue()) {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new EditMessage(3));
|
ModUtils.PACKET_HANDLER.sendToServer(new EditMessage(3));
|
||||||
}
|
}
|
||||||
|
if (key == ModKeyMappings.SENSITIVITY_INCREASE.getKey().getValue()) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new SensitivityMessage(true));
|
||||||
|
}
|
||||||
|
if (key == ModKeyMappings.SENSITIVITY_REDUCE.getKey().getValue()) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new SensitivityMessage(false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,18 +16,7 @@ import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||||
public class ModKeyMappings {
|
public class ModKeyMappings {
|
||||||
public static final KeyMapping RELOAD = new KeyMapping("key.superbwarfare.reload", GLFW.GLFW_KEY_R, "key.categories.superbwarfare") {
|
public static final KeyMapping RELOAD = new KeyMapping("key.superbwarfare.reload", GLFW.GLFW_KEY_R, "key.categories.superbwarfare");
|
||||||
private boolean isDownOld = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDown(boolean isDown) {
|
|
||||||
super.setDown(isDown);
|
|
||||||
if (isDownOld != isDown && isDown && Minecraft.getInstance().player != null) {
|
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
|
||||||
}
|
|
||||||
isDownOld = isDown;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final KeyMapping FIRE_MODE = new KeyMapping("key.superbwarfare.fire_mode", GLFW.GLFW_KEY_N, "key.categories.superbwarfare") {
|
public static final KeyMapping FIRE_MODE = new KeyMapping("key.superbwarfare.fire_mode", GLFW.GLFW_KEY_N, "key.categories.superbwarfare") {
|
||||||
private boolean isDownOld = false;
|
private boolean isDownOld = false;
|
||||||
|
@ -43,31 +32,8 @@ public class ModKeyMappings {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final KeyMapping SENSITIVITY_INCREASE = new KeyMapping("key.superbwarfare.sensitivity_increase", GLFW.GLFW_KEY_PAGE_UP, "key.categories.superbwarfare") {
|
public static final KeyMapping SENSITIVITY_INCREASE = new KeyMapping("key.superbwarfare.sensitivity_increase", GLFW.GLFW_KEY_PAGE_UP, "key.categories.superbwarfare");
|
||||||
private boolean isDownOld = false;
|
public static final KeyMapping SENSITIVITY_REDUCE = new KeyMapping("key.superbwarfare.sensitivity_reduce", GLFW.GLFW_KEY_PAGE_DOWN, "key.categories.superbwarfare");
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDown(boolean isDown) {
|
|
||||||
super.setDown(isDown);
|
|
||||||
if (isDownOld != isDown && isDown) {
|
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new SensitivityMessage(true));
|
|
||||||
}
|
|
||||||
isDownOld = isDown;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final KeyMapping SENSITIVITY_REDUCE = new KeyMapping("key.superbwarfare.sensitivity_reduce", GLFW.GLFW_KEY_PAGE_DOWN, "key.categories.superbwarfare") {
|
|
||||||
private boolean isDownOld = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDown(boolean isDown) {
|
|
||||||
super.setDown(isDown);
|
|
||||||
if (isDownOld != isDown && isDown) {
|
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new SensitivityMessage(false));
|
|
||||||
}
|
|
||||||
isDownOld = isDown;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final KeyMapping INTERACT = new KeyMapping("key.superbwarfare.interact", GLFW.GLFW_KEY_X, "key.categories.superbwarfare") {
|
public static final KeyMapping INTERACT = new KeyMapping("key.superbwarfare.interact", GLFW.GLFW_KEY_X, "key.categories.superbwarfare") {
|
||||||
private boolean isDownOld = false;
|
private boolean isDownOld = false;
|
||||||
|
@ -130,10 +96,7 @@ public class ModKeyMappings {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
||||||
if (Minecraft.getInstance().screen == null) {
|
if (Minecraft.getInstance().screen == null) {
|
||||||
RELOAD.consumeClick();
|
|
||||||
FIRE_MODE.consumeClick();
|
FIRE_MODE.consumeClick();
|
||||||
SENSITIVITY_INCREASE.consumeClick();
|
|
||||||
SENSITIVITY_REDUCE.consumeClick();
|
|
||||||
INTERACT.consumeClick();
|
INTERACT.consumeClick();
|
||||||
BREATH.consumeClick();
|
BREATH.consumeClick();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue