添加防弹插板配置项
This commit is contained in:
parent
25f205a78d
commit
c3888465ab
4 changed files with 41 additions and 23 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue