From e8a27a99cf0f98c4f8312c6e7fb64254c763a60e Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Fri, 9 May 2025 22:28:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0perk=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86tooltip=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/client/TooltipTool.java | 17 ------ .../tooltip/ClientBocekImageTooltip.java | 26 ++++++--- .../client/tooltip/ClientGunImageTooltip.java | 16 ++++-- .../tooltip/ClientSentinelImageTooltip.java | 21 +++++--- .../tooltip/ClientShotgunImageTooltip.java | 32 +++++++++-- .../superbwarfare/init/ModPerks.java | 53 ++++++++++--------- .../atsuishio/superbwarfare/perk/Perk.java | 14 +++++ .../superbwarfare/perk/ammo/HEBullet.java | 5 ++ .../perk/functional/CupidArrow.java | 53 +++++++++++++++++++ .../data/superbwarfare/guns/bocek.json | 1 + 10 files changed, 172 insertions(+), 66 deletions(-) create mode 100644 src/main/java/com/atsuishio/superbwarfare/perk/functional/CupidArrow.java diff --git a/src/main/java/com/atsuishio/superbwarfare/client/TooltipTool.java b/src/main/java/com/atsuishio/superbwarfare/client/TooltipTool.java index 0b15c3f1a..cbf637225 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/TooltipTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/TooltipTool.java @@ -1,12 +1,8 @@ package com.atsuishio.superbwarfare.client; -import com.atsuishio.superbwarfare.init.ModPerks; -import com.atsuishio.superbwarfare.item.gun.data.GunData; -import com.atsuishio.superbwarfare.perk.Perk; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -import net.minecraft.world.item.ItemStack; import java.util.List; @@ -21,17 +17,4 @@ public class TooltipTool { public static void addDevelopingText(List tooltip) { tooltip.add(Component.translatable("des.superbwarfare.developing").withStyle(ChatFormatting.LIGHT_PURPLE).withStyle(ChatFormatting.BOLD)); } - - public static boolean heBullet(ItemStack stack) { - var perkInstance = GunData.from(stack).perk.getInstance(Perk.Type.AMMO); - return perkInstance != null && perkInstance.perk() == ModPerks.HE_BULLET.get(); - } - - public static int heBulletLevel(ItemStack stack) { - var perkInstance = GunData.from(stack).perk.getInstance(Perk.Type.AMMO); - if (perkInstance != null && perkInstance.perk() == ModPerks.HE_BULLET.get()) { - return perkInstance.level(); - } - return 0; - } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientBocekImageTooltip.java b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientBocekImageTooltip.java index 2889ae9f9..da5dc6ad7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientBocekImageTooltip.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientBocekImageTooltip.java @@ -1,6 +1,5 @@ package com.atsuishio.superbwarfare.client.tooltip; -import com.atsuishio.superbwarfare.client.TooltipTool; import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.AmmoPerk; @@ -25,19 +24,30 @@ public class ClientBocekImageTooltip extends ClientGunImageTooltip { slug = true; } - double total = data.damage(); + double damage = data.damage(); if (slug) { - return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY) - .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(total) + (TooltipTool.heBullet(stack) ? " + " + - FormatTool.format1D(0.8 * total * (1 + 0.1 * TooltipTool.heBulletLevel(stack))) : "")).withStyle(ChatFormatting.GREEN)); + return super.getDamageComponent(); } else { + double shotDamage = damage * 0.1; + double extraDamage = -1; + for (var type : Perk.Type.values()) { + var instance = data.perk.getInstance(type); + if (instance != null) { + shotDamage = instance.perk().getDisplayDamage(shotDamage, getGunData(), instance); + if (instance.perk().getExtraDisplayDamage(shotDamage, getGunData(), instance) >= 0) { + extraDamage = instance.perk().getExtraDisplayDamage(shotDamage, getGunData(), instance); + } + } + } + return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(total * 0.1, " * 10")).withStyle(ChatFormatting.GREEN)) + .append(Component.literal(extraDamage >= 0 ? ("(" + FormatTool.format1D(shotDamage) + " + " + FormatTool.format1D(extraDamage) + ") * 10") + : FormatTool.format1D(shotDamage, " * 10")) + .withStyle(ChatFormatting.GREEN)) .append(Component.literal(" / ").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(total)).withStyle(ChatFormatting.GREEN)); + .append(Component.literal(FormatTool.format1D(shotDamage)).withStyle(ChatFormatting.GREEN)); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java index 128d91b14..9cce867e9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java @@ -1,6 +1,5 @@ package com.atsuishio.superbwarfare.client.tooltip; -import com.atsuishio.superbwarfare.client.TooltipTool; import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; import com.atsuishio.superbwarfare.init.ModKeyMappings; import com.atsuishio.superbwarfare.init.ModPerks; @@ -93,10 +92,21 @@ public class ClientGunImageTooltip implements ClientTooltipComponent { */ protected Component getDamageComponent() { double damage = data.damage(); + double extraDamage = -1; + for (var type : Perk.Type.values()) { + var instance = data.perk.getInstance(type); + if (instance != null) { + damage = instance.perk().getDisplayDamage(damage, data, instance); + if (instance.perk().getExtraDisplayDamage(damage, data, instance) >= 0) { + extraDamage = instance.perk().getExtraDisplayDamage(damage, data, instance); + } + } + } + return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(damage) + (TooltipTool.heBullet(stack) ? " + " - + FormatTool.format1D(0.8 * damage * (1 + 0.1 * TooltipTool.heBulletLevel(stack))) : "")).withStyle(ChatFormatting.GREEN)); + .append(Component.literal(FormatTool.format1D(damage) + (extraDamage >= 0 ? " + " + FormatTool.format1D(extraDamage) : "")) + .withStyle(ChatFormatting.GREEN)); } /** diff --git a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientSentinelImageTooltip.java b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientSentinelImageTooltip.java index 9ab0c4189..930fa6f9d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientSentinelImageTooltip.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientSentinelImageTooltip.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.client.tooltip; -import com.atsuishio.superbwarfare.client.TooltipTool; import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; +import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.tools.FormatTool; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -19,17 +19,22 @@ public class ClientSentinelImageTooltip extends ClientEnergyImageTooltip { if (cap != null && cap.getEnergyStored() > 0) { double damage = data.damage(); + double extraDamage = -1; + for (var type : Perk.Type.values()) { + var instance = data.perk.getInstance(type); + if (instance != null) { + damage = instance.perk().getDisplayDamage(damage, data, instance); + if (instance.perk().getExtraDisplayDamage(damage, data, instance) >= 0) { + extraDamage = instance.perk().getExtraDisplayDamage(damage, data, instance); + } + } + } return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(damage) + (TooltipTool.heBullet(stack) ? " + " + - FormatTool.format1D(0.8 * damage * (1 + 0.1 * TooltipTool.heBulletLevel(stack))) : "")) + .append(Component.literal(FormatTool.format1D(damage) + (extraDamage >= 0 ? " + " + FormatTool.format1D(extraDamage) : "")) .withStyle(ChatFormatting.AQUA).withStyle(ChatFormatting.BOLD)); } else { - double damage = data.damage(); - return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY) - .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(damage) + (TooltipTool.heBullet(stack) ? - FormatTool.format1D(0.4 * damage * (1 + 0.1 * TooltipTool.heBulletLevel(stack))) : "")).withStyle(ChatFormatting.GREEN)); + return super.getDamageComponent(); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java index f20235f4a..bd32fe75f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java @@ -1,6 +1,5 @@ package com.atsuishio.superbwarfare.client.tooltip; -import com.atsuishio.superbwarfare.client.TooltipTool; import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; @@ -25,15 +24,40 @@ public class ClientShotgunImageTooltip extends ClientGunImageTooltip { if (slug) { double damage = data.damage() * data.projectileAmount(); + double extraDamage = -1; + for (var type : Perk.Type.values()) { + var instance = data.perk.getInstance(type); + if (instance != null) { + damage = instance.perk().getDisplayDamage(damage, data, instance); + if (instance.perk().getExtraDisplayDamage(damage, data, instance) >= 0) { + extraDamage = instance.perk().getExtraDisplayDamage(damage, data, instance); + } + } + } + return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(damage) + (TooltipTool.heBullet(stack) ? " + " + - FormatTool.format1D(0.8 * damage * (1 + 0.1 * TooltipTool.heBulletLevel(stack))) : "")).withStyle(ChatFormatting.GREEN)); + .append(Component.literal(FormatTool.format1D(damage) + (extraDamage >= 0 ? " + " + FormatTool.format1D(extraDamage) : "")).withStyle(ChatFormatting.GREEN)); } else { double damage = data.damage(); + double extraDamage = -1; + for (var type : Perk.Type.values()) { + var instance = data.perk.getInstance(type); + if (instance != null) { + damage = instance.perk().getDisplayDamage(damage, data, instance); + if (instance.perk().getExtraDisplayDamage(damage, data, instance) >= 0) { + extraDamage = instance.perk().getExtraDisplayDamage(damage, data, instance); + } + } + } + return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format1D(damage) + " * " + FormatTool.format0D(data.projectileAmount())).withStyle(ChatFormatting.GREEN)); + .append(Component.literal(FormatTool.format1D(damage) + " * " + FormatTool.format0D(data.projectileAmount())).withStyle(ChatFormatting.GREEN)) + .append(Component.literal(extraDamage >= 0 ? + ("(" + FormatTool.format1D(damage) + " + " + FormatTool.format1D(extraDamage) + ") * " + FormatTool.format0D(data.projectileAmount())) + : FormatTool.format1D(damage, " * ") + FormatTool.format0D(data.projectileAmount()) + ).withStyle(ChatFormatting.GREEN)); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java b/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java index dbb9fbf0f..2b561550b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java @@ -31,49 +31,50 @@ public class ModPerks { /** * Ammo Perks */ - public static final DeferredRegister AMMO_PERKS = DeferredRegister.create(Mod.loc("perk"), Mod.MODID); + public static final DeferredRegister AMMO_PERKS = DeferredRegister.create(Mod.loc("per"), Mod.MODID); - public static final DeferredHolder AP_BULLET = AMMO_PERKS.register("ap_bullet", APBullet::new); - public static final DeferredHolder JHP_BULLET = AMMO_PERKS.register("jhp_bullet", JHPBullet::new); - public static final DeferredHolder HE_BULLET = AMMO_PERKS.register("he_bullet", HEBullet::new); - public static final DeferredHolder SILVER_BULLET = AMMO_PERKS.register("silver_bullet", SilverBullet::new); + public static final DeferredHolder AP_BULLET = AMMO_PERKS.register("ap_bullet", APBullet::new); + public static final DeferredHolder JHP_BULLET = AMMO_PERKS.register("jhp_bullet", JHPBullet::new); + public static final DeferredHolder HE_BULLET = AMMO_PERKS.register("he_bullet", HEBullet::new); + public static final DeferredHolder SILVER_BULLET = AMMO_PERKS.register("silver_bullet", SilverBullet::new); public static final DeferredHolder POISONOUS_BULLET = AMMO_PERKS.register("poisonous_bullet", () -> new AmmoPerk(new AmmoPerk.Builder("poisonous_bullet", Perk.Type.AMMO).bypassArmorRate(0.0f).damageRate(1.0f).speedRate(1.0f).rgb(48, 131, 6) .mobEffect(MobEffects.POISON::value))); - public static final DeferredHolder BEAST_BULLET = AMMO_PERKS.register("beast_bullet", BeastBullet::new); - public static final DeferredHolder LONGER_WIRE = AMMO_PERKS.register("longer_wire", LongerWire::new); - public static final DeferredHolder INCENDIARY_BULLET = AMMO_PERKS.register("incendiary_bullet", IncendiaryBullet::new); - public static final DeferredHolder MICRO_MISSILE = AMMO_PERKS.register("micro_missile", MicroMissile::new); + public static final DeferredHolder BEAST_BULLET = AMMO_PERKS.register("beast_bullet", BeastBullet::new); + public static final DeferredHolder LONGER_WIRE = AMMO_PERKS.register("longer_wire", LongerWire::new); + public static final DeferredHolder INCENDIARY_BULLET = AMMO_PERKS.register("incendiary_bullet", IncendiaryBullet::new); + public static final DeferredHolder MICRO_MISSILE = AMMO_PERKS.register("micro_missile", MicroMissile::new); /** * Functional Perks */ public static final DeferredRegister FUNC_PERKS = DeferredRegister.create(Mod.loc("perk"), Mod.MODID); - public static final DeferredHolder HEAL_CLIP = FUNC_PERKS.register("heal_clip", HealClip::new); - public static final DeferredHolder FOURTH_TIMES_CHARM = FUNC_PERKS.register("fourth_times_charm", FourthTimesCharm::new); - public static final DeferredHolder SUBSISTENCE = FUNC_PERKS.register("subsistence", Subsistence::new); - public static final DeferredHolder FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", FieldDoctor::new); - public static final DeferredHolder REGENERATION = FUNC_PERKS.register("regeneration", Regeneration::new); - public static final DeferredHolder TURBO_CHARGER = FUNC_PERKS.register("turbo_charger", TurboCharger::new); - public static final DeferredHolder POWERFUL_ATTRACTION = FUNC_PERKS.register("powerful_attraction", PowerfulAttraction::new); + public static final DeferredHolder HEAL_CLIP = FUNC_PERKS.register("heal_clip", HealClip::new); + public static final DeferredHolder FOURTH_TIMES_CHARM = FUNC_PERKS.register("fourth_times_charm", FourthTimesCharm::new); + public static final DeferredHolder SUBSISTENCE = FUNC_PERKS.register("subsistence", Subsistence::new); + public static final DeferredHolder FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", FieldDoctor::new); + public static final DeferredHolder REGENERATION = FUNC_PERKS.register("regeneration", Regeneration::new); + public static final DeferredHolder TURBO_CHARGER = FUNC_PERKS.register("turbo_charger", TurboCharger::new); + public static final DeferredHolder POWERFUL_ATTRACTION = FUNC_PERKS.register("powerful_attraction", PowerfulAttraction::new); public static final DeferredHolder INTELLIGENT_CHIP = FUNC_PERKS.register("intelligent_chip", () -> new Perk("intelligent_chip", Perk.Type.FUNCTIONAL)); + public static final DeferredHolder CUPID_ARROW = FUNC_PERKS.register("cupid_arrow", CupidArrow::new); /** * Damage Perks */ public static final DeferredRegister DAMAGE_PERKS = DeferredRegister.create(Mod.loc("perk"), Mod.MODID); - public static final DeferredHolder KILL_CLIP = DAMAGE_PERKS.register("kill_clip", KillClip::new); - public static final DeferredHolder GUTSHOT_STRAIGHT = DAMAGE_PERKS.register("gutshot_straight", GutshotStraight::new); - public static final DeferredHolder KILLING_TALLY = DAMAGE_PERKS.register("killing_tally", KillingTally::new); - public static final DeferredHolder HEAD_SEEKER = DAMAGE_PERKS.register("head_seeker", HeadSeeker::new); - public static final DeferredHolder MONSTER_HUNTER = DAMAGE_PERKS.register("monster_hunter", MonsterHunter::new); - public static final DeferredHolder VOLT_OVERLOAD = DAMAGE_PERKS.register("volt_overload", VoltOverload::new); - public static final DeferredHolder DESPERADO = DAMAGE_PERKS.register("desperado", Desperado::new); - public static final DeferredHolder VORPAL_WEAPON = DAMAGE_PERKS.register("vorpal_weapon", VorpalWeapon::new); - public static final DeferredHolder MAGNIFICENT_HOWL = DAMAGE_PERKS.register("magnificent_howl", MagnificentHowl::new); - public static final DeferredHolder FIREFLY = DAMAGE_PERKS.register("firefly", Firefly::new); + public static final DeferredHolder KILL_CLIP = DAMAGE_PERKS.register("kill_clip", KillClip::new); + public static final DeferredHolder GUTSHOT_STRAIGHT = DAMAGE_PERKS.register("gutshot_straight", GutshotStraight::new); + public static final DeferredHolder KILLING_TALLY = DAMAGE_PERKS.register("killing_tally", KillingTally::new); + public static final DeferredHolder HEAD_SEEKER = DAMAGE_PERKS.register("head_seeker", HeadSeeker::new); + public static final DeferredHolder MONSTER_HUNTER = DAMAGE_PERKS.register("monster_hunter", MonsterHunter::new); + public static final DeferredHolder VOLT_OVERLOAD = DAMAGE_PERKS.register("volt_overload", VoltOverload::new); + public static final DeferredHolder DESPERADO = DAMAGE_PERKS.register("desperado", Desperado::new); + public static final DeferredHolder VORPAL_WEAPON = DAMAGE_PERKS.register("vorpal_weapon", VorpalWeapon::new); + public static final DeferredHolder MAGNIFICENT_HOWL = DAMAGE_PERKS.register("magnificent_howl", MagnificentHowl::new); + public static final DeferredHolder FIREFLY = DAMAGE_PERKS.register("firefly", Firefly::new); // public static void registerCompatPerks() { // if (ModList.get().isLoaded(CompatHolder.DMV)) { diff --git a/src/main/java/com/atsuishio/superbwarfare/perk/Perk.java b/src/main/java/com/atsuishio/superbwarfare/perk/Perk.java index 466e327ed..ba1853e43 100644 --- a/src/main/java/com/atsuishio/superbwarfare/perk/Perk.java +++ b/src/main/java/com/atsuishio/superbwarfare/perk/Perk.java @@ -95,6 +95,20 @@ public class Perk { public void modifyProjectile(GunData data, PerkInstance instance, Entity entity) { } + /** + * 用于武器伤害信息显示 + */ + public double getDisplayDamage(double damage, GunData data, PerkInstance instance) { + return damage; + } + + /** + * 用于武器额外伤害信息显示,默认为负数 + */ + public double getExtraDisplayDamage(double damage, GunData data, PerkInstance instance) { + return -1; + } + public enum Type { AMMO("Ammo", ChatFormatting.YELLOW), FUNCTIONAL("Functional", ChatFormatting.GREEN), diff --git a/src/main/java/com/atsuishio/superbwarfare/perk/ammo/HEBullet.java b/src/main/java/com/atsuishio/superbwarfare/perk/ammo/HEBullet.java index 3a8b9709c..036139993 100644 --- a/src/main/java/com/atsuishio/superbwarfare/perk/ammo/HEBullet.java +++ b/src/main/java/com/atsuishio/superbwarfare/perk/ammo/HEBullet.java @@ -19,4 +19,9 @@ public class HEBullet extends AmmoPerk { if (!(entity instanceof ProjectileEntity projectile)) return; projectile.heBullet(instance.level()); } + + @Override + public double getExtraDisplayDamage(double damage, GunData data, PerkInstance instance) { + return 0.8 * damage * (1 + 0.1 * instance.level()); + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/perk/functional/CupidArrow.java b/src/main/java/com/atsuishio/superbwarfare/perk/functional/CupidArrow.java new file mode 100644 index 000000000..43c66b651 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/perk/functional/CupidArrow.java @@ -0,0 +1,53 @@ +package com.atsuishio.superbwarfare.perk.functional; + +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.perk.Perk; +import com.atsuishio.superbwarfare.perk.PerkInstance; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.Projectile; +import org.jetbrains.annotations.Nullable; + +public class CupidArrow extends Perk { + + public CupidArrow() { + super("cupid_arrow", Perk.Type.FUNCTIONAL); + } + + @Override + public void onHit(float damage, GunData data, PerkInstance instance, LivingEntity target, DamageSource source) { + Player attacker = null; + if (source.getEntity() instanceof Player player) { + attacker = player; + } + if (source.getDirectEntity() instanceof Projectile p && p.getOwner() instanceof Player player) { + attacker = player; + } + + if (target instanceof Animal animal && animal.canFallInLove()) { + animal.setInLove(attacker); + } + } + + @Override + public float getModifiedDamage(float damage, GunData data, PerkInstance instance, @Nullable LivingEntity target, DamageSource source) { + return 0; + } + + @Override + public boolean shouldCancelHurtEvent(float damage, GunData data, PerkInstance instance, LivingEntity target, DamageSource source) { + return true; + } + + @Override + public double getDisplayDamage(double damage, GunData data, PerkInstance instance) { + return 0; + } + + @Override + public double getExtraDisplayDamage(double damage, GunData data, PerkInstance instance) { + return 0; + } +} diff --git a/src/main/resources/data/superbwarfare/guns/bocek.json b/src/main/resources/data/superbwarfare/guns/bocek.json index 92d08d967..2c6d8b37f 100644 --- a/src/main/resources/data/superbwarfare/guns/bocek.json +++ b/src/main/resources/data/superbwarfare/guns/bocek.json @@ -12,6 +12,7 @@ "superbwarfare:field_doctor", "superbwarfare:intelligent_chip", "superbwarfare:monster_hunter", + "superbwarfare:cupid_arrow", "!superbwarfare:micro_missile", "!superbwarfare:butterfly_bullet" ]