add of SR-Core and many more things
Some checks failed
Build / build (push) Failing after 1m19s

This commit is contained in:
unurled 2024-09-06 09:29:26 +02:00
parent d58e3da6ac
commit ced4c0d186
Signed by: unurled
GPG key ID: EFC5F5E709B47DDD
122 changed files with 13914 additions and 524 deletions

View file

@ -0,0 +1,67 @@
package me.unurled.sacredrealms.sr.utils;
import static me.unurled.sacredrealms.sr.utils.Component.textComp;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import me.unurled.sacredrealms.sr.components.cutscene.Frame;
import me.unurled.sacredrealms.sr.components.cutscene.Marker;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.title.Title;
import net.kyori.adventure.title.Title.Times;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class CutsceneUtil {
private static final String FONT = "custom";
private CutsceneUtil() {}
public static void showBlackScreen(@NotNull Player p, int duration, int fadeIn, int fadeOut) {
// /title @s title {"text":"\uE000","color":"black"}
Title title =
Title.title(
textComp("\uE000").font(Key.key(FONT)),
textComp(""),
Times.times(
Duration.ofSeconds(fadeIn),
Duration.ofSeconds(duration),
Duration.ofSeconds(fadeOut)));
p.showTitle(title);
}
public static @NotNull List<Frame> interpolateFrames(
@NotNull Marker startMarker, @NotNull Marker endMarker, long stepMillis) {
long duration = startMarker.getOverAllTime();
int numFrames = (int) (duration / stepMillis);
double xDiff = (endMarker.getStart().getX() - startMarker.getStart().getX()) / numFrames;
double yDiff = (endMarker.getStart().getY() - startMarker.getStart().getY()) / numFrames;
double zDiff = (endMarker.getStart().getZ() - startMarker.getStart().getZ()) / numFrames;
double yawDiff = (endMarker.getStart().getYaw() - startMarker.getStart().getYaw()) / numFrames;
double pitchDiff =
(endMarker.getStart().getPitch() - startMarker.getStart().getPitch()) / numFrames;
ArrayList<Frame> frames = new ArrayList<>();
for (int i = 0; i < numFrames; i++) {
double x = startMarker.getStart().getX() + xDiff * i;
double y = startMarker.getStart().getY() + yDiff * i;
double z = startMarker.getStart().getZ() + zDiff * i;
double yaw = startMarker.getStart().getYaw() + yawDiff * i;
double pitch = startMarker.getStart().getPitch() + pitchDiff * i;
Frame frame =
new Frame(
new Location(startMarker.getStart().getWorld(), x, y, z, (float) yaw, (float) pitch));
frames.add(frame);
}
return frames;
}
}