MOVEMENT move -> input
This commit is contained in:
parent
0f7bfff5d3
commit
68e7572139
@ -37,8 +37,7 @@ dependencies {
|
|||||||
// include this if you don't want force your users to install owo
|
// include this if you don't want force your users to install owo
|
||||||
// sentinel will warn them and give the option to download it automatically
|
// sentinel will warn them and give the option to download it automatically
|
||||||
include "io.wispforest:owo-sentinel:${project.owo_version}"
|
include "io.wispforest:owo-sentinel:${project.owo_version}"
|
||||||
|
modImplementation 'org.yaml:snakeyaml:2.0'
|
||||||
implementation 'org.yaml:snakeyaml:2.0'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base {
|
base {
|
||||||
|
@ -9,7 +9,7 @@ yarn_mappings=1.19.3+build.1
|
|||||||
loader_version=0.14.17
|
loader_version=0.14.17
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.0
|
mod_version = 1.0.1
|
||||||
maven_group = themixray.repeating.mod
|
maven_group = themixray.repeating.mod
|
||||||
archives_base_name = repeating-mod
|
archives_base_name = repeating-mod
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ public class EasyConfig {
|
|||||||
public Map<String,Object> data;
|
public Map<String,Object> data;
|
||||||
private Yaml yaml;
|
private Yaml yaml;
|
||||||
|
|
||||||
public EasyConfig(Path path, Map<String,Object> def) {
|
public EasyConfig(File f, Map<String,Object> def) {
|
||||||
this.path = path;
|
this.path = f.toPath();
|
||||||
this.file = path.toFile();
|
this.file = f;
|
||||||
this.data = new HashMap<>();
|
this.data = new HashMap<>();
|
||||||
this.yaml = new Yaml();
|
this.yaml = new Yaml();
|
||||||
|
|
||||||
@ -31,15 +31,38 @@ public class EasyConfig {
|
|||||||
}
|
}
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
public EasyConfig(Path f, Map<String,Object> def) {
|
||||||
|
this(f.toFile(),def);
|
||||||
|
}
|
||||||
|
public EasyConfig(String parent,String child,Map<String,Object> def) {
|
||||||
|
this(new File(parent,child),def);
|
||||||
|
}
|
||||||
|
public EasyConfig(File parent,String child,Map<String,Object> def) {
|
||||||
|
this(new File(parent,child),def);
|
||||||
|
}
|
||||||
|
public EasyConfig(Path parent,String child,Map<String,Object> def) {
|
||||||
|
this(new File(parent.toFile(),child),def);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EasyConfig(File f) {
|
||||||
|
this(f,new HashMap<>());
|
||||||
|
}
|
||||||
public EasyConfig(Path path) {
|
public EasyConfig(Path path) {
|
||||||
this(path,new HashMap<>());
|
this(path.toFile(),new HashMap<>());
|
||||||
|
}
|
||||||
|
public EasyConfig(String parent,String child) {
|
||||||
|
this(new File(parent,child),new HashMap<>());
|
||||||
|
}
|
||||||
|
public EasyConfig(File parent,String child) {
|
||||||
|
this(new File(parent,child),new HashMap<>());
|
||||||
|
}
|
||||||
|
public EasyConfig(Path parent,String child) {
|
||||||
|
this(new File(parent.toFile(),child),new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() {
|
public void reload() {
|
||||||
data = read();
|
data = read();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
write(data);
|
write(data);
|
||||||
}
|
}
|
||||||
@ -47,9 +70,8 @@ public class EasyConfig {
|
|||||||
private String toYaml(Map<String,Object> p) {
|
private String toYaml(Map<String,Object> p) {
|
||||||
return yaml.dump(p);
|
return yaml.dump(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String,Object> toMap(String j) {
|
private Map<String,Object> toMap(String j) {
|
||||||
return yaml.load(j);
|
return (Map<String, Object>) yaml.load(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String,Object> read() {
|
private Map<String,Object> read() {
|
||||||
@ -60,7 +82,6 @@ public class EasyConfig {
|
|||||||
}
|
}
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void write(Map<String,Object> p) {
|
private void write(Map<String,Object> p) {
|
||||||
try {
|
try {
|
||||||
Files.write(path, toYaml(p).getBytes());
|
Files.write(path, toYaml(p).getBytes());
|
||||||
|
@ -4,22 +4,13 @@ import com.google.common.collect.Lists;
|
|||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
|
|
||||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
|
||||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.option.KeyBinding;
|
import net.minecraft.client.option.KeyBinding;
|
||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import net.minecraft.entity.MovementType;
|
import net.minecraft.entity.MovementType;
|
||||||
import net.minecraft.registry.Registries;
|
|
||||||
import net.minecraft.registry.Registry;
|
|
||||||
import net.minecraft.resource.Resource;
|
|
||||||
import net.minecraft.resource.ResourceManager;
|
|
||||||
import net.minecraft.resource.ResourceType;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
@ -29,7 +20,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class RepeatingMod implements ClientModInitializer {
|
public class RepeatingMod implements ClientModInitializer {
|
||||||
@ -45,7 +35,7 @@ public class RepeatingMod implements ClientModInitializer {
|
|||||||
public Thread replay = null;
|
public Thread replay = null;
|
||||||
public boolean is_replaying = false;
|
public boolean is_replaying = false;
|
||||||
public boolean loop_replay = false;
|
public boolean loop_replay = false;
|
||||||
public static boolean replay_sneaking = false;
|
public static RecordInputEvent input_replay = null;
|
||||||
|
|
||||||
public static RepeatingScreen menu;
|
public static RepeatingScreen menu;
|
||||||
private static KeyBinding menu_key;
|
private static KeyBinding menu_key;
|
||||||
@ -118,6 +108,7 @@ public class RepeatingMod implements ClientModInitializer {
|
|||||||
is_recording = true;
|
is_recording = true;
|
||||||
menu.update_btns();
|
menu.update_btns();
|
||||||
record.clear();
|
record.clear();
|
||||||
|
record.add(new RecordMoveEvent(client.player.getPos(),client.player.getHeadYaw(),client.player.getPitch()));
|
||||||
sendMessage(Text.translatable("message.repeating-mod.record_start"));
|
sendMessage(Text.translatable("message.repeating-mod.record_start"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,12 +134,13 @@ public class RepeatingMod implements ClientModInitializer {
|
|||||||
is_recording = false;
|
is_recording = false;
|
||||||
is_replaying = true;
|
is_replaying = true;
|
||||||
menu.update_btns();
|
menu.update_btns();
|
||||||
client.player.setNoGravity(true);
|
|
||||||
replay = new Thread(() -> {
|
replay = new Thread(() -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
for (RecordEvent e : record)
|
for (RecordEvent e : record) {
|
||||||
if (is_replaying)
|
if (is_replaying) {
|
||||||
e.callback();
|
e.callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!loop_replay || !is_replaying) break;
|
if (!loop_replay || !is_replaying) break;
|
||||||
}
|
}
|
||||||
stopReplay();
|
stopReplay();
|
||||||
@ -161,7 +153,6 @@ public class RepeatingMod implements ClientModInitializer {
|
|||||||
is_recording = false;
|
is_recording = false;
|
||||||
is_replaying = false;
|
is_replaying = false;
|
||||||
menu.update_btns();
|
menu.update_btns();
|
||||||
client.player.setNoGravity(false);
|
|
||||||
sendMessage(Text.translatable("message.repeating-mod.replay_stop"));
|
sendMessage(Text.translatable("message.repeating-mod.replay_stop"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,9 +187,20 @@ public class RepeatingMod implements ClientModInitializer {
|
|||||||
Double.parseDouble(args[2])),
|
Double.parseDouble(args[2])),
|
||||||
Float.parseFloat(args[3]),
|
Float.parseFloat(args[3]),
|
||||||
Float.parseFloat(args[4]));
|
Float.parseFloat(args[4]));
|
||||||
} else if (type.equals("s")) {
|
} else if (type.equals("p")) {
|
||||||
return new RecordSneakEvent(
|
return new RecordInputEvent(
|
||||||
args[0].equals("1"));
|
(args[0].equals("n")?null:args[0].equals("1")),
|
||||||
|
(args[1].equals("n")?null:args[1].equals("1")),
|
||||||
|
(args[2].equals("n")?null:Float.parseFloat(args[2])),
|
||||||
|
(args[3].equals("n")?null:Float.parseFloat(args[3])),
|
||||||
|
(args[4].equals("n")?null:args[4].equals("1")),
|
||||||
|
(args[5].equals("n")?null:args[5].equals("1")),
|
||||||
|
(args[6].equals("n")?null:args[6].equals("1")),
|
||||||
|
(args[7].equals("n")?null:args[7].equals("1")),
|
||||||
|
Float.parseFloat(args[8]),Float.parseFloat(args[9]),
|
||||||
|
Float.parseFloat(args[10]),
|
||||||
|
(args[11].equals("n")?null:args[11].equals("1")),
|
||||||
|
Float.parseFloat(args[12]));
|
||||||
} else if (type.equals("b")) {
|
} else if (type.equals("b")) {
|
||||||
return new RecordBlockBreakEvent(new BlockPos(
|
return new RecordBlockBreakEvent(new BlockPos(
|
||||||
Integer.parseInt(args[0]),
|
Integer.parseInt(args[0]),
|
||||||
@ -275,22 +277,99 @@ public class RepeatingMod implements ClientModInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RecordSneakEvent extends RecordEvent {
|
public static class RecordInputEvent extends RecordEvent {
|
||||||
public boolean sneaking;
|
public Boolean sneaking;
|
||||||
|
public Boolean jumping;
|
||||||
|
public Boolean pressingForward;
|
||||||
|
public Boolean pressingBack;
|
||||||
|
public Boolean pressingLeft;
|
||||||
|
public Boolean pressingRight;
|
||||||
|
public Boolean sprinting;
|
||||||
|
|
||||||
public RecordSneakEvent(boolean sneaking) {
|
public Float movementSideways;
|
||||||
|
public Float movementForward;
|
||||||
|
|
||||||
|
public float yaw;
|
||||||
|
public float head_yaw;
|
||||||
|
public float body_yaw;
|
||||||
|
public float pitch;
|
||||||
|
|
||||||
|
|
||||||
|
public RecordInputEvent(Boolean sneaking,
|
||||||
|
Boolean jumping,
|
||||||
|
Float movementSideways,
|
||||||
|
Float movementForward,
|
||||||
|
Boolean pressingForward,
|
||||||
|
Boolean pressingBack,
|
||||||
|
Boolean pressingLeft,
|
||||||
|
Boolean pressingRight,
|
||||||
|
float head_yaw,
|
||||||
|
float body_yaw,
|
||||||
|
float head_pitch,
|
||||||
|
Boolean sprinting,
|
||||||
|
float yaw) {
|
||||||
this.sneaking = sneaking;
|
this.sneaking = sneaking;
|
||||||
|
this.jumping = jumping;
|
||||||
|
this.movementSideways = movementSideways;
|
||||||
|
this.movementForward = movementForward;
|
||||||
|
this.pressingForward = pressingForward;
|
||||||
|
this.pressingBack = pressingBack;
|
||||||
|
this.pressingLeft = pressingLeft;
|
||||||
|
this.pressingRight = pressingRight;
|
||||||
|
this.head_yaw = head_yaw;
|
||||||
|
this.body_yaw = body_yaw;
|
||||||
|
this.pitch = head_pitch;
|
||||||
|
this.sprinting = sprinting;
|
||||||
|
this.yaw = yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return sneaking == null &&
|
||||||
|
jumping == null &&
|
||||||
|
movementSideways == null &&
|
||||||
|
movementForward == null &&
|
||||||
|
pressingForward == null &&
|
||||||
|
pressingBack == null &&
|
||||||
|
pressingLeft == null &&
|
||||||
|
pressingRight == null &&
|
||||||
|
sprinting == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callback() {
|
public void callback() {
|
||||||
RepeatingMod.replay_sneaking = sneaking;
|
input_replay = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inputCallback() {
|
||||||
|
if (sneaking != null) if (client.player.input.sneaking != sneaking) client.player.input.sneaking = sneaking;
|
||||||
|
if (jumping != null) if (client.player.input.jumping != jumping) client.player.input.jumping = jumping;
|
||||||
|
if (movementSideways != null) if (client.player.input.movementSideways != movementSideways) client.player.input.movementSideways = movementSideways;
|
||||||
|
if (movementForward != null) if (client.player.input.movementForward != movementForward) client.player.input.movementForward = movementForward;
|
||||||
|
if (pressingForward != null) if (client.player.input.pressingForward != pressingForward) client.player.input.pressingForward = pressingForward;
|
||||||
|
if (pressingBack != null) if (client.player.input.pressingBack != pressingBack) client.player.input.pressingBack = pressingBack;
|
||||||
|
if (pressingLeft != null) if (client.player.input.pressingLeft != pressingLeft) client.player.input.pressingLeft = pressingLeft;
|
||||||
|
if (pressingRight != null) if (client.player.input.pressingRight != pressingRight) client.player.input.pressingRight = pressingRight;
|
||||||
|
if (sprinting != null) if (client.player.isSprinting() != sprinting) client.player.setSprinting(sprinting);
|
||||||
|
if (client.player.getYaw() != yaw) client.player.setYaw(yaw);
|
||||||
|
if (client.player.getHeadYaw() != head_yaw) client.player.setHeadYaw(head_yaw);
|
||||||
|
if (client.player.getBodyYaw() != body_yaw) client.player.setBodyYaw(body_yaw);
|
||||||
|
if (client.player.getPitch() != pitch) client.player.setPitch(pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toText() {
|
public String toText() {
|
||||||
return "s="+(sneaking?"1":"0");
|
return "p="+
|
||||||
|
((sneaking==null)?"n":(sneaking?"1":"0"))+"&"+
|
||||||
|
((jumping==null)?"n":(jumping?"1":"0"))+"&"+
|
||||||
|
((movementSideways==null)?"n":movementSideways)+"&"+
|
||||||
|
((movementForward==null)?"n":movementForward)+"&"+
|
||||||
|
((pressingForward==null)?"n":(pressingForward?"1":"0"))+"&"+
|
||||||
|
((pressingBack==null)?"n":(pressingBack?"1":"0"))+"&"+
|
||||||
|
((pressingLeft==null)?"n":(pressingLeft?"1":"0"))+"&"+
|
||||||
|
((pressingRight==null)?"n":(pressingRight?"1":"0"))+"&"+
|
||||||
|
head_yaw+"&"+body_yaw+"&"+ pitch +"&"+
|
||||||
|
((sprinting==null)?"n":(sprinting?"1":"0"));
|
||||||
}
|
}
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return "sneak";
|
return "input";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,26 +6,12 @@ import io.wispforest.owo.ui.container.*;
|
|||||||
import io.wispforest.owo.ui.container.FlowLayout;
|
import io.wispforest.owo.ui.container.FlowLayout;
|
||||||
import io.wispforest.owo.ui.core.*;
|
import io.wispforest.owo.ui.core.*;
|
||||||
import io.wispforest.owo.ui.core.Insets;
|
import io.wispforest.owo.ui.core.Insets;
|
||||||
import io.wispforest.owo.util.EventSource;
|
|
||||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.resource.ResourceManager;
|
|
||||||
import net.minecraft.resource.ResourceType;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.datatransfer.Clipboard;
|
|
||||||
import java.awt.datatransfer.DataFlavor;
|
|
||||||
import java.awt.datatransfer.StringSelection;
|
|
||||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.OpenOption;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class RepeatingScreen extends BaseOwoScreen<FlowLayout> {
|
public class RepeatingScreen extends BaseOwoScreen<FlowLayout> {
|
||||||
public RepeatingMod mod;
|
public RepeatingMod mod;
|
||||||
@ -49,7 +35,7 @@ public class RepeatingScreen extends BaseOwoScreen<FlowLayout> {
|
|||||||
record_btn.setMessage(Text.translatable("text.repeating-mod." +
|
record_btn.setMessage(Text.translatable("text.repeating-mod." +
|
||||||
((mod.is_recording) ? "stop" : "start")).append(" ")
|
((mod.is_recording) ? "stop" : "start")).append(" ")
|
||||||
.append(Text.translatable("text.repeating-mod.record")));
|
.append(Text.translatable("text.repeating-mod.record")));
|
||||||
loop_btn.setMessage(Text.of(((mod.loop_replay) ? "\uefff" : "\ueffe")));
|
loop_btn.setMessage(Text.of(((mod.loop_replay) ? "\uefff " : "\ueffe ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -167,7 +153,7 @@ public class RepeatingScreen extends BaseOwoScreen<FlowLayout> {
|
|||||||
.surface(Surface.DARK_PANEL)
|
.surface(Surface.DARK_PANEL)
|
||||||
.verticalAlignment(VerticalAlignment.CENTER)
|
.verticalAlignment(VerticalAlignment.CENTER)
|
||||||
.horizontalAlignment(HorizontalAlignment.CENTER)
|
.horizontalAlignment(HorizontalAlignment.CENTER)
|
||||||
.margins(Insets.of(1)))*/
|
.margins(Insets.of(1)))
|
||||||
).child(
|
).child(
|
||||||
Containers.verticalFlow(Sizing.content(), Sizing.content())
|
Containers.verticalFlow(Sizing.content(), Sizing.content())
|
||||||
.child(Containers.verticalFlow(Sizing.content(), Sizing.content())
|
.child(Containers.verticalFlow(Sizing.content(), Sizing.content())
|
||||||
@ -204,7 +190,7 @@ public class RepeatingScreen extends BaseOwoScreen<FlowLayout> {
|
|||||||
.surface(Surface.DARK_PANEL)
|
.surface(Surface.DARK_PANEL)
|
||||||
.verticalAlignment(VerticalAlignment.CENTER)
|
.verticalAlignment(VerticalAlignment.CENTER)
|
||||||
.horizontalAlignment(HorizontalAlignment.CENTER)
|
.horizontalAlignment(HorizontalAlignment.CENTER)
|
||||||
.margins(Insets.of(1)))
|
.margins(Insets.of(1)))*/
|
||||||
);
|
);
|
||||||
update_btns();
|
update_btns();
|
||||||
}
|
}
|
||||||
|
@ -12,19 +12,9 @@ public abstract class InputMixin {
|
|||||||
@Inject(at = @At(value = "TAIL"), method = "tick")
|
@Inject(at = @At(value = "TAIL"), method = "tick")
|
||||||
private void onTickTail(boolean slowDown, float f, CallbackInfo ci) {
|
private void onTickTail(boolean slowDown, float f, CallbackInfo ci) {
|
||||||
if (RepeatingMod.me.is_replaying) {
|
if (RepeatingMod.me.is_replaying) {
|
||||||
RepeatingMod.client.player.input.sneaking = RepeatingMod.replay_sneaking;
|
if (RepeatingMod.input_replay != null) {
|
||||||
}
|
RepeatingMod.input_replay.inputCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At(value = "HEAD"), method = "tick")
|
|
||||||
private void onTickHead(boolean slowDown, float f, CallbackInfo ci) {
|
|
||||||
if (RepeatingMod.me.is_recording) {
|
|
||||||
RepeatingMod.RecordSneakEvent e = new RepeatingMod.
|
|
||||||
RecordSneakEvent(RepeatingMod.client.player.input.sneaking);
|
|
||||||
RepeatingMod.RecordSneakEvent l = ((RepeatingMod.RecordSneakEvent)
|
|
||||||
RepeatingMod.me.getLastRecord("sneak"));
|
|
||||||
if (l == null || l.sneaking != e.sneaking)
|
|
||||||
RepeatingMod.me.recordTick(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,50 +43,58 @@ public abstract class MovementMixin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At(value = "HEAD"), method = "move")
|
@Inject(at = @At(value = "HEAD"), method = "tickMovement")
|
||||||
private void onMove(MovementType movementType, Vec3d vec, CallbackInfo ci) {
|
private void onMove(CallbackInfo ci) {
|
||||||
if (RepeatingMod.me.is_recording) {
|
if (RepeatingMod.me.is_recording) {
|
||||||
if (vec != lastVec) {
|
RepeatingMod.RecordInputEvent l = ((RepeatingMod.RecordInputEvent)RepeatingMod.me.getLastRecord("input"));
|
||||||
double dist = 0;
|
if (l == null) {
|
||||||
if (lastVec != null)
|
RepeatingMod.RecordInputEvent e = new RepeatingMod.RecordInputEvent(
|
||||||
dist = vec.distanceTo(lastVec);
|
RepeatingMod.client.player.input.sneaking,
|
||||||
if (dist > 0.0) {
|
RepeatingMod.client.player.input.jumping,
|
||||||
Vec3d c = client.player.getPos();
|
RepeatingMod.client.player.input.movementSideways,
|
||||||
|
RepeatingMod.client.player.input.movementForward,
|
||||||
|
RepeatingMod.client.player.input.pressingForward,
|
||||||
|
RepeatingMod.client.player.input.pressingBack,
|
||||||
|
RepeatingMod.client.player.input.pressingLeft,
|
||||||
|
RepeatingMod.client.player.input.pressingRight,
|
||||||
|
RepeatingMod.client.player.getHeadYaw(),
|
||||||
|
RepeatingMod.client.player.getBodyYaw(),
|
||||||
|
RepeatingMod.client.player.getPitch(),
|
||||||
|
RepeatingMod.client.player.isSprinting(),
|
||||||
|
RepeatingMod.client.player.getYaw());
|
||||||
|
RepeatingMod.me.recordTick(e);
|
||||||
|
} else {
|
||||||
|
RepeatingMod.RecordInputEvent e = new RepeatingMod.RecordInputEvent(
|
||||||
|
((Boolean) RepeatingMod.client.player.input.sneaking == l.sneaking) ? null : RepeatingMod.client.player.input.sneaking,
|
||||||
|
((Boolean) RepeatingMod.client.player.input.jumping == l.jumping) ? null : RepeatingMod.client.player.input.jumping,
|
||||||
|
(((Float) RepeatingMod.client.player.input.movementSideways).equals(l.movementSideways)) ? null : RepeatingMod.client.player.input.movementSideways,
|
||||||
|
(((Float) RepeatingMod.client.player.input.movementForward).equals(l.movementForward)) ? null : RepeatingMod.client.player.input.movementForward,
|
||||||
|
((Boolean) RepeatingMod.client.player.input.pressingForward == l.pressingForward) ? null : RepeatingMod.client.player.input.pressingForward,
|
||||||
|
((Boolean) RepeatingMod.client.player.input.pressingBack == l.pressingBack) ? null : RepeatingMod.client.player.input.pressingBack,
|
||||||
|
((Boolean) RepeatingMod.client.player.input.pressingLeft == l.pressingLeft) ? null : RepeatingMod.client.player.input.pressingLeft,
|
||||||
|
((Boolean) RepeatingMod.client.player.input.pressingRight == l.pressingRight) ? null : RepeatingMod.client.player.input.pressingRight,
|
||||||
|
RepeatingMod.client.player.getHeadYaw(),RepeatingMod.client.player.getBodyYaw(),RepeatingMod.client.player.getPitch(),
|
||||||
|
((Boolean) RepeatingMod.client.player.isSprinting() == l.sprinting) ? null : RepeatingMod.client.player.isSprinting(),
|
||||||
|
RepeatingMod.client.player.getYaw());
|
||||||
|
|
||||||
RepeatingMod.RecordMoveEvent ev = new RepeatingMod.RecordMoveEvent(
|
if (!(e.isEmpty() &&
|
||||||
new Vec3d(c.getX() + vec.getX(),
|
e.yaw == l.yaw &&
|
||||||
c.getY() + vec.getY(),
|
e.head_yaw == l.head_yaw &&
|
||||||
c.getZ() + vec.getZ()),
|
e.pitch == l.pitch &&
|
||||||
lastYaw, lastPitch);
|
e.body_yaw == l.body_yaw)) {
|
||||||
|
RepeatingMod.me.recordTick(e);
|
||||||
boolean just_add = true;
|
|
||||||
Date now = new Date();
|
|
||||||
if (RepeatingMod.me.last_record != null) {
|
|
||||||
long diff = now.getTime() - RepeatingMod.me.last_record.getTime();
|
|
||||||
boolean add_delay = true;
|
|
||||||
if (diff > 0) {
|
|
||||||
RepeatingMod.RecordEvent last_ev = RepeatingMod.me.record.get(RepeatingMod.me.record.size()-1);
|
|
||||||
if (last_ev instanceof RepeatingMod.RecordMoveEvent) {
|
|
||||||
RepeatingMod.RecordMoveEvent last_ev1 = (RepeatingMod.RecordMoveEvent) last_ev;
|
|
||||||
if (last_ev1.vec.distanceTo(ev.vec) < RepeatingMod.me.record_blocks_limit &&
|
|
||||||
diff < RepeatingMod.me.record_time_limit) {
|
|
||||||
just_add = false;
|
|
||||||
add_delay = false;
|
|
||||||
last_ev1.vec = ev.vec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (add_delay) {
|
|
||||||
RepeatingMod.me.record.add(new RepeatingMod.RecordDelayEvent(diff));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (just_add) {
|
|
||||||
RepeatingMod.me.record.add(ev);
|
|
||||||
RepeatingMod.me.last_record = now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastVec = vec;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At(value = "INVOKE"), method = "setSprinting", cancellable = true)
|
||||||
|
private void onSprint(boolean sprinting,CallbackInfo ci) {
|
||||||
|
if (RepeatingMod.me.is_replaying) {
|
||||||
|
if (RepeatingMod.input_replay != null &&
|
||||||
|
RepeatingMod.input_replay.sprinting != sprinting) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
"TheMixRay"
|
"TheMixRay"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://fabricmc.net/",
|
"homepage": "https://modrinth.com/mod/repeating-mod",
|
||||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
"sources": "https://github.com/MeexReay/repeating-mod"
|
||||||
},
|
},
|
||||||
|
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user