diff --git a/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java b/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java index e7a637fd2..9b2526079 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java +++ b/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java @@ -3,12 +3,14 @@ package net.mcreator.superbwarfare.client.screens; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.config.client.DisplayConfig; import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModItems; import net.mcreator.superbwarfare.init.ModTags; import net.minecraft.client.CameraType; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -26,6 +28,9 @@ import static net.mcreator.superbwarfare.tools.RenderTool.preciseBlit; @Mod.EventBusSubscriber(value = Dist.CLIENT) public class CrossHairOverlay { + private static final ResourceLocation REX_HORIZONTAL = new ResourceLocation(ModUtils.MODID, "textures/screens/rex_horizontal.png"); + private static final ResourceLocation REX_VERTICAL = new ResourceLocation(ModUtils.MODID, "textures/screens/rex_vertical.png"); + public static int HIT_INDICATOR = 0; public static int HEAD_INDICATOR = 0; public static int KILL_INDICATOR = 0; @@ -35,15 +40,19 @@ public class CrossHairOverlay { public static void eventHandler(RenderGuiEvent.Pre event) { int w = event.getWindow().getGuiScaledWidth(); int h = event.getWindow().getGuiScaledHeight(); + Player player = Minecraft.getInstance().player; if (player == null) { return; } + + GuiGraphics guiGraphics = event.getGuiGraphics(); + ItemStack stack = player.getMainHandItem(); double spread = ClientEventHandler.gunSpread + 3 * ClientEventHandler.firePos; float deltaFrame = Minecraft.getInstance().getDeltaFrameTime(); float moveX = (float) (-6 * ClientEventHandler.turnRot[1] - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosX); - float moveY = (float) (-6 * ClientEventHandler.turnRot[0] + 6 * (float)ClientEventHandler.velocityY - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosY - 2 * ClientEventHandler.firePos); + float moveY = (float) (-6 * ClientEventHandler.turnRot[0] + 6 * (float) ClientEventHandler.velocityY - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosY - 2 * ClientEventHandler.firePos); RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); @@ -53,61 +62,46 @@ public class CrossHairOverlay { RenderSystem.setShaderColor(1, 1, 1, 1); scopeScale = (float) Mth.lerp(0.5F * deltaFrame, scopeScale, 1 + 1.5f * spread); - float f = (float)Math.min(w, h); - float f1 = Math.min((float)w / f, (float)h / f) * 0.012f * scopeScale; + float f = (float) Math.min(w, h); + float f1 = Math.min((float) w / f, (float) h / f) * 0.012f * scopeScale; float i = Mth.floor(f * f1); float j = Mth.floor(f * f1); float k = ((w - i) / 2) + moveX; float l = ((h - j) / 2) + moveY; if (shouldRenderCrossHair(player) || stack.is(ModItems.MINIGUN.get())) { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/point.png"), w / 2f - 7.5f + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/point.png"), w / 2f - 7.5f + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); if (!player.isSprinting() || player.getPersistentData().getDouble("noRun") > 0) { if (stack.is(ModTags.Items.SHOTGUN)) { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), k, l, 0, 0.0F, i, j, i, j); + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), k, l, 0, 0.0F, i, j, i, j); } else { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), (float) (w / 2f - 13.5f - 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), (float) (w / 2f - 2.5f + 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f + moveX, (float) (h / 2f - 2.5f + 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f + moveX, (float) (h / 2f - 13.5f - 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 13.5f - 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 2.5f + 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_VERTICAL, w / 2f - 7.5f + moveX, (float) (h / 2f - 2.5f + 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_VERTICAL, w / 2f - 7.5f + moveX, (float) (h / 2f - 13.5f - 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); } } } if (stack.is(ModItems.BOCEK.get())) { - if (stack.getOrCreateTag().getBoolean("HoloHidden")) { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/point.png"), w / 2f - 7.5f + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/point.png"), w / 2f - 7.5f + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); if (!player.isSprinting() || player.getPersistentData().getDouble("noRun") > 0 || ClientEventHandler.pullPos > 0) { if (ClientEventHandler.zoomTime < 0.1) { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), k, l, 0, 0.0F, i, j, i, j); + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), k, l, 0, 0.0F, i, j, i, j); } else { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), (float) (w / 2f - 13.5f - 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), (float) (w / 2f - 2.5f + 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f + moveX, (float) (h / 2f - 2.5f + 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f + moveX, (float) (h / 2f - 13.5f - 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 13.5f - 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 2.5f + 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_VERTICAL, w / 2f - 7.5f + moveX, (float) (h / 2f - 2.5f + 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, REX_VERTICAL, w / 2f - 7.5f + moveX, (float) (h / 2f - 13.5f - 2.8f * spread) + moveY, 0, 0, 16, 16, 16, 16); } } } } - float ww = w / 2f - 7.5f + (float) (2 * (Math.random() - 0.5f)); - float hh = h / 2f - 7.5f + (float) (2 * (Math.random() - 0.5f)); - float m = (40 - KILL_INDICATOR * 5) / 5.5f; - - if (HIT_INDICATOR > 0) { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/hit_marker.png"), ww + moveX, hh + moveY, 0, 0, 16, 16, 16, 16); - } - - if (HEAD_INDICATOR > 0) { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/headshotmark.png"), ww + moveX, hh + moveY, 0, 0, 16, 16, 16, 16); - } - - if (KILL_INDICATOR > 0) { - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark1.png"), w / 2f - 7.5f - 2 + m + moveX, h / 2f - 7.5f - 2 + m + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark2.png"), w / 2f - 7.5f + 2 - m + moveX, h / 2f - 7.5f - 2 + m + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark3.png"), w / 2f - 7.5f - 2 + m + moveX, h / 2f - 7.5f + 2 - m + moveY, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark4.png"), w / 2f - 7.5f + 2 - m + moveX, h / 2f - 7.5f + 2 - m + moveY, 0, 0, 16, 16, 16, 16); + // 在开启伤害指示器时才进行渲染 + if (DisplayConfig.KILL_INDICATION.get()) { + renderKillIndicator(guiGraphics, w, h, moveX, moveY); } RenderSystem.depthMask(true); @@ -122,7 +116,7 @@ public class CrossHairOverlay { Font font = Minecraft.getInstance().font; Component component = Component.translatable("des.superbwarfare.need_bolt_action"); - event.getGuiGraphics().drawString(font, component, w / 2 - font.width(component) / 2, h / 2 + 50, 0xFF6969); + guiGraphics.drawString(font, component, w / 2 - font.width(component) / 2, h / 2 + 50, 0xFF6969); } } @@ -138,6 +132,32 @@ public class CrossHairOverlay { && Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON; } + private static void renderKillIndicator(GuiGraphics guiGraphics, int w, int h, float moveX, float moveY) { + float posX = w / 2f - 7.5f + (float) (2 * (Math.random() - 0.5f)); + float posY = h / 2f - 7.5f + (float) (2 * (Math.random() - 0.5f)); + float rate = (40 - KILL_INDICATOR * 5) / 5.5f; + + if (HIT_INDICATOR > 0) { + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/hit_marker.png"), posX + moveX, posY + moveY, 0, 0, 16, 16, 16, 16); + } + + if (HEAD_INDICATOR > 0) { + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/headshot_mark.png"), posX + moveX, posY + moveY, 0, 0, 16, 16, 16, 16); + } + + if (KILL_INDICATOR > 0) { + float posX1 = w / 2f - 7.5f - 2 + rate + moveX; + float posY1 = h / 2f - 7.5f - 2 + rate + moveY; + float posX2 = w / 2f - 7.5f + 2 - rate + moveX; + float posY2 = h / 2f - 7.5f + 2 - rate + moveY; + + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark1.png"), posX1, posY1, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark2.png"), posX2, posY1, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark3.png"), posX1, posY2, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/kill_mark4.png"), posX2, posY2, 0, 0, 16, 16, 16, 16); + } + } + @SubscribeEvent public static void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.END) { diff --git a/src/main/java/net/mcreator/superbwarfare/client/screens/KillMessageOverlay.java b/src/main/java/net/mcreator/superbwarfare/client/screens/KillMessageOverlay.java index ae409fd33..4ec383a3b 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/screens/KillMessageOverlay.java +++ b/src/main/java/net/mcreator/superbwarfare/client/screens/KillMessageOverlay.java @@ -3,7 +3,7 @@ package net.mcreator.superbwarfare.client.screens; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.mcreator.superbwarfare.ModUtils; -import net.mcreator.superbwarfare.config.client.KillMessageClientConfig; +import net.mcreator.superbwarfare.config.client.KillMessageConfig; import net.mcreator.superbwarfare.event.KillMessageHandler; import net.mcreator.superbwarfare.init.ModDamageTypes; import net.mcreator.superbwarfare.init.ModItems; @@ -46,7 +46,7 @@ public class KillMessageOverlay { @SubscribeEvent(priority = EventPriority.NORMAL) public static void onRenderGui(RenderGuiEvent.Pre event) { - if (!KillMessageClientConfig.SHOW_KILL_MESSAGE.get()) { + if (!KillMessageConfig.SHOW_KILL_MESSAGE.get()) { return; } diff --git a/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/ClothConfigHelper.java b/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/ClothConfigHelper.java index 482e55c67..2679fd43f 100644 --- a/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/ClothConfigHelper.java +++ b/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/ClothConfigHelper.java @@ -2,7 +2,8 @@ package net.mcreator.superbwarfare.compat.clothconfig; import me.shedaniel.clothconfig2.api.ConfigBuilder; import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; -import net.mcreator.superbwarfare.compat.clothconfig.client.KillMessageClientClothConfig; +import net.mcreator.superbwarfare.compat.clothconfig.client.DisplayClothConfig; +import net.mcreator.superbwarfare.compat.clothconfig.client.KillMessageClothConfig; import net.mcreator.superbwarfare.compat.clothconfig.client.ReloadClothConfig; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -19,7 +20,8 @@ public class ClothConfigHelper { ConfigEntryBuilder entryBuilder = root.entryBuilder(); ReloadClothConfig.init(root, entryBuilder); - KillMessageClientClothConfig.init(root, entryBuilder); + KillMessageClothConfig.init(root, entryBuilder); + DisplayClothConfig.init(root, entryBuilder); return root; } diff --git a/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/DisplayClothConfig.java b/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/DisplayClothConfig.java new file mode 100644 index 000000000..7ee68e7b4 --- /dev/null +++ b/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/DisplayClothConfig.java @@ -0,0 +1,31 @@ +package net.mcreator.superbwarfare.compat.clothconfig.client; + +import me.shedaniel.clothconfig2.api.ConfigBuilder; +import me.shedaniel.clothconfig2.api.ConfigCategory; +import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; +import net.mcreator.superbwarfare.config.client.DisplayConfig; +import net.mcreator.superbwarfare.config.client.KillMessageConfig; +import net.minecraft.network.chat.Component; + +public class DisplayClothConfig { + + public static void init(ConfigBuilder root, ConfigEntryBuilder entryBuilder) { + ConfigCategory category = root.getOrCreateCategory(Component.translatable("config.superbwarfare.client.display")); + + category.addEntry(entryBuilder + .startBooleanToggle(Component.translatable("config.superbwarfare.client.display.kill_indication"), DisplayConfig.KILL_INDICATION.get()) + .setDefaultValue(true) + .setSaveConsumer(DisplayConfig.KILL_INDICATION::set) + .setTooltip(Component.translatable("config.superbwarfare.client.display.kill_indication.des")) + .build() + ); + + category.addEntry(entryBuilder + .startBooleanToggle(Component.translatable("config.superbwarfare.client.display.global_indication"), DisplayConfig.GLOBAL_INDICATION.get()) + .setDefaultValue(false) + .setSaveConsumer(DisplayConfig.GLOBAL_INDICATION::set) + .setTooltip(Component.translatable("config.superbwarfare.client.display.global_indication.des")) + .build() + ); + } +} diff --git a/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/KillMessageClientClothConfig.java b/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/KillMessageClothConfig.java similarity index 77% rename from src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/KillMessageClientClothConfig.java rename to src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/KillMessageClothConfig.java index 93013e62d..a1d10c1a3 100644 --- a/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/KillMessageClientClothConfig.java +++ b/src/main/java/net/mcreator/superbwarfare/compat/clothconfig/client/KillMessageClothConfig.java @@ -3,28 +3,28 @@ package net.mcreator.superbwarfare.compat.clothconfig.client; import me.shedaniel.clothconfig2.api.ConfigBuilder; import me.shedaniel.clothconfig2.api.ConfigCategory; import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; -import net.mcreator.superbwarfare.config.client.KillMessageClientConfig; +import net.mcreator.superbwarfare.config.client.KillMessageConfig; import net.minecraft.network.chat.Component; -public class KillMessageClientClothConfig { +public class KillMessageClothConfig { public static void init(ConfigBuilder root, ConfigEntryBuilder entryBuilder) { ConfigCategory category = root.getOrCreateCategory(Component.translatable("config.superbwarfare.client.kill_message")); category.addEntry(entryBuilder - .startBooleanToggle(Component.translatable("config.superbwarfare.client.kill_message.show_kill_message"), KillMessageClientConfig.SHOW_KILL_MESSAGE.get()) + .startBooleanToggle(Component.translatable("config.superbwarfare.client.kill_message.show_kill_message"), KillMessageConfig.SHOW_KILL_MESSAGE.get()) .setDefaultValue(false) - .setSaveConsumer(KillMessageClientConfig.SHOW_KILL_MESSAGE::set) + .setSaveConsumer(KillMessageConfig.SHOW_KILL_MESSAGE::set) .setTooltip(Component.translatable("config.superbwarfare.client.kill_message.show_kill_message.des")) .build() ); category.addEntry(entryBuilder - .startIntField(Component.translatable("config.superbwarfare.client.kill_message.kill_message_count"), KillMessageClientConfig.KILL_MESSAGE_COUNT.get()) + .startIntField(Component.translatable("config.superbwarfare.client.kill_message.kill_message_count"), KillMessageConfig.KILL_MESSAGE_COUNT.get()) .setDefaultValue(5) .setMin(1) .setMax(20) - .setSaveConsumer(KillMessageClientConfig.KILL_MESSAGE_COUNT::set) + .setSaveConsumer(KillMessageConfig.KILL_MESSAGE_COUNT::set) .setTooltip(Component.translatable("config.superbwarfare.client.kill_message.kill_message_count.des")) .build() ); diff --git a/src/main/java/net/mcreator/superbwarfare/config/ClientConfig.java b/src/main/java/net/mcreator/superbwarfare/config/ClientConfig.java index 260584efc..dbdc7a327 100644 --- a/src/main/java/net/mcreator/superbwarfare/config/ClientConfig.java +++ b/src/main/java/net/mcreator/superbwarfare/config/ClientConfig.java @@ -1,7 +1,8 @@ package net.mcreator.superbwarfare.config; +import net.mcreator.superbwarfare.config.client.DisplayConfig; import net.mcreator.superbwarfare.config.client.ReloadConfig; -import net.mcreator.superbwarfare.config.client.KillMessageClientConfig; +import net.mcreator.superbwarfare.config.client.KillMessageConfig; import net.minecraftforge.common.ForgeConfigSpec; public class ClientConfig { @@ -10,7 +11,8 @@ public class ClientConfig { ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); ReloadConfig.init(builder); - KillMessageClientConfig.init(builder); + KillMessageConfig.init(builder); + DisplayConfig.init(builder); return builder.build(); } diff --git a/src/main/java/net/mcreator/superbwarfare/config/client/DisplayConfig.java b/src/main/java/net/mcreator/superbwarfare/config/client/DisplayConfig.java new file mode 100644 index 000000000..dc69c806f --- /dev/null +++ b/src/main/java/net/mcreator/superbwarfare/config/client/DisplayConfig.java @@ -0,0 +1,21 @@ +package net.mcreator.superbwarfare.config.client; + +import net.minecraftforge.common.ForgeConfigSpec; + +public class DisplayConfig { + + public static ForgeConfigSpec.BooleanValue KILL_INDICATION; + public static ForgeConfigSpec.BooleanValue GLOBAL_INDICATION; + + public static void init(ForgeConfigSpec.Builder builder) { + builder.push("display"); + + builder.comment("Set TRUE if you want to show kill indication while killing an entity"); + KILL_INDICATION = builder.define("kill_indication", true); + + builder.comment("Set FALSE if you want to show kill indication ONLY while killing an entity with a gun"); + GLOBAL_INDICATION = builder.define("global_indication", false); + + builder.pop(); + } +} diff --git a/src/main/java/net/mcreator/superbwarfare/config/client/KillMessageClientConfig.java b/src/main/java/net/mcreator/superbwarfare/config/client/KillMessageConfig.java similarity index 94% rename from src/main/java/net/mcreator/superbwarfare/config/client/KillMessageClientConfig.java rename to src/main/java/net/mcreator/superbwarfare/config/client/KillMessageConfig.java index 36e6386ab..6acc7da47 100644 --- a/src/main/java/net/mcreator/superbwarfare/config/client/KillMessageClientConfig.java +++ b/src/main/java/net/mcreator/superbwarfare/config/client/KillMessageConfig.java @@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.config.client; import net.minecraftforge.common.ForgeConfigSpec; -public class KillMessageClientConfig { +public class KillMessageConfig { public static ForgeConfigSpec.BooleanValue SHOW_KILL_MESSAGE; public static ForgeConfigSpec.IntValue KILL_MESSAGE_COUNT; diff --git a/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java index b211892d8..ba234e80f 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.event; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.config.client.DisplayConfig; import net.mcreator.superbwarfare.entity.TargetEntity; import net.mcreator.superbwarfare.entity.projectile.ProjectileEntity; import net.mcreator.superbwarfare.init.*; @@ -52,7 +53,7 @@ public class LivingEventHandler { return; } - killIndication(event.getSource().getEntity()); + killIndication(event.getSource()); handleGunPerksWhenDeath(event); handlePlayerKillEntity(event); } @@ -107,11 +108,17 @@ public class LivingEventHandler { return amount / (1 + rate * Math.max(0, distance - minDistance)); } - private static void killIndication(Entity sourceEntity) { + private static void killIndication(DamageSource source) { + var sourceEntity = source.getEntity(); if (sourceEntity == null) { return; } + // 如果配置不选择全局伤害提示,则只在伤害类型为mod添加的时显示指示器 + if (!DisplayConfig.GLOBAL_INDICATION.get() && !DamageTypeTool.isModDamage(source)) { + return; + } + if (!sourceEntity.level().isClientSide() && sourceEntity instanceof ServerPlayer player) { SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 100f, 1f); diff --git a/src/main/java/net/mcreator/superbwarfare/network/ClientPacketHandler.java b/src/main/java/net/mcreator/superbwarfare/network/ClientPacketHandler.java index be3ee8800..9a308aa1a 100644 --- a/src/main/java/net/mcreator/superbwarfare/network/ClientPacketHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/network/ClientPacketHandler.java @@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.network; import net.mcreator.superbwarfare.client.screens.CrossHairOverlay; import net.mcreator.superbwarfare.client.screens.DroneUIOverlay; -import net.mcreator.superbwarfare.config.client.KillMessageClientConfig; +import net.mcreator.superbwarfare.config.client.KillMessageConfig; import net.mcreator.superbwarfare.event.KillMessageHandler; import net.mcreator.superbwarfare.network.message.ClientIndicatorMessage; import net.mcreator.superbwarfare.network.message.GunsDataMessage; @@ -27,7 +27,7 @@ public class ClientPacketHandler { public static void handlePlayerKillMessage(Player attacker, Entity target, boolean headshot, ResourceKey damageType, Supplier ctx) { if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) { - if (KillMessageHandler.QUEUE.size() >= KillMessageClientConfig.KILL_MESSAGE_COUNT.get()) { + if (KillMessageHandler.QUEUE.size() >= KillMessageConfig.KILL_MESSAGE_COUNT.get()) { KillMessageHandler.QUEUE.poll(); } KillMessageHandler.QUEUE.offer(new PlayerKillRecord(attacker, target, attacker.getMainHandItem(), headshot, damageType)); diff --git a/src/main/java/net/mcreator/superbwarfare/tools/DamageTypeTool.java b/src/main/java/net/mcreator/superbwarfare/tools/DamageTypeTool.java index 9f99c9570..63e10b71a 100644 --- a/src/main/java/net/mcreator/superbwarfare/tools/DamageTypeTool.java +++ b/src/main/java/net/mcreator/superbwarfare/tools/DamageTypeTool.java @@ -29,4 +29,11 @@ public class DamageTypeTool { return source.is(ModDamageTypes.GUN_FIRE) || source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE); } + public static boolean isModDamage(DamageSource source) { + return source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE) || source.is(ModDamageTypes.GUN_FIRE_HEADSHOT_ABSOLUTE) + || source.is(ModDamageTypes.GUN_FIRE) || source.is(ModDamageTypes.GUN_FIRE_HEADSHOT) + || source.is(ModDamageTypes.MINE) || source.is(ModDamageTypes.SHOCK) + || source.is(ModDamageTypes.PROJECTILE_BOOM) || source.is(ModDamageTypes.CANNON_FIRE); + } + } diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index e9364a312..b66461822 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -352,5 +352,10 @@ "config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息", "config.superbwarfare.client.kill_message.show_kill_message.des": "开启时,在屏幕右上角显示击杀信息", "config.superbwarfare.client.kill_message.kill_message_count": "击杀信息数量", - "config.superbwarfare.client.kill_message.kill_message_count.des": "同时显示的最大击杀信息数量" + "config.superbwarfare.client.kill_message.kill_message_count.des": "同时显示的最大击杀信息数量", + "config.superbwarfare.client.display": "显示配置", + "config.superbwarfare.client.display.kill_indication": "击杀提示", + "config.superbwarfare.client.display.kill_indication.des": "开启时,击杀生物时会在准星周围显示击杀提示", + "config.superbwarfare.client.display.global_indication": "全局伤害提示", + "config.superbwarfare.client.display.global_indication.des": "是否在仅使用本模组的伤害类型击杀生物时,在准星周围显示击杀提示" } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 323e5741e..76e1b5216 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -351,5 +351,10 @@ "config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息", "config.superbwarfare.client.kill_message.show_kill_message.des": "开启时,在屏幕右上角显示击杀信息", "config.superbwarfare.client.kill_message.kill_message_count": "击杀信息数量", - "config.superbwarfare.client.kill_message.kill_message_count.des": "同时显示的最大击杀信息数量" + "config.superbwarfare.client.kill_message.kill_message_count.des": "同时显示的最大击杀信息数量", + "config.superbwarfare.client.display": "显示配置", + "config.superbwarfare.client.display.kill_indication": "击杀提示", + "config.superbwarfare.client.display.kill_indication.des": "开启时,击杀生物时会在准星周围显示击杀提示", + "config.superbwarfare.client.display.global_indication": "全局伤害提示", + "config.superbwarfare.client.display.global_indication.des": "是否在仅使用本模组的伤害类型击杀生物时,在准星周围显示击杀提示" } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/textures/screens/headshotmark.png b/src/main/resources/assets/superbwarfare/textures/screens/headshot_mark.png similarity index 100% rename from src/main/resources/assets/superbwarfare/textures/screens/headshotmark.png rename to src/main/resources/assets/superbwarfare/textures/screens/headshot_mark.png diff --git a/src/main/resources/assets/superbwarfare/textures/screens/rexheng.png b/src/main/resources/assets/superbwarfare/textures/screens/rex_horizontal.png similarity index 100% rename from src/main/resources/assets/superbwarfare/textures/screens/rexheng.png rename to src/main/resources/assets/superbwarfare/textures/screens/rex_horizontal.png diff --git a/src/main/resources/assets/superbwarfare/textures/screens/rexshu.png b/src/main/resources/assets/superbwarfare/textures/screens/rex_vertical.png similarity index 100% rename from src/main/resources/assets/superbwarfare/textures/screens/rexshu.png rename to src/main/resources/assets/superbwarfare/textures/screens/rex_vertical.png