added move tp when repeating is wrong

This commit is contained in:
MeexReay 2023-05-30 22:58:25 +03:00
parent 887bcd2221
commit 96c4ce4b9d
6 changed files with 47 additions and 38 deletions

View File

@ -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.2 mod_version = 1.0.3
maven_group = themixray.repeating.mod maven_group = themixray.repeating.mod
archives_base_name = repeating-mod archives_base_name = repeating-mod

View File

@ -29,7 +29,14 @@ public class EasyConfig {
e.printStackTrace(); e.printStackTrace();
} }
} }
reload(); reload();
for (Map.Entry<String,Object> m:def.entrySet())
if (!data.containsKey(m.getKey()))
data.put(m.getKey(),m.getValue());
save();
} }
public EasyConfig(Path f, Map<String,Object> def) { public EasyConfig(Path f, Map<String,Object> def) {
this(f.toFile(),def); this(f.toFile(),def);

View File

@ -28,6 +28,7 @@ public class RepeatingMod implements ClientModInitializer {
public static final FabricLoader loader = FabricLoader.getInstance(); public static final FabricLoader loader = FabricLoader.getInstance();
public static RepeatingMod me; public static RepeatingMod me;
public Thread move_tick = null;
public List<RecordEvent> record = new ArrayList<>(); public List<RecordEvent> record = new ArrayList<>();
public boolean is_recording = false; public boolean is_recording = false;
public Date last_record = null; public Date last_record = null;
@ -42,8 +43,7 @@ public class RepeatingMod implements ClientModInitializer {
private static KeyBinding toggle_replay_key; private static KeyBinding toggle_replay_key;
private static KeyBinding toggle_record_key; private static KeyBinding toggle_record_key;
public double record_blocks_limit = 2; public long record_pos_delay = 1000;
public long record_time_limit = 50;
public EasyConfig conf; public EasyConfig conf;
@ -53,12 +53,11 @@ public class RepeatingMod implements ClientModInitializer {
me = this; me = this;
Map<String,Object> def = new HashMap<>(); Map<String,Object> def = new HashMap<>();
def.put("record_blocks_limit", record_blocks_limit); def.put("record_pos_delay", (int) record_pos_delay);
def.put("record_time_limit", record_time_limit);
conf = new EasyConfig(new File(loader.getConfigDir().toFile(),"repeating-mod.yml").toPath(),def);
record_blocks_limit = (double) conf.data.get("record_blocks_limit"); conf = new EasyConfig(loader.getConfigDir(),"repeating-mod.yml",def);
record_time_limit = (Integer) conf.data.get("record_time_limit");
record_pos_delay = (Integer) conf.data.get("record_pos_delay");
menu_key = KeyBindingHelper.registerKeyBinding(new KeyBinding( menu_key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.repeating-mod.menu",InputUtil.Type.KEYSYM, "key.repeating-mod.menu",InputUtil.Type.KEYSYM,
@ -108,7 +107,20 @@ 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()));
move_tick = new Thread(() -> {
while (is_recording) {
record.add(new RecordMoveEvent(client.player.getPos(),
client.player.getHeadYaw(),client.player.getPitch()));
try {
Thread.sleep(record_pos_delay);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
move_tick.start();
sendMessage(Text.translatable("message.repeating-mod.record_start")); sendMessage(Text.translatable("message.repeating-mod.record_start"));
} }
@ -200,6 +212,7 @@ public class RepeatingMod implements ClientModInitializer {
public void stopRecording() { public void stopRecording() {
is_recording = false; is_recording = false;
move_tick = null;
menu.update_btns(); menu.update_btns();
last_record = null; last_record = null;
sendMessage(Text.translatable("message.repeating-mod.record_stop")); sendMessage(Text.translatable("message.repeating-mod.record_stop"));
@ -228,6 +241,7 @@ public class RepeatingMod implements ClientModInitializer {
public void stopReplay() { public void stopReplay() {
is_recording = false; is_recording = false;
is_replaying = false; is_replaying = false;
replay = null;
menu.update_btns(); menu.update_btns();
sendMessage(Text.translatable("message.repeating-mod.replay_stop")); sendMessage(Text.translatable("message.repeating-mod.replay_stop"));
} }

View File

@ -155,7 +155,7 @@ public class RepeatingScreen extends BaseOwoScreen<FlowLayout> {
.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())
.child(Components.label(Text.translatable("text.repeating-mod.settings")).margins(Insets.of(1))) .child(Components.label(Text.translatable("text.repeating-mod.settings")).margins(Insets.of(1)))
@ -165,34 +165,24 @@ public class RepeatingScreen extends BaseOwoScreen<FlowLayout> {
.horizontalAlignment(HorizontalAlignment.CENTER) .horizontalAlignment(HorizontalAlignment.CENTER)
.margins(Insets.of(1))) .margins(Insets.of(1)))
.child(Containers.verticalFlow(Sizing.content(), Sizing.content()) .child(Containers.verticalFlow(Sizing.content(), Sizing.content())
.child(Components.discreteSlider(Sizing.fixed(120),0,5) .child(Components.discreteSlider(Sizing.fixed(120),-24,5000)
.decimalPlaces(2) .setFromDiscreteValue(mod.record_pos_delay)
.setFromDiscreteValue(mod.record_blocks_limit)
.message((String s)->{ .message((String s)->{
mod.record_blocks_limit = Double.parseDouble(s.replace(",",".")); mod.record_pos_delay = Long.parseLong(s);
mod.conf.data.put("record_blocks_limit",mod.record_blocks_limit); mod.conf.data.put("record_pos_delay",mod.record_pos_delay);
mod.conf.save(); mod.conf.save();
return Text.translatable("text.repeating-mod.block_limit",s); if (mod.record_pos_delay > -1)
}).scrollStep(0.2) return Text.translatable("text.repeating-mod.pos_delay", s);
return Text.translatable("text.repeating-mod.nan_pos_delay", s);
}).scrollStep(25)
.margins(Insets.of(1)) .margins(Insets.of(1))
.tooltip(Text.translatable("text.repeating-mod.block_limit_tooltip"))) .tooltip(Text.translatable("text.repeating-mod.pos_delay_text")))
.child(Components.discreteSlider(Sizing.fixed(120),0,1000)
.decimalPlaces(0)
.setFromDiscreteValue(mod.record_time_limit)
.message((String s)->{
mod.record_time_limit = (long) Double.parseDouble(s.replace(",","."));
mod.conf.data.put("record_time_limit",mod.record_time_limit);
mod.conf.save();
return Text.translatable("text.repeating-mod.time_limit",s);
}).scrollStep(2)
.margins(Insets.of(1))
.tooltip(Text.translatable("text.repeating-mod.time_limit_tooltip")))
.padding(Insets.of(10)) .padding(Insets.of(10))
.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();
} }
} }

View File

@ -14,10 +14,9 @@
"text.repeating-mod.parkour": "Parkour mode", "text.repeating-mod.parkour": "Parkour mode",
"text.repeating-mod.settings": "Settings", "text.repeating-mod.settings": "Settings",
"text.repeating-mod.dev": "In development...", "text.repeating-mod.dev": "In development...",
"text.repeating-mod.block_limit": "Block limit: %s", "text.repeating-mod.nan_pos_delay": "No pos delay",
"text.repeating-mod.block_limit_tooltip": "Two recording events will\nbe summed up if the\ndistance between them is\nless than the limit.", "text.repeating-mod.pos_delay": "Pos delay: %s ms",
"text.repeating-mod.time_limit": "Time limit: %s ms", "text.repeating-mod.pos_delay_text": "Delay after which the pos event is added",
"text.repeating-mod.time_limit_tooltip": "Two recording events will\nbe summed up if the time\nbetween them is less than\nthe limit.",
"message.repeating-mod.replay_start": "Replay started", "message.repeating-mod.replay_start": "Replay started",
"message.repeating-mod.replay_stop": "Replay finished", "message.repeating-mod.replay_stop": "Replay finished",

View File

@ -14,10 +14,9 @@
"text.repeating-mod.parkour": "Режим паркура", "text.repeating-mod.parkour": "Режим паркура",
"text.repeating-mod.settings": "Настройки", "text.repeating-mod.settings": "Настройки",
"text.repeating-mod.dev": "В разработке...", "text.repeating-mod.dev": "В разработке...",
"text.repeating-mod.block_limit": "Лимит блоков: %s", "text.repeating-mod.nan_pos_delay": "Задержки позиции нету",
"text.repeating-mod.block_limit_tooltip": "Два ивента записи будут\nсуммироваться, если\nрасстояние между ними\nменьше лимита.", "text.repeating-mod.pos_delay": "Задержка позиции: %s мс",
"text.repeating-mod.time_limit": "Лимит времени: %s мс", "text.repeating-mod.pos_delay_text": "Задержка, после которой добавляется ивент позиции",
"text.repeating-mod.time_limit_tooltip": "Два ивента записи будут\nсуммироваться, если время\nмежду ними меньше лимита.",
"message.repeating-mod.replay_start": "Повтор начат", "message.repeating-mod.replay_start": "Повтор начат",
"message.repeating-mod.replay_stop": "Повтор закончен", "message.repeating-mod.replay_stop": "Повтор закончен",