Fly scheme and base

This commit is contained in:
Christoph J. Scherr 2023-11-12 13:01:57 +01:00
parent 0837516809
commit ecb2cdcd85
2 changed files with 71 additions and 20 deletions

View File

@ -0,0 +1,42 @@
package de.cscherr.mcpht;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;
import java.util.ArrayList;
import java.util.List;
public class Fly {
public boolean enable = true;
private static KeyBinding toggleKey;
public void init() {
toggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.mcpht.toggleXray", // Translation of name
InputUtil.Type.KEYSYM, // Type: MOUSE or KESYM (Keyboard)
GLFW.GLFW_KEY_Y, // The keycode of the key (default?)
"category.mcpht.rendering" // Translation key for the keybinding category
));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
// NOTE: IDK why we need a while here
while (toggleKey.wasPressed()) {
if (MCPHTClient.XRAY.getEnable()) {
MCPHTClient.LOGGER.info(String.format("toggle XRay: %s", MCPHTClient.XRAY.enable));
MCPHTClient.XRAY.enable = !MCPHTClient.XRAY.enable;
MCPHTClient.MC.worldRenderer.reload();
}
}
});
}
public boolean getEnable() {
return enable && MCPHTClient.CONFIG.fly.enable;
}
}

View File

@ -9,16 +9,45 @@ import java.util.regex.Pattern;
@Config(name = "mcphtconf")
public class MCPHTConfig implements ConfigData {
public static class NetworkLoggingScheme {
public boolean RX = false;
public boolean TX = false;
public NetworkPacketVerbosity verbosity = NetworkPacketVerbosity.NAME;
public String regex = ".*";
public enum NetworkPacketVerbosity {
ALL, NAME
}
}
@ConfigEntry.Category("Networking")
@ConfigEntry.Gui.CollapsibleObject
public NetworkLoggingScheme networkLogging = new NetworkLoggingScheme();
@ConfigEntry.Category("Rendering")
@ConfigEntry.Gui.CollapsibleObject
public XRayScheme xRay = new XRayScheme();
// TODO: toggle with hotkey
public static class XRayScheme {
public boolean enable = false;
public boolean overwriteBrightness;
}
@ConfigEntry.Category("Movement")
@ConfigEntry.Gui.CollapsibleObject
public FlyScheme fly = new FlyScheme();
// TODO: toggle with hotkey
public static class FlyScheme {
public boolean enable = false;
}
public void onSave() {
MCPHTClient.LOGGER.info("saving and processing configs");
MCPHTClient.networkPacketFilter = compileFilter();
MCPHTClient.MC.worldRenderer.reload();
logSettings();
}
public void onLoad() {
MCPHTClient.LOGGER.info("loading configs");
MCPHTClient.networkPacketFilter = compileFilter();
MCPHTClient.MC.worldRenderer.reload();
logSettings();
}
public void logSettings() {
@ -49,24 +78,4 @@ public class MCPHTConfig implements ConfigData {
return Pattern.compile(".*"); // just accept all on error
}
}
public static class NetworkLoggingScheme {
public boolean RX = false;
public boolean TX = false;
public NetworkPacketVerbosity verbosity = NetworkPacketVerbosity.NAME;
public String regex = ".*";
public enum NetworkPacketVerbosity {
ALL, NAME
}
}
@ConfigEntry.Category("Networking")
@ConfigEntry.Gui.CollapsibleObject
public NetworkLoggingScheme networkLogging = new NetworkLoggingScheme();
@ConfigEntry.Category("Rendering")
@ConfigEntry.Gui.CollapsibleObject
public XRayScheme xRay = new XRayScheme();
// TODO: toggle with hotkey
public static class XRayScheme {
public boolean enable = false;
public boolean overwriteBrightness;
}
}