Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
654589355d | |||
0b3bac264f | |||
59a2175fb2 | |||
ac1ee8ec6d | |||
c65e906500 | |||
f082788406 | |||
072efb64f6 | |||
d101b11c36 | |||
412c3f47ab | |||
9d7ac6b213 |
@ -4,17 +4,17 @@ org.gradle.parallel=true
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.21
|
minecraft_version=1.21.6
|
||||||
yarn_mappings=1.21+build.9
|
yarn_mappings=1.21.6+build.1
|
||||||
loader_version=0.16.14
|
loader_version=0.16.14
|
||||||
loom_version=1.10-SNAPSHOT
|
loom_version=1.10-SNAPSHOT
|
||||||
|
|
||||||
# Fabric API
|
# Fabric API
|
||||||
fabric_version=0.102.0+1.21
|
fabric_version=0.127.0+1.21.6
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.1.2+1.21
|
mod_version = 1.1.2+1.21.6
|
||||||
maven_group = ru.themixray
|
maven_group = ru.themixray
|
||||||
archives_base_name = repeating-mod
|
archives_base_name = repeating-mod
|
||||||
|
|
||||||
# Compatible with: 1.21, 1.21.1
|
# Compatible with: 1.21.6
|
@ -209,46 +209,14 @@ public class Main implements ClientModInitializer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputEvent l = ((InputEvent) now_record.getLastEvent("input"));
|
InputEvent curr = InputEvent.current();
|
||||||
if (l == null) {
|
if (curr == null) return;
|
||||||
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());
|
|
||||||
|
|
||||||
if (!(e.isEmpty() &&
|
InputEvent last = ((InputEvent) now_record.getLastEvent("input"));
|
||||||
e.yaw == l.yaw &&
|
if (last == null) {
|
||||||
e.head_yaw == l.head_yaw &&
|
recordTick(curr);
|
||||||
e.pitch == l.pitch &&
|
} else if (!curr.equals(last)) {
|
||||||
e.body_yaw == l.body_yaw)) {
|
recordTick(curr.differs(last));
|
||||||
e.fillEmpty(l);
|
|
||||||
recordTick(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,10 +300,10 @@ public class Main implements ClientModInitializer {
|
|||||||
client.player.sendMessage(Text.literal("[")
|
client.player.sendMessage(Text.literal("[")
|
||||||
.append(Text.translatable("text.repeating-mod.name"))
|
.append(Text.translatable("text.repeating-mod.name"))
|
||||||
.append("] ").formatted(Formatting.BOLD,Formatting.DARK_GRAY)
|
.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) {
|
// public static void sendDebug(String s) {
|
||||||
client.player.sendMessage(Text.literal("[DEBUG] ").append(Text.of(s)));
|
// client.player.sendMessage(Text.literal("[DEBUG] ").append(Text.of(s)), false);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class RepeatingScreen extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||||
renderBackground(context, mouseX, mouseY, delta);
|
// renderBackground(context, mouseX, mouseY, delta);
|
||||||
|
|
||||||
for (RenderListener l : render_listeners) {
|
for (RenderListener l : render_listeners) {
|
||||||
if (l.beforeRender()) {
|
if (l.beforeRender()) {
|
||||||
|
@ -19,7 +19,7 @@ public class BlockInteractEvent extends RecordEvent {
|
|||||||
Double.parseDouble(a[0]),
|
Double.parseDouble(a[0]),
|
||||||
Double.parseDouble(a[1]),
|
Double.parseDouble(a[1]),
|
||||||
Double.parseDouble(a[2])),
|
Double.parseDouble(a[2])),
|
||||||
Direction.byId(Integer.parseInt(a[4])),
|
Direction.byIndex(Integer.parseInt(a[4])),
|
||||||
new BlockPos(
|
new BlockPos(
|
||||||
Integer.parseInt(a[0]),
|
Integer.parseInt(a[0]),
|
||||||
Integer.parseInt(a[1]),
|
Integer.parseInt(a[1]),
|
||||||
@ -44,7 +44,7 @@ public class BlockInteractEvent extends RecordEvent {
|
|||||||
String.valueOf(hitResult.getBlockPos().getY()),
|
String.valueOf(hitResult.getBlockPos().getY()),
|
||||||
String.valueOf(hitResult.getBlockPos().getZ()),
|
String.valueOf(hitResult.getBlockPos().getZ()),
|
||||||
(hitResult.isInsideBlock() ? "1" : "0"),
|
(hitResult.isInsideBlock() ? "1" : "0"),
|
||||||
String.valueOf(hitResult.getSide().getId()),
|
String.valueOf(hitResult.getSide().getIndex()),
|
||||||
hand.name()
|
hand.name()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,114 +1,156 @@
|
|||||||
package ru.themixray.repeating_mod.event.events;
|
package ru.themixray.repeating_mod.event.events;
|
||||||
|
|
||||||
|
import net.minecraft.client.input.Input;
|
||||||
|
import net.minecraft.util.PlayerInput;
|
||||||
|
import net.minecraft.util.math.Vec2f;
|
||||||
import ru.themixray.repeating_mod.Main;
|
import ru.themixray.repeating_mod.Main;
|
||||||
import ru.themixray.repeating_mod.event.RecordEvent;
|
import ru.themixray.repeating_mod.event.RecordEvent;
|
||||||
|
|
||||||
public class InputEvent extends RecordEvent {
|
import java.lang.reflect.Field;
|
||||||
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 class InputEvent extends RecordEvent {
|
||||||
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 yaw;
|
||||||
public float head_yaw;
|
public float head_yaw;
|
||||||
public float body_yaw;
|
public float body_yaw;
|
||||||
public float pitch;
|
public float pitch;
|
||||||
public float speed;
|
public float speed;
|
||||||
|
public float movementForward;
|
||||||
|
public float movementSideways;
|
||||||
|
|
||||||
public InputEvent(Boolean sneaking,
|
public static InputEvent current() {
|
||||||
Boolean jumping,
|
if (Main.client.player == null) return null;
|
||||||
Float movementSideways,
|
return new InputEvent(
|
||||||
Float movementForward,
|
Main.client.player.input.playerInput.forward(),
|
||||||
Boolean pressingForward,
|
Main.client.player.input.playerInput.backward(),
|
||||||
Boolean pressingBack,
|
Main.client.player.input.playerInput.left(),
|
||||||
Boolean pressingLeft,
|
Main.client.player.input.playerInput.right(),
|
||||||
Boolean pressingRight,
|
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(),
|
||||||
|
Main.client.player.input.getMovementInput().y,
|
||||||
|
Main.client.player.input.getMovementInput().x
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputEvent(Boolean forward,
|
||||||
|
Boolean backward,
|
||||||
|
Boolean left,
|
||||||
|
Boolean right,
|
||||||
|
Boolean jump,
|
||||||
|
Boolean sneak,
|
||||||
|
Boolean sprint,
|
||||||
float head_yaw,
|
float head_yaw,
|
||||||
float body_yaw,
|
float body_yaw,
|
||||||
float head_pitch,
|
float head_pitch,
|
||||||
Boolean sprinting,
|
|
||||||
float yaw,
|
float yaw,
|
||||||
float speed) {
|
float speed,
|
||||||
this.sneaking = sneaking;
|
float movementForward,
|
||||||
this.jumping = jumping;
|
float movementSideways) {
|
||||||
this.movementSideways = movementSideways;
|
this.forward = forward;
|
||||||
this.movementForward = movementForward;
|
this.backward = backward;
|
||||||
this.pressingForward = pressingForward;
|
this.left = left;
|
||||||
this.pressingBack = pressingBack;
|
this.right = right;
|
||||||
this.pressingLeft = pressingLeft;
|
this.jump = jump;
|
||||||
this.pressingRight = pressingRight;
|
this.sneak = sneak;
|
||||||
|
this.sprint = sprint;
|
||||||
|
|
||||||
this.head_yaw = head_yaw;
|
this.head_yaw = head_yaw;
|
||||||
this.body_yaw = body_yaw;
|
this.body_yaw = body_yaw;
|
||||||
this.pitch = head_pitch;
|
this.pitch = head_pitch;
|
||||||
this.sprinting = sprinting;
|
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
|
this.movementForward = movementForward;
|
||||||
|
this.movementSideways = movementSideways;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
movementForward,
|
||||||
|
movementSideways
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InputEvent deserialize(String[] a) {
|
public static InputEvent deserialize(String[] a) {
|
||||||
return new InputEvent(
|
return new InputEvent(
|
||||||
(a[0].equals("n") ? null : a[0].equals("1")),
|
(a[0].equals("n") ? null : a[0].equals("1")),
|
||||||
(a[1].equals("n") ? null : a[1].equals("1")),
|
(a[1].equals("n") ? null : a[1].equals("1")),
|
||||||
(a[2].equals("n") ? null : Float.parseFloat(a[2])),
|
(a[2].equals("n") ? null : a[2].equals("1")),
|
||||||
(a[3].equals("n") ? null : Float.parseFloat(a[3])),
|
(a[3].equals("n") ? null : a[3].equals("1")),
|
||||||
(a[4].equals("n") ? null : a[4].equals("1")),
|
(a[4].equals("n") ? null : a[4].equals("1")),
|
||||||
(a[5].equals("n") ? null : a[5].equals("1")),
|
(a[5].equals("n") ? null : a[5].equals("1")),
|
||||||
(a[6].equals("n") ? null : a[6].equals("1")),
|
(a[6].equals("n") ? null : a[6].equals("1")),
|
||||||
(a[7].equals("n") ? null : a[7].equals("1")),
|
Float.parseFloat(a[7]),
|
||||||
Float.parseFloat(a[8]), Float.parseFloat(a[9]),
|
Float.parseFloat(a[8]),
|
||||||
|
Float.parseFloat(a[9]),
|
||||||
Float.parseFloat(a[10]),
|
Float.parseFloat(a[10]),
|
||||||
(a[11].equals("n") ? null : a[11].equals("1")),
|
Float.parseFloat(a[11]),
|
||||||
Float.parseFloat(a[12]),
|
Float.parseFloat(a[12]),
|
||||||
Float.parseFloat(a[13]));
|
Float.parseFloat(a[13])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] serializeArgs() {
|
protected String[] serializeArgs() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
((sneaking == null) ? "n" : (sneaking ? "1" : "0")), // sneaking
|
((forward == null) ? "n" : (forward ? "1" : "0")),
|
||||||
((jumping == null) ? "n" : (jumping ? "1" : "0")), // jumping
|
((backward == null) ? "n" : (backward ? "1" : "0")),
|
||||||
((movementSideways == null) ? "n" : String.valueOf(movementSideways)), // movement sideways
|
((left == null) ? "n" : (left ? "1" : "0")),
|
||||||
((movementForward == null) ? "n" : String.valueOf(movementForward)), // movement forward
|
((right == null) ? "n" : (right ? "1" : "0")),
|
||||||
((pressingForward == null) ? "n" : (pressingForward ? "1" : "0")), // pressing forward
|
((jump == null) ? "n" : (jump ? "1" : "0")),
|
||||||
((pressingBack == null) ? "n" : (pressingBack ? "1" : "0")), // pressing back
|
((sneak == null) ? "n" : (sneak ? "1" : "0")),
|
||||||
((pressingLeft == null) ? "n" : (pressingLeft ? "1" : "0")), // pressing left
|
((sprint == null) ? "n" : (sprint ? "1" : "0")),
|
||||||
((pressingRight == null) ? "n" : (pressingRight ? "1" : "0")), // pressing right
|
String.valueOf(head_yaw),
|
||||||
String.valueOf(head_yaw), // head yaw
|
String.valueOf(body_yaw),
|
||||||
String.valueOf(body_yaw), // body yaw
|
String.valueOf(pitch),
|
||||||
String.valueOf(pitch), // pitch
|
String.valueOf(yaw),
|
||||||
((sprinting == null) ? "n" : (sprinting ? "1" : "0")), // sprinting
|
String.valueOf(speed),
|
||||||
String.valueOf(yaw), // yaw
|
String.valueOf(movementForward),
|
||||||
String.valueOf(speed) // speed
|
String.valueOf(movementSideways)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillEmpty(InputEvent e) {
|
public boolean equals(InputEvent event) {
|
||||||
if (sneaking == null) sneaking = e.sneaking;
|
return event.forward == forward &&
|
||||||
if (jumping == null) jumping = e.jumping;
|
event.backward == backward &&
|
||||||
if (movementSideways == null) movementSideways = e.movementSideways;
|
event.sprint == sprint &&
|
||||||
if (movementForward == null) movementForward = e.movementForward;
|
event.jump == jump &&
|
||||||
if (pressingForward == null) pressingForward = e.pressingForward;
|
event.sneak == sneak &&
|
||||||
if (pressingBack == null) pressingBack = e.pressingBack;
|
event.left == left &&
|
||||||
if (pressingLeft == null) pressingLeft = e.pressingLeft;
|
event.right == right &&
|
||||||
if (pressingRight == null) pressingRight = e.pressingRight;
|
event.speed == speed &&
|
||||||
if (sprinting == null) sprinting = e.sprinting;
|
event.head_yaw == head_yaw &&
|
||||||
}
|
event.body_yaw == body_yaw &&
|
||||||
|
event.yaw == yaw &&
|
||||||
public boolean isEmpty() {
|
event.pitch == pitch &&
|
||||||
return sneaking == null &&
|
event.movementForward == movementForward &&
|
||||||
jumping == null &&
|
event.movementSideways == movementSideways;
|
||||||
movementSideways == null &&
|
|
||||||
movementForward == null &&
|
|
||||||
pressingForward == null &&
|
|
||||||
pressingBack == null &&
|
|
||||||
pressingLeft == null &&
|
|
||||||
pressingRight == null &&
|
|
||||||
sprinting == null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replay() {
|
public void replay() {
|
||||||
@ -117,8 +159,8 @@ public class InputEvent extends RecordEvent {
|
|||||||
|
|
||||||
public void inputCallback() {
|
public void inputCallback() {
|
||||||
if (Main.client.player != null) {
|
if (Main.client.player != null) {
|
||||||
if (sprinting != null && Main.client.player.isSprinting() != sprinting)
|
if (sprint != null && Main.client.player.isSprinting() != sprint)
|
||||||
Main.client.player.setSprinting(sprinting);
|
Main.client.player.setSprinting(sprint);
|
||||||
if (Main.client.player.getYaw() != yaw)
|
if (Main.client.player.getYaw() != yaw)
|
||||||
Main.client.player.setYaw(yaw);
|
Main.client.player.setYaw(yaw);
|
||||||
if (Main.client.player.getHeadYaw() != head_yaw)
|
if (Main.client.player.getHeadYaw() != head_yaw)
|
||||||
@ -129,22 +171,25 @@ public class InputEvent extends RecordEvent {
|
|||||||
Main.client.player.setPitch(pitch);
|
Main.client.player.setPitch(pitch);
|
||||||
if (Main.client.player.getMovementSpeed() != speed)
|
if (Main.client.player.getMovementSpeed() != speed)
|
||||||
Main.client.player.setMovementSpeed(speed);
|
Main.client.player.setMovementSpeed(speed);
|
||||||
if (sneaking != null && Main.client.player.input.sneaking != sneaking)
|
|
||||||
Main.client.player.input.sneaking = sneaking;
|
try {
|
||||||
if (jumping != null && Main.client.player.input.jumping != jumping)
|
Field field = Input.class.getDeclaredField("movementVector");
|
||||||
Main.client.player.input.jumping = jumping;
|
field.setAccessible(true);
|
||||||
if (movementSideways != null && Main.client.player.input.movementSideways != movementSideways)
|
field.set(Main.client.player.input, new Vec2f(movementSideways, movementForward));
|
||||||
Main.client.player.input.movementSideways = movementSideways;
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
if (movementForward != null && Main.client.player.input.movementForward != movementForward)
|
e.printStackTrace();
|
||||||
Main.client.player.input.movementForward = movementForward;
|
}
|
||||||
if (pressingForward != null && Main.client.player.input.pressingForward != pressingForward)
|
|
||||||
Main.client.player.input.pressingForward = pressingForward;
|
PlayerInput input = Main.client.player.input.playerInput;
|
||||||
if (pressingBack != null && Main.client.player.input.pressingBack != pressingBack)
|
Main.client.player.input.playerInput = new PlayerInput(
|
||||||
Main.client.player.input.pressingBack = pressingBack;
|
this.forward == null ? input.forward() : this.forward,
|
||||||
if (pressingLeft != null && Main.client.player.input.pressingLeft != pressingLeft)
|
this.backward == null ? input.backward() : this.backward,
|
||||||
Main.client.player.input.pressingLeft = pressingLeft;
|
this.left == null ? input.left() : this.left,
|
||||||
if (pressingRight != null && Main.client.player.input.pressingRight != pressingRight)
|
this.right == null ? input.right() : this.right,
|
||||||
Main.client.player.input.pressingRight = pressingRight;
|
this.jump == null ? input.jump() : this.jump,
|
||||||
|
this.sneak == null ? input.sneak() : this.sneak,
|
||||||
|
this.sprint == null ? input.sprint() : this.sprint
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ public abstract class EntityMixin {
|
|||||||
if (getUuid().equals(Main.client.player.getUuid())) {
|
if (getUuid().equals(Main.client.player.getUuid())) {
|
||||||
if (Main.me.is_replaying) {
|
if (Main.me.is_replaying) {
|
||||||
if (Main.input_replay != null &&
|
if (Main.input_replay != null &&
|
||||||
Main.input_replay.sprinting != null &&
|
Main.input_replay.sprint != null &&
|
||||||
Main.input_replay.sprinting != sprinting) {
|
Main.input_replay.sprint != sprinting) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import ru.themixray.repeating_mod.Main;
|
|||||||
@Mixin(KeyboardInput.class)
|
@Mixin(KeyboardInput.class)
|
||||||
public abstract class InputMixin {
|
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(CallbackInfo ci) {
|
||||||
if (Main.me.is_replaying) {
|
if (Main.me.is_replaying) {
|
||||||
if (Main.input_replay != null) {
|
if (Main.input_replay != null) {
|
||||||
Main.input_replay.inputCallback();
|
Main.input_replay.inputCallback();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ru.themixray.repeating_mod.render.shader;
|
package ru.themixray.repeating_mod.render.shader;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.opengl.GlStateManager;
|
||||||
import com.mojang.blaze3d.platform.TextureUtil;
|
import com.mojang.blaze3d.platform.TextureUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
@ -51,7 +51,7 @@ public class ShaderManager {
|
|||||||
public String loadImport(boolean inline, String name) {
|
public String loadImport(boolean inline, String name) {
|
||||||
return IOUtils.toString(resource.get().getInputStream(), StandardCharsets.UTF_8);
|
return IOUtils.toString(resource.get().getInputStream(), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
}.readSource(readResourceAsString(resource.get().getInputStream())));
|
}.readSource(readResourceAsString(resource.get().getInputStream())).getFirst());
|
||||||
} else file_present = false;
|
} else file_present = false;
|
||||||
glCompileShader(i);
|
glCompileShader(i);
|
||||||
if (glGetShaderi(i, GL_COMPILE_STATUS) == 0 || !file_present) {
|
if (glGetShaderi(i, GL_COMPILE_STATUS) == 0 || !file_present) {
|
||||||
|
@ -26,27 +26,40 @@ public class RecordListWidget extends ScrollableWidget {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getContentsHeightWithPadding() {
|
||||||
|
return !widgets.isEmpty() ? widgets.size() * 55 + (widgets.size() - 1) * 2 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double getDeltaYPerScroll() {
|
protected double getDeltaYPerScroll() {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderContents(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
protected void renderWidget(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
||||||
int y = 0;
|
ctx.fill(this.getX(), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), 0xff000000);
|
||||||
|
|
||||||
|
ctx.enableScissor(this.getX(), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight());
|
||||||
|
|
||||||
|
int y = (int) -this.getScrollY();
|
||||||
for (RecordWidget wid: widgets) {
|
for (RecordWidget wid: widgets) {
|
||||||
wid.setY(y);
|
wid.setY(y);
|
||||||
wid.render(ctx, mouseX, (int) (mouseY + this.getScrollY()), delta);
|
wid.render(ctx, mouseX, (int) (mouseY), delta);
|
||||||
|
|
||||||
y += wid.getHeight();
|
y += wid.getHeight();
|
||||||
y += 2;
|
y += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.disableScissor();
|
||||||
|
|
||||||
|
this.drawScrollbar(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWidget(RecordState record) {
|
public void addWidget(RecordState record) {
|
||||||
RecordWidget widget = new RecordWidget(0, 0, width, 55, record, this);
|
RecordWidget widget = new RecordWidget(0, 0, width - 6, 55, record, this);
|
||||||
widget.init(null);
|
widget.init(null);
|
||||||
widgets.add(0, widget);
|
widgets.addFirst(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeWidget(RecordState record) {
|
public void removeWidget(RecordState record) {
|
||||||
@ -63,11 +76,6 @@ public class RecordListWidget extends ScrollableWidget {
|
|||||||
return focused;
|
return focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getContentsHeight() {
|
|
||||||
return !widgets.isEmpty() ? widgets.size() * 55 + (widgets.size() - 1) * 2 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(RepeatingScreen screen) {
|
public void init(RepeatingScreen screen) {
|
||||||
for (RecordWidget widget : widgets) {
|
for (RecordWidget widget : widgets) {
|
||||||
widget.init(screen);
|
widget.init(screen);
|
||||||
@ -125,7 +133,7 @@ public class RecordListWidget extends ScrollableWidget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
return checkTransportNF(mouseX, mouseY + getScrollY(), button) || super.mouseClicked(mouseX, mouseY, button);
|
return checkTransportNF(mouseX, mouseY, button) || super.checkScrollbarDragged(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.themixray.repeating_mod.widget;
|
package ru.themixray.repeating_mod.widget;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.Drawable;
|
import net.minecraft.client.gui.Drawable;
|
||||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||||
@ -18,6 +19,7 @@ import java.util.List;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class RecordWidget implements Drawable, Widget {
|
public class RecordWidget implements Drawable, Widget {
|
||||||
|
@Getter
|
||||||
private RecordState record;
|
private RecordState record;
|
||||||
|
|
||||||
private List<ClickableWidget> children;
|
private List<ClickableWidget> children;
|
||||||
@ -150,22 +152,13 @@ public class RecordWidget implements Drawable, Widget {
|
|||||||
children.add(replay_button);
|
children.add(replay_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordState getRecord() {
|
public void drawText(int x, int y, DrawContext ctx, List<Text> lines, int line_height, boolean shadow) {
|
||||||
return record;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawText(int x, int y, DrawContext ctx, List<Text> lines, float size, int line_height, boolean shadow) {
|
|
||||||
ctx.getMatrices().push();
|
|
||||||
ctx.getMatrices().scale(size, size, size);
|
|
||||||
|
|
||||||
int now_y = y;
|
int now_y = y;
|
||||||
|
|
||||||
for (Text line : lines) {
|
for (Text line : lines) {
|
||||||
ctx.drawText(Main.client.textRenderer, line, (int) (x / size), (int) (now_y / size), line.getStyle().getColor().getRgb(), shadow);
|
ctx.drawText(Main.client.textRenderer, line, x, now_y, 0xff000000 + line.getStyle().getColor().getRgb(), shadow);
|
||||||
now_y += line_height;
|
now_y += line_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.getMatrices().pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -190,7 +183,7 @@ public class RecordWidget implements Drawable, Widget {
|
|||||||
.append(": ")
|
.append(": ")
|
||||||
.styled((s) -> s.withColor(0xbbbbbb)),
|
.styled((s) -> s.withColor(0xbbbbbb)),
|
||||||
Text.literal(record.getAuthor()).styled((s) -> s.withColor(0xffffff))
|
Text.literal(record.getAuthor()).styled((s) -> s.withColor(0xffffff))
|
||||||
), 1,
|
),
|
||||||
9,
|
9,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.14",
|
"fabricloader": ">=0.14.14",
|
||||||
"fabric-api": "*",
|
"fabric-api": "*",
|
||||||
"minecraft": ">=1.21",
|
"minecraft": ">=1.21.4",
|
||||||
"java": ">=17"
|
"java": ">=17"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user