实现从下至上的渲染
This commit is contained in:
parent
cf2a2999cc
commit
dee1e8a1ad
1 changed files with 9 additions and 7 deletions
|
@ -78,8 +78,8 @@ public class KillMessageOverlay implements LayeredDraw.Layer {
|
||||||
var pos = KillMessageConfig.KILL_MESSAGE_POSITION.get();
|
var pos = KillMessageConfig.KILL_MESSAGE_POSITION.get();
|
||||||
int posX = screenWidth;
|
int posX = screenWidth;
|
||||||
float posY = KillMessageConfig.KILL_MESSAGE_MARGIN_Y.get();
|
float posY = KillMessageConfig.KILL_MESSAGE_MARGIN_Y.get();
|
||||||
int count = KillMessageConfig.KILL_MESSAGE_COUNT.get();
|
|
||||||
boolean left = false;
|
boolean left = false;
|
||||||
|
boolean bottom = false;
|
||||||
|
|
||||||
switch (pos) {
|
switch (pos) {
|
||||||
case LEFT_TOP -> {
|
case LEFT_TOP -> {
|
||||||
|
@ -93,12 +93,14 @@ public class KillMessageOverlay implements LayeredDraw.Layer {
|
||||||
}
|
}
|
||||||
case LEFT_BOTTOM -> {
|
case LEFT_BOTTOM -> {
|
||||||
posX = KillMessageConfig.KILL_MESSAGE_MARGIN_X.get();
|
posX = KillMessageConfig.KILL_MESSAGE_MARGIN_X.get();
|
||||||
posY = screenHeight - KillMessageConfig.KILL_MESSAGE_MARGIN_Y.get() - count * 10;
|
posY = screenHeight - KillMessageConfig.KILL_MESSAGE_MARGIN_Y.get() - 10;
|
||||||
left = true;
|
left = true;
|
||||||
|
bottom = true;
|
||||||
}
|
}
|
||||||
case RIGHT_BOTTOM -> {
|
case RIGHT_BOTTOM -> {
|
||||||
posX = screenWidth - KillMessageConfig.KILL_MESSAGE_MARGIN_X.get();
|
posX = screenWidth - KillMessageConfig.KILL_MESSAGE_MARGIN_X.get();
|
||||||
posY = screenHeight - KillMessageConfig.KILL_MESSAGE_MARGIN_Y.get() - count * 10;
|
posY = screenHeight - KillMessageConfig.KILL_MESSAGE_MARGIN_Y.get() - 10;
|
||||||
|
bottom = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +124,11 @@ public class KillMessageOverlay implements LayeredDraw.Layer {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PlayerKillRecord r : KillMessageHandler.QUEUE) {
|
for (PlayerKillRecord r : KillMessageHandler.QUEUE) {
|
||||||
posY = renderKillMessages(r, guiGraphics, deltaTracker.getGameTimeDeltaPartialTick(true), posX, posY, left);
|
posY = renderKillMessages(r, guiGraphics, deltaTracker.getGameTimeDeltaPartialTick(true), posX, posY, left, bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float renderKillMessages(PlayerKillRecord record, GuiGraphics guiGraphics, float partialTick, int width, float baseTop, boolean left) {
|
private static float renderKillMessages(PlayerKillRecord record, GuiGraphics guiGraphics, float partialTick, int width, float baseTop, boolean left, boolean bottom) {
|
||||||
float top = baseTop;
|
float top = baseTop;
|
||||||
|
|
||||||
Font font = Minecraft.getInstance().font;
|
Font font = Minecraft.getInstance().font;
|
||||||
|
@ -155,9 +157,9 @@ public class KillMessageOverlay implements LayeredDraw.Layer {
|
||||||
float rate = (float) Math.pow((record.tick + partialTick - 80) / animationTickCount, 5);
|
float rate = (float) Math.pow((record.tick + partialTick - 80) / animationTickCount, 5);
|
||||||
guiGraphics.pose().translate(rate * 100 * (left ? -1 : 1), 0, 0);
|
guiGraphics.pose().translate(rate * 100 * (left ? -1 : 1), 0, 0);
|
||||||
guiGraphics.setColor(1, 1, 1, 1 - rate);
|
guiGraphics.setColor(1, 1, 1, 1 - rate);
|
||||||
baseTop += 10 * (1 - rate);
|
baseTop += 10 * (1 - rate) * (bottom ? -1 : 1);
|
||||||
} else {
|
} else {
|
||||||
baseTop += 10;
|
baseTop += 10 * (bottom ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 击杀提示默认是右对齐的,这里从右向左渲染
|
// 击杀提示默认是右对齐的,这里从右向左渲染
|
||||||
|
|
Loading…
Add table
Reference in a new issue