From 3bfffa8dbf15d99a9d7c1033342850b306ff04af Mon Sep 17 00:00:00 2001 From: Kenichi Matsushita Date: Wed, 27 May 2026 16:43:20 +0900 Subject: [PATCH 1/5] refactor: extract HUD constants, fix line overlap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HUD行描画のindexOf(s)起因で重複文字列が重なるバグをインデックスループで修正 - areaWidth算出をmapToInt().max().orElse(0)にし、空リスト時の例外を回避 - エリトラ色判定の変数leftを実体(消耗率)に合わせwearへ改名し早期リターン化 - getElytraLifeの-1の意図(残り耐久1で飛行不能)をコメントで明示 - 行高・HUD座標・色・速度換算・カメラ切替tick等のマジックナンバーを定数化 - fabric/neoforge両ローダーに同一の修正を適用 Co-Authored-By: Claude Opus 4.7 (1M context) --- .../flightview/fabric/FlightViewRenderer.java | 57 ++++++++++++------- .../fabric/WorldRenderLastEventListener.java | 5 +- .../neoforge/FlightViewRenderer.java | 57 ++++++++++++------- .../WorldRenderLastEventListener.java | 5 +- 4 files changed, 84 insertions(+), 40 deletions(-) diff --git a/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java b/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java index fa02e8a..e8984d8 100644 --- a/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java +++ b/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java @@ -18,6 +18,24 @@ public class FlightViewRenderer { + private static final int HUD_X = 8; + private static final int HUD_Y = 32; + private static final int LINE_HEIGHT = 10; + private static final int BACKGROUND_PADDING = 2; + private static final int ELYTRA_INFO_X_OFFSET = 20; + private static final float BACKGROUND_OPACITY = 0.4F; + + // 速度換算: ブロック/tick から km/h へ (20 tick/秒 × 3.6) + private static final double BLOCKS_PER_TICK_TO_KMH = 20.0D * 3.6D; + + // エリトラ耐久の消耗率しきい値。この割合を超えると警告色で表示する + private static final double ELYTRA_WEAR_CRITICAL = 0.95D; + private static final double ELYTRA_WEAR_WARNING = 0.9D; + + private static final int COLOR_TEXT = ARGB.color(224, 224, 224); + private static final int COLOR_CRITICAL = ARGB.color(224, 64, 64); + private static final int COLOR_WARNING = ARGB.color(224, 128, 64); + public FlightViewRenderer() { HudElementRegistry.addLast(Identifier.fromNamespaceAndPath("flightview", "hud"), (context, tickDelta) -> { Minecraft mc = Minecraft.getInstance(); @@ -30,7 +48,7 @@ public FlightViewRenderer() { return; ItemStack itemstack = player.getItemBySlot(EquipmentSlot.CHEST); - renderFlightInfo(context, 8, 32, player, itemstack); + renderFlightInfo(context, HUD_X, HUD_Y, player, itemstack); }); } @@ -44,14 +62,15 @@ protected List getFlightInfoString(Player player) { float yaw = Mth.wrapDegrees(player.getYRot()); float pitch = Mth.wrapDegrees(player.getXRot()); - stringArray.add(String.format("GS: %.2f(km/h)", groundSpeed * 20.0D * 3.6D)); - stringArray.add(String.format("AS: %.2f(km/h)", airSpeed * 20.0D * 3.6D)); + stringArray.add(String.format("GS: %.2f(km/h)", groundSpeed * BLOCKS_PER_TICK_TO_KMH)); + stringArray.add(String.format("AS: %.2f(km/h)", airSpeed * BLOCKS_PER_TICK_TO_KMH)); stringArray.add(String.format("Y: %.1f P: %.1f", yaw, pitch)); return stringArray; } protected int getElytraLife(ItemStack stack) { + // エリトラは残り耐久が1に達した時点で飛行不能になるため、飛行可能な残量として1を引く return stack.getMaxDamage() - stack.getDamageValue() - 1; } @@ -60,13 +79,12 @@ protected String getElytraInfoString(ItemStack stack) { } protected int getElytraInfoColor(ItemStack stack) { - int color = ARGB.color(224, 224, 224); - double left = (double)stack.getDamageValue() / stack.getMaxDamage(); - if (left > 0.95D) - color = ARGB.color(224, 64, 64); - else if (left > 0.9D) - color = ARGB.color(224, 128, 64); - return color; + double wear = (double) stack.getDamageValue() / stack.getMaxDamage(); + if (wear > ELYTRA_WEAR_CRITICAL) + return COLOR_CRITICAL; + if (wear > ELYTRA_WEAR_WARNING) + return COLOR_WARNING; + return COLOR_TEXT; } protected int renderFlightInfo(GuiGraphicsExtractor drawContext, int x, int y, Player player, ItemStack stack) { @@ -74,22 +92,23 @@ protected int renderFlightInfo(GuiGraphicsExtractor drawContext, int x, int y, P List flightInfoString = getFlightInfoString(player); String elytraInfoString = getElytraInfoString(stack); - int backgroundColor = mc.options.getBackgroundColor(0.4f); + int backgroundColor = mc.options.getBackgroundColor(BACKGROUND_OPACITY); final boolean hasElytra = stack.getItem() == Items.ELYTRA; - final int lineHeight = 10; - final int areaWidth = flightInfoString.stream().map(mc.font::width).max(Integer::compare).get(); - final int areaHeight = lineHeight * flightInfoString.size() + (hasElytra ? (int)(lineHeight * 1.5) : 0); + final int areaWidth = flightInfoString.stream().mapToInt(mc.font::width).max().orElse(0); + final int areaHeight = LINE_HEIGHT * flightInfoString.size() + (hasElytra ? (int)(LINE_HEIGHT * 1.5) : 0); drawContext.pose().pushMatrix(); - drawContext.fill(x - 2, y - 2, x + areaWidth + 2, y + areaHeight + 2, backgroundColor); + drawContext.fill(x - BACKGROUND_PADDING, y - BACKGROUND_PADDING, x + areaWidth + BACKGROUND_PADDING, y + areaHeight + BACKGROUND_PADDING, backgroundColor); - flightInfoString.forEach(s -> drawContext.text(mc.font, s, x, y + lineHeight * flightInfoString.indexOf(s), ARGB.color(224, 224, 224), false)); + for (int i = 0; i < flightInfoString.size(); i++) { + drawContext.text(mc.font, flightInfoString.get(i), x, y + LINE_HEIGHT * i, COLOR_TEXT, false); + } if (hasElytra) { - int px = x + 20; - int py = (int)(y + flightInfoString.size() * lineHeight + lineHeight * 0.5f); + int px = x + ELYTRA_INFO_X_OFFSET; + int py = (int)(y + flightInfoString.size() * LINE_HEIGHT + LINE_HEIGHT * 0.5f); drawContext.text(mc.font, elytraInfoString, px, py, getElytraInfoColor(stack), false); - drawElytraIcon(drawContext, x, y + flightInfoString.size() * lineHeight, stack); + drawElytraIcon(drawContext, x, y + flightInfoString.size() * LINE_HEIGHT, stack); } drawContext.pose().popMatrix(); diff --git a/fabric/src/main/java/net/ironingot/flightview/fabric/WorldRenderLastEventListener.java b/fabric/src/main/java/net/ironingot/flightview/fabric/WorldRenderLastEventListener.java index 4c44048..ab931a9 100644 --- a/fabric/src/main/java/net/ironingot/flightview/fabric/WorldRenderLastEventListener.java +++ b/fabric/src/main/java/net/ironingot/flightview/fabric/WorldRenderLastEventListener.java @@ -6,6 +6,9 @@ import net.minecraft.client.player.LocalPlayer; public class WorldRenderLastEventListener { + // 飛行開始からこの tick 数を超えたら自動でカメラを切り替える + private static final long CAMERA_SWITCH_DELAY_TICKS = 15; + private boolean isLastFlying = false; private CameraType lastCameraType = null; private boolean isCameraChanged = false; @@ -57,7 +60,7 @@ public void endElytraFlying() { public void updateElytraFlying(long ticks) { Minecraft mc = Minecraft.getInstance(); - if (!isCameraChanged && ticks > 15) { + if (!isCameraChanged && ticks > CAMERA_SWITCH_DELAY_TICKS) { if (FlightViewMod.isCameraChange()) { mc.options.setCameraType(CameraType.THIRD_PERSON_BACK); } diff --git a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java index 095f357..a3f45ad 100644 --- a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java +++ b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java @@ -19,6 +19,24 @@ import net.neoforged.neoforge.client.event.RenderGuiEvent; public class FlightViewRenderer { + private static final int HUD_X = 8; + private static final int HUD_Y = 32; + private static final int LINE_HEIGHT = 10; + private static final int BACKGROUND_PADDING = 2; + private static final int ELYTRA_INFO_X_OFFSET = 20; + private static final float BACKGROUND_OPACITY = 0.4F; + + // 速度換算: ブロック/tick から km/h へ (20 tick/秒 × 3.6) + private static final double BLOCKS_PER_TICK_TO_KMH = 20.0D * 3.6D; + + // エリトラ耐久の消耗率しきい値。この割合を超えると警告色で表示する + private static final double ELYTRA_WEAR_CRITICAL = 0.95D; + private static final double ELYTRA_WEAR_WARNING = 0.9D; + + private static final int COLOR_TEXT = ARGB.color(224, 224, 224); + private static final int COLOR_CRITICAL = ARGB.color(224, 64, 64); + private static final int COLOR_WARNING = ARGB.color(224, 128, 64); + public FlightViewRenderer() { NeoForge.EVENT_BUS.addListener(this::onRenderGui); } @@ -35,7 +53,7 @@ public void onRenderGui(RenderGuiEvent.Post event) { return; ItemStack itemstack = player.getItemBySlot(EquipmentSlot.CHEST); - renderFlightInfo(event.getGuiGraphics(), 8, 32, player, itemstack); + renderFlightInfo(event.getGuiGraphics(), HUD_X, HUD_Y, player, itemstack); } protected List getFlightInfoString(Player player) { @@ -48,14 +66,15 @@ protected List getFlightInfoString(Player player) { float yaw = Mth.wrapDegrees(player.getYRot()); float pitch = Mth.wrapDegrees(player.getXRot()); - stringArray.add(String.format("GS: %.2f(km/h)", groundSpeed * 20.0D * 3.6D)); - stringArray.add(String.format("AS: %.2f(km/h)", airSpeed * 20.0D * 3.6D)); + stringArray.add(String.format("GS: %.2f(km/h)", groundSpeed * BLOCKS_PER_TICK_TO_KMH)); + stringArray.add(String.format("AS: %.2f(km/h)", airSpeed * BLOCKS_PER_TICK_TO_KMH)); stringArray.add(String.format("Y: %.1f P: %.1f", yaw, pitch)); return stringArray; } protected int getElytraLife(ItemStack stack) { + // エリトラは残り耐久が1に達した時点で飛行不能になるため、飛行可能な残量として1を引く return stack.getMaxDamage() - stack.getDamageValue() - 1; } @@ -64,13 +83,12 @@ protected String getElytraInfoString(ItemStack stack) { } protected int getElytraInfoColor(ItemStack stack) { - int color = ARGB.color(224, 224, 224); - double left = (double)stack.getDamageValue() / stack.getMaxDamage(); - if (left > 0.95D) - color = ARGB.color(224, 64, 64); - else if (left > 0.9D) - color = ARGB.color(224, 128, 64); - return color; + double wear = (double) stack.getDamageValue() / stack.getMaxDamage(); + if (wear > ELYTRA_WEAR_CRITICAL) + return COLOR_CRITICAL; + if (wear > ELYTRA_WEAR_WARNING) + return COLOR_WARNING; + return COLOR_TEXT; } protected int renderFlightInfo(GuiGraphicsExtractor drawContext, int x, int y, Player player, ItemStack stack) { @@ -78,22 +96,23 @@ protected int renderFlightInfo(GuiGraphicsExtractor drawContext, int x, int y, P List flightInfoString = getFlightInfoString(player); String elytraInfoString = getElytraInfoString(stack); - int backgroundColor = mc.options.getBackgroundColor(0.4f); + int backgroundColor = mc.options.getBackgroundColor(BACKGROUND_OPACITY); final boolean hasElytra = stack.getItem() == Items.ELYTRA; - final int lineHeight = 10; - final int areaWidth = flightInfoString.stream().map(mc.font::width).max(Integer::compare).get(); - final int areaHeight = lineHeight * flightInfoString.size() + (hasElytra ? (int)(lineHeight * 1.5) : 0); + final int areaWidth = flightInfoString.stream().mapToInt(mc.font::width).max().orElse(0); + final int areaHeight = LINE_HEIGHT * flightInfoString.size() + (hasElytra ? (int)(LINE_HEIGHT * 1.5) : 0); drawContext.pose().pushMatrix(); - drawContext.fill(x - 2, y - 2, x + areaWidth + 2, y + areaHeight + 2, backgroundColor); + drawContext.fill(x - BACKGROUND_PADDING, y - BACKGROUND_PADDING, x + areaWidth + BACKGROUND_PADDING, y + areaHeight + BACKGROUND_PADDING, backgroundColor); - flightInfoString.forEach(s -> drawContext.text(mc.font, s, x, y + lineHeight * flightInfoString.indexOf(s), ARGB.color(224, 224, 224), false)); + for (int i = 0; i < flightInfoString.size(); i++) { + drawContext.text(mc.font, flightInfoString.get(i), x, y + LINE_HEIGHT * i, COLOR_TEXT, false); + } if (hasElytra) { - int px = x + 20; - int py = (int)(y + flightInfoString.size() * lineHeight + lineHeight * 0.5f); + int px = x + ELYTRA_INFO_X_OFFSET; + int py = (int)(y + flightInfoString.size() * LINE_HEIGHT + LINE_HEIGHT * 0.5f); drawContext.text(mc.font, elytraInfoString, px, py, getElytraInfoColor(stack), false); - drawElytraIcon(drawContext, x, y + flightInfoString.size() * lineHeight, stack); + drawElytraIcon(drawContext, x, y + flightInfoString.size() * LINE_HEIGHT, stack); } drawContext.pose().popMatrix(); diff --git a/neoforge/src/main/java/net/ironingot/flightview/neoforge/WorldRenderLastEventListener.java b/neoforge/src/main/java/net/ironingot/flightview/neoforge/WorldRenderLastEventListener.java index 9e9dc0e..10f24cd 100644 --- a/neoforge/src/main/java/net/ironingot/flightview/neoforge/WorldRenderLastEventListener.java +++ b/neoforge/src/main/java/net/ironingot/flightview/neoforge/WorldRenderLastEventListener.java @@ -9,6 +9,9 @@ import net.neoforged.neoforge.client.event.RenderLevelStageEvent; public class WorldRenderLastEventListener { + // 飛行開始からこの tick 数を超えたら自動でカメラを切り替える + private static final long CAMERA_SWITCH_DELAY_TICKS = 15; + private boolean isLastFlying = false; private CameraType lastCameraType = null; private boolean isCameraChanged = false; @@ -62,7 +65,7 @@ public void endElytraFlying() { public void updateElytraFlying(long ticks) { Minecraft mc = Minecraft.getInstance(); - if (!isCameraChanged && ticks > 15) { + if (!isCameraChanged && ticks > CAMERA_SWITCH_DELAY_TICKS) { if (FlightViewMod.isCameraChange()) { mc.options.setCameraType(CameraType.THIRD_PERSON_BACK); } From 521a429789e280aef0a4a4081b9f89eccad39834 Mon Sep 17 00:00:00 2001 From: Kenichi Matsushita Date: Wed, 27 May 2026 16:48:40 +0900 Subject: [PATCH 2/5] chore: untrack IDE files and clean .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - neoforge/.eclipse の Eclipse 実行設定(.launch 12ファイル)を追跡から除外 - .gitignore の */.eclipse/ で無視対象だが追跡済みだったため git rm --cached で除外 - .gitignore の実ファイルと矛盾する無意味な記述(CHANGELOG, LICENSE.txt)を削除 Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitignore | 2 -- .../configurations/Neoforge - Client.launch | 12 ------------ .../configurations/Neoforge - Data.launch | 12 ------------ .../Neoforge - GameTestServer.launch | 12 ------------ .../configurations/Neoforge - Server.launch | 12 ------------ .../Prepare Neoforge - Client.launch | 16 ---------------- .../Prepare Neoforge - Data.launch | 16 ---------------- .../Prepare Neoforge - GameTestServer.launch | 16 ---------------- .../Prepare Neoforge - Server.launch | 16 ---------------- .../configurations/Run Neoforge - Client.launch | 13 ------------- .../configurations/Run Neoforge - Data.launch | 13 ------------- .../Run Neoforge - GameTestServer.launch | 13 ------------- .../configurations/Run Neoforge - Server.launch | 13 ------------- 13 files changed, 166 deletions(-) delete mode 100644 neoforge/.eclipse/configurations/Neoforge - Client.launch delete mode 100644 neoforge/.eclipse/configurations/Neoforge - Data.launch delete mode 100644 neoforge/.eclipse/configurations/Neoforge - GameTestServer.launch delete mode 100644 neoforge/.eclipse/configurations/Neoforge - Server.launch delete mode 100644 neoforge/.eclipse/configurations/Prepare Neoforge - Client.launch delete mode 100644 neoforge/.eclipse/configurations/Prepare Neoforge - Data.launch delete mode 100644 neoforge/.eclipse/configurations/Prepare Neoforge - GameTestServer.launch delete mode 100644 neoforge/.eclipse/configurations/Prepare Neoforge - Server.launch delete mode 100644 neoforge/.eclipse/configurations/Run Neoforge - Client.launch delete mode 100644 neoforge/.eclipse/configurations/Run Neoforge - Data.launch delete mode 100644 neoforge/.eclipse/configurations/Run Neoforge - GameTestServer.launch delete mode 100644 neoforge/.eclipse/configurations/Run Neoforge - Server.launch diff --git a/.gitignore b/.gitignore index eaf06a0..5f4b856 100644 --- a/.gitignore +++ b/.gitignore @@ -37,8 +37,6 @@ logs/ runtime/ temp/ reobf/ -CHANGELOG -LICENSE.txt *.sh # Misc diff --git a/neoforge/.eclipse/configurations/Neoforge - Client.launch b/neoforge/.eclipse/configurations/Neoforge - Client.launch deleted file mode 100644 index f8d524b..0000000 --- a/neoforge/.eclipse/configurations/Neoforge - Client.launch +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Neoforge - Data.launch b/neoforge/.eclipse/configurations/Neoforge - Data.launch deleted file mode 100644 index dd08232..0000000 --- a/neoforge/.eclipse/configurations/Neoforge - Data.launch +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Neoforge - GameTestServer.launch b/neoforge/.eclipse/configurations/Neoforge - GameTestServer.launch deleted file mode 100644 index 5941bf0..0000000 --- a/neoforge/.eclipse/configurations/Neoforge - GameTestServer.launch +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Neoforge - Server.launch b/neoforge/.eclipse/configurations/Neoforge - Server.launch deleted file mode 100644 index 1c3ffe8..0000000 --- a/neoforge/.eclipse/configurations/Neoforge - Server.launch +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Prepare Neoforge - Client.launch b/neoforge/.eclipse/configurations/Prepare Neoforge - Client.launch deleted file mode 100644 index a8940f7..0000000 --- a/neoforge/.eclipse/configurations/Prepare Neoforge - Client.launch +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Prepare Neoforge - Data.launch b/neoforge/.eclipse/configurations/Prepare Neoforge - Data.launch deleted file mode 100644 index ed7ba69..0000000 --- a/neoforge/.eclipse/configurations/Prepare Neoforge - Data.launch +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Prepare Neoforge - GameTestServer.launch b/neoforge/.eclipse/configurations/Prepare Neoforge - GameTestServer.launch deleted file mode 100644 index 819e514..0000000 --- a/neoforge/.eclipse/configurations/Prepare Neoforge - GameTestServer.launch +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Prepare Neoforge - Server.launch b/neoforge/.eclipse/configurations/Prepare Neoforge - Server.launch deleted file mode 100644 index bb40a22..0000000 --- a/neoforge/.eclipse/configurations/Prepare Neoforge - Server.launch +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Run Neoforge - Client.launch b/neoforge/.eclipse/configurations/Run Neoforge - Client.launch deleted file mode 100644 index f419de9..0000000 --- a/neoforge/.eclipse/configurations/Run Neoforge - Client.launch +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Run Neoforge - Data.launch b/neoforge/.eclipse/configurations/Run Neoforge - Data.launch deleted file mode 100644 index 7f45a2d..0000000 --- a/neoforge/.eclipse/configurations/Run Neoforge - Data.launch +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Run Neoforge - GameTestServer.launch b/neoforge/.eclipse/configurations/Run Neoforge - GameTestServer.launch deleted file mode 100644 index c4baaa9..0000000 --- a/neoforge/.eclipse/configurations/Run Neoforge - GameTestServer.launch +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/neoforge/.eclipse/configurations/Run Neoforge - Server.launch b/neoforge/.eclipse/configurations/Run Neoforge - Server.launch deleted file mode 100644 index 374faa0..0000000 --- a/neoforge/.eclipse/configurations/Run Neoforge - Server.launch +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file From 4b51ec15852e446204f0ba21fbda706030503d70 Mon Sep 17 00:00:00 2001 From: Kenichi Matsushita Date: Wed, 27 May 2026 17:09:35 +0900 Subject: [PATCH 3/5] refactor: rename flight-info API, drop dead field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getFlightInfoString を返り値(List)に合わせ getFlightInfoLines へ改名 - ローカル変数 stringArray/flightInfoString を lines/flightInfoLines へ改名 - neoforge の new ArrayList() を diamond 演算子に統一 - 未使用フィールド buildId を削除 Co-Authored-By: Claude Opus 4.7 (1M context) --- .../flightview/fabric/FlightViewRenderer.java | 26 +++++++++---------- .../flightview/neoforge/FlightViewMod.java | 1 - .../neoforge/FlightViewRenderer.java | 26 +++++++++---------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java b/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java index e8984d8..4d33814 100644 --- a/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java +++ b/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewRenderer.java @@ -52,8 +52,8 @@ public FlightViewRenderer() { }); } - protected List getFlightInfoString(Player player) { - List stringArray = new ArrayList<>(); + protected List getFlightInfoLines(Player player) { + List lines = new ArrayList<>(); double dx = player.position().x - player.xOld; double dy = player.position().y - player.yOld; double dz = player.position().z - player.zOld; @@ -62,11 +62,11 @@ protected List getFlightInfoString(Player player) { float yaw = Mth.wrapDegrees(player.getYRot()); float pitch = Mth.wrapDegrees(player.getXRot()); - stringArray.add(String.format("GS: %.2f(km/h)", groundSpeed * BLOCKS_PER_TICK_TO_KMH)); - stringArray.add(String.format("AS: %.2f(km/h)", airSpeed * BLOCKS_PER_TICK_TO_KMH)); - stringArray.add(String.format("Y: %.1f P: %.1f", yaw, pitch)); + lines.add(String.format("GS: %.2f(km/h)", groundSpeed * BLOCKS_PER_TICK_TO_KMH)); + lines.add(String.format("AS: %.2f(km/h)", airSpeed * BLOCKS_PER_TICK_TO_KMH)); + lines.add(String.format("Y: %.1f P: %.1f", yaw, pitch)); - return stringArray; + return lines; } protected int getElytraLife(ItemStack stack) { @@ -89,26 +89,26 @@ protected int getElytraInfoColor(ItemStack stack) { protected int renderFlightInfo(GuiGraphicsExtractor drawContext, int x, int y, Player player, ItemStack stack) { Minecraft mc = Minecraft.getInstance(); - List flightInfoString = getFlightInfoString(player); + List flightInfoLines = getFlightInfoLines(player); String elytraInfoString = getElytraInfoString(stack); int backgroundColor = mc.options.getBackgroundColor(BACKGROUND_OPACITY); final boolean hasElytra = stack.getItem() == Items.ELYTRA; - final int areaWidth = flightInfoString.stream().mapToInt(mc.font::width).max().orElse(0); - final int areaHeight = LINE_HEIGHT * flightInfoString.size() + (hasElytra ? (int)(LINE_HEIGHT * 1.5) : 0); + final int areaWidth = flightInfoLines.stream().mapToInt(mc.font::width).max().orElse(0); + final int areaHeight = LINE_HEIGHT * flightInfoLines.size() + (hasElytra ? (int)(LINE_HEIGHT * 1.5) : 0); drawContext.pose().pushMatrix(); drawContext.fill(x - BACKGROUND_PADDING, y - BACKGROUND_PADDING, x + areaWidth + BACKGROUND_PADDING, y + areaHeight + BACKGROUND_PADDING, backgroundColor); - for (int i = 0; i < flightInfoString.size(); i++) { - drawContext.text(mc.font, flightInfoString.get(i), x, y + LINE_HEIGHT * i, COLOR_TEXT, false); + for (int i = 0; i < flightInfoLines.size(); i++) { + drawContext.text(mc.font, flightInfoLines.get(i), x, y + LINE_HEIGHT * i, COLOR_TEXT, false); } if (hasElytra) { int px = x + ELYTRA_INFO_X_OFFSET; - int py = (int)(y + flightInfoString.size() * LINE_HEIGHT + LINE_HEIGHT * 0.5f); + int py = (int)(y + flightInfoLines.size() * LINE_HEIGHT + LINE_HEIGHT * 0.5f); drawContext.text(mc.font, elytraInfoString, px, py, getElytraInfoColor(stack), false); - drawElytraIcon(drawContext, x, y + flightInfoString.size() * LINE_HEIGHT, stack); + drawElytraIcon(drawContext, x, y + flightInfoLines.size() * LINE_HEIGHT, stack); } drawContext.pose().popMatrix(); diff --git a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java index 3798548..3a66e8a 100644 --- a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java +++ b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java @@ -27,7 +27,6 @@ public class FlightViewMod { public static final Logger logger = LogManager.getLogger(); public static final String modId = "flightview"; - public static final String buildId = "2019-6"; public static String modVersion; public static final KeyMapping.Category KEYBINDING_CATEGORY = new KeyMapping.Category( diff --git a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java index a3f45ad..791bac1 100644 --- a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java +++ b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewRenderer.java @@ -56,8 +56,8 @@ public void onRenderGui(RenderGuiEvent.Post event) { renderFlightInfo(event.getGuiGraphics(), HUD_X, HUD_Y, player, itemstack); } - protected List getFlightInfoString(Player player) { - List stringArray = new ArrayList(); + protected List getFlightInfoLines(Player player) { + List lines = new ArrayList<>(); double dx = player.position().x - player.xOld; double dy = player.position().y - player.yOld; double dz = player.position().z - player.zOld; @@ -66,11 +66,11 @@ protected List getFlightInfoString(Player player) { float yaw = Mth.wrapDegrees(player.getYRot()); float pitch = Mth.wrapDegrees(player.getXRot()); - stringArray.add(String.format("GS: %.2f(km/h)", groundSpeed * BLOCKS_PER_TICK_TO_KMH)); - stringArray.add(String.format("AS: %.2f(km/h)", airSpeed * BLOCKS_PER_TICK_TO_KMH)); - stringArray.add(String.format("Y: %.1f P: %.1f", yaw, pitch)); + lines.add(String.format("GS: %.2f(km/h)", groundSpeed * BLOCKS_PER_TICK_TO_KMH)); + lines.add(String.format("AS: %.2f(km/h)", airSpeed * BLOCKS_PER_TICK_TO_KMH)); + lines.add(String.format("Y: %.1f P: %.1f", yaw, pitch)); - return stringArray; + return lines; } protected int getElytraLife(ItemStack stack) { @@ -93,26 +93,26 @@ protected int getElytraInfoColor(ItemStack stack) { protected int renderFlightInfo(GuiGraphicsExtractor drawContext, int x, int y, Player player, ItemStack stack) { Minecraft mc = Minecraft.getInstance(); - List flightInfoString = getFlightInfoString(player); + List flightInfoLines = getFlightInfoLines(player); String elytraInfoString = getElytraInfoString(stack); int backgroundColor = mc.options.getBackgroundColor(BACKGROUND_OPACITY); final boolean hasElytra = stack.getItem() == Items.ELYTRA; - final int areaWidth = flightInfoString.stream().mapToInt(mc.font::width).max().orElse(0); - final int areaHeight = LINE_HEIGHT * flightInfoString.size() + (hasElytra ? (int)(LINE_HEIGHT * 1.5) : 0); + final int areaWidth = flightInfoLines.stream().mapToInt(mc.font::width).max().orElse(0); + final int areaHeight = LINE_HEIGHT * flightInfoLines.size() + (hasElytra ? (int)(LINE_HEIGHT * 1.5) : 0); drawContext.pose().pushMatrix(); drawContext.fill(x - BACKGROUND_PADDING, y - BACKGROUND_PADDING, x + areaWidth + BACKGROUND_PADDING, y + areaHeight + BACKGROUND_PADDING, backgroundColor); - for (int i = 0; i < flightInfoString.size(); i++) { - drawContext.text(mc.font, flightInfoString.get(i), x, y + LINE_HEIGHT * i, COLOR_TEXT, false); + for (int i = 0; i < flightInfoLines.size(); i++) { + drawContext.text(mc.font, flightInfoLines.get(i), x, y + LINE_HEIGHT * i, COLOR_TEXT, false); } if (hasElytra) { int px = x + ELYTRA_INFO_X_OFFSET; - int py = (int)(y + flightInfoString.size() * LINE_HEIGHT + LINE_HEIGHT * 0.5f); + int py = (int)(y + flightInfoLines.size() * LINE_HEIGHT + LINE_HEIGHT * 0.5f); drawContext.text(mc.font, elytraInfoString, px, py, getElytraInfoColor(stack), false); - drawElytraIcon(drawContext, x, y + flightInfoString.size() * LINE_HEIGHT, stack); + drawElytraIcon(drawContext, x, y + flightInfoLines.size() * LINE_HEIGHT, stack); } drawContext.pose().popMatrix(); From a3bd942b866533220fe717fb61c16b650696c443 Mon Sep 17 00:00:00 2001 From: Kenichi Matsushita Date: Wed, 27 May 2026 17:20:35 +0900 Subject: [PATCH 4/5] refactor: rename listener to ElytraFlightTracker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - WorldRenderLastEventListener を実態(エリトラ飛行監視とカメラ切替)に合わせ ElytraFlightTracker へ改名 - fabric/neoforge 両方のクラス名・ファイル名・参照箇所を更新 Co-Authored-By: Claude Opus 4.7 (1M context) --- ...dRenderLastEventListener.java => ElytraFlightTracker.java} | 4 ++-- .../java/net/ironingot/flightview/fabric/FlightViewMod.java | 2 +- ...dRenderLastEventListener.java => ElytraFlightTracker.java} | 4 ++-- .../java/net/ironingot/flightview/neoforge/FlightViewMod.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename fabric/src/main/java/net/ironingot/flightview/fabric/{WorldRenderLastEventListener.java => ElytraFlightTracker.java} (95%) rename neoforge/src/main/java/net/ironingot/flightview/neoforge/{WorldRenderLastEventListener.java => ElytraFlightTracker.java} (96%) diff --git a/fabric/src/main/java/net/ironingot/flightview/fabric/WorldRenderLastEventListener.java b/fabric/src/main/java/net/ironingot/flightview/fabric/ElytraFlightTracker.java similarity index 95% rename from fabric/src/main/java/net/ironingot/flightview/fabric/WorldRenderLastEventListener.java rename to fabric/src/main/java/net/ironingot/flightview/fabric/ElytraFlightTracker.java index ab931a9..1cd0b00 100644 --- a/fabric/src/main/java/net/ironingot/flightview/fabric/WorldRenderLastEventListener.java +++ b/fabric/src/main/java/net/ironingot/flightview/fabric/ElytraFlightTracker.java @@ -5,7 +5,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; -public class WorldRenderLastEventListener { +public class ElytraFlightTracker { // 飛行開始からこの tick 数を超えたら自動でカメラを切り替える private static final long CAMERA_SWITCH_DELAY_TICKS = 15; @@ -13,7 +13,7 @@ public class WorldRenderLastEventListener { private CameraType lastCameraType = null; private boolean isCameraChanged = false; - public WorldRenderLastEventListener() { + public ElytraFlightTracker() { ClientTickEvents.END_CLIENT_TICK.register(this::onWorldRenderLast); } diff --git a/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewMod.java b/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewMod.java index d9e4c3d..943fe37 100644 --- a/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewMod.java +++ b/fabric/src/main/java/net/ironingot/flightview/fabric/FlightViewMod.java @@ -33,7 +33,7 @@ public void onInitializeClient() { } }); - new WorldRenderLastEventListener(); + new ElytraFlightTracker(); new FlightViewRenderer(); } diff --git a/neoforge/src/main/java/net/ironingot/flightview/neoforge/WorldRenderLastEventListener.java b/neoforge/src/main/java/net/ironingot/flightview/neoforge/ElytraFlightTracker.java similarity index 96% rename from neoforge/src/main/java/net/ironingot/flightview/neoforge/WorldRenderLastEventListener.java rename to neoforge/src/main/java/net/ironingot/flightview/neoforge/ElytraFlightTracker.java index 10f24cd..c7988e3 100644 --- a/neoforge/src/main/java/net/ironingot/flightview/neoforge/WorldRenderLastEventListener.java +++ b/neoforge/src/main/java/net/ironingot/flightview/neoforge/ElytraFlightTracker.java @@ -8,7 +8,7 @@ import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.client.event.RenderLevelStageEvent; -public class WorldRenderLastEventListener { +public class ElytraFlightTracker { // 飛行開始からこの tick 数を超えたら自動でカメラを切り替える private static final long CAMERA_SWITCH_DELAY_TICKS = 15; @@ -16,7 +16,7 @@ public class WorldRenderLastEventListener { private CameraType lastCameraType = null; private boolean isCameraChanged = false; - public WorldRenderLastEventListener() { + public ElytraFlightTracker() { NeoForge.EVENT_BUS.addListener(this::onRenderLevelStage); } diff --git a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java index 3a66e8a..5ba60d1 100644 --- a/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java +++ b/neoforge/src/main/java/net/ironingot/flightview/neoforge/FlightViewMod.java @@ -52,7 +52,7 @@ public FlightViewMod(IEventBus modBus, ModContainer modContainer) { @OnlyIn(Dist.CLIENT) public void onClientSetup(FMLClientSetupEvent event) { - new WorldRenderLastEventListener(); + new ElytraFlightTracker(); new FlightViewRenderer(); logger.info("[FlightView] Initialized."); } From dee2eed4775b5f4f9288f60f143afd093510941b Mon Sep 17 00:00:00 2001 From: Kenichi Matsushita Date: Wed, 27 May 2026 17:26:13 +0900 Subject: [PATCH 5/5] docs: rewrite README and drop stale CHANGELOG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - README に機能・操作(Vキー3モード)・技術スタック・ビルド手順・構成を記載 - 対応バージョンは変動するため gradle.properties 参照とし、ビルド状態はCIバッジで表示 - 古い CHANGELOG.md を削除し、変更履歴は GitHub Release(CI生成)へ一本化 Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 17 ----------------- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 19 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index b583155..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,17 +0,0 @@ -# Changelog - -## [1.21.1-1.4] - 2024-08-20 - -- minecraft 1.21.1 (fabric, neoforge) - -## [1.19-1.3] - 2022-06-21 - -- minecraft 1.19 - -## [1.18.1-1.2] - 2022-01-05 - -- minecraft 1.18.1 - -## [1.17.1-1.0] - 2021-08-17 - -- Port to fabric diff --git a/README.md b/README.md index cf626fb..ab64e63 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,49 @@ -FlightView -========== +# FlightView + +[![Build](https://github.com/fubira/FlightView/actions/workflows/build.yml/badge.svg)](https://github.com/fubira/FlightView/actions/workflows/build.yml) + +Minecraft client mod that displays elytra flight information. Available for both Fabric and NeoForge. + +## Features + +- **Flight HUD** — ground speed (GS) and air speed (AS) in km/h, plus yaw and pitch +- **Elytra durability** — remaining durability, colored as it wears down +- **Auto camera** — switches to third-person back view while flying, restores the previous view on landing + +## Controls + +Press **V** to cycle through modes: + +| Mode | Behavior | +|------|----------| +| 0 | Disabled | +| 1 | HUD only | +| 2 | HUD + auto camera | + +## Tech stack + +Java 25, Gradle. Fabric Loom for the Fabric module and NeoForge ModDev for the NeoForge module. Settings persist through Cloth Config (Fabric) and the NeoForge config spec (NeoForge). + +## Requirements + +Minecraft and mod-loader versions are defined in [`gradle.properties`](gradle.properties). + +## Build + +```sh +./gradlew build +``` + +Combined artifacts are written to `build/libs/`. + +## Structure + +| Module | Contents | +|--------|----------| +| `common` | Shared resources (language files) | +| `fabric` | Fabric implementation | +| `neoforge` | NeoForge implementation | + +## License + +[MIT](LICENSE.md) © fubira