small refactoring
This commit is contained in:
parent
543f2a18cf
commit
f3acb4df10
@ -8,12 +8,10 @@ minecraft_version=1.20
|
||||
yarn_mappings=1.20+build.1
|
||||
loader_version=0.14.23
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.7
|
||||
maven_group = themixray.repeating.mod
|
||||
archives_base_name = repeating-mod
|
||||
|
||||
# Dependencies
|
||||
#Fabric api
|
||||
fabric_version=0.83.0+1.20
|
||||
|
||||
#owo_version=0.11.1+1.20
|
||||
# Mod Properties
|
||||
mod_version = 1.0.6
|
||||
maven_group = themixray.repeating.mod
|
||||
archives_base_name = repeating-mod
|
104
src/main/java/themixray/repeating/mod/RecordFile.java
Normal file
104
src/main/java/themixray/repeating/mod/RecordFile.java
Normal file
@ -0,0 +1,104 @@
|
||||
package themixray.repeating.mod;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import themixray.repeating.mod.events.RecordEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
public class RecordFile {
|
||||
private final File file;
|
||||
private String name;
|
||||
private String date;
|
||||
private String author;
|
||||
|
||||
private List<RecordEvent> events;
|
||||
private Vec3d start_record_pos;
|
||||
private Vec3d finish_record_pos;
|
||||
|
||||
public RecordFile(File file,
|
||||
String name,
|
||||
String date,
|
||||
String author,
|
||||
List<RecordEvent> events,
|
||||
Vec3d start_record_pos,
|
||||
Vec3d finish_record_pos) {
|
||||
this.file = file;
|
||||
this.name = name;
|
||||
this.date = date;
|
||||
this.author = author;
|
||||
|
||||
this.events = events;
|
||||
this.start_record_pos = start_record_pos;
|
||||
this.finish_record_pos = finish_record_pos;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void writeToMod() {
|
||||
|
||||
}
|
||||
|
||||
public void writeToFile(File file) {
|
||||
|
||||
}
|
||||
|
||||
public static void readFromMod() {
|
||||
|
||||
}
|
||||
|
||||
public static RecordFile readFromFile(File file) throws IOException {
|
||||
String text = Files.readString(file.toPath());
|
||||
|
||||
List<String> lines = List.of(text.split("\n"));
|
||||
String last_line = lines.get(lines.size()-1);
|
||||
lines = lines.subList(0,lines.size()-1);
|
||||
|
||||
List<RecordEvent>
|
||||
|
||||
for (String line: lines)
|
||||
RepeatingMod.me.record.add(RecordEvent.deserialize(line));
|
||||
|
||||
String[] lss0 = ls.split("x");
|
||||
String[] lss1 = lss0[0].split("n");
|
||||
String[] lss2 = lss0[1].split("n");
|
||||
RepeatingMod.me.start_record_pos = new Vec3d(
|
||||
Float.parseFloat(lss1[0]),
|
||||
Float.parseFloat(lss1[1]),
|
||||
Float.parseFloat(lss1[2]));
|
||||
RepeatingMod.me.finish_record_pos = new Vec3d(
|
||||
Float.parseFloat(lss2[0]),
|
||||
Float.parseFloat(lss2[1]),
|
||||
Float.parseFloat(lss2[2]));
|
||||
RepeatingMod.sendMessage(Text.literal(""));
|
||||
}
|
||||
}
|
5
src/main/java/themixray/repeating/mod/RecordList.java
Normal file
5
src/main/java/themixray/repeating/mod/RecordList.java
Normal file
@ -0,0 +1,5 @@
|
||||
package themixray.repeating.mod;
|
||||
|
||||
public class RecordList {
|
||||
|
||||
}
|
@ -4,32 +4,22 @@ import com.google.common.collect.Lists;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
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.rendering.v1.DimensionRenderingRegistry;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TextColor;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import themixray.repeating.mod.events.RecordDelayEvent;
|
||||
import themixray.repeating.mod.events.RecordEvent;
|
||||
import themixray.repeating.mod.events.RecordInputEvent;
|
||||
import themixray.repeating.mod.events.RecordMoveEvent;
|
||||
import themixray.repeating.mod.render.RenderHelper;
|
||||
import themixray.repeating.mod.render.RenderSystem;
|
||||
import themixray.repeating.mod.render.buffer.WorldBuffer;
|
||||
@ -256,41 +246,6 @@ public class RepeatingMod implements ClientModInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
public void recordCameraInput() {
|
||||
RecordInputEvent l = ((RecordInputEvent)getLastRecord("input"));
|
||||
if (l == null) {
|
||||
RecordInputEvent e = new RecordInputEvent(
|
||||
client.player.input.sneaking,
|
||||
client.player.input.jumping,
|
||||
client.player.input.movementSideways,
|
||||
client.player.input.movementForward,
|
||||
client.player.input.pressingForward,
|
||||
client.player.input.pressingBack,
|
||||
client.player.input.pressingLeft,
|
||||
client.player.input.pressingRight,
|
||||
client.player.getHeadYaw(),
|
||||
client.player.getBodyYaw(),
|
||||
client.player.getPitch(),
|
||||
client.player.isSprinting(),
|
||||
client.player.getYaw(),
|
||||
client.player.getMovementSpeed());
|
||||
recordTick(e);
|
||||
} else {
|
||||
RecordInputEvent e = new RecordInputEvent(null,null,null,
|
||||
null,null,null,null,null,
|
||||
client.player.getHeadYaw(),RepeatingMod.client.player.getBodyYaw(),client.player.getPitch(),
|
||||
null,client.player.getYaw(),client.player.getMovementSpeed());
|
||||
|
||||
if (!(e.yaw == l.yaw &&
|
||||
e.head_yaw == l.head_yaw &&
|
||||
e.pitch == l.pitch &&
|
||||
e.body_yaw == l.body_yaw)) {
|
||||
e.fillEmpty(l);
|
||||
recordTick(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopRecording() {
|
||||
is_recording = false;
|
||||
finish_record_pos = client.player.getPos();
|
||||
@ -318,7 +273,7 @@ public class RepeatingMod implements ClientModInitializer {
|
||||
if (e instanceof RecordDelayEvent) {
|
||||
setDelay(((RecordDelayEvent) e).delay);
|
||||
} else {
|
||||
e.callback();
|
||||
e.replay();
|
||||
}
|
||||
|
||||
replay_index++;
|
||||
@ -347,12 +302,6 @@ public class RepeatingMod implements ClientModInitializer {
|
||||
sendMessage(Text.translatable("message.repeating-mod.replay_stop"));
|
||||
}
|
||||
|
||||
public static double round(double value, int places) {
|
||||
if (places < 0) throw new IllegalArgumentException();
|
||||
long factor = (long) Math.pow(10, places);
|
||||
return (double) Math.round(value * factor) / factor;
|
||||
}
|
||||
|
||||
public static void sendMessage(MutableText text) {
|
||||
client.player.sendMessage(Text.literal("[")
|
||||
.append(Text.translatable("text.repeating-mod.name"))
|
||||
@ -363,302 +312,4 @@ public class RepeatingMod implements ClientModInitializer {
|
||||
public static void sendDebug(String s) {
|
||||
client.player.sendMessage(Text.literal("[DEBUG] ").append(Text.of(s)));
|
||||
}
|
||||
|
||||
public static abstract class RecordEvent {
|
||||
abstract void callback();
|
||||
abstract String toText();
|
||||
abstract String getType();
|
||||
|
||||
public static RecordEvent fromText(String t) {
|
||||
try {
|
||||
String type = String.valueOf(t.charAt(0));
|
||||
String[] args = t.substring(2).split("&");
|
||||
if (type.equals("d")) {
|
||||
return RecordDelayEvent.fromArgs(args);
|
||||
} else if (type.equals("m")) {
|
||||
return RecordMoveEvent.fromArgs(args);
|
||||
} else if (type.equals("p")) {
|
||||
return RecordInputEvent.fromArgs(args);
|
||||
} else if (type.equals("b")) {
|
||||
return RecordBlockBreakEvent.fromArgs(args);
|
||||
} else if (type.equals("i")) {
|
||||
return RecordBlockInteractEvent.fromArgs(args);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecordDelayEvent extends RecordEvent {
|
||||
public long delay;
|
||||
|
||||
public static RecordDelayEvent fromArgs(String[] a) {
|
||||
return new RecordDelayEvent(Long.parseLong(a[0]));
|
||||
}
|
||||
|
||||
public RecordDelayEvent(long delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public void callback() {
|
||||
try {
|
||||
Thread.sleep(delay/20*1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String toText() {
|
||||
return "d="+delay;
|
||||
}
|
||||
public String getType() {
|
||||
return "delay";
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecordMoveEvent extends RecordEvent {
|
||||
public Vec3d vec;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
|
||||
public static RecordMoveEvent fromArgs(String[] a) {
|
||||
return new RecordMoveEvent(new Vec3d(
|
||||
Double.parseDouble(a[0]),
|
||||
Double.parseDouble(a[1]),
|
||||
Double.parseDouble(a[2])),
|
||||
Float.parseFloat(a[3]),
|
||||
Float.parseFloat(a[4]));
|
||||
}
|
||||
|
||||
public RecordMoveEvent(Vec3d vec,float yaw,float pitch) {
|
||||
this.vec = vec;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public void callback() {
|
||||
Vec3d p = client.player.getPos();
|
||||
Vec3d v = new Vec3d(vec.getX()-p.getX(),vec.getY()-p.getY(),vec.getZ()-p.getZ());
|
||||
client.player.move(MovementType.SELF,v);
|
||||
client.player.setYaw(yaw);
|
||||
client.player.setPitch(pitch);
|
||||
}
|
||||
|
||||
public String toText() {
|
||||
return "m="+vec.getX()+"&"+vec.getY()+"&"+vec.getZ()+"&"+yaw+"&"+pitch;
|
||||
}
|
||||
public String getType() {
|
||||
return "move";
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecordInputEvent extends RecordEvent {
|
||||
public Boolean sneaking;
|
||||
public Boolean jumping;
|
||||
public Boolean pressingForward;
|
||||
public Boolean pressingBack;
|
||||
public Boolean pressingLeft;
|
||||
public Boolean pressingRight;
|
||||
public Boolean sprinting;
|
||||
|
||||
public Float movementSideways;
|
||||
public Float movementForward;
|
||||
|
||||
public float yaw;
|
||||
public float head_yaw;
|
||||
public float body_yaw;
|
||||
public float pitch;
|
||||
public float speed;
|
||||
|
||||
public static RecordInputEvent fromArgs(String[] a) {
|
||||
return new RecordInputEvent(
|
||||
(a[0].equals("n")?null:a[0].equals("1")),
|
||||
(a[1].equals("n")?null:a[1].equals("1")),
|
||||
(a[2].equals("n")?null:Float.parseFloat(a[2])),
|
||||
(a[3].equals("n")?null:Float.parseFloat(a[3])),
|
||||
(a[4].equals("n")?null:a[4].equals("1")),
|
||||
(a[5].equals("n")?null:a[5].equals("1")),
|
||||
(a[6].equals("n")?null:a[6].equals("1")),
|
||||
(a[7].equals("n")?null:a[7].equals("1")),
|
||||
Float.parseFloat(a[8]),Float.parseFloat(a[9]),
|
||||
Float.parseFloat(a[10]),
|
||||
(a[11].equals("n")?null:a[11].equals("1")),
|
||||
Float.parseFloat(a[12]),
|
||||
Float.parseFloat(a[13]));
|
||||
}
|
||||
|
||||
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,
|
||||
float speed) {
|
||||
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;
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public void fillEmpty(RecordInputEvent e) {
|
||||
if (sneaking == null) sneaking = e.sneaking;
|
||||
if (jumping == null) jumping = e.jumping;
|
||||
if (movementSideways == null) movementSideways = e.movementSideways;
|
||||
if (movementForward == null) movementForward = e.movementForward;
|
||||
if (pressingForward == null) pressingForward = e.pressingForward;
|
||||
if (pressingBack == null) pressingBack = e.pressingBack;
|
||||
if (pressingLeft == null) pressingLeft = e.pressingLeft;
|
||||
if (pressingRight == null) pressingRight = e.pressingRight;
|
||||
if (sprinting == null) sprinting = e.sprinting;
|
||||
}
|
||||
|
||||
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() {
|
||||
input_replay = this;
|
||||
}
|
||||
|
||||
public void inputCallback() {
|
||||
if (sprinting != null && 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);
|
||||
if (client.player.getMovementSpeed() != speed)
|
||||
client.player.setMovementSpeed(speed);
|
||||
if (sneaking != null && client.player.input.sneaking != sneaking)
|
||||
client.player.input.sneaking = sneaking;
|
||||
if (jumping != null && client.player.input.jumping != jumping)
|
||||
client.player.input.jumping = jumping;
|
||||
if (movementSideways != null && client.player.input.movementSideways != movementSideways)
|
||||
client.player.input.movementSideways = movementSideways;
|
||||
if (movementForward != null && client.player.input.movementForward != movementForward)
|
||||
client.player.input.movementForward = movementForward;
|
||||
if (pressingForward != null && client.player.input.pressingForward != pressingForward)
|
||||
client.player.input.pressingForward = pressingForward;
|
||||
if (pressingBack != null && client.player.input.pressingBack != pressingBack)
|
||||
client.player.input.pressingBack = pressingBack;
|
||||
if (pressingLeft != null && client.player.input.pressingLeft != pressingLeft)
|
||||
client.player.input.pressingLeft = pressingLeft;
|
||||
if (pressingRight != null && client.player.input.pressingRight != pressingRight)
|
||||
client.player.input.pressingRight = pressingRight;
|
||||
}
|
||||
|
||||
public String toText() {
|
||||
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")+
|
||||
"&"+yaw+"&"+speed);
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "input";
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecordBlockBreakEvent extends RecordEvent {
|
||||
public BlockPos pos;
|
||||
|
||||
public static RecordBlockBreakEvent fromArgs(String[] a) {
|
||||
return new RecordBlockBreakEvent(new BlockPos(
|
||||
Integer.parseInt(a[0]),
|
||||
Integer.parseInt(a[1]),
|
||||
Integer.parseInt(a[2])));
|
||||
}
|
||||
|
||||
public RecordBlockBreakEvent(
|
||||
BlockPos pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public void callback() {
|
||||
client.interactionManager.breakBlock(pos);
|
||||
}
|
||||
|
||||
public String toText() {
|
||||
return "b="+pos.getX()+"&"+pos.getY()+"&"+pos.getZ();
|
||||
}
|
||||
public String getType() {
|
||||
return "block_break";
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecordBlockInteractEvent extends RecordEvent {
|
||||
public Hand hand;
|
||||
public BlockHitResult hitResult;
|
||||
|
||||
public static RecordBlockInteractEvent fromArgs(String[] a) {
|
||||
return new RecordBlockInteractEvent(
|
||||
Hand.valueOf(a[5]),
|
||||
new BlockHitResult(new Vec3d(
|
||||
Double.parseDouble(a[0]),
|
||||
Double.parseDouble(a[1]),
|
||||
Double.parseDouble(a[2])),
|
||||
Direction.byId(Integer.parseInt(a[4])),
|
||||
new BlockPos(
|
||||
Integer.parseInt(a[0]),
|
||||
Integer.parseInt(a[1]),
|
||||
Integer.parseInt(a[2])),
|
||||
a[3].equals("1")));
|
||||
}
|
||||
|
||||
public RecordBlockInteractEvent(Hand hand, BlockHitResult hitResult) {
|
||||
this.hand = hand;
|
||||
this.hitResult = hitResult;
|
||||
}
|
||||
|
||||
public void callback() {
|
||||
client.interactionManager.interactBlock(client.player,hand,hitResult);
|
||||
}
|
||||
|
||||
public String toText() {
|
||||
return "i="+hitResult.getBlockPos().getX()+"&"+hitResult.getBlockPos().getY()+"&"+hitResult.getBlockPos().getZ()+
|
||||
"&"+(hitResult.isInsideBlock()?"1":"0")+"&"+hitResult.getSide().getId()+"&"+hand.name();
|
||||
}
|
||||
public String getType() {
|
||||
return "block_interact";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,16 +7,16 @@ import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.OptionSliderWidget;
|
||||
import net.minecraft.client.gui.widget.SliderWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import themixray.repeating.mod.events.RecordEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -52,11 +52,7 @@ public class RepeatingScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
renderBackgroundTexture(context);
|
||||
// context.drawCenteredTextWithShadow(textRenderer,
|
||||
// Text.literal("You must see me"),
|
||||
// width / 2, height / 2,
|
||||
// Color.white.getRGB());
|
||||
renderBackground(context);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@ -101,7 +97,7 @@ public class RepeatingScreen extends Screen {
|
||||
if (mod.finish_record_pos == null) return;
|
||||
StringBuilder t = new StringBuilder();
|
||||
for (int i = 0; i < mod.record.size(); i++) {
|
||||
t.append(mod.record.get(i).toText());
|
||||
t.append(mod.record.get(i).serialize());
|
||||
t.append("\n");
|
||||
}
|
||||
t.append(mod.start_record_pos.getX()+"n"+
|
||||
@ -134,33 +130,43 @@ public class RepeatingScreen extends Screen {
|
||||
|
||||
File p = new File(FabricLoader.getInstance().getGameDir().toFile(),"repeating");
|
||||
if (!p.exists()) p.mkdir();
|
||||
File file = new File(p,"import.txt");
|
||||
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
Runtime.getRuntime().exec("explorer /select,\""+file.getAbsolutePath()+"\"");
|
||||
return;
|
||||
JFileChooser fc = new JFileChooser() {
|
||||
@Override
|
||||
protected JDialog createDialog(Component parent) throws HeadlessException {
|
||||
JDialog dialog = super.createDialog(parent);
|
||||
dialog.setLocationByPlatform(true);
|
||||
dialog.setAlwaysOnTop(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int retValue = fc.showOpenDialog(null);
|
||||
if (retValue == JFileChooser.APPROVE_OPTION){
|
||||
File file = fc.getSelectedFile();
|
||||
try {
|
||||
String t = Files.readString(file.toPath());
|
||||
List<String> ss = List.of(t.split("\n"));
|
||||
String ls = ss.get(ss.size()-1);
|
||||
ss = ss.subList(0,ss.size()-1);
|
||||
for (String s:ss)
|
||||
mod.record.add(RecordEvent.deserialize(s));
|
||||
String[] lss0 = ls.split("x");
|
||||
String[] lss1 = lss0[0].split("n");
|
||||
String[] lss2 = lss0[1].split("n");
|
||||
mod.start_record_pos = new Vec3d(
|
||||
Float.parseFloat(lss1[0]),
|
||||
Float.parseFloat(lss1[1]),
|
||||
Float.parseFloat(lss1[2]));
|
||||
mod.finish_record_pos = new Vec3d(
|
||||
Float.parseFloat(lss2[0]),
|
||||
Float.parseFloat(lss2[1]),
|
||||
Float.parseFloat(lss2[2]));
|
||||
RepeatingMod.sendMessage(Text.literal(""));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String t = Files.readString(file.toPath());
|
||||
List<String> ss = List.of(t.split("\n"));
|
||||
String ls = ss.get(ss.size()-1);
|
||||
ss = ss.subList(0,ss.size()-1);
|
||||
for (String s:ss)
|
||||
mod.record.add(RepeatingMod.RecordEvent.fromText(s));
|
||||
String[] lss0 = ls.split("x");
|
||||
String[] lss1 = lss0[0].split("n");
|
||||
String[] lss2 = lss0[1].split("n");
|
||||
mod.start_record_pos = new Vec3d(
|
||||
Float.parseFloat(lss1[0]),
|
||||
Float.parseFloat(lss1[1]),
|
||||
Float.parseFloat(lss1[2]));
|
||||
mod.finish_record_pos = new Vec3d(
|
||||
Float.parseFloat(lss2[0]),
|
||||
Float.parseFloat(lss2[1]),
|
||||
Float.parseFloat(lss2[2]));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
})
|
||||
.dimensions(width / 2 - 60, height / 2 + 12, 120, 20)
|
||||
@ -171,21 +177,21 @@ public class RepeatingScreen extends Screen {
|
||||
width / 2 - 60, height / 2 + 34, 120, 20,
|
||||
(mod.record_pos_delay < 0) ? Text.translatable("text.repeating-mod.nan_pos_delay") :
|
||||
Text.translatable("text.repeating-mod.pos_delay", String.valueOf(mod.record_pos_delay)),
|
||||
(mod.record_pos_delay/10d+1d)/101d) {
|
||||
(mod.record_pos_delay+1d)/101d) {
|
||||
|
||||
@Override
|
||||
protected void updateMessage() {
|
||||
double v = value*101d-1d;
|
||||
if (v <= 1) setMessage(Text.translatable("text.repeating-mod.nan_pos_delay"));
|
||||
else setMessage(Text.translatable("text.repeating-mod.pos_delay", String.valueOf((long) (v*10))));
|
||||
else setMessage(Text.translatable("text.repeating-mod.pos_delay", String.valueOf((long) v)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyValue() {
|
||||
double v = value*101d-1d;
|
||||
if (v <= 1) setMessage(Text.translatable("text.repeating-mod.nan_pos_delay"));
|
||||
else setMessage(Text.translatable("text.repeating-mod.pos_delay", String.valueOf((long) (v*10))));
|
||||
mod.record_pos_delay = (long) (v*10);
|
||||
else setMessage(Text.translatable("text.repeating-mod.pos_delay", String.valueOf((long) v)));
|
||||
mod.record_pos_delay = (long) v;
|
||||
mod.conf.data.put("record_pos_delay",String.valueOf(mod.record_pos_delay));
|
||||
mod.conf.save();
|
||||
}
|
||||
@ -220,152 +226,5 @@ public class RepeatingScreen extends Screen {
|
||||
addDrawableChild(export_btn);
|
||||
addDrawableChild(import_btn);
|
||||
addDrawableChild(pos_delay_slider);
|
||||
|
||||
|
||||
// rootComponent
|
||||
// .surface(Surface.VANILLA_TRANSLUCENT)
|
||||
// .horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
// .verticalAlignment(VerticalAlignment.CENTER);
|
||||
//
|
||||
// replay_btn = (ButtonComponent) Components.button(Text.of("replay"),
|
||||
// (ButtonComponent btn) -> {
|
||||
// if (!mod.is_recording) {
|
||||
// if (mod.is_replaying)
|
||||
// mod.stopReplay();
|
||||
// else mod.startReplay();
|
||||
// update_btns();
|
||||
// }
|
||||
// }).margins(Insets.of(1)).sizing(
|
||||
// Sizing.fixed(98),Sizing.fixed(20));
|
||||
//
|
||||
// loop_btn = (ButtonComponent) Components.button(Text.of(""),
|
||||
// (ButtonComponent btn) -> {
|
||||
// mod.loop_replay = !mod.loop_replay;
|
||||
// update_btns();
|
||||
// }).margins(Insets.of(1))
|
||||
// .sizing(Sizing.fixed(20),Sizing.fixed(20));
|
||||
//
|
||||
// record_btn = (ButtonComponent) Components.button(Text.of("record"),
|
||||
// (ButtonComponent btn) -> {
|
||||
// if (!mod.is_replaying) {
|
||||
// if (mod.is_recording)
|
||||
// mod.stopRecording();
|
||||
// else mod.startRecording();
|
||||
// update_btns();
|
||||
// }
|
||||
// }).margins(Insets.of(1)).sizing(
|
||||
// Sizing.fixed(120),Sizing.fixed(20));
|
||||
// was_build = true;
|
||||
//
|
||||
// rootComponent.child(
|
||||
// Containers.horizontalFlow(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.basic")).margins(Insets.of(1)))
|
||||
// .padding(Insets.of(5))
|
||||
// .surface(Surface.DARK_PANEL)
|
||||
// .verticalAlignment(VerticalAlignment.CENTER)
|
||||
// .horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
// .margins(Insets.of(1)))
|
||||
// .child(Containers.verticalFlow(Sizing.content(), Sizing.content())
|
||||
// .child(Containers.horizontalFlow(Sizing.content(), Sizing.content())
|
||||
// .child(replay_btn).child(loop_btn))
|
||||
// .child(record_btn)
|
||||
// .child(Components.button(Text.translatable(
|
||||
// "text.repeating-mod.export"),
|
||||
// (ButtonComponent btn) -> {
|
||||
// String t = "";
|
||||
// for (int i = 0; i < mod.record.size(); i++) {
|
||||
// t += mod.record.get(i).toText();
|
||||
// if (i != mod.record.size()-1)
|
||||
// t += "\n";
|
||||
// }
|
||||
//
|
||||
// File p = new File(FabricLoader.getInstance().getGameDir().toFile(),"repeating");
|
||||
// if (!p.exists()) p.mkdir();
|
||||
// File file = new File(p,"export.txt");
|
||||
//
|
||||
// try {
|
||||
// if (!file.exists()) file.createNewFile();
|
||||
// Files.write(file.toPath(), t.getBytes());
|
||||
// Runtime.getRuntime().exec("explorer /select,\""+file.getAbsolutePath()+"\"");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }).margins(Insets.of(10,1,1,1)).sizing(
|
||||
// Sizing.fixed(120),Sizing.fixed(20)))
|
||||
// .child(Components.button(Text.translatable(
|
||||
// "text.repeating-mod.import"),
|
||||
// (ButtonComponent btn) -> {
|
||||
// mod.record.clear();
|
||||
//
|
||||
// File p = new File(FabricLoader.getInstance().getGameDir().toFile(),"repeating");
|
||||
// if (!p.exists()) p.mkdir();
|
||||
// File file = new File(p,"import.txt");
|
||||
//
|
||||
// try {
|
||||
// if (!file.exists()) {
|
||||
// file.createNewFile();
|
||||
// Runtime.getRuntime().exec("explorer /select,\""+file.getAbsolutePath()+"\"");
|
||||
// return;
|
||||
// }
|
||||
// String t = Files.readString(file.toPath());
|
||||
// for (String s:t.split("\n"))
|
||||
// mod.record.add(RepeatingMod.RecordEvent.fromText(s));
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }).margins(Insets.of(1)).sizing(
|
||||
// Sizing.fixed(120),Sizing.fixed(20)))
|
||||
// .padding(Insets.of(10))
|
||||
// .surface(Surface.DARK_PANEL)
|
||||
// .verticalAlignment(VerticalAlignment.CENTER)
|
||||
// .horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
// .margins(Insets.of(1)))
|
||||
// /*).child(
|
||||
// Containers.verticalFlow(Sizing.content(), Sizing.content())
|
||||
// .child(Containers.verticalFlow(Sizing.content(), Sizing.content())
|
||||
// .child(Components.label(Text.translatable("text.repeating-mod.parkour")).margins(Insets.of(1)))
|
||||
// .padding(Insets.of(5))
|
||||
// .surface(Surface.DARK_PANEL)
|
||||
// .verticalAlignment(VerticalAlignment.CENTER)
|
||||
// .horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
// .margins(Insets.of(1)))
|
||||
// .child(Containers.verticalFlow(Sizing.content(), Sizing.content())
|
||||
// .child(Components.label(Text.translatable("text.repeating-mod.dev")).margins(Insets.of(1)))
|
||||
// .padding(Insets.of(10))
|
||||
// .surface(Surface.DARK_PANEL)
|
||||
// .verticalAlignment(VerticalAlignment.CENTER)
|
||||
// .horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
// .margins(Insets.of(1)))*/
|
||||
// ).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)))
|
||||
// .padding(Insets.of(5))
|
||||
// .surface(Surface.DARK_PANEL)
|
||||
// .verticalAlignment(VerticalAlignment.CENTER)
|
||||
// .horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
// .margins(Insets.of(1)))
|
||||
// .child(Containers.verticalFlow(Sizing.content(), Sizing.content())
|
||||
// .child(Components.discreteSlider(Sizing.fixed(120),-20,100)
|
||||
// .setFromDiscreteValue(mod.record_pos_delay)
|
||||
// .message((String s)->{
|
||||
// mod.record_pos_delay = Long.parseLong(s);
|
||||
// mod.conf.data.put("record_pos_delay",String.valueOf(mod.record_pos_delay));
|
||||
// mod.conf.save();
|
||||
// if (mod.record_pos_delay > -1)
|
||||
// return Text.translatable("text.repeating-mod.pos_delay", s);
|
||||
// return Text.translatable("text.repeating-mod.nan_pos_delay");
|
||||
// }).scrollStep(25)
|
||||
// .margins(Insets.of(1))
|
||||
// .tooltip(Text.translatable("text.repeating-mod.pos_delay_text")))
|
||||
// .padding(Insets.of(10))
|
||||
// .surface(Surface.DARK_PANEL)
|
||||
// .verticalAlignment(VerticalAlignment.CENTER)
|
||||
// .horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
// .margins(Insets.of(1)))
|
||||
// ));
|
||||
update_btns();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package themixray.repeating.mod.events;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import themixray.repeating.mod.RepeatingMod;
|
||||
|
||||
public class RecordBlockBreakEvent extends RecordEvent {
|
||||
public BlockPos pos;
|
||||
|
||||
public static RecordBlockBreakEvent fromArgs(String[] a) {
|
||||
return new RecordBlockBreakEvent(new BlockPos(
|
||||
Integer.parseInt(a[0]),
|
||||
Integer.parseInt(a[1]),
|
||||
Integer.parseInt(a[2])));
|
||||
}
|
||||
|
||||
public RecordBlockBreakEvent(
|
||||
BlockPos pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public void replay() {
|
||||
RepeatingMod.client.interactionManager.breakBlock(pos);
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
return "b=" + pos.getX() + "&" + pos.getY() + "&" + pos.getZ();
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "block_break";
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package themixray.repeating.mod.events;
|
||||
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import themixray.repeating.mod.RepeatingMod;
|
||||
|
||||
public class RecordBlockInteractEvent extends RecordEvent {
|
||||
public Hand hand;
|
||||
public BlockHitResult hitResult;
|
||||
|
||||
public static RecordBlockInteractEvent fromArgs(String[] a) {
|
||||
return new RecordBlockInteractEvent(
|
||||
Hand.valueOf(a[5]),
|
||||
new BlockHitResult(new Vec3d(
|
||||
Double.parseDouble(a[0]),
|
||||
Double.parseDouble(a[1]),
|
||||
Double.parseDouble(a[2])),
|
||||
Direction.byId(Integer.parseInt(a[4])),
|
||||
new BlockPos(
|
||||
Integer.parseInt(a[0]),
|
||||
Integer.parseInt(a[1]),
|
||||
Integer.parseInt(a[2])),
|
||||
a[3].equals("1")));
|
||||
}
|
||||
|
||||
public RecordBlockInteractEvent(Hand hand, BlockHitResult hitResult) {
|
||||
this.hand = hand;
|
||||
this.hitResult = hitResult;
|
||||
}
|
||||
|
||||
public void replay() {
|
||||
RepeatingMod.client.interactionManager.interactBlock(RepeatingMod.client.player, hand, hitResult);
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
return "i=" + hitResult.getBlockPos().getX() + "&" + hitResult.getBlockPos().getY() + "&" + hitResult.getBlockPos().getZ() +
|
||||
"&" + (hitResult.isInsideBlock() ? "1" : "0") + "&" + hitResult.getSide().getId() + "&" + hand.name();
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "block_interact";
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package themixray.repeating.mod.events;
|
||||
|
||||
public class RecordDelayEvent extends RecordEvent {
|
||||
public long delay;
|
||||
|
||||
public static RecordDelayEvent fromArgs(String[] a) {
|
||||
return new RecordDelayEvent(Long.parseLong(a[0]));
|
||||
}
|
||||
|
||||
public RecordDelayEvent(long delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public void replay() {
|
||||
try {
|
||||
Thread.sleep(delay / 20 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
return "d=" + delay;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "delay";
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package themixray.repeating.mod.events;
|
||||
|
||||
public abstract class RecordEvent {
|
||||
public abstract void replay();
|
||||
public abstract String serialize();
|
||||
public abstract String getType();
|
||||
|
||||
public static RecordEvent deserialize(String t) {
|
||||
try {
|
||||
String type = String.valueOf(t.charAt(0));
|
||||
String[] args = t.substring(2).split("&");
|
||||
if (type.equals("d")) {
|
||||
return RecordDelayEvent.fromArgs(args);
|
||||
} else if (type.equals("m")) {
|
||||
return RecordMoveEvent.fromArgs(args);
|
||||
} else if (type.equals("p")) {
|
||||
return RecordInputEvent.fromArgs(args);
|
||||
} else if (type.equals("b")) {
|
||||
return RecordBlockBreakEvent.fromArgs(args);
|
||||
} else if (type.equals("i")) {
|
||||
return RecordBlockInteractEvent.fromArgs(args);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package themixray.repeating.mod.events;
|
||||
|
||||
import themixray.repeating.mod.RepeatingMod;
|
||||
|
||||
public class RecordInputEvent extends RecordEvent {
|
||||
public Boolean sneaking;
|
||||
public Boolean jumping;
|
||||
public Boolean pressingForward;
|
||||
public Boolean pressingBack;
|
||||
public Boolean pressingLeft;
|
||||
public Boolean pressingRight;
|
||||
public Boolean sprinting;
|
||||
|
||||
public Float movementSideways;
|
||||
public Float movementForward;
|
||||
|
||||
public float yaw;
|
||||
public float head_yaw;
|
||||
public float body_yaw;
|
||||
public float pitch;
|
||||
public float speed;
|
||||
|
||||
public static RecordInputEvent fromArgs(String[] a) {
|
||||
return new RecordInputEvent(
|
||||
(a[0].equals("n") ? null : a[0].equals("1")),
|
||||
(a[1].equals("n") ? null : a[1].equals("1")),
|
||||
(a[2].equals("n") ? null : Float.parseFloat(a[2])),
|
||||
(a[3].equals("n") ? null : Float.parseFloat(a[3])),
|
||||
(a[4].equals("n") ? null : a[4].equals("1")),
|
||||
(a[5].equals("n") ? null : a[5].equals("1")),
|
||||
(a[6].equals("n") ? null : a[6].equals("1")),
|
||||
(a[7].equals("n") ? null : a[7].equals("1")),
|
||||
Float.parseFloat(a[8]), Float.parseFloat(a[9]),
|
||||
Float.parseFloat(a[10]),
|
||||
(a[11].equals("n") ? null : a[11].equals("1")),
|
||||
Float.parseFloat(a[12]),
|
||||
Float.parseFloat(a[13]));
|
||||
}
|
||||
|
||||
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,
|
||||
float speed) {
|
||||
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;
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public void fillEmpty(RecordInputEvent e) {
|
||||
if (sneaking == null) sneaking = e.sneaking;
|
||||
if (jumping == null) jumping = e.jumping;
|
||||
if (movementSideways == null) movementSideways = e.movementSideways;
|
||||
if (movementForward == null) movementForward = e.movementForward;
|
||||
if (pressingForward == null) pressingForward = e.pressingForward;
|
||||
if (pressingBack == null) pressingBack = e.pressingBack;
|
||||
if (pressingLeft == null) pressingLeft = e.pressingLeft;
|
||||
if (pressingRight == null) pressingRight = e.pressingRight;
|
||||
if (sprinting == null) sprinting = e.sprinting;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return sneaking == null &&
|
||||
jumping == null &&
|
||||
movementSideways == null &&
|
||||
movementForward == null &&
|
||||
pressingForward == null &&
|
||||
pressingBack == null &&
|
||||
pressingLeft == null &&
|
||||
pressingRight == null &&
|
||||
sprinting == null;
|
||||
}
|
||||
|
||||
public void replay() {
|
||||
RepeatingMod.input_replay = this;
|
||||
}
|
||||
|
||||
public void inputCallback() {
|
||||
if (sprinting != null && RepeatingMod.client.player.isSprinting() != sprinting)
|
||||
RepeatingMod.client.player.setSprinting(sprinting);
|
||||
if (RepeatingMod.client.player.getYaw() != yaw)
|
||||
RepeatingMod.client.player.setYaw(yaw);
|
||||
if (RepeatingMod.client.player.getHeadYaw() != head_yaw)
|
||||
RepeatingMod.client.player.setHeadYaw(head_yaw);
|
||||
if (RepeatingMod.client.player.getBodyYaw() != body_yaw)
|
||||
RepeatingMod.client.player.setBodyYaw(body_yaw);
|
||||
if (RepeatingMod.client.player.getPitch() != pitch)
|
||||
RepeatingMod.client.player.setPitch(pitch);
|
||||
if (RepeatingMod.client.player.getMovementSpeed() != speed)
|
||||
RepeatingMod.client.player.setMovementSpeed(speed);
|
||||
if (sneaking != null && RepeatingMod.client.player.input.sneaking != sneaking)
|
||||
RepeatingMod.client.player.input.sneaking = sneaking;
|
||||
if (jumping != null && RepeatingMod.client.player.input.jumping != jumping)
|
||||
RepeatingMod.client.player.input.jumping = jumping;
|
||||
if (movementSideways != null && RepeatingMod.client.player.input.movementSideways != movementSideways)
|
||||
RepeatingMod.client.player.input.movementSideways = movementSideways;
|
||||
if (movementForward != null && RepeatingMod.client.player.input.movementForward != movementForward)
|
||||
RepeatingMod.client.player.input.movementForward = movementForward;
|
||||
if (pressingForward != null && RepeatingMod.client.player.input.pressingForward != pressingForward)
|
||||
RepeatingMod.client.player.input.pressingForward = pressingForward;
|
||||
if (pressingBack != null && RepeatingMod.client.player.input.pressingBack != pressingBack)
|
||||
RepeatingMod.client.player.input.pressingBack = pressingBack;
|
||||
if (pressingLeft != null && RepeatingMod.client.player.input.pressingLeft != pressingLeft)
|
||||
RepeatingMod.client.player.input.pressingLeft = pressingLeft;
|
||||
if (pressingRight != null && RepeatingMod.client.player.input.pressingRight != pressingRight)
|
||||
RepeatingMod.client.player.input.pressingRight = pressingRight;
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
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") +
|
||||
"&" + yaw + "&" + speed);
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "input";
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package themixray.repeating.mod.events;
|
||||
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import themixray.repeating.mod.RepeatingMod;
|
||||
|
||||
public class RecordMoveEvent extends RecordEvent {
|
||||
public Vec3d vec;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
|
||||
public static RecordMoveEvent fromArgs(String[] a) {
|
||||
return new RecordMoveEvent(new Vec3d(
|
||||
Double.parseDouble(a[0]),
|
||||
Double.parseDouble(a[1]),
|
||||
Double.parseDouble(a[2])),
|
||||
Float.parseFloat(a[3]),
|
||||
Float.parseFloat(a[4]));
|
||||
}
|
||||
|
||||
public RecordMoveEvent(Vec3d vec, float yaw, float pitch) {
|
||||
this.vec = vec;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public void replay() {
|
||||
Vec3d p = RepeatingMod.client.player.getPos();
|
||||
Vec3d v = new Vec3d(vec.getX() - p.getX(), vec.getY() - p.getY(), vec.getZ() - p.getZ());
|
||||
RepeatingMod.client.player.move(MovementType.SELF, v);
|
||||
RepeatingMod.client.player.setYaw(yaw);
|
||||
RepeatingMod.client.player.setPitch(pitch);
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
return "m=" + vec.getX() + "&" + vec.getY() + "&" + vec.getZ() + "&" + yaw + "&" + pitch;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "move";
|
||||
}
|
||||
}
|
@ -9,11 +9,11 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import themixray.repeating.mod.events.RecordBlockBreakEvent;
|
||||
import themixray.repeating.mod.events.RecordBlockInteractEvent;
|
||||
import themixray.repeating.mod.RepeatingMod;
|
||||
import themixray.repeating.mod.TickTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public abstract class MovementMixin {
|
||||
|
||||
@ -21,13 +21,13 @@ public abstract class MovementMixin {
|
||||
private void init(CallbackInfo ci) {
|
||||
PlayerBlockBreakEvents.AFTER.register((world, player, pos, blockState, blockEntity) -> {
|
||||
if (RepeatingMod.me.is_recording)
|
||||
RepeatingMod.me.recordTick(new RepeatingMod.RecordBlockBreakEvent(pos));
|
||||
RepeatingMod.me.recordTick(new RecordBlockBreakEvent(pos));
|
||||
});
|
||||
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
||||
if (hitResult.getType().equals(HitResult.Type.BLOCK))
|
||||
if (RepeatingMod.me.is_recording)
|
||||
RepeatingMod.me.recordTick(new RepeatingMod.RecordBlockInteractEvent(hand,hitResult));
|
||||
RepeatingMod.me.recordTick(new RecordBlockInteractEvent(hand,hitResult));
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package themixray.repeating.mod.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.listener.ServerPlayPacketListener;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import themixray.repeating.mod.RepeatingMod;
|
||||
import themixray.repeating.mod.TickTask;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public abstract class NetworkMixin {
|
||||
@Inject(at = @At(value = "HEAD"), method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V")
|
||||
private void onSendPacket1Head(Packet<?> packet,
|
||||
CallbackInfo ci) {
|
||||
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "HEAD"), method = "sendPacket(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V")
|
||||
private void onSendPacket2Head(Packet<ServerPlayPacketListener> packet,
|
||||
BooleanSupplier sendCondition,
|
||||
Duration expirationTime,
|
||||
CallbackInfo ci) {
|
||||
|
||||
}
|
||||
}
|
@ -31,11 +31,11 @@ public class RenderHelper {
|
||||
buffer.vert(x2, y2, z2, color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f);
|
||||
}
|
||||
|
||||
public WorldBuffer startTri(WorldRenderContext context) {
|
||||
public static WorldBuffer startTri(WorldRenderContext context) {
|
||||
return new WorldBuffer(GL_TRIANGLES, ShaderManager.getPositionColorShader(), context);
|
||||
}
|
||||
|
||||
public void endTri(WorldBuffer buffer) {
|
||||
public static void endTri(WorldBuffer buffer) {
|
||||
//glDepthRange(0, 0.7);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@ -54,12 +54,12 @@ public class RenderHelper {
|
||||
buffer.vert(x3, y3, z3, color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f);
|
||||
}
|
||||
|
||||
public void drawRectFromTri(WorldBuffer buffer,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Color color) {
|
||||
public static void drawRectFromTri(WorldBuffer buffer,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Color color) {
|
||||
drawTri(buffer,
|
||||
x1, y1, z1,
|
||||
x2, y2, z2,
|
||||
|
@ -6,7 +6,7 @@ import themixray.repeating.mod.render.shader.ShaderManager;
|
||||
|
||||
@UtilityClass
|
||||
public class RenderSystem {
|
||||
public void init() {
|
||||
public static void init() {
|
||||
BufferManager.init();
|
||||
ShaderManager.init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user