优化NBT#ChargedDamage

This commit is contained in:
17146 2025-01-04 01:36:15 +08:00
parent ba4cadccb3
commit 645effa77b
3 changed files with 9 additions and 9 deletions

View file

@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.client.tooltip;
import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent;
import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.ItemNBTTool;
import com.atsuishio.superbwarfare.tools.TooltipTool; import com.atsuishio.superbwarfare.tools.TooltipTool;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -27,7 +26,7 @@ public class ClientSentinelImageTooltip extends ClientEnergyImageTooltip {
if (flag.get()) { if (flag.get()) {
double damage = (GunsTool.getGunDoubleTag(stack, "Damage", 0) + double damage = (GunsTool.getGunDoubleTag(stack, "Damage", 0) +
ItemNBTTool.getDouble(stack, "sentinelChargeDamage", 0)) GunsTool.getGunDoubleTag(stack, "ChargedDamage", 0))
* TooltipTool.perkDamage(stack); * TooltipTool.perkDamage(stack);
return Component.translatable("des.superbwarfare.tips.damage").withStyle(ChatFormatting.GRAY) return Component.translatable("des.superbwarfare.tips.damage").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET)) .append(Component.literal("").withStyle(ChatFormatting.RESET))

View file

@ -187,7 +187,8 @@ public class GunEventHandler {
if (!player.level().isClientSide()) { if (!player.level().isClientSide()) {
float headshot = (float) GunsTool.getGunDoubleTag(stack, "Headshot", 0); float headshot = (float) GunsTool.getGunDoubleTag(stack, "Headshot", 0);
float damage = (float) (GunsTool.getGunDoubleTag(stack, "Damage", 0) + stack.getOrCreateTag().getDouble("sentinelChargeDamage")) * (float) perkDamage(stack); float damage = (float) (GunsTool.getGunDoubleTag(stack, "Damage", 0) +
GunsTool.getGunDoubleTag(stack, "ChargedDamage", 0)) * (float) perkDamage(stack);
float velocity = (float) ((GunsTool.getGunDoubleTag(stack, "Velocity", 0) + GunsTool.getGunDoubleTag(stack, "CustomVelocity", 0)) * perkSpeed(stack)); float velocity = (float) ((GunsTool.getGunDoubleTag(stack, "Velocity", 0) + GunsTool.getGunDoubleTag(stack, "CustomVelocity", 0)) * perkSpeed(stack));
int projectileAmount = GunsTool.getGunIntTag(stack, "ProjectileAmount", 1); int projectileAmount = GunsTool.getGunIntTag(stack, "ProjectileAmount", 1);
float bypassArmorRate = (float) GunsTool.getGunDoubleTag(stack, "BypassesArmor", 0); float bypassArmorRate = (float) GunsTool.getGunDoubleTag(stack, "BypassesArmor", 0);

View file

@ -177,18 +177,18 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
} }
@Override @Override
public void inventoryTick(ItemStack itemStack, Level world, Entity entity, int slot, boolean selected) { public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
super.inventoryTick(itemStack, world, entity, slot, selected); super.inventoryTick(stack, world, entity, slot, selected);
var tag = itemStack.getOrCreateTag(); stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
itemStack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
energy -> { energy -> {
int energyStored = energy.getEnergyStored(); int energyStored = energy.getEnergyStored();
if (energyStored > 0) { if (energyStored > 0) {
energy.extractEnergy(1, false); energy.extractEnergy(1, false);
tag.putDouble("sentinelChargeDamage", 0.2857142857142857 * GunsTool.getGunDoubleTag(itemStack, "Damage", 0)); GunsTool.setGunDoubleTag(stack, "ChargedDamage", 0.2857142857142857
* GunsTool.getGunDoubleTag(stack, "Damage", 0));
} else { } else {
tag.putDouble("sentinelChargeDamage", 0); GunsTool.setGunDoubleTag(stack, "ChargedDamage", 0);
} }
} }
); );