From c3888465ab7f7859a790692a3ef54e4e3332e831 Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Mon, 14 Apr 2025 23:49:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=B2=E5=BC=B9=E6=8F=92?= =?UTF-8?q?=E6=9D=BF=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/overlay/ArmorPlateOverlay.java | 18 +++++++++--------- .../config/server/MiscConfig.java | 16 ++++++++++++++++ .../event/PlayerEventHandler.java | 13 +++++++------ .../superbwarfare/item/ArmorPlate.java | 17 +++++++++-------- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/ArmorPlateOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/ArmorPlateOverlay.java index ee46cbc04..bc96985e1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/ArmorPlateOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/ArmorPlateOverlay.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.client.DisplayConfig; +import com.atsuishio.superbwarfare.config.server.MiscConfig; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.DeltaTracker; @@ -45,15 +46,16 @@ public class ArmorPlateOverlay implements LayeredDraw.Layer { var tag = NBTTool.getTag(stack); if (!tag.contains("ArmorPlate")) return; - double amount = 2 * tag.getDouble("ArmorPlate"); - - int armorLevel = 1; + int armorLevel = MiscConfig.DEFAULT_ARMOR_LEVEL.get(); if (stack.is(ModTags.Items.MILITARY_ARMOR)) { - armorLevel = 2; + armorLevel = MiscConfig.MILITARY_ARMOR_LEVEL.get(); } else if (stack.is(ModTags.Items.MILITARY_ARMOR_HEAVY)) { - armorLevel = 3; + armorLevel = MiscConfig.HEAVY_MILITARY_ARMOR_LEVEL.get(); } + var max = armorLevel * MiscConfig.ARMOR_PONT_PER_LEVEL.get(); + double amount = 60 * (NBTTool.getTag(stack).getDouble("ArmorPlate") / max); + ResourceLocation texture = switch (armorLevel) { case 2 -> LEVEL2; case 3 -> LEVEL3; @@ -65,17 +67,15 @@ public class ArmorPlateOverlay implements LayeredDraw.Layer { default -> LEVEL1_FRAME; }; - int length = armorLevel * 30; - guiGraphics.pose().pushPose(); // 渲染图标 guiGraphics.blit(ICON, 10, h - 13, 0, 0, 8, 8, 8, 8); // 渲染框架 - guiGraphics.blit(frame, 20, h - 12, 0, 0, length, 6, length, 6); + guiGraphics.blit(frame, 20, h - 12, 0, 0, 60, 6, 60, 6); // 渲染盔甲值 - guiGraphics.blit(texture, 20, h - 12, 0, 0, (int) amount, 6, length, 6); + guiGraphics.blit(texture, 20, h - 12, 0, 0, (int) amount, 6, 60, 6); guiGraphics.pose().popPose(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/MiscConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/MiscConfig.java index 0d952d4c6..01b9fb0d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/MiscConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/MiscConfig.java @@ -6,6 +6,10 @@ public class MiscConfig { public static ModConfigSpec.BooleanValue ALLOW_TACTICAL_SPRINT; public static ModConfigSpec.BooleanValue SEND_KILL_FEEDBACK; + public static ModConfigSpec.IntValue DEFAULT_ARMOR_LEVEL; + public static ModConfigSpec.IntValue MILITARY_ARMOR_LEVEL; + public static ModConfigSpec.IntValue HEAVY_MILITARY_ARMOR_LEVEL; + public static ModConfigSpec.IntValue ARMOR_PONT_PER_LEVEL; public static void init(ModConfigSpec.Builder builder) { builder.push("misc"); @@ -16,6 +20,18 @@ public class MiscConfig { builder.comment("Set true to enable kill feedback sending"); SEND_KILL_FEEDBACK = builder.define("send_kill_feedback", true); + builder.comment("The default maximum armor level for normal armors"); + DEFAULT_ARMOR_LEVEL = builder.defineInRange("default_armor_level", 1, 0, 10000000); + + builder.comment("The maximum armor level for armors with superbwarfare:military_armor tag"); + MILITARY_ARMOR_LEVEL = builder.defineInRange("military_armor_level", 2, 0, 10000000); + + builder.comment("The maximum armor level for armors with superbwarfare:military_armor_heavy tag(will override superbwarfare:military_armor tag!)"); + HEAVY_MILITARY_ARMOR_LEVEL = builder.defineInRange("heavy_military_armor_level", 3, 0, 10000000); + + builder.comment("The points per level for armor plate"); + ARMOR_PONT_PER_LEVEL = builder.defineInRange("armor_point_per_level", 15, 0, 10000000); + builder.pop(); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java index b9178fced..53cf722fe 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.event; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.common.GameplayConfig; +import com.atsuishio.superbwarfare.config.server.MiscConfig; import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModTags; @@ -126,25 +127,25 @@ public class PlayerEventHandler { var tag = NBTTool.getTag(armor); double armorPlate = tag.getDouble("ArmorPlate"); - int armorLevel = 1; + int armorLevel = MiscConfig.DEFAULT_ARMOR_LEVEL.get(); if (armor.is(ModTags.Items.MILITARY_ARMOR)) { - armorLevel = 2; + armorLevel = MiscConfig.MILITARY_ARMOR_LEVEL.get(); } else if (armor.is(ModTags.Items.MILITARY_ARMOR_HEAVY)) { - armorLevel = 3; + armorLevel = MiscConfig.HEAVY_MILITARY_ARMOR_LEVEL.get(); } - if (armorPlate >= armorLevel * 15) return; + if (armorPlate >= armorLevel * MiscConfig.ARMOR_PONT_PER_LEVEL.get()) return; for (var stack : player.getInventory().items) { if (stack.is(ModItems.ARMOR_PLATE.get())) { var stackTag = NBTTool.getTag(stack); if (stackTag.getBoolean("Infinite")) { - tag.putDouble("ArmorPlate", armorLevel * 15); + tag.putDouble("ArmorPlate", armorLevel * MiscConfig.ARMOR_PONT_PER_LEVEL.get()); if (player instanceof ServerPlayer serverPlayer) { serverPlayer.level().playSound(null, serverPlayer.getOnPos(), SoundEvents.ARMOR_EQUIP_IRON.value(), SoundSource.PLAYERS, 0.5f, 1); } } else { - for (int index0 = 0; index0 < Math.ceil(((armorLevel * 15) - armorPlate) / 15); index0++) { + for (int index0 = 0; index0 < Math.ceil(((armorLevel * MiscConfig.ARMOR_PONT_PER_LEVEL.get()) - armorPlate) / MiscConfig.ARMOR_PONT_PER_LEVEL.get()); index0++) { stack.finishUsingItem(player.level(), player); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/ArmorPlate.java b/src/main/java/com/atsuishio/superbwarfare/item/ArmorPlate.java index dcd4c6594..d6470d72a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/ArmorPlate.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/ArmorPlate.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.item; +import com.atsuishio.superbwarfare.config.server.MiscConfig; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.tools.NBTTool; @@ -46,14 +47,14 @@ public class ArmorPlate extends Item { if (armor == ItemStack.EMPTY) return InteractionResultHolder.fail(stack); - int armorLevel = 1; + int armorLevel = MiscConfig.DEFAULT_ARMOR_LEVEL.get(); if (armor.is(ModTags.Items.MILITARY_ARMOR)) { - armorLevel = 2; + armorLevel = MiscConfig.MILITARY_ARMOR_LEVEL.get(); } else if (armor.is(ModTags.Items.MILITARY_ARMOR_HEAVY)) { - armorLevel = 3; + armorLevel = MiscConfig.HEAVY_MILITARY_ARMOR_LEVEL.get(); } - if (NBTTool.getTag(armor).getDouble("ArmorPlate") < armorLevel * 15) { + if (NBTTool.getTag(armor).getDouble("ArmorPlate") < armorLevel * MiscConfig.ARMOR_PONT_PER_LEVEL.get()) { playerIn.startUsingItem(handIn); } @@ -71,15 +72,15 @@ public class ArmorPlate extends Item { if (!pLevel.isClientSide) { ItemStack armor = pLivingEntity.getItemBySlot(EquipmentSlot.CHEST); - int armorLevel = 1; + int armorLevel = MiscConfig.DEFAULT_ARMOR_LEVEL.get(); if (armor.is(ModTags.Items.MILITARY_ARMOR)) { - armorLevel = 2; + armorLevel = MiscConfig.MILITARY_ARMOR_LEVEL.get(); } else if (armor.is(ModTags.Items.MILITARY_ARMOR_HEAVY)) { - armorLevel = 3; + armorLevel = MiscConfig.HEAVY_MILITARY_ARMOR_LEVEL.get(); } var tag = NBTTool.getTag(armor); - tag.putDouble("ArmorPlate", Mth.clamp(tag.getDouble("ArmorPlate") + 15, 0, armorLevel * 15)); + tag.putDouble("ArmorPlate", Mth.clamp(tag.getDouble("ArmorPlate") + MiscConfig.ARMOR_PONT_PER_LEVEL.get(), 0, armorLevel * MiscConfig.ARMOR_PONT_PER_LEVEL.get())); NBTTool.saveTag(armor, tag); if (pLivingEntity instanceof ServerPlayer serverPlayer) {