From 34667e0555165c8dae1dbd51eaaa5639f2717f66 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Mon, 30 Dec 2024 15:14:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=8B=E8=BD=AC=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/screens/FuMO25Screen.java | 33 +++++++++++++++++-- .../client/screens/FuMO25ScreenHelper.java | 9 ++--- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25Screen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25Screen.java index 5879fc839..ae15241b5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25Screen.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25Screen.java @@ -5,10 +5,14 @@ import com.atsuishio.superbwarfare.block.entity.FuMO25BlockEntity; import com.atsuishio.superbwarfare.menu.FuMO25Menu; import com.atsuishio.superbwarfare.network.message.RadarChangeModeMessage; import com.atsuishio.superbwarfare.network.message.RadarSetParametersMessage; +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.math.Axis; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; @@ -37,6 +41,9 @@ public class FuMO25Screen extends AbstractContainerScreen { int j = (this.height - this.imageHeight) / 2; pGuiGraphics.blit(TEXTURE, i, j, 0, 0, this.imageWidth, this.imageHeight, 358, 328); + // 目标位置 + renderTargets(pGuiGraphics, pPartialTick); + // 扫描盘 renderScan(pGuiGraphics, pPartialTick); @@ -49,13 +56,33 @@ public class FuMO25Screen extends AbstractContainerScreen { pGuiGraphics.blit(TEXTURE, i + 278, j + 39, 178, 167, (int) (54 * energyRate), 16, 358, 328); } + private void renderTargets(GuiGraphics guiGraphics, float partialTick) { + var entities = FuMO25ScreenHelper.entities; + if (entities == null || entities.isEmpty()) return; + + guiGraphics.drawString(this.font, Component.literal("Entity Count: " + entities.size()), 12, 10, 0xffffff, false); + } + private void renderScan(GuiGraphics guiGraphics, float partialTick) { if (FuMO25Screen.this.menu.getEnergy() <= 0) return; - var entities = FuMO25ScreenHelper.entities; - if (entities.isEmpty()) return; + var poseStack = guiGraphics.pose(); + poseStack.pushPose(); - guiGraphics.drawString(this.font, Component.literal("Entity Count: " + entities.size()), 12, 10, 0xffffff, false); + RenderSystem.disableDepthTest(); + RenderSystem.depthMask(false); + RenderSystem.enableBlend(); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + + int i = (this.width - this.imageWidth) / 2; + int j = (this.height - this.imageHeight) / 2; + + poseStack.rotateAround(Axis.ZP.rotationDegrees(System.currentTimeMillis() % 36000000 / 30f), i + 9 + 145 / 2f, j + 12 + 145 / 2f, 0); + + guiGraphics.blit(SCAN, i + 9, j + 12, 0, 0, 145, 145, 145, 145); + + poseStack.popPose(); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25ScreenHelper.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25ScreenHelper.java index e5431dddf..1a74f11a8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25ScreenHelper.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25ScreenHelper.java @@ -13,14 +13,13 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.common.Mod; -import java.util.ArrayList; import java.util.List; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class FuMO25ScreenHelper { public static BlockPos pos = null; - public static List entities = new ArrayList<>(); + public static List entities = null; @SubscribeEvent public static void onClientTick(TickEvent.ClientTickEvent event) { @@ -33,9 +32,7 @@ public class FuMO25ScreenHelper { if (pos == null) return; if (fuMO25Menu.getEnergy() <= 0) { - if (entities != null) { - entities.clear(); - } + resetEntities(); return; } @@ -45,7 +42,7 @@ public class FuMO25ScreenHelper { public static void resetEntities() { if (entities != null) { - entities.clear(); + entities = null; } } }