1
mirror of https://github.com/Shiewk/BedrockDeathScreen.git synced 2026-04-27 22:44:17 +02:00
This commit is contained in:
Shy
2024-09-17 17:53:35 +02:00
parent fcd4869316
commit 580fb0fd4e
2 changed files with 10 additions and 7 deletions
@@ -10,6 +10,7 @@ import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -17,6 +18,7 @@ import java.awt.*;
public class BedrockDeathScreen extends DeathScreen {
private int ticksSinceDeath = 0;
private long screenTime = 0;
private final Text message;
private Text scoreText = Text.empty();
private static final Text menuMessage = Text.translatable("deathScreen.titleScreen");
@@ -31,6 +33,7 @@ public class BedrockDeathScreen extends DeathScreen {
super(message, isHardcore);
this.message = message;
this.hardcore = isHardcore;
screenTime = Util.getMeasuringTimeNano();
}
private boolean hoversRespawn(int mouseX, int mouseY){
@@ -38,7 +41,7 @@ public class BedrockDeathScreen extends DeathScreen {
int startY = height - height / 3 - 9;
int endX = width/2 + 75;
int endY = height - height / 3 + 13;
return getTotalDelta(0) > 1050 &&
return getTotalDelta() > 1050 &&
mouseX > startX &&
mouseX < endX &&
mouseY > startY &&
@@ -50,7 +53,7 @@ public class BedrockDeathScreen extends DeathScreen {
final int startY = height - height / 3 - 9 + 30;
final int endX = width/2 + 75;
final int endY = height - height / 3 + 13 + 30;
return getTotalDelta(0) > 1050 &&
return getTotalDelta() > 1050 &&
mouseX > startX &&
mouseX < endX &&
mouseY > startY &&
@@ -149,13 +152,13 @@ public class BedrockDeathScreen extends DeathScreen {
context.drawText(textRenderer, menuMessage, (width/2) - (textRenderer.getWidth(menuMessage)/2), height - height/3 - 1, textColor, false);
}
public float getTotalDelta(float delta){
return ticksSinceDeath * 50f + delta;
public float getTotalDelta(){
return (Util.getMeasuringTimeNano() - screenTime) / 1000000f;
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
final float totalDelta = getTotalDelta(delta);
final float totalDelta = getTotalDelta();
context.fill(0, 0, width, height, new Color(0, 0, 0, (int) Math.min(80, totalDelta/4f)).getRGB());
if (totalDelta > 750.0f){
final int backOpacity = (int) Math.min(255, (totalDelta - 750f) / 10f);
@@ -263,7 +266,7 @@ public class BedrockDeathScreen extends DeathScreen {
public float calcCameraOffset(float delta){
final double e = Math.E;
final double del = getTotalDelta(delta) / 600d;
final double del = getTotalDelta() / 600d;
final double ep = Math.pow(e, del);
return (float) (ep / (1d + ep) * 7d + 2d);
}