添加新的配置项
This commit is contained in:
parent
a22440ddff
commit
3f724aa538
16 changed files with 153 additions and 53 deletions
|
@ -3,12 +3,14 @@ package net.mcreator.superbwarfare.client.screens;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
|
import net.mcreator.superbwarfare.config.client.DisplayConfig;
|
||||||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.init.ModTags;
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
import net.minecraft.client.CameraType;
|
import net.minecraft.client.CameraType;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -26,6 +28,9 @@ import static net.mcreator.superbwarfare.tools.RenderTool.preciseBlit;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class CrossHairOverlay {
|
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 HIT_INDICATOR = 0;
|
||||||
public static int HEAD_INDICATOR = 0;
|
public static int HEAD_INDICATOR = 0;
|
||||||
public static int KILL_INDICATOR = 0;
|
public static int KILL_INDICATOR = 0;
|
||||||
|
@ -35,15 +40,19 @@ public class CrossHairOverlay {
|
||||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||||
int w = event.getWindow().getGuiScaledWidth();
|
int w = event.getWindow().getGuiScaledWidth();
|
||||||
int h = event.getWindow().getGuiScaledHeight();
|
int h = event.getWindow().getGuiScaledHeight();
|
||||||
|
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuiGraphics guiGraphics = event.getGuiGraphics();
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
double spread = ClientEventHandler.gunSpread + 3 * ClientEventHandler.firePos;
|
double spread = ClientEventHandler.gunSpread + 3 * ClientEventHandler.firePos;
|
||||||
float deltaFrame = Minecraft.getInstance().getDeltaFrameTime();
|
float deltaFrame = Minecraft.getInstance().getDeltaFrameTime();
|
||||||
float moveX = (float) (-6 * ClientEventHandler.turnRot[1] - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosX);
|
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.disableDepthTest();
|
||||||
RenderSystem.depthMask(false);
|
RenderSystem.depthMask(false);
|
||||||
|
@ -53,61 +62,46 @@ public class CrossHairOverlay {
|
||||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
|
|
||||||
scopeScale = (float) Mth.lerp(0.5F * deltaFrame, scopeScale, 1 + 1.5f * spread);
|
scopeScale = (float) Mth.lerp(0.5F * deltaFrame, scopeScale, 1 + 1.5f * spread);
|
||||||
float f = (float)Math.min(w, h);
|
float f = (float) Math.min(w, h);
|
||||||
float f1 = Math.min((float)w / f, (float)h / f) * 0.012f * scopeScale;
|
float f1 = Math.min((float) w / f, (float) h / f) * 0.012f * scopeScale;
|
||||||
float i = Mth.floor(f * f1);
|
float i = Mth.floor(f * f1);
|
||||||
float j = Mth.floor(f * f1);
|
float j = Mth.floor(f * f1);
|
||||||
float k = ((w - i) / 2) + moveX;
|
float k = ((w - i) / 2) + moveX;
|
||||||
float l = ((h - j) / 2) + moveY;
|
float l = ((h - j) / 2) + moveY;
|
||||||
|
|
||||||
if (shouldRenderCrossHair(player) || stack.is(ModItems.MINIGUN.get())) {
|
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 (!player.isSprinting() || player.getPersistentData().getDouble("noRun") > 0) {
|
||||||
if (stack.is(ModTags.Items.SHOTGUN)) {
|
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 {
|
} 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(guiGraphics, REX_HORIZONTAL, (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(guiGraphics, REX_HORIZONTAL, (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(guiGraphics, REX_VERTICAL, 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_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.is(ModItems.BOCEK.get())) {
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getBoolean("HoloHidden")) {
|
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 (!player.isSprinting() || player.getPersistentData().getDouble("noRun") > 0 || ClientEventHandler.pullPos > 0) {
|
||||||
if (ClientEventHandler.zoomTime < 0.1) {
|
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 {
|
} 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(guiGraphics, REX_HORIZONTAL, (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(guiGraphics, REX_HORIZONTAL, (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(guiGraphics, REX_VERTICAL, 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_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));
|
if (DisplayConfig.KILL_INDICATION.get()) {
|
||||||
float m = (40 - KILL_INDICATOR * 5) / 5.5f;
|
renderKillIndicator(guiGraphics, w, h, moveX, moveY);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
|
@ -122,7 +116,7 @@ public class CrossHairOverlay {
|
||||||
Font font = Minecraft.getInstance().font;
|
Font font = Minecraft.getInstance().font;
|
||||||
Component component = Component.translatable("des.superbwarfare.need_bolt_action");
|
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;
|
&& 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
|
@SubscribeEvent
|
||||||
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
||||||
if (event.phase != TickEvent.Phase.END) {
|
if (event.phase != TickEvent.Phase.END) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package net.mcreator.superbwarfare.client.screens;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
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.event.KillMessageHandler;
|
||||||
import net.mcreator.superbwarfare.init.ModDamageTypes;
|
import net.mcreator.superbwarfare.init.ModDamageTypes;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
@ -46,7 +46,7 @@ public class KillMessageOverlay {
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||||
public static void onRenderGui(RenderGuiEvent.Pre event) {
|
public static void onRenderGui(RenderGuiEvent.Pre event) {
|
||||||
if (!KillMessageClientConfig.SHOW_KILL_MESSAGE.get()) {
|
if (!KillMessageConfig.SHOW_KILL_MESSAGE.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ package net.mcreator.superbwarfare.compat.clothconfig;
|
||||||
|
|
||||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
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.mcreator.superbwarfare.compat.clothconfig.client.ReloadClothConfig;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -19,7 +20,8 @@ public class ClothConfigHelper {
|
||||||
ConfigEntryBuilder entryBuilder = root.entryBuilder();
|
ConfigEntryBuilder entryBuilder = root.entryBuilder();
|
||||||
|
|
||||||
ReloadClothConfig.init(root, entryBuilder);
|
ReloadClothConfig.init(root, entryBuilder);
|
||||||
KillMessageClientClothConfig.init(root, entryBuilder);
|
KillMessageClothConfig.init(root, entryBuilder);
|
||||||
|
DisplayClothConfig.init(root, entryBuilder);
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,28 +3,28 @@ package net.mcreator.superbwarfare.compat.clothconfig.client;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
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;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class KillMessageClientClothConfig {
|
public class KillMessageClothConfig {
|
||||||
|
|
||||||
public static void init(ConfigBuilder root, ConfigEntryBuilder entryBuilder) {
|
public static void init(ConfigBuilder root, ConfigEntryBuilder entryBuilder) {
|
||||||
ConfigCategory category = root.getOrCreateCategory(Component.translatable("config.superbwarfare.client.kill_message"));
|
ConfigCategory category = root.getOrCreateCategory(Component.translatable("config.superbwarfare.client.kill_message"));
|
||||||
|
|
||||||
category.addEntry(entryBuilder
|
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)
|
.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"))
|
.setTooltip(Component.translatable("config.superbwarfare.client.kill_message.show_kill_message.des"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
category.addEntry(entryBuilder
|
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)
|
.setDefaultValue(5)
|
||||||
.setMin(1)
|
.setMin(1)
|
||||||
.setMax(20)
|
.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"))
|
.setTooltip(Component.translatable("config.superbwarfare.client.kill_message.kill_message_count.des"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
|
@ -1,7 +1,8 @@
|
||||||
package net.mcreator.superbwarfare.config;
|
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.ReloadConfig;
|
||||||
import net.mcreator.superbwarfare.config.client.KillMessageClientConfig;
|
import net.mcreator.superbwarfare.config.client.KillMessageConfig;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
public class ClientConfig {
|
public class ClientConfig {
|
||||||
|
@ -10,7 +11,8 @@ public class ClientConfig {
|
||||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||||
|
|
||||||
ReloadConfig.init(builder);
|
ReloadConfig.init(builder);
|
||||||
KillMessageClientConfig.init(builder);
|
KillMessageConfig.init(builder);
|
||||||
|
DisplayConfig.init(builder);
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.config.client;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
public class KillMessageClientConfig {
|
public class KillMessageConfig {
|
||||||
|
|
||||||
public static ForgeConfigSpec.BooleanValue SHOW_KILL_MESSAGE;
|
public static ForgeConfigSpec.BooleanValue SHOW_KILL_MESSAGE;
|
||||||
public static ForgeConfigSpec.IntValue KILL_MESSAGE_COUNT;
|
public static ForgeConfigSpec.IntValue KILL_MESSAGE_COUNT;
|
|
@ -1,6 +1,7 @@
|
||||||
package net.mcreator.superbwarfare.event;
|
package net.mcreator.superbwarfare.event;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
|
import net.mcreator.superbwarfare.config.client.DisplayConfig;
|
||||||
import net.mcreator.superbwarfare.entity.TargetEntity;
|
import net.mcreator.superbwarfare.entity.TargetEntity;
|
||||||
import net.mcreator.superbwarfare.entity.projectile.ProjectileEntity;
|
import net.mcreator.superbwarfare.entity.projectile.ProjectileEntity;
|
||||||
import net.mcreator.superbwarfare.init.*;
|
import net.mcreator.superbwarfare.init.*;
|
||||||
|
@ -52,7 +53,7 @@ public class LivingEventHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
killIndication(event.getSource().getEntity());
|
killIndication(event.getSource());
|
||||||
handleGunPerksWhenDeath(event);
|
handleGunPerksWhenDeath(event);
|
||||||
handlePlayerKillEntity(event);
|
handlePlayerKillEntity(event);
|
||||||
}
|
}
|
||||||
|
@ -107,11 +108,17 @@ public class LivingEventHandler {
|
||||||
return amount / (1 + rate * Math.max(0, distance - minDistance));
|
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) {
|
if (sourceEntity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果配置不选择全局伤害提示,则只在伤害类型为mod添加的时显示指示器
|
||||||
|
if (!DisplayConfig.GLOBAL_INDICATION.get() && !DamageTypeTool.isModDamage(source)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!sourceEntity.level().isClientSide() && sourceEntity instanceof ServerPlayer player) {
|
if (!sourceEntity.level().isClientSide() && sourceEntity instanceof ServerPlayer player) {
|
||||||
SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 100f, 1f);
|
SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 100f, 1f);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.network;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.client.screens.CrossHairOverlay;
|
import net.mcreator.superbwarfare.client.screens.CrossHairOverlay;
|
||||||
import net.mcreator.superbwarfare.client.screens.DroneUIOverlay;
|
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.event.KillMessageHandler;
|
||||||
import net.mcreator.superbwarfare.network.message.ClientIndicatorMessage;
|
import net.mcreator.superbwarfare.network.message.ClientIndicatorMessage;
|
||||||
import net.mcreator.superbwarfare.network.message.GunsDataMessage;
|
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> damageType, Supplier<NetworkEvent.Context> ctx) {
|
public static void handlePlayerKillMessage(Player attacker, Entity target, boolean headshot, ResourceKey<DamageType> damageType, Supplier<NetworkEvent.Context> ctx) {
|
||||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
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.poll();
|
||||||
}
|
}
|
||||||
KillMessageHandler.QUEUE.offer(new PlayerKillRecord(attacker, target, attacker.getMainHandItem(), headshot, damageType));
|
KillMessageHandler.QUEUE.offer(new PlayerKillRecord(attacker, target, attacker.getMainHandItem(), headshot, damageType));
|
||||||
|
|
|
@ -29,4 +29,11 @@ public class DamageTypeTool {
|
||||||
return source.is(ModDamageTypes.GUN_FIRE) || source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,5 +352,10 @@
|
||||||
"config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息",
|
"config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息",
|
||||||
"config.superbwarfare.client.kill_message.show_kill_message.des": "开启时,在屏幕右上角显示击杀信息",
|
"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": "击杀信息数量",
|
||||||
"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": "是否在仅使用本模组的伤害类型击杀生物时,在准星周围显示击杀提示"
|
||||||
}
|
}
|
|
@ -351,5 +351,10 @@
|
||||||
"config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息",
|
"config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息",
|
||||||
"config.superbwarfare.client.kill_message.show_kill_message.des": "开启时,在屏幕右上角显示击杀信息",
|
"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": "击杀信息数量",
|
||||||
"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": "是否在仅使用本模组的伤害类型击杀生物时,在准星周围显示击杀提示"
|
||||||
}
|
}
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 80 B After Width: | Height: | Size: 80 B |
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 85 B |
Loading…
Add table
Reference in a new issue