Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Christoph J. Scherr | 78a0bc2034 | |
Christoph J. Scherr | e5ec40b8c2 | |
Christoph J. Scherr | ecb2cdcd85 | |
Christoph J. Scherr | 0837516809 |
|
@ -1,6 +1,7 @@
|
|||
package de.cscherr.mcpht;
|
||||
|
||||
import de.cscherr.mcpht.config.MCPHTConfig;
|
||||
import de.cscherr.mcpht.hack.XRay;
|
||||
import me.shedaniel.autoconfig.AutoConfig;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
|
||||
|
|
|
@ -9,46 +9,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
@Config(name = "mcphtconf")
|
||||
public class MCPHTConfig implements ConfigData {
|
||||
public void onSave() {
|
||||
MCPHTClient.LOGGER.info("saving and processing configs");
|
||||
MCPHTClient.networkPacketFilter = compileFilter();
|
||||
|
||||
logSettings();
|
||||
}
|
||||
public void onLoad() {
|
||||
MCPHTClient.LOGGER.info("loading configs");
|
||||
MCPHTClient.networkPacketFilter = compileFilter();
|
||||
|
||||
logSettings();
|
||||
}
|
||||
public void logSettings() {
|
||||
MCPHTClient.LOGGER.info(String.format("""
|
||||
CONFIG:\s
|
||||
NetworkLogging
|
||||
RX: %b
|
||||
TX: %b
|
||||
verbosity: %s
|
||||
regex: '%s'
|
||||
filter: %s
|
||||
Rendering
|
||||
enabled: %b""",
|
||||
MCPHTClient.CONFIG.networkLogging.RX,
|
||||
MCPHTClient.CONFIG.networkLogging.TX,
|
||||
MCPHTClient.CONFIG.networkLogging.verbosity,
|
||||
MCPHTClient.CONFIG.networkLogging.regex,
|
||||
MCPHTClient.networkPacketFilter,
|
||||
|
||||
MCPHTClient.CONFIG.xRay.enable
|
||||
));
|
||||
}
|
||||
private Pattern compileFilter() {
|
||||
try {
|
||||
return Pattern.compile(this.networkLogging.regex);
|
||||
} catch (Exception e) {
|
||||
MCPHTClient.LOGGER.warn(String.format("Invalid regex: %s", this.networkLogging.regex));
|
||||
return Pattern.compile(".*"); // just accept all on error
|
||||
}
|
||||
}
|
||||
public static class NetworkLoggingScheme {
|
||||
public boolean RX = false;
|
||||
public boolean TX = false;
|
||||
|
@ -69,4 +29,61 @@ public class MCPHTConfig implements ConfigData {
|
|||
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();
|
||||
|
||||
if (MCPHTClient.MC.worldRenderer != null) {
|
||||
MCPHTClient.MC.worldRenderer.reload();
|
||||
}
|
||||
logSettings();
|
||||
}
|
||||
public void logSettings() {
|
||||
// TODO: autogenerate this from Hack classes
|
||||
MCPHTClient.LOGGER.info(String.format("""
|
||||
Networking
|
||||
NetworkLogging
|
||||
RX: %b
|
||||
TX: %b
|
||||
verbosity: %s
|
||||
regex: '%s'
|
||||
filter: %s
|
||||
Rendering
|
||||
XRay:
|
||||
enabled: %b
|
||||
XRay:
|
||||
enabled: %b
|
||||
""",
|
||||
MCPHTClient.CONFIG.networkLogging.RX,
|
||||
MCPHTClient.CONFIG.networkLogging.TX,
|
||||
MCPHTClient.CONFIG.networkLogging.verbosity,
|
||||
MCPHTClient.CONFIG.networkLogging.regex,
|
||||
MCPHTClient.networkPacketFilter,
|
||||
|
||||
MCPHTClient.CONFIG.xRay.enable,
|
||||
MCPHTClient.CONFIG.fly.enable
|
||||
));
|
||||
}
|
||||
private Pattern compileFilter() {
|
||||
try {
|
||||
return Pattern.compile(this.networkLogging.regex);
|
||||
} catch (Exception e) {
|
||||
MCPHTClient.LOGGER.warn(String.format("Invalid regex: %s", this.networkLogging.regex));
|
||||
return Pattern.compile(".*"); // just accept all on error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package de.cscherr.mcpht.hack;
|
||||
|
||||
|
||||
import de.cscherr.mcpht.MCPHTClient;
|
||||
import de.cscherr.mcpht.util.Hack;
|
||||
import de.cscherr.mcpht.util.MaybeKey;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
|
||||
public class Fly extends Hack {
|
||||
public Fly() {
|
||||
super(new MaybeKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyPress() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnable() {
|
||||
return enable && MCPHTClient.CONFIG.fly.enable;
|
||||
}
|
||||
}
|
|
@ -1,19 +1,17 @@
|
|||
package de.cscherr.mcpht;
|
||||
package de.cscherr.mcpht.hack;
|
||||
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import de.cscherr.mcpht.MCPHTClient;
|
||||
import de.cscherr.mcpht.util.Hack;
|
||||
import de.cscherr.mcpht.util.MaybeKey;
|
||||
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 XRay {
|
||||
public boolean enable = true;
|
||||
public class XRay extends Hack {
|
||||
public ArrayList<Block> whitelistBlocks = new ArrayList<>(
|
||||
List.of(
|
||||
// Ores
|
||||
|
@ -80,30 +78,26 @@ public class XRay {
|
|||
Blocks.RED_SHULKER_BOX
|
||||
)
|
||||
);
|
||||
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_R, // 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()) {
|
||||
MCPHTClient.LOGGER.info(String.format("toggle XRay: %s", MCPHTClient.XRAY.enable));
|
||||
MCPHTClient.XRAY.enable = !MCPHTClient.XRAY.enable;
|
||||
MCPHTClient.MC.worldRenderer.reload();
|
||||
public XRay() {
|
||||
super(new MaybeKey("key.mcpht.toggleXray",
|
||||
"category.mcpht.rendering",
|
||||
GLFW.GLFW_KEY_X));
|
||||
MCPHTClient.LOGGER.info(String.format("xray key: %s (%b)", this.toggleKey, this.toggleKey.hasKey));
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onKeyPress() {
|
||||
MCPHTClient.XRAY.setEnable(!MCPHTClient.XRAY.getEnable());
|
||||
MCPHTClient.MC.worldRenderer.reload();
|
||||
}
|
||||
|
||||
public boolean showRenderBlock(BlockState state) {
|
||||
return whitelistBlocks.contains(state.getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnable() {
|
||||
return enable && MCPHTClient.CONFIG.xRay.enable;
|
||||
return this.enable && MCPHTClient.CONFIG.xRay.enable;
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package de.cscherr.mcpht.mixin.client;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Pseudo
|
||||
@Mixin(targets = "me.jellysquid.mods.sodium.client.render.occlusion.BlockOcclusionCache")
|
||||
/**
|
||||
* Fix for sodium, so that it doesn't break xray.
|
||||
*/
|
||||
public class MixinBlockOcclusionCache {
|
||||
@Inject(at = @At("HEAD"), method = "shouldDrawSide", cancellable = true, remap = false)
|
||||
private void shouldDrawSide(BlockState state, BlockView reader, BlockPos pos, Direction face,
|
||||
CallbackInfoReturnable<Boolean> ci) {
|
||||
}
|
||||
}
|
|
@ -15,37 +15,32 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public class MixinNetworkPacketLog {
|
||||
public class MixinClientConnection {
|
||||
@Unique
|
||||
private static boolean filterPacket(Packet<?> packet) {
|
||||
return MCPHTClient.networkPacketFilter.matcher(packet.getClass().getSimpleName()).find();
|
||||
}
|
||||
@Unique
|
||||
private static String getPacketInfo(Packet<?> packet) {
|
||||
String information = null;
|
||||
String information;
|
||||
switch (MCPHTClient.CONFIG.networkLogging.verbosity) {
|
||||
case NAME -> {
|
||||
information = packet.getClass().getSimpleName();
|
||||
break;
|
||||
}
|
||||
case ALL -> {
|
||||
information = String.format("%s:\n%s", packet.getClass().getSimpleName(), getPacketFields(packet));
|
||||
break;
|
||||
}
|
||||
case NAME -> information = packet.getClass().getSimpleName();
|
||||
case ALL -> information = String.format("%s:\n%s", packet.getClass().getSimpleName(), getPacketFields(packet));
|
||||
default ->
|
||||
throw new IllegalStateException("Unexpected value: " + MCPHTClient.CONFIG.networkLogging.verbosity);
|
||||
}
|
||||
return information;
|
||||
}
|
||||
@Unique
|
||||
private static String getPacketFields(Packet<?> packet) {
|
||||
String fieldInfo = "";
|
||||
String fieldInfo;
|
||||
switch (packet.getClass().getSimpleName()) {
|
||||
case "PositionAndOnGround" -> {
|
||||
PlayerMoveC2SPacket ppacket = (PlayerMoveC2SPacket)packet;
|
||||
PlayerMoveC2SPacket pmPacket = (PlayerMoveC2SPacket)packet;
|
||||
fieldInfo = String.format("X: %f | Y: %f | Z: %f\n" +
|
||||
"Ground: %b", ppacket.getX(0), ppacket.getY(0), ppacket.getZ(0), ppacket.isOnGround());
|
||||
}
|
||||
default -> {
|
||||
fieldInfo = "<None>";
|
||||
"Ground: %b", pmPacket.getX(0), pmPacket.getY(0), pmPacket.getZ(0), pmPacket.isOnGround());
|
||||
}
|
||||
default -> fieldInfo = "<None>";
|
||||
}
|
||||
return fieldInfo;
|
||||
}
|
||||
|
@ -72,7 +67,7 @@ public class MixinNetworkPacketLog {
|
|||
* Must be static for some reason
|
||||
*
|
||||
* @param packet the Network packet to be sent
|
||||
* @param listener i dont know what this does
|
||||
* @param listener i don't know what this does
|
||||
* @param ci magical fabric mixin stuff
|
||||
*/
|
||||
@Inject(method = "handlePacket", at = @At("HEAD"))
|
|
@ -0,0 +1,37 @@
|
|||
package de.cscherr.mcpht.util;
|
||||
|
||||
import de.cscherr.mcpht.MCPHTClient;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
|
||||
public abstract class Hack {
|
||||
public boolean enable = false;
|
||||
public MaybeKey toggleKey;
|
||||
|
||||
public Hack(MaybeKey toggleKey) {
|
||||
this.toggleKey = toggleKey;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (toggleKey.hasKey) {
|
||||
MCPHTClient.LOGGER.info("init key register start");
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
// NOTE: IDK why we need a while here
|
||||
while (toggleKey.key.wasPressed()) {
|
||||
MCPHTClient.LOGGER.info(String.format("toggle %s: %s",
|
||||
this.getClass().getSimpleName(),
|
||||
this.getEnable()));
|
||||
onKeyPress();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onKeyPress();
|
||||
|
||||
public abstract boolean getEnable();
|
||||
|
||||
public void setEnable(boolean newEnable) {
|
||||
MCPHTClient.LOGGER.info(String.format("set enable xray: %b", newEnable));
|
||||
this.enable = newEnable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package de.cscherr.mcpht.util;
|
||||
|
||||
import de.cscherr.mcpht.MCPHTClient;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
|
||||
public class MaybeKey {
|
||||
public KeyBinding key;
|
||||
public String translationKey;
|
||||
public String translationCategory;
|
||||
public int keyCode;
|
||||
public boolean hasKey;
|
||||
|
||||
public MaybeKey() {
|
||||
hasKey = false;
|
||||
}
|
||||
|
||||
public MaybeKey(String translationKey, String translationCategory, int keyCode) {
|
||||
this.key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||
translationKey, // Translation of name
|
||||
InputUtil.Type.KEYSYM, // Type: MOUSE or KESYM (Keyboard)
|
||||
keyCode, // The keycode of the key (default key)
|
||||
translationCategory // Translation key for the keybinding category
|
||||
));
|
||||
MCPHTClient.LOGGER.info(String.format("key: %s", this.key));
|
||||
this.hasKey = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package de.cscherr.mcpht.util.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class Event<T extends Listener> {
|
||||
public abstract void fire(ArrayList<T> listeners);
|
||||
|
||||
public abstract Class<T> getListenerType();
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package de.cscherr.mcpht.util.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface Listener extends EventListener {
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package de.cscherr.mcpht.util.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface UpdateListener extends Listener {
|
||||
public void onUpdate();
|
||||
public static class UpdateEvent extends Event<UpdateListener>
|
||||
{
|
||||
public static final UpdateEvent INSTANCE = new UpdateEvent();
|
||||
|
||||
@Override
|
||||
public void fire(ArrayList<UpdateListener> listeners)
|
||||
{
|
||||
for(UpdateListener listener : listeners)
|
||||
listener.onUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<UpdateListener> getListenerType()
|
||||
{
|
||||
return UpdateListener.class;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,7 @@
|
|||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"MixinBlock",
|
||||
"MixinNetworkPacketLog",
|
||||
"MixinBlockOcclusionCache",
|
||||
"MixinClientConnection",
|
||||
"MixinLightmapTextureManager",
|
||||
"MixinMinecraftClient"
|
||||
],
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "de.cscherr.mcpht.mixin.client",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [],
|
||||
"client": [
|
||||
"MixinBlock",
|
||||
"MixinBlockOcclusionCache",
|
||||
"MixinMinecraftClient",
|
||||
"MixinLightmapTextureManager"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -6,8 +6,7 @@
|
|||
"description": "Plex Hack Tools",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christoph J. Scherr",
|
||||
"email": "software@cscherr.de"
|
||||
"name": "Christoph J. Scherr"
|
||||
}
|
||||
],
|
||||
"contact": {
|
||||
|
@ -35,10 +34,6 @@
|
|||
{
|
||||
"config": "mcpht.client.mixins.json",
|
||||
"environment": "client"
|
||||
},
|
||||
{
|
||||
"config": "mcpht.sodium.mixins.json",
|
||||
"environment": "client"
|
||||
}
|
||||
],
|
||||
"depends": {
|
||||
|
|
Loading…
Reference in New Issue