清理不规范命名和代码

This commit is contained in:
17146 2024-10-10 00:27:47 +08:00
parent 62a9a53e3f
commit ec66fe642e
12 changed files with 152 additions and 170 deletions

View file

@ -67,42 +67,7 @@ public class LivingEventHandler {
killIndication(event.getSource()); killIndication(event.getSource());
handleGunPerksWhenDeath(event); handleGunPerksWhenDeath(event);
handlePlayerKillEntity(event); handlePlayerKillEntity(event);
handlePlayerDeathDropAmmo(event.getEntity());
//开启死亡掉落时掉落一个弹药盒
if (!event.getEntity().level().getLevelData().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) && event.getEntity() instanceof Player player) {
var cap =player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
boolean drop = (cap.rifleAmmo + cap.handgunAmmo + cap.shotgunAmmo + cap.sniperAmmo > 0);
if (drop) {
ItemStack stack = new ItemStack(ModItems.AMMOBOX.get());
CompoundTag tag = stack.getOrCreateTag();
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
tag.putInt("rifleAmmo",cap.rifleAmmo);
capability.rifleAmmo = 0;
tag.putInt("handgunAmmo",cap.handgunAmmo);
capability.handgunAmmo = 0;
tag.putInt("shotgunAmmo",cap.shotgunAmmo);
capability.shotgunAmmo = 0;
tag.putInt("sniperAmmo",cap.sniperAmmo);
capability.sniperAmmo = 0;
tag.putBoolean("isDrop",true);
capability.syncPlayerVariables(player);
});
if (player.level() instanceof ServerLevel level) {
var x = player.getX();
var y = player.getY();
var z = player.getZ();
ItemEntity ammobox = new ItemEntity(level, x, (y + 1), z, stack);
ammobox.setPickUpDelay(10);
level.addFreshEntity(ammobox);
}
}
}
} }
/** /**
@ -605,4 +570,39 @@ public class LivingEventHandler {
event.setAmount(event.getAmount() * (1.095f + 0.0225f * level)); event.setAmount(event.getAmount() * (1.095f + 0.0225f * level));
} }
} }
/**
* 开启死亡掉落时掉落一个弹药盒
*/
private static void handlePlayerDeathDropAmmo(LivingEntity entity) {
if (!entity.level().getLevelData().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) && entity instanceof Player player) {
var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
boolean drop = cap.rifleAmmo + cap.handgunAmmo + cap.shotgunAmmo + cap.sniperAmmo > 0;
if (drop) {
ItemStack stack = new ItemStack(ModItems.AMMO_BOX.get());
CompoundTag tag = stack.getOrCreateTag();
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
tag.putInt("RifleAmmo", cap.rifleAmmo);
capability.rifleAmmo = 0;
tag.putInt("HandgunAmmo", cap.handgunAmmo);
capability.handgunAmmo = 0;
tag.putInt("ShotgunAmmo", cap.shotgunAmmo);
capability.shotgunAmmo = 0;
tag.putInt("SniperAmmo", cap.sniperAmmo);
capability.sniperAmmo = 0;
tag.putBoolean("IsDrop", true);
capability.syncPlayerVariables(player);
});
if (player.level() instanceof ServerLevel level) {
ItemEntity itemEntity = new ItemEntity(level, player.getX(), player.getY() + 1, player.getZ(), stack);
itemEntity.setPickUpDelay(10);
level.addFreshEntity(itemEntity);
}
}
}
}
} }

View file

@ -115,7 +115,6 @@ public class PlayerEventHandler {
} }
private static void handleBreath(Player player) { private static void handleBreath(Player player) {
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).breath) { if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).breath) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.breathTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null) capability.breathTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null)

View file

@ -92,7 +92,7 @@ public class ModItems {
public static final RegistryObject<Item> SNIPER_AMMO_BOX = AMMO.register("sniper_ammo_box", SniperAmmoBox::new); public static final RegistryObject<Item> SNIPER_AMMO_BOX = AMMO.register("sniper_ammo_box", SniperAmmoBox::new);
public static final RegistryObject<Item> SHOTGUN_AMMO_BOX = AMMO.register("shotgun_ammo_box", ShotgunAmmoBox::new); public static final RegistryObject<Item> SHOTGUN_AMMO_BOX = AMMO.register("shotgun_ammo_box", ShotgunAmmoBox::new);
public static final RegistryObject<Item> CREATIVE_AMMO_BOX = AMMO.register("creative_ammo_box", () -> new Item(new Item.Properties().rarity(Rarity.EPIC))); public static final RegistryObject<Item> CREATIVE_AMMO_BOX = AMMO.register("creative_ammo_box", () -> new Item(new Item.Properties().rarity(Rarity.EPIC)));
public static final RegistryObject<Item> AMMOBOX = AMMO.register("ammobox", AmmoBox::new); public static final RegistryObject<Item> AMMO_BOX = AMMO.register("ammo_box", AmmoBox::new);
public static final RegistryObject<Item> TASER_ELECTRODE = AMMO.register("taser_electrode", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> TASER_ELECTRODE = AMMO.register("taser_electrode", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> GRENADE_40MM = AMMO.register("grenade_40mm", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> GRENADE_40MM = AMMO.register("grenade_40mm", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> JAVELIN_MISSILE = AMMO.register("javelin_missile", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> JAVELIN_MISSILE = AMMO.register("javelin_missile", () -> new Item(new Item.Properties()));
@ -251,13 +251,11 @@ public class ModItems {
ModPerks.DAMAGE_PERKS.getEntries().forEach(registryObject -> PERKS.register(registryObject.getId().getPath(), () -> new PerkItem(registryObject))); ModPerks.DAMAGE_PERKS.getEntries().forEach(registryObject -> PERKS.register(registryObject.getId().getPath(), () -> new PerkItem(registryObject)));
} }
public static final RegistryObject<Item> SHORTCUT_PACK = PERKS.register("shortcut_pack", ShortcutPack::new);
public static final RegistryObject<Item> EMPTY_PERK = PERKS.register("empty_perk", () -> new Item(new Item.Properties()));
/** /**
* 单独注册用于Tab图标不要删 * 单独注册用于Tab图标不要删
*/ */
public static final RegistryObject<Item> SHORTCUT_PACK = PERKS.register("shortcut_pack", shortcutPack::new);
public static final RegistryObject<Item> EMPTY_PERK = PERKS.register("empty_perk", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> AP_BULLET = PERKS.register("ap_bullet", () -> new PerkItem(ModPerks.AP_BULLET)); public static final RegistryObject<Item> AP_BULLET = PERKS.register("ap_bullet", () -> new PerkItem(ModPerks.AP_BULLET));
public static void register(IEventBus bus) { public static void register(IEventBus bus) {

View file

@ -1,6 +1,6 @@
package net.mcreator.superbwarfare.item; package net.mcreator.superbwarfare.item;
import net.mcreator.superbwarfare.tools.TooltipTool; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -11,14 +11,15 @@ import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
public class shortcutPack extends Item { public class ShortcutPack extends Item {
public shortcutPack() { public ShortcutPack() {
super(new Properties().rarity(Rarity.EPIC)); super(new Properties().rarity(Rarity.EPIC));
} }
@Override @Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> list, TooltipFlag flag) { public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> list, TooltipFlag flag) {
TooltipTool.shortcutPackTips(list); list.add(Component.translatable("des.superbwarfare.tips.shortcut_pack").withStyle(ChatFormatting.GRAY));
list.add(Component.translatable("des.superbwarfare.use_tip.shortcut_pack"));
} }
} }

View file

@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.item.common.ammo;
import net.mcreator.superbwarfare.init.ModSounds; import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.network.ModVariables; import net.mcreator.superbwarfare.network.ModVariables;
import net.mcreator.superbwarfare.tools.TooltipTool; import net.mcreator.superbwarfare.tools.ItemNBTTool;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -14,16 +14,16 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.text.DecimalFormat;
import java.util.List; import java.util.List;
public class AmmoBox extends Item { public class AmmoBox extends Item {
public AmmoBox() { public AmmoBox() {
super(new Properties().stacksTo(1).rarity(Rarity.COMMON)); super(new Properties().stacksTo(1));
} }
@Override @Override
@ -32,30 +32,29 @@ public class AmmoBox extends Item {
CompoundTag tag = stack.getOrCreateTag(); CompoundTag tag = stack.getOrCreateTag();
player.getCooldowns().addCooldown(this, 10); player.getCooldowns().addCooldown(this, 10);
int type = stack.getOrCreateTag().getInt("Type");
var cap =player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()); var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
if (!player.isCrouching()) { if (!player.isCrouching()) {
if (type == 0 || type == 1) {
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 1) { capability.rifleAmmo = cap.rifleAmmo + tag.getInt("RifleAmmo");
capability.rifleAmmo = cap.rifleAmmo + tag.getInt("rifleAmmo"); tag.putInt("RifleAmmo", 0);
tag.putInt("rifleAmmo",0);
} }
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 2) { if (type == 0 || type == 2) {
capability.handgunAmmo = cap.handgunAmmo + tag.getInt("handgunAmmo"); capability.handgunAmmo = cap.handgunAmmo + tag.getInt("HandgunAmmo");
tag.putInt("handgunAmmo",0); tag.putInt("HandgunAmmo", 0);
} }
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 3) { if (type == 0 || type == 3) {
capability.shotgunAmmo = cap.shotgunAmmo + tag.getInt("shotgunAmmo"); capability.shotgunAmmo = cap.shotgunAmmo + tag.getInt("ShotgunAmmo");
tag.putInt("shotgunAmmo",0); tag.putInt("ShotgunAmmo", 0);
} }
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 4) { if (type == 0 || type == 4) {
capability.sniperAmmo = cap.sniperAmmo + tag.getInt("sniperAmmo"); capability.sniperAmmo = cap.sniperAmmo + tag.getInt("SniperAmmo");
tag.putInt("sniperAmmo",0); tag.putInt("SniperAmmo", 0);
} }
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
@ -64,79 +63,87 @@ public class AmmoBox extends Item {
level.playSound(null, player.blockPosition(), ModSounds.BULLET_SUPPLY.get(), SoundSource.PLAYERS, 1, 1); level.playSound(null, player.blockPosition(), ModSounds.BULLET_SUPPLY.get(), SoundSource.PLAYERS, 1, 1);
} }
if (tag.getBoolean("isDrop")) { if (tag.getBoolean("IsDrop")) {
stack.shrink(1); stack.shrink(1);
} }
} else { } else {
if (type == 0 || type == 1) {
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 1) { tag.putInt("RifleAmmo", tag.getInt("RifleAmmo") + cap.rifleAmmo);
tag.putInt("rifleAmmo",tag.getInt("rifleAmmo") + cap.rifleAmmo);
capability.rifleAmmo = 0; capability.rifleAmmo = 0;
} }
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 2) { if (type == 0 || type == 2) {
tag.putInt("handgunAmmo",tag.getInt("handgunAmmo") + cap.handgunAmmo); tag.putInt("HandgunAmmo", tag.getInt("HandgunAmmo") + cap.handgunAmmo);
capability.handgunAmmo = 0; capability.handgunAmmo = 0;
} }
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 3) { if (type == 0 || type == 3) {
tag.putInt("shotgunAmmo",tag.getInt("shotgunAmmo") + cap.shotgunAmmo); tag.putInt("ShotgunAmmo", tag.getInt("ShotgunAmmo") + cap.shotgunAmmo);
capability.shotgunAmmo = 0; capability.shotgunAmmo = 0;
} }
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 4) { if (type == 0 || type == 4) {
tag.putInt("sniperAmmo",tag.getInt("sniperAmmo") + cap.sniperAmmo); tag.putInt("SniperAmmo", tag.getInt("SniperAmmo") + cap.sniperAmmo);
capability.sniperAmmo = 0; capability.sniperAmmo = 0;
} }
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
if (!level.isClientSide()) { if (!level.isClientSide()) {
level.playSound(null, player.blockPosition(), SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 1, 1); level.playSound(null, player.blockPosition(), SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 1, 1);
} }
} }
}); });
return InteractionResultHolder.consume(stack); return InteractionResultHolder.consume(stack);
} }
@Override @Override
public boolean onEntitySwing(ItemStack itemstack, LivingEntity entity) { public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
boolean retval = super.onEntitySwing(itemstack, entity);
if (entity instanceof Player player && player.isCrouching()) { if (entity instanceof Player player && player.isCrouching()) {
int type = stack.getOrCreateTag().getInt("Type");
++type;
type %= 5;
itemstack.getOrCreateTag().putInt("type",itemstack.getOrCreateTag().getInt("type") + 1); switch (type) {
if (itemstack.getOrCreateTag().getInt("type") > 4) { case 0 ->
itemstack.getOrCreateTag().putInt("type",0); player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.all").withStyle(ChatFormatting.WHITE), true);
} case 1 ->
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.rifle").withStyle(ChatFormatting.GREEN), true);
if (itemstack.getOrCreateTag().getInt("type") == 0) { case 2 ->
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.all").withStyle(ChatFormatting.WHITE),true); player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.handgun").withStyle(ChatFormatting.AQUA), true);
} case 3 ->
if (itemstack.getOrCreateTag().getInt("type") == 1) { player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.shotgun").withStyle(ChatFormatting.RED), true);
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.rifle").withStyle(ChatFormatting.GREEN),true); case 4 ->
} player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.sniper").withStyle(ChatFormatting.GOLD), true);
if (itemstack.getOrCreateTag().getInt("type") == 2) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.handgun").withStyle(ChatFormatting.AQUA),true);
}
if (itemstack.getOrCreateTag().getInt("type") == 3) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.shotgun").withStyle(ChatFormatting.RED),true);
}
if (itemstack.getOrCreateTag().getInt("type") == 4) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.sniper").withStyle(ChatFormatting.GOLD),true);
} }
entity.playSound(ModSounds.FIRE_RATE.get(), 1f, 1f); entity.playSound(ModSounds.FIRE_RATE.get(), 1f, 1f);
stack.getOrCreateTag().putInt("Type", type);
} }
return retval;
return super.onEntitySwing(stack, entity);
} }
@Override @Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> list, TooltipFlag flag) { public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag) {
TooltipTool.ammoBoxTips(list, stack); int type = stack.getOrCreateTag().getInt("Type");
tooltip.add(Component.translatable("des.superbwarfare.use_tip.ammo_box").withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("des.superbwarfare.tips.rifle_ammo").withStyle(ChatFormatting.GREEN)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "RifleAmmo", 0)) + ((type == 0 || type == 1) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.handgun_ammo").withStyle(ChatFormatting.AQUA)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "HandgunAmmo", 0)) + ((type == 0 || type == 2) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.shotgun_ammo").withStyle(ChatFormatting.RED)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "ShotgunAmmo", 0)) + ((type == 0 || type == 3) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.sniper_ammo").withStyle(ChatFormatting.GOLD)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "SniperAmmo", 0)) + ((type == 0 || type == 4) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
} }
} }

View file

@ -87,7 +87,7 @@ public abstract class GunItem extends Item {
handleGunPerks(itemstack); handleGunPerks(itemstack);
if ((itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") + 1) if ((itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") + 1)
||(!itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag")) || (!itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag"))
) { ) {
int count = itemstack.getOrCreateTag().getInt("ammo") - itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") - (itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) ? 1 : 0); int count = itemstack.getOrCreateTag().getInt("ammo") - itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") - (itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) ? 1 : 0);
@ -106,14 +106,14 @@ public abstract class GunItem extends Item {
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
itemstack.getOrCreateTag().putInt("ammo",itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") + (itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) ? 1 : 0)); itemstack.getOrCreateTag().putInt("ammo", itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") + (itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) ? 1 : 0));
} }
} }
} }
@Override @Override
public boolean onEntitySwing(ItemStack stack, LivingEntity entity) { public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
return false; return super.onEntitySwing(stack, entity);
} }
@Override @Override
@ -194,13 +194,13 @@ public abstract class GunItem extends Item {
stack.getOrCreateTag().putInt("HeadSeeker", Math.max(0, stack.getOrCreateTag().getInt("HeadSeeker") - 1)); stack.getOrCreateTag().putInt("HeadSeeker", Math.max(0, stack.getOrCreateTag().getInt("HeadSeeker") - 1));
} }
int mag_ = stack.getOrCreateTag().getInt("mag"); int ctmMag = stack.getOrCreateTag().getInt("mag");
if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) { if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.1 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * mag_))); stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.1 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * ctmMag)));
} else if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) { } else if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.075 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * mag_))); stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.075 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * ctmMag)));
} else { } else {
stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.15 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * mag_))); stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.15 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * ctmMag)));
} }
} }

View file

@ -128,21 +128,21 @@ public class TooltipTool {
int upgradePoint = Mth.floor(ItemNBTTool.getDouble(stack, "UpgradePoint", 0)); int upgradePoint = Mth.floor(ItemNBTTool.getDouble(stack, "UpgradePoint", 0));
tooltip.add(Component.translatable("des.superbwarfare.tips.upgradepoint").withStyle(ChatFormatting.GRAY) tooltip.add(Component.translatable("des.superbwarfare.tips.upgrade_point").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET)) .append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(String.valueOf(upgradePoint)).withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.BOLD))); .append(Component.literal(String.valueOf(upgradePoint)).withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.BOLD)));
} }
private static void addBypassTips(List<Component> tooltip, ItemStack stack) { private static void addBypassTips(List<Component> tooltip, ItemStack stack) {
double perkbypassArmorRate = 0; double perkBypassArmorRate = 0;
var perk = PerkHelper.getPerkByType(stack, Perk.Type.AMMO); var perk = PerkHelper.getPerkByType(stack, Perk.Type.AMMO);
if (perk instanceof AmmoPerk ammoPerk) { if (perk instanceof AmmoPerk ammoPerk) {
int level = PerkHelper.getItemPerkLevel(perk, stack); int level = PerkHelper.getItemPerkLevel(perk, stack);
perkbypassArmorRate = ammoPerk.bypassArmorRate + (perk == ModPerks.AP_BULLET.get() ? 0.05f * (level - 1) : 0); perkBypassArmorRate = ammoPerk.bypassArmorRate + (perk == ModPerks.AP_BULLET.get() ? 0.05f * (level - 1) : 0);
} }
double byPassRate = Math.max(ItemNBTTool.getDouble(stack, "BypassesArmor", 0) + perkbypassArmorRate, 0); double byPassRate = Math.max(ItemNBTTool.getDouble(stack, "BypassesArmor", 0) + perkBypassArmorRate, 0);
tooltip.add(Component.translatable("des.superbwarfare.tips.bypass").withStyle(ChatFormatting.GRAY) tooltip.add(Component.translatable("des.superbwarfare.tips.bypass").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET)) .append(Component.literal("").withStyle(ChatFormatting.RESET))
@ -284,7 +284,7 @@ public class TooltipTool {
int upgradePoint = Mth.floor(ItemNBTTool.getDouble(stack, "UpgradePoint", 0)); int upgradePoint = Mth.floor(ItemNBTTool.getDouble(stack, "UpgradePoint", 0));
tooltip.add(Component.translatable("des.superbwarfare.tips.upgradepoint").withStyle(ChatFormatting.GRAY) tooltip.add(Component.translatable("des.superbwarfare.tips.upgrade_point").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET)) .append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(String.valueOf(upgradePoint)).withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.BOLD))); .append(Component.literal(String.valueOf(upgradePoint)).withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.BOLD)));
addPerkTips(tooltip, stack); addPerkTips(tooltip, stack);
@ -324,28 +324,4 @@ public class TooltipTool {
.append(Component.literal("Distance:" + new DecimalFormat("##.#").format(player.distanceTo(entity)) + "M").withStyle(ChatFormatting.GRAY))); .append(Component.literal("Distance:" + new DecimalFormat("##.#").format(player.distanceTo(entity)) + "M").withStyle(ChatFormatting.GRAY)));
} }
public static void ammoBoxTips(List<Component> tooltip, ItemStack stack) {
tooltip.add(Component.translatable("des.superbwarfare.use_tip.ammobox").withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("des.superbwarfare.tips.rifleammo").withStyle(ChatFormatting.GREEN)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "rifleAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 1) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.handgunammo").withStyle(ChatFormatting.AQUA)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "handgunAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 2) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.shotgunammo").withStyle(ChatFormatting.RED)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "shotgunAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 3) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.sniperammo").withStyle(ChatFormatting.GOLD)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "sniperAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 4) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
}
public static void shortcutPackTips(List<Component> tooltip) {
tooltip.add(Component.translatable("des.superbwarfare.tips.shortcutpack").withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("des.superbwarfare.use_tip.shortcutpack"));
}
} }

View file

@ -24,7 +24,7 @@
"item.superbwarfare.m_4": "M4A1", "item.superbwarfare.m_4": "M4A1",
"item.superbwarfare.aa_12": "AA-12", "item.superbwarfare.aa_12": "AA-12",
"item.superbwarfare.sks": "SKS", "item.superbwarfare.sks": "SKS",
"item.superbwarfare.abekiri": "Legendary Gun:Abe Slayer", "item.superbwarfare.abekiri": "Legendary Gun: Abe Slayer",
"item.superbwarfare.trachelium": "\"Trachelium-Caeruleum\"", "item.superbwarfare.trachelium": "\"Trachelium-Caeruleum\"",
"des.superbwarfare.trachelium_1": "Calm Spirit and Gentle Love", "des.superbwarfare.trachelium_1": "Calm Spirit and Gentle Love",
"des.superbwarfare.trachelium_2": "\"May the flowers in my hand convey my feelings to you\"", "des.superbwarfare.trachelium_2": "\"May the flowers in my hand convey my feelings to you\"",
@ -50,23 +50,24 @@
"des.superbwarfare.tips.level": "Level: ", "des.superbwarfare.tips.level": "Level: ",
"des.superbwarfare.tips.bypass": "Armor Piercing: ", "des.superbwarfare.tips.bypass": "Armor Piercing: ",
"des.superbwarfare.tips.distance": "Drone Distance: ", "des.superbwarfare.tips.distance": "Drone Distance: ",
"des.superbwarfare.tips.upgradepoint": "Upgrade Point: ", "des.superbwarfare.tips.upgrade_point": "Upgrade Point: ",
"des.superbwarfare.tips.rpm": "Rpm: ", "des.superbwarfare.tips.rpm": "Rpm: ",
"item.superbwarfare.ammobox": "AmmoBox", "item.superbwarfare.ammo_box": "Ammo Box",
"des.superbwarfare.tips.rifleammo": "Storage Rifle Ammo: ", "des.superbwarfare.tips.rifle_ammo": "Storage Rifle Ammo: ",
"des.superbwarfare.tips.handgunammo": "Storage Handgun Ammo: ", "des.superbwarfare.tips.handgun_ammo": "Storage Handgun Ammo: ",
"des.superbwarfare.tips.shotgunammo": "Storage Shotgun Ammo: ", "des.superbwarfare.tips.shotgun_ammo": "Storage Shotgun Ammo: ",
"des.superbwarfare.tips.sniperammo": "Storage Sniper Ammo: ", "des.superbwarfare.tips.sniper_ammo": "Storage Sniper Ammo: ",
"des.superbwarfare.tips.ammo_type.all": "All Ammo Choosed", "des.superbwarfare.tips.ammo_type.all": "All Ammo Chosen",
"des.superbwarfare.tips.ammo_type.rifle": "Rifle Ammo Choosed", "des.superbwarfare.tips.ammo_type.rifle": "Rifle Ammo Chosen",
"des.superbwarfare.tips.ammo_type.handgun": "Handgun Ammo Choosed", "des.superbwarfare.tips.ammo_type.handgun": "Handgun Ammo Chosen",
"des.superbwarfare.tips.ammo_type.shotgun": "Shotgun Ammo Choosed", "des.superbwarfare.tips.ammo_type.shotgun": "Shotgun Ammo Chosen",
"des.superbwarfare.tips.ammo_type.sniper": "Sniper Ammo Choosed", "des.superbwarfare.tips.ammo_type.sniper": "Sniper Ammo Chosen",
"des.superbwarfare.use_tip.ammo_box": "When sneaking, left-click to switch ammo types, right-click to store that type of ammo. Right-click with out sneaking to take out the corresponding type of ammo ",
"des.superbwarfare.tips.shortcutpack": "Really?", "des.superbwarfare.tips.shortcut_pack": "Really?",
"des.superbwarfare.use_tip.shortcutpack": "Synthesize firearms and shortcut kits at the anvil for one upgrade point", "des.superbwarfare.use_tip.shortcut_pack": "Synthesize firearms and shortcut kits at the anvil for one upgrade point",
"item.superbwarfare.vector_blueprint": "VECTOR Blueprint", "item.superbwarfare.vector_blueprint": "VECTOR Blueprint",
"item.superbwarfare.m_60_blueprint": "M60 Blueprint", "item.superbwarfare.m_60_blueprint": "M60 Blueprint",
@ -388,12 +389,10 @@
"config.superbwarfare.client.display.camera_rotate.des": "Slightly shaky view when holding a firearm in your hand", "config.superbwarfare.client.display.camera_rotate.des": "Slightly shaky view when holding a firearm in your hand",
"config.superbwarfare.client.display.armor_plate_hud": "Armor Plate HUD", "config.superbwarfare.client.display.armor_plate_hud": "Armor Plate HUD",
"config.superbwarfare.client.display.armor_plate_hud.des": "Display the durability of the bulletproof insert currently equipped on the chest armor in the lower left corner when turned on", "config.superbwarfare.client.display.armor_plate_hud.des": "Display the durability of the bulletproof insert currently equipped on the chest armor in the lower left corner when turned on",
"des.superbwarfare.use_tip.ammobox": "When sneaking, left-click to switch ammo types, right-click to take out that type of ammo. Right-click with out sneaking to take out the corresponding type of ammo ",
"des.superbwarfare.perk_damage_reduce": "Damage -", "des.superbwarfare.perk_damage_reduce": "Damage -",
"des.superbwarfare.perk_damage_plus": "Damage +", "des.superbwarfare.perk_damage_plus": "Damage +",
"des.superbwarfare.perk_speed_reduce": "Velocity -", "des.superbwarfare.perk_speed_reduce": "Velocity -",
"des.superbwarfare.perk_speed_plus": "Velocity +", "des.superbwarfare.perk_speed_plus": "Velocity +",
"des.superbwarfare.perk_slug": "Slug" "des.superbwarfare.perk_slug": "Slug"
} }

View file

@ -46,27 +46,28 @@
"item.superbwarfare.mosin_nagant": "莫辛纳甘", "item.superbwarfare.mosin_nagant": "莫辛纳甘",
"item.superbwarfare.javelin": "FGM-148标枪导弹", "item.superbwarfare.javelin": "FGM-148标枪导弹",
"des.superbwarfare.tips.upgradepoint": "升级点数: ", "des.superbwarfare.tips.upgrade_point": "升级点数: ",
"des.superbwarfare.tips.damage": "伤害: ", "des.superbwarfare.tips.damage": "伤害: ",
"des.superbwarfare.tips.level": "等级: ", "des.superbwarfare.tips.level": "等级: ",
"des.superbwarfare.tips.bypass": "护甲穿透: ", "des.superbwarfare.tips.bypass": "护甲穿透: ",
"des.superbwarfare.tips.distance": "无人机距离你: ", "des.superbwarfare.tips.distance": "无人机距离你: ",
"des.superbwarfare.tips.rpm": "射速: ", "des.superbwarfare.tips.rpm": "射速: ",
"item.superbwarfare.ammobox": "弹药盒", "item.superbwarfare.ammo_box": "弹药盒",
"des.superbwarfare.tips.rifleammo": "已存储的步枪弹药: ", "des.superbwarfare.tips.rifle_ammo": "已存储的步枪弹药: ",
"des.superbwarfare.tips.handgunammo": "已存储的手枪弹药: ", "des.superbwarfare.tips.handgun_ammo": "已存储的手枪弹药: ",
"des.superbwarfare.tips.shotgunammo": "已存储的霰弹弹药: ", "des.superbwarfare.tips.shotgun_ammo": "已存储的霰弹弹药: ",
"des.superbwarfare.tips.sniperammo": "已存储的狙击弹药: ", "des.superbwarfare.tips.sniper_ammo": "已存储的狙击弹药: ",
"des.superbwarfare.tips.ammo_type.all": "已选择所有弹药种类", "des.superbwarfare.tips.ammo_type.all": "已选择所有弹药种类",
"des.superbwarfare.tips.ammo_type.rifle": "已选择步枪弹药", "des.superbwarfare.tips.ammo_type.rifle": "已选择步枪弹药",
"des.superbwarfare.tips.ammo_type.handgun": "已选择手枪弹药", "des.superbwarfare.tips.ammo_type.handgun": "已选择手枪弹药",
"des.superbwarfare.tips.ammo_type.shotgun": "已选择霰弹弹药", "des.superbwarfare.tips.ammo_type.shotgun": "已选择霰弹弹药",
"des.superbwarfare.tips.ammo_type.sniper": "已选择狙击弹药", "des.superbwarfare.tips.ammo_type.sniper": "已选择狙击弹药",
"des.superbwarfare.use_tip.ammo_box": "潜行时,左击选择弹药类型,右击存入该类型的弹药,非潜行时右击取出对应类型的弹药",
"des.superbwarfare.tips.shortcutpack": "真的吗?", "des.superbwarfare.tips.shortcut_pack": "真的吗?",
"des.superbwarfare.use_tip.shortcutpack": "将枪械和捷径包在铁砧合成,可直接获得一个升级点数", "des.superbwarfare.use_tip.shortcut_pack": "将枪械和捷径包在铁砧合成,可直接获得一个升级点数",
"item.superbwarfare.vector_blueprint": "短剑冲锋枪蓝图", "item.superbwarfare.vector_blueprint": "短剑冲锋枪蓝图",
"item.superbwarfare.m_60_blueprint": "M60通用机枪蓝图", "item.superbwarfare.m_60_blueprint": "M60通用机枪蓝图",
@ -254,6 +255,8 @@
"des.superbwarfare.field_doctor": "腰射时发射的子弹可以治疗队友", "des.superbwarfare.field_doctor": "腰射时发射的子弹可以治疗队友",
"item.superbwarfare.super_recharge": "超级快充", "item.superbwarfare.super_recharge": "超级快充",
"des.superbwarfare.super_recharge": "增加泰瑟枪充能的速度", "des.superbwarfare.super_recharge": "增加泰瑟枪充能的速度",
"item.superbwarfare.dimension_magazine": "次元弹匣",
"des.superbwarfare.dimension_magazine": "增加弹匣容量",
"item.superbwarfare.kill_clip": "杀戮弹匣", "item.superbwarfare.kill_clip": "杀戮弹匣",
"des.superbwarfare.kill_clip": "完成击杀后填装可提升武器伤害", "des.superbwarfare.kill_clip": "完成击杀后填装可提升武器伤害",
@ -267,16 +270,15 @@
"des.superbwarfare.monster_hunter": "增加武器对怪物的伤害", "des.superbwarfare.monster_hunter": "增加武器对怪物的伤害",
"item.superbwarfare.volt_overload": "电压过载", "item.superbwarfare.volt_overload": "电压过载",
"des.superbwarfare.volt_overload": "增加泰瑟枪电击的伤害", "des.superbwarfare.volt_overload": "增加泰瑟枪电击的伤害",
"item.superbwarfare.dimension_magazine": "次元弹匣",
"des.superbwarfare.dimension_magazine": "增加弹匣容量", "item.superbwarfare.empty_perk": "空白模组",
"item.superbwarfare.shortcut_pack": "捷径包",
"perk.superbwarfare.tips": "[武器模组]", "perk.superbwarfare.tips": "[武器模组]",
"perk.superbwarfare.slot": "类型: ", "perk.superbwarfare.slot": "类型: ",
"perk.superbwarfare.slot_Ammo": "子弹模组", "perk.superbwarfare.slot_Ammo": "子弹模组",
"perk.superbwarfare.slot_Functional": "功能模组", "perk.superbwarfare.slot_Functional": "功能模组",
"perk.superbwarfare.slot_Damage": "伤害模组", "perk.superbwarfare.slot_Damage": "伤害模组",
"item.superbwarfare.empty_perk": "空白模组",
"item.superbwarfare.shortcut_pack": "捷径包",
"death.attack.gunfire": "%1$s被%2$s射爆了", "death.attack.gunfire": "%1$s被%2$s射爆了",
"death.attack.gunfire.entity": "%1$s被%2$s射爆了", "death.attack.gunfire.entity": "%1$s被%2$s射爆了",

View file

@ -2,8 +2,8 @@
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"texture_size": [32, 32], "texture_size": [32, 32],
"textures": { "textures": {
"0": "superbwarfare:item/ammobox", "0": "superbwarfare:item/ammo_box",
"particle": "superbwarfare:item/ammobox" "particle": "superbwarfare:item/ammo_box"
}, },
"elements": [ "elements": [
{ {

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -14,7 +14,7 @@
} }
}, },
"result": { "result": {
"item": "superbwarfare:ammobox", "item": "superbwarfare:ammo_box",
"count": 1 "count": 1
} }
} }