add "Help Up" feature for knocked players, improve execution handling, and update mod version to 1.6.0

This commit is contained in:
2026-05-23 19:37:58 +02:00
parent 25d0ae5229
commit 332b6552cf
30 changed files with 956 additions and 42 deletions
@@ -8,17 +8,40 @@ import java.util.UUID;
import java.util.function.Supplier;
public class ExecutionProgressPacket {
public enum Action {
NONE,
EXECUTION,
HELP_UP
}
private final int timeLeft;
private final int totalTicks;
private final Action action;
private final String targetName;
@Nullable
private final UUID executorId;
public ExecutionProgressPacket(int timeLeft, @Nullable UUID executorId) {
this(timeLeft, PlayerExecutionHandler.getExecutionTime(), timeLeft > 0 ? Action.EXECUTION : Action.NONE, "", executorId);
}
public ExecutionProgressPacket(int timeLeft, int totalTicks, Action action, @Nullable UUID executorId) {
this(timeLeft, totalTicks, action, "", executorId);
}
public ExecutionProgressPacket(int timeLeft, int totalTicks, Action action, String targetName, @Nullable UUID executorId) {
this.timeLeft = timeLeft;
this.totalTicks = totalTicks;
this.action = timeLeft > 0 ? action : Action.NONE;
this.targetName = timeLeft > 0 ? targetName : "";
this.executorId = executorId;
}
public static void encode(ExecutionProgressPacket msg, FriendlyByteBuf buf) {
buf.writeInt(msg.timeLeft);
buf.writeInt(msg.totalTicks);
buf.writeEnum(msg.action);
buf.writeUtf(msg.targetName);
buf.writeBoolean(msg.executorId != null);
if (msg.executorId != null) {
buf.writeUUID(msg.executorId);
@@ -27,13 +50,16 @@ public class ExecutionProgressPacket {
public static ExecutionProgressPacket decode(FriendlyByteBuf buf) {
int timeLeft = buf.readInt();
int totalTicks = buf.readInt();
Action action = buf.readEnum(Action.class);
String targetName = buf.readUtf();
UUID executorId = buf.readBoolean() ? buf.readUUID() : null;
return new ExecutionProgressPacket(timeLeft, executorId);
return new ExecutionProgressPacket(timeLeft, totalTicks, action, targetName, executorId);
}
public static void handle(ExecutionProgressPacket msg, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> {
net.fretux.knockedback.client.ClientExecutionState.setExecution(msg.timeLeft, msg.executorId);
net.fretux.knockedback.client.ClientExecutionState.setProgress(msg.timeLeft, msg.totalTicks, msg.action, msg.targetName, msg.executorId);
});
ctx.get().setPacketHandled(true);
}