port to 1.21.2, MOVEMENTS ARE BROKEN
All checks were successful
Build fabric mod / build (push) Successful in 35m46s

This commit is contained in:
MeexReay 2025-06-14 23:46:18 +03:00
parent 9d7ac6b213
commit 412c3f47ab
5 changed files with 131 additions and 145 deletions

View File

@ -4,16 +4,16 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.9
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
loader_version=0.16.14
loom_version=1.10-SNAPSHOT
# Fabric API
fabric_version=0.102.0+1.21
fabric_version=0.106.1+1.21.2
# Mod Properties
mod_version = 1.1.2+1.21
mod_version = 1.1.2+1.21.2
maven_group = ru.themixray
archives_base_name = repeating-mod

View File

@ -209,46 +209,14 @@ public class Main implements ClientModInitializer {
return;
}
InputEvent l = ((InputEvent) now_record.getLastEvent("input"));
if (l == null) {
InputEvent e = new InputEvent(
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 {
InputEvent e = new InputEvent(
((Boolean) client.player.input.sneaking == l.sneaking) ? null : client.player.input.sneaking,
((Boolean) client.player.input.jumping == l.jumping) ? null : client.player.input.jumping,
(((Float) client.player.input.movementSideways).equals(l.movementSideways)) ? null : client.player.input.movementSideways,
(((Float) client.player.input.movementForward).equals(l.movementForward)) ? null : client.player.input.movementForward,
((Boolean) client.player.input.pressingForward == l.pressingForward) ? null : client.player.input.pressingForward,
((Boolean) client.player.input.pressingBack == l.pressingBack) ? null : client.player.input.pressingBack,
((Boolean) client.player.input.pressingLeft == l.pressingLeft) ? null : client.player.input.pressingLeft,
((Boolean) client.player.input.pressingRight == l.pressingRight) ? null : client.player.input.pressingRight,
client.player.getHeadYaw(), Main.client.player.getBodyYaw(),client.player.getPitch(),
((Boolean) client.player.isSprinting() == l.sprinting) ? null : client.player.isSprinting(),
client.player.getYaw(),client.player.getMovementSpeed());
InputEvent curr = InputEvent.current();
if (curr == null) return;
if (!(e.isEmpty() &&
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);
}
InputEvent last = ((InputEvent) now_record.getLastEvent("input"));
if (last == null) {
recordTick(curr);
} else if (!curr.equals(last)) {
recordTick(curr.differs(last));
}
}
@ -332,10 +300,10 @@ public class Main implements ClientModInitializer {
client.player.sendMessage(Text.literal("[")
.append(Text.translatable("text.repeating-mod.name"))
.append("] ").formatted(Formatting.BOLD,Formatting.DARK_GRAY)
.append(text.formatted(Formatting.RESET).formatted(Formatting.GRAY)));
.append(text.formatted(Formatting.RESET).formatted(Formatting.GRAY)), false);
}
public static void sendDebug(String s) {
client.player.sendMessage(Text.literal("[DEBUG] ").append(Text.of(s)));
}
// public static void sendDebug(String s) {
// client.player.sendMessage(Text.literal("[DEBUG] ").append(Text.of(s)), false);
// }
}

View File

@ -1,19 +1,17 @@
package ru.themixray.repeating_mod.event.events;
import net.minecraft.util.PlayerInput;
import ru.themixray.repeating_mod.Main;
import ru.themixray.repeating_mod.event.RecordEvent;
public class InputEvent 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 Boolean forward;
public Boolean backward;
public Boolean left;
public Boolean right;
public Boolean jump;
public Boolean sneak;
public Boolean sprint;
public float yaw;
public float head_yaw;
@ -21,94 +19,118 @@ public class InputEvent extends RecordEvent {
public float pitch;
public float speed;
public InputEvent(Boolean sneaking,
Boolean jumping,
Float movementSideways,
Float movementForward,
Boolean pressingForward,
Boolean pressingBack,
Boolean pressingLeft,
Boolean pressingRight,
public static InputEvent current() {
if (Main.client.player == null) return null;
return new InputEvent(
Main.client.player.input.playerInput.forward(),
Main.client.player.input.playerInput.backward(),
Main.client.player.input.playerInput.left(),
Main.client.player.input.playerInput.right(),
Main.client.player.input.playerInput.jump(),
Main.client.player.input.playerInput.sneak(),
Main.client.player.input.playerInput.sprint(),
Main.client.player.getHeadYaw(),
Main.client.player.getBodyYaw(),
Main.client.player.getPitch(),
Main.client.player.getYaw(),
Main.client.player.getMovementSpeed()
);
}
public InputEvent(Boolean forward,
Boolean backward,
Boolean left,
Boolean right,
Boolean jump,
Boolean sneak,
Boolean sprint,
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.forward = forward;
this.backward = backward;
this.left = left;
this.right = right;
this.jump = jump;
this.sneak = sneak;
this.sprint = sprint;
this.head_yaw = head_yaw;
this.body_yaw = body_yaw;
this.pitch = head_pitch;
this.sprinting = sprinting;
this.yaw = yaw;
this.speed = speed;
}
/**
* Returns differences of this InputEvent to the provided one, saving first booleans if differ and first floats always
*/
public InputEvent differs(InputEvent event) {
return new InputEvent(
forward == event.forward ? null : forward,
backward == event.backward ? null : backward,
left == event.left ? null : left,
right == event.right ? null : right,
jump == event.jump ? null : jump,
sneak == event.sneak ? null : sneak,
sprint == event.sprint ? null : sprint,
head_yaw,
body_yaw,
pitch,
yaw,
speed
);
}
public static InputEvent deserialize(String[] a) {
return new InputEvent(
(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[2].equals("n") ? null : a[2].equals("1")),
(a[3].equals("n") ? null : a[3].equals("1")),
(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[7]),
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]));
Float.parseFloat(a[11])
);
}
protected String[] serializeArgs() {
return new String[] {
((sneaking == null) ? "n" : (sneaking ? "1" : "0")), // sneaking
((jumping == null) ? "n" : (jumping ? "1" : "0")), // jumping
((movementSideways == null) ? "n" : String.valueOf(movementSideways)), // movement sideways
((movementForward == null) ? "n" : String.valueOf(movementForward)), // movement forward
((pressingForward == null) ? "n" : (pressingForward ? "1" : "0")), // pressing forward
((pressingBack == null) ? "n" : (pressingBack ? "1" : "0")), // pressing back
((pressingLeft == null) ? "n" : (pressingLeft ? "1" : "0")), // pressing left
((pressingRight == null) ? "n" : (pressingRight ? "1" : "0")), // pressing right
String.valueOf(head_yaw), // head yaw
String.valueOf(body_yaw), // body yaw
String.valueOf(pitch), // pitch
((sprinting == null) ? "n" : (sprinting ? "1" : "0")), // sprinting
String.valueOf(yaw), // yaw
String.valueOf(speed) // speed
((forward == null) ? "n" : (forward ? "1" : "0")),
((backward == null) ? "n" : (backward ? "1" : "0")),
((left == null) ? "n" : (left ? "1" : "0")),
((right == null) ? "n" : (right ? "1" : "0")),
((jump == null) ? "n" : (jump ? "1" : "0")),
((sneak == null) ? "n" : (sneak ? "1" : "0")),
((sprint == null) ? "n" : (sprint ? "1" : "0")),
String.valueOf(head_yaw),
String.valueOf(body_yaw),
String.valueOf(pitch),
String.valueOf(yaw),
String.valueOf(speed),
};
}
public void fillEmpty(InputEvent 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 boolean equals(InputEvent event) {
return event.forward == forward &&
event.backward == backward &&
event.sprint == sprint &&
event.jump == jump &&
event.sneak == sneak &&
event.left == left &&
event.right == right &&
event.speed == speed &&
event.head_yaw == head_yaw &&
event.body_yaw == body_yaw &&
event.yaw == yaw &&
event.pitch == pitch;
}
public void replay() {
@ -117,8 +139,8 @@ public class InputEvent extends RecordEvent {
public void inputCallback() {
if (Main.client.player != null) {
if (sprinting != null && Main.client.player.isSprinting() != sprinting)
Main.client.player.setSprinting(sprinting);
if (sprint != null && Main.client.player.isSprinting() != sprint)
Main.client.player.setSprinting(sprint);
if (Main.client.player.getYaw() != yaw)
Main.client.player.setYaw(yaw);
if (Main.client.player.getHeadYaw() != head_yaw)
@ -129,22 +151,18 @@ public class InputEvent extends RecordEvent {
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;
PlayerInput input = Main.client.player.input.playerInput;
Main.client.player.input.playerInput = new PlayerInput(
this.forward == null ? input.forward() : this.forward,
this.backward == null ? input.backward() : this.backward,
this.left == null ? input.left() : this.left,
this.right == null ? input.right() : this.right,
this.jump == null ? input.jump() : this.jump,
this.sneak == null ? input.sneak() : this.sneak,
this.sprint == null ? input.sprint() : this.sprint
);
}
}
}

View File

@ -20,8 +20,8 @@ public abstract class EntityMixin {
if (getUuid().equals(Main.client.player.getUuid())) {
if (Main.me.is_replaying) {
if (Main.input_replay != null &&
Main.input_replay.sprinting != null &&
Main.input_replay.sprinting != sprinting) {
Main.input_replay.sprint != null &&
Main.input_replay.sprint != sprinting) {
ci.cancel();
}
}

View File

@ -51,7 +51,7 @@ public class ShaderManager {
public String loadImport(boolean inline, String name) {
return IOUtils.toString(resource.get().getInputStream(), StandardCharsets.UTF_8);
}
}.readSource(readResourceAsString(resource.get().getInputStream())));
}.readSource(readResourceAsString(resource.get().getInputStream())).getFirst());
} else file_present = false;
glCompileShader(i);
if (glGetShaderi(i, GL_COMPILE_STATUS) == 0 || !file_present) {