From 8d47394acc7f8442ab81f1bb1228282387b4ceac Mon Sep 17 00:00:00 2001 From: MeexReay Date: Tue, 23 Apr 2024 20:37:36 +0300 Subject: [PATCH] gui not working, but im tried --- .../java/themixray/repeating/mod/Main.java | 12 +++- .../themixray/repeating/mod/TickTask.java | 3 +- .../repeating/mod/event/RecordEventType.java | 22 ++++--- .../mod/event/events/BlockBreakEvent.java | 4 +- .../mod/event/events/BlockInteractEvent.java | 4 +- .../mod/event/events/GuiCharTypeEvent.java | 34 +++++++++++ .../mod/event/events/GuiCloseEvent.java | 22 +++++++ .../mod/event/events/GuiKeyPressEvent.java | 38 ++++++++++++ .../mod/event/events/GuiKeyReleaseEvent.java | 38 ++++++++++++ .../mod/event/events/GuiMouseClickEvent.java | 38 ++++++++++++ .../mod/event/events/GuiMouseDragEvent.java | 46 +++++++++++++++ .../mod/event/events/GuiMouseMoveEvent.java | 34 +++++++++++ .../event/events/GuiMouseReleaseEvent.java | 38 ++++++++++++ .../mod/event/events/GuiMouseScrollEvent.java | 38 ++++++++++++ .../mod/event/events/InputEvent.java | 58 ++++++++++--------- .../repeating/mod/event/events/MoveEvent.java | 12 ++-- .../repeating/mod/mixin/PlayerMixin.java | 4 +- .../repeating/mod/mixin/ScreenMixin.java | 42 +++++++++++--- 18 files changed, 428 insertions(+), 59 deletions(-) create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiCharTypeEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiCloseEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiKeyPressEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiKeyReleaseEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiMouseClickEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiMouseDragEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiMouseMoveEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiMouseReleaseEvent.java create mode 100644 src/main/java/themixray/repeating/mod/event/events/GuiMouseScrollEvent.java diff --git a/src/main/java/themixray/repeating/mod/Main.java b/src/main/java/themixray/repeating/mod/Main.java index 45a10cf..37e5e28 100644 --- a/src/main/java/themixray/repeating/mod/Main.java +++ b/src/main/java/themixray/repeating/mod/Main.java @@ -87,6 +87,10 @@ public class Main implements ClientModInitializer { RenderHelper.endTri(buffer); }); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + TickTask.tickTasks(TickTask.TickAt.CLIENT_EVENT); + }); + Map def = new HashMap<>(); def.put("record_pos_delay", String.valueOf(record_pos_delay)); @@ -273,12 +277,16 @@ public class Main implements ClientModInitializer { List events = now_record.getEvents(); - replay_tick = new TickTask(0,0, TickTask.TickAt.CLIENT_TAIL) { + replay_tick = new TickTask(0,0, TickTask.TickAt.CLIENT_EVENT) { public int replay_index = 0; @Override public void run() { - if (!is_replaying) cancel(); + if (!is_replaying) { + cancel(); + return; + } + RecordEvent e = events.get(replay_index); if (e instanceof DelayEvent) { setDelay(((DelayEvent) e).delay); diff --git a/src/main/java/themixray/repeating/mod/TickTask.java b/src/main/java/themixray/repeating/mod/TickTask.java index f3beed1..e014511 100644 --- a/src/main/java/themixray/repeating/mod/TickTask.java +++ b/src/main/java/themixray/repeating/mod/TickTask.java @@ -23,7 +23,8 @@ public abstract class TickTask implements Runnable { public enum TickAt { CLIENT_HEAD, CLIENT_TAIL, MOVEMENT_HEAD, MOVEMENT_TAIL, - RENDER_HEAD, RENDER_TAIL + RENDER_HEAD, RENDER_TAIL, + CLIENT_EVENT } public TickTask(long delay, TickAt at) { diff --git a/src/main/java/themixray/repeating/mod/event/RecordEventType.java b/src/main/java/themixray/repeating/mod/event/RecordEventType.java index 45208d7..957159f 100644 --- a/src/main/java/themixray/repeating/mod/event/RecordEventType.java +++ b/src/main/java/themixray/repeating/mod/event/RecordEventType.java @@ -2,23 +2,21 @@ package themixray.repeating.mod.event; import themixray.repeating.mod.event.events.*; -import java.lang.reflect.InvocationTargetException; -import java.util.function.Consumer; - public enum RecordEventType { BLOCK_BREAK('b',"block_break",BlockBreakEvent.class), BLOCK_INTERACT('i',"block_interact",BlockInteractEvent.class), DELAY('d',"delay",DelayEvent.class), INPUT('p',"input",InputEvent.class), - MOVE('m',"move",MoveEvent.class), - GUI_KEY_PRESS('r',"key_press",BlockBreakEvent.class), - GUI_KEY_RELEASE('s',"key_release",BlockBreakEvent.class), - GUI_CHAR_TYPE('h',"char_type",BlockBreakEvent.class), - GUI_MOUSE_CLICK('c',"mouse_click",BlockBreakEvent.class), - GUI_MOUSE_RELEASE('l',"mouse_release",BlockBreakEvent.class), - GUI_MOUSE_DRAG('g',"mouse_drag",BlockBreakEvent.class), - GUI_MOUSE_SCROLL('o',"mouse_scroll",BlockBreakEvent.class), - GUI_CLOSE('e',"close",BlockBreakEvent.class); + MOVE('m',"move",MoveEvent.class); +// GUI_KEY_PRESS('r',"key_press", GuiKeyPressEvent.class), +// GUI_KEY_RELEASE('s',"key_release",GuiKeyReleaseEvent.class), +// GUI_CHAR_TYPE('h',"char_type",GuiCharTypeEvent.class), +// GUI_MOUSE_CLICK('c',"mouse_click",GuiMouseClickEvent.class), +// GUI_MOUSE_RELEASE('l',"mouse_release",GuiMouseReleaseEvent.class), +// GUI_MOUSE_DRAG('g',"mouse_drag",GuiMouseDragEvent.class), +// GUI_MOUSE_MOVE('v',"mouse_move",GuiMouseMoveEvent.class), +// GUI_MOUSE_SCROLL('o',"mouse_scroll",GuiMouseScrollEvent.class), +// GUI_CLOSE('e',"close",GuiCloseEvent.class); private Class ev; private char ch; diff --git a/src/main/java/themixray/repeating/mod/event/events/BlockBreakEvent.java b/src/main/java/themixray/repeating/mod/event/events/BlockBreakEvent.java index a240052..0e34fba 100644 --- a/src/main/java/themixray/repeating/mod/event/events/BlockBreakEvent.java +++ b/src/main/java/themixray/repeating/mod/event/events/BlockBreakEvent.java @@ -28,6 +28,8 @@ public class BlockBreakEvent extends RecordEvent { } public void replay() { - Main.client.interactionManager.breakBlock(pos); + if (Main.client.interactionManager != null) { + Main.client.interactionManager.breakBlock(pos); + } } } diff --git a/src/main/java/themixray/repeating/mod/event/events/BlockInteractEvent.java b/src/main/java/themixray/repeating/mod/event/events/BlockInteractEvent.java index 4eb99d1..bdae075 100644 --- a/src/main/java/themixray/repeating/mod/event/events/BlockInteractEvent.java +++ b/src/main/java/themixray/repeating/mod/event/events/BlockInteractEvent.java @@ -33,7 +33,9 @@ public class BlockInteractEvent extends RecordEvent { } public void replay() { - Main.client.interactionManager.interactBlock(Main.client.player, hand, hitResult); + if (Main.client.interactionManager != null) { + Main.client.interactionManager.interactBlock(Main.client.player, hand, hitResult); + } } protected String[] serializeArgs() { diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiCharTypeEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiCharTypeEvent.java new file mode 100644 index 0000000..4428984 --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiCharTypeEvent.java @@ -0,0 +1,34 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiCharTypeEvent extends RecordEvent { + private char chr; + private int modifiers; + + public GuiCharTypeEvent(char chr, int modifiers) { + this.chr = chr; + this.modifiers = modifiers; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.charTyped(chr, modifiers); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf((int) chr), + String.valueOf(modifiers) + }; + } + + public static GuiCharTypeEvent deserialize(String[] args) { + return new GuiCharTypeEvent( + (char) Integer.parseInt(args[0]), + Integer.parseInt(args[1]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiCloseEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiCloseEvent.java new file mode 100644 index 0000000..f2c3024 --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiCloseEvent.java @@ -0,0 +1,22 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiCloseEvent extends RecordEvent { + public GuiCloseEvent() {} + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.setScreen(null); + } + } + + protected String[] serializeArgs() { + return new String[] {}; + } + + public static GuiCloseEvent deserialize(String[] args) { + return new GuiCloseEvent(); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiKeyPressEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiKeyPressEvent.java new file mode 100644 index 0000000..cf5221f --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiKeyPressEvent.java @@ -0,0 +1,38 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiKeyPressEvent extends RecordEvent { + private int keyCode; + private int scanCode; + private int modifiers; + + public GuiKeyPressEvent(int keyCode, int scanCode, int modifiers) { + this.keyCode = keyCode; + this.scanCode = scanCode; + this.modifiers = modifiers; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.keyPressed(keyCode, scanCode, modifiers); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf(keyCode), + String.valueOf(scanCode), + String.valueOf(modifiers) + }; + } + + public static GuiKeyPressEvent deserialize(String[] args) { + return new GuiKeyPressEvent( + Integer.parseInt(args[0]), + Integer.parseInt(args[1]), + Integer.parseInt(args[2]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiKeyReleaseEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiKeyReleaseEvent.java new file mode 100644 index 0000000..8134c73 --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiKeyReleaseEvent.java @@ -0,0 +1,38 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiKeyReleaseEvent extends RecordEvent { + private int keyCode; + private int scanCode; + private int modifiers; + + public GuiKeyReleaseEvent(int keyCode, int scanCode, int modifiers) { + this.keyCode = keyCode; + this.scanCode = scanCode; + this.modifiers = modifiers; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.keyReleased(keyCode, scanCode, modifiers); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf(keyCode), + String.valueOf(scanCode), + String.valueOf(modifiers) + }; + } + + public static GuiKeyReleaseEvent deserialize(String[] args) { + return new GuiKeyReleaseEvent( + Integer.parseInt(args[0]), + Integer.parseInt(args[1]), + Integer.parseInt(args[2]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiMouseClickEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiMouseClickEvent.java new file mode 100644 index 0000000..1c47776 --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiMouseClickEvent.java @@ -0,0 +1,38 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiMouseClickEvent extends RecordEvent { + private double mouseX; + private double mouseY; + private int button; + + public GuiMouseClickEvent(double mouseX, double mouseY, int button) { + this.mouseX = mouseX; + this.mouseY = mouseY; + this.button = button; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.mouseClicked(mouseX, mouseY, button); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf(mouseX), + String.valueOf(mouseY), + String.valueOf(button) + }; + } + + public static GuiMouseClickEvent deserialize(String[] args) { + return new GuiMouseClickEvent( + Double.parseDouble(args[0]), + Double.parseDouble(args[1]), + Integer.parseInt(args[2]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiMouseDragEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiMouseDragEvent.java new file mode 100644 index 0000000..f351482 --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiMouseDragEvent.java @@ -0,0 +1,46 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiMouseDragEvent extends RecordEvent { + private double mouseX; + private double mouseY; + private double deltaX; + private double deltaY; + private int button; + + public GuiMouseDragEvent(double mouseX, double mouseY, int button, double deltaX, double deltaY) { + this.mouseX = mouseX; + this.mouseY = mouseY; + this.deltaX = deltaX; + this.deltaY = deltaY; + this.button = button; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf(mouseX), + String.valueOf(mouseY), + String.valueOf(button), + String.valueOf(deltaX), + String.valueOf(deltaY) + }; + } + + public static GuiMouseDragEvent deserialize(String[] args) { + return new GuiMouseDragEvent( + Double.parseDouble(args[0]), + Double.parseDouble(args[1]), + Integer.parseInt(args[2]), + Double.parseDouble(args[3]), + Double.parseDouble(args[4]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiMouseMoveEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiMouseMoveEvent.java new file mode 100644 index 0000000..7da1c82 --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiMouseMoveEvent.java @@ -0,0 +1,34 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiMouseMoveEvent extends RecordEvent { + private double mouseX; + private double mouseY; + + public GuiMouseMoveEvent(double mouseX, double mouseY) { + this.mouseX = mouseX; + this.mouseY = mouseY; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.mouseMoved(mouseX, mouseY); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf(mouseX), + String.valueOf(mouseY) + }; + } + + public static GuiMouseMoveEvent deserialize(String[] args) { + return new GuiMouseMoveEvent( + Double.parseDouble(args[0]), + Double.parseDouble(args[1]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiMouseReleaseEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiMouseReleaseEvent.java new file mode 100644 index 0000000..63b8b6b --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiMouseReleaseEvent.java @@ -0,0 +1,38 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiMouseReleaseEvent extends RecordEvent { + private double mouseX; + private double mouseY; + private int button; + + public GuiMouseReleaseEvent(double mouseX, double mouseY, int button) { + this.mouseX = mouseX; + this.mouseY = mouseY; + this.button = button; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.mouseReleased(mouseX, mouseY, button); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf(mouseX), + String.valueOf(mouseY), + String.valueOf(button) + }; + } + + public static GuiMouseReleaseEvent deserialize(String[] args) { + return new GuiMouseReleaseEvent( + Double.parseDouble(args[0]), + Double.parseDouble(args[1]), + Integer.parseInt(args[2]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/GuiMouseScrollEvent.java b/src/main/java/themixray/repeating/mod/event/events/GuiMouseScrollEvent.java new file mode 100644 index 0000000..470c29c --- /dev/null +++ b/src/main/java/themixray/repeating/mod/event/events/GuiMouseScrollEvent.java @@ -0,0 +1,38 @@ +package themixray.repeating.mod.event.events; + +import themixray.repeating.mod.Main; +import themixray.repeating.mod.event.RecordEvent; + +public class GuiMouseScrollEvent extends RecordEvent { + private double mouseX; + private double mouseY; + private double amount; + + public GuiMouseScrollEvent(double mouseX, double mouseY, double amount) { + this.mouseX = mouseX; + this.mouseY = mouseY; + this.amount = amount; + } + + public void replay() { + if (Main.client.currentScreen != null) { + Main.client.currentScreen.mouseScrolled(mouseX, mouseY, amount); + } + } + + protected String[] serializeArgs() { + return new String[] { + String.valueOf(mouseX), + String.valueOf(mouseY), + String.valueOf(amount) + }; + } + + public static GuiMouseScrollEvent deserialize(String[] args) { + return new GuiMouseScrollEvent( + Double.parseDouble(args[0]), + Double.parseDouble(args[1]), + Double.parseDouble(args[2]) + ); + } +} diff --git a/src/main/java/themixray/repeating/mod/event/events/InputEvent.java b/src/main/java/themixray/repeating/mod/event/events/InputEvent.java index 19c8b66..9ca3128 100644 --- a/src/main/java/themixray/repeating/mod/event/events/InputEvent.java +++ b/src/main/java/themixray/repeating/mod/event/events/InputEvent.java @@ -116,33 +116,35 @@ public class InputEvent extends RecordEvent { } public void inputCallback() { - if (sprinting != null && Main.client.player.isSprinting() != sprinting) - Main.client.player.setSprinting(sprinting); - if (Main.client.player.getYaw() != yaw) - Main.client.player.setYaw(yaw); - if (Main.client.player.getHeadYaw() != head_yaw) - Main.client.player.setHeadYaw(head_yaw); - if (Main.client.player.getBodyYaw() != body_yaw) - Main.client.player.setBodyYaw(body_yaw); - if (Main.client.player.getPitch() != pitch) - Main.client.player.setPitch(pitch); - if (Main.client.player.getMovementSpeed() != speed) - Main.client.player.setMovementSpeed(speed); - if (sneaking != null && Main.client.player.input.sneaking != sneaking) - Main.client.player.input.sneaking = sneaking; - if (jumping != null && Main.client.player.input.jumping != jumping) - Main.client.player.input.jumping = jumping; - if (movementSideways != null && Main.client.player.input.movementSideways != movementSideways) - Main.client.player.input.movementSideways = movementSideways; - if (movementForward != null && Main.client.player.input.movementForward != movementForward) - Main.client.player.input.movementForward = movementForward; - if (pressingForward != null && Main.client.player.input.pressingForward != pressingForward) - Main.client.player.input.pressingForward = pressingForward; - if (pressingBack != null && Main.client.player.input.pressingBack != pressingBack) - Main.client.player.input.pressingBack = pressingBack; - if (pressingLeft != null && Main.client.player.input.pressingLeft != pressingLeft) - Main.client.player.input.pressingLeft = pressingLeft; - if (pressingRight != null && Main.client.player.input.pressingRight != pressingRight) - Main.client.player.input.pressingRight = pressingRight; + if (Main.client.player != null) { + if (sprinting != null && Main.client.player.isSprinting() != sprinting) + Main.client.player.setSprinting(sprinting); + if (Main.client.player.getYaw() != yaw) + Main.client.player.setYaw(yaw); + if (Main.client.player.getHeadYaw() != head_yaw) + Main.client.player.setHeadYaw(head_yaw); + if (Main.client.player.getBodyYaw() != body_yaw) + Main.client.player.setBodyYaw(body_yaw); + if (Main.client.player.getPitch() != pitch) + Main.client.player.setPitch(pitch); + if (Main.client.player.getMovementSpeed() != speed) + Main.client.player.setMovementSpeed(speed); + if (sneaking != null && Main.client.player.input.sneaking != sneaking) + Main.client.player.input.sneaking = sneaking; + if (jumping != null && Main.client.player.input.jumping != jumping) + Main.client.player.input.jumping = jumping; + if (movementSideways != null && Main.client.player.input.movementSideways != movementSideways) + Main.client.player.input.movementSideways = movementSideways; + if (movementForward != null && Main.client.player.input.movementForward != movementForward) + Main.client.player.input.movementForward = movementForward; + if (pressingForward != null && Main.client.player.input.pressingForward != pressingForward) + Main.client.player.input.pressingForward = pressingForward; + if (pressingBack != null && Main.client.player.input.pressingBack != pressingBack) + Main.client.player.input.pressingBack = pressingBack; + if (pressingLeft != null && Main.client.player.input.pressingLeft != pressingLeft) + Main.client.player.input.pressingLeft = pressingLeft; + if (pressingRight != null && Main.client.player.input.pressingRight != pressingRight) + Main.client.player.input.pressingRight = pressingRight; + } } } diff --git a/src/main/java/themixray/repeating/mod/event/events/MoveEvent.java b/src/main/java/themixray/repeating/mod/event/events/MoveEvent.java index 9957dbf..c8b8bf1 100644 --- a/src/main/java/themixray/repeating/mod/event/events/MoveEvent.java +++ b/src/main/java/themixray/repeating/mod/event/events/MoveEvent.java @@ -26,11 +26,13 @@ public class MoveEvent extends RecordEvent { } public void replay() { - Vec3d p = Main.client.player.getPos(); - Vec3d v = new Vec3d(vec.getX() - p.getX(), vec.getY() - p.getY(), vec.getZ() - p.getZ()); - Main.client.player.move(MovementType.SELF, v); - Main.client.player.setYaw(yaw); - Main.client.player.setPitch(pitch); + if (Main.client.player != null) { + Vec3d p = Main.client.player.getPos(); + Vec3d v = new Vec3d(vec.getX() - p.getX(), vec.getY() - p.getY(), vec.getZ() - p.getZ()); + Main.client.player.move(MovementType.SELF, v); + Main.client.player.setYaw(yaw); + Main.client.player.setPitch(pitch); + } } protected String[] serializeArgs() { diff --git a/src/main/java/themixray/repeating/mod/mixin/PlayerMixin.java b/src/main/java/themixray/repeating/mod/mixin/PlayerMixin.java index 566b520..67735f9 100644 --- a/src/main/java/themixray/repeating/mod/mixin/PlayerMixin.java +++ b/src/main/java/themixray/repeating/mod/mixin/PlayerMixin.java @@ -18,6 +18,8 @@ import java.util.UUID; public abstract class PlayerMixin { @Inject(at = @At(value = "HEAD"), method = "disconnect") private void disconnect(Text disconnectReason, CallbackInfo ci) { - System.out.println("on client close"); + if (Main.me.is_replaying) { + Main.me.stopReplay(); + } } } diff --git a/src/main/java/themixray/repeating/mod/mixin/ScreenMixin.java b/src/main/java/themixray/repeating/mod/mixin/ScreenMixin.java index 1dd91e8..25b9504 100644 --- a/src/main/java/themixray/repeating/mod/mixin/ScreenMixin.java +++ b/src/main/java/themixray/repeating/mod/mixin/ScreenMixin.java @@ -12,53 +12,79 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import themixray.repeating.mod.Main; import themixray.repeating.mod.TickTask; +import themixray.repeating.mod.event.events.*; @Mixin(Screen.class) public abstract class ScreenMixin extends AbstractParentElement implements Drawable { @Inject(at = @At(value = "HEAD"), method = "close") private void close(CallbackInfo ci) { - System.out.println("on screen close"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiCloseEvent()); + } } @Inject(at = @At(value = "HEAD"), method = "keyPressed") private void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { - System.out.println("on screen keyPressed"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiKeyPressEvent(keyCode, scanCode, modifiers)); + } } @Override public boolean charTyped(char chr, int modifiers) { - System.out.println("on screen charTyped"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiCharTypeEvent(chr, modifiers)); + } return super.charTyped(chr, modifiers); } @Override public boolean keyReleased(int keyCode, int scanCode, int modifiers) { - System.out.println("on screen keyReleased"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiKeyReleaseEvent(keyCode, scanCode, modifiers)); + } return super.keyReleased(keyCode, scanCode, modifiers); } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - System.out.println("on screen mouseClicked"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiMouseClickEvent(mouseX, mouseY, button)); + } return super.mouseClicked(mouseX, mouseY, button); } + @Override + public void mouseMoved(double mouseX, double mouseY) { + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiMouseMoveEvent(mouseX, mouseY)); + } + super.mouseMoved(mouseX, mouseY); + } + @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - System.out.println("on screen mouseDragged"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiMouseDragEvent(mouseX, mouseY, button, deltaX, deltaY)); + } return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); } @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { - System.out.println("on screen mouseReleased"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiMouseReleaseEvent(mouseX, mouseY, button)); + } return super.mouseReleased(mouseX, mouseY, button); } @Override public boolean mouseScrolled(double mouseX, double mouseY, double amount) { - System.out.println("on screen mouseScrolled"); + if (Main.me.is_recording) { + Main.me.now_record.addEvent(new GuiMouseScrollEvent(mouseX, mouseY, amount)); + } return super.mouseScrolled(mouseX, mouseY, amount); } }