添加新perk,修改部分tooltip方法
This commit is contained in:
parent
157c113e97
commit
e8a27a99cf
10 changed files with 172 additions and 66 deletions
|
@ -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<Component> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,49 +31,50 @@ public class ModPerks {
|
|||
/**
|
||||
* Ammo Perks
|
||||
*/
|
||||
public static final DeferredRegister<Perk> AMMO_PERKS = DeferredRegister.create(Mod.loc("perk"), Mod.MODID);
|
||||
public static final DeferredRegister<Perk> AMMO_PERKS = DeferredRegister.create(Mod.loc("per"), Mod.MODID);
|
||||
|
||||
public static final DeferredHolder<Perk, Perk> AP_BULLET = AMMO_PERKS.register("ap_bullet", APBullet::new);
|
||||
public static final DeferredHolder<Perk, Perk> JHP_BULLET = AMMO_PERKS.register("jhp_bullet", JHPBullet::new);
|
||||
public static final DeferredHolder<Perk, Perk> HE_BULLET = AMMO_PERKS.register("he_bullet", HEBullet::new);
|
||||
public static final DeferredHolder<Perk, Perk> SILVER_BULLET = AMMO_PERKS.register("silver_bullet", SilverBullet::new);
|
||||
public static final DeferredHolder<Perk, APBullet> AP_BULLET = AMMO_PERKS.register("ap_bullet", APBullet::new);
|
||||
public static final DeferredHolder<Perk, JHPBullet> JHP_BULLET = AMMO_PERKS.register("jhp_bullet", JHPBullet::new);
|
||||
public static final DeferredHolder<Perk, HEBullet> HE_BULLET = AMMO_PERKS.register("he_bullet", HEBullet::new);
|
||||
public static final DeferredHolder<Perk, SilverBullet> SILVER_BULLET = AMMO_PERKS.register("silver_bullet", SilverBullet::new);
|
||||
public static final DeferredHolder<Perk, Perk> 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<Perk, Perk> BEAST_BULLET = AMMO_PERKS.register("beast_bullet", BeastBullet::new);
|
||||
public static final DeferredHolder<Perk, Perk> LONGER_WIRE = AMMO_PERKS.register("longer_wire", LongerWire::new);
|
||||
public static final DeferredHolder<Perk, Perk> INCENDIARY_BULLET = AMMO_PERKS.register("incendiary_bullet", IncendiaryBullet::new);
|
||||
public static final DeferredHolder<Perk, Perk> MICRO_MISSILE = AMMO_PERKS.register("micro_missile", MicroMissile::new);
|
||||
public static final DeferredHolder<Perk, BeastBullet> BEAST_BULLET = AMMO_PERKS.register("beast_bullet", BeastBullet::new);
|
||||
public static final DeferredHolder<Perk, LongerWire> LONGER_WIRE = AMMO_PERKS.register("longer_wire", LongerWire::new);
|
||||
public static final DeferredHolder<Perk, IncendiaryBullet> INCENDIARY_BULLET = AMMO_PERKS.register("incendiary_bullet", IncendiaryBullet::new);
|
||||
public static final DeferredHolder<Perk, MicroMissile> MICRO_MISSILE = AMMO_PERKS.register("micro_missile", MicroMissile::new);
|
||||
|
||||
/**
|
||||
* Functional Perks
|
||||
*/
|
||||
public static final DeferredRegister<Perk> FUNC_PERKS = DeferredRegister.create(Mod.loc("perk"), Mod.MODID);
|
||||
|
||||
public static final DeferredHolder<Perk, Perk> HEAL_CLIP = FUNC_PERKS.register("heal_clip", HealClip::new);
|
||||
public static final DeferredHolder<Perk, Perk> FOURTH_TIMES_CHARM = FUNC_PERKS.register("fourth_times_charm", FourthTimesCharm::new);
|
||||
public static final DeferredHolder<Perk, Perk> SUBSISTENCE = FUNC_PERKS.register("subsistence", Subsistence::new);
|
||||
public static final DeferredHolder<Perk, Perk> FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", FieldDoctor::new);
|
||||
public static final DeferredHolder<Perk, Perk> REGENERATION = FUNC_PERKS.register("regeneration", Regeneration::new);
|
||||
public static final DeferredHolder<Perk, Perk> TURBO_CHARGER = FUNC_PERKS.register("turbo_charger", TurboCharger::new);
|
||||
public static final DeferredHolder<Perk, Perk> POWERFUL_ATTRACTION = FUNC_PERKS.register("powerful_attraction", PowerfulAttraction::new);
|
||||
public static final DeferredHolder<Perk, HealClip> HEAL_CLIP = FUNC_PERKS.register("heal_clip", HealClip::new);
|
||||
public static final DeferredHolder<Perk, FourthTimesCharm> FOURTH_TIMES_CHARM = FUNC_PERKS.register("fourth_times_charm", FourthTimesCharm::new);
|
||||
public static final DeferredHolder<Perk, Subsistence> SUBSISTENCE = FUNC_PERKS.register("subsistence", Subsistence::new);
|
||||
public static final DeferredHolder<Perk, FieldDoctor> FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", FieldDoctor::new);
|
||||
public static final DeferredHolder<Perk, Regeneration> REGENERATION = FUNC_PERKS.register("regeneration", Regeneration::new);
|
||||
public static final DeferredHolder<Perk, TurboCharger> TURBO_CHARGER = FUNC_PERKS.register("turbo_charger", TurboCharger::new);
|
||||
public static final DeferredHolder<Perk, PowerfulAttraction> POWERFUL_ATTRACTION = FUNC_PERKS.register("powerful_attraction", PowerfulAttraction::new);
|
||||
public static final DeferredHolder<Perk, Perk> INTELLIGENT_CHIP = FUNC_PERKS.register("intelligent_chip", () -> new Perk("intelligent_chip", Perk.Type.FUNCTIONAL));
|
||||
public static final DeferredHolder<Perk, CupidArrow> CUPID_ARROW = FUNC_PERKS.register("cupid_arrow", CupidArrow::new);
|
||||
|
||||
/**
|
||||
* Damage Perks
|
||||
*/
|
||||
public static final DeferredRegister<Perk> DAMAGE_PERKS = DeferredRegister.create(Mod.loc("perk"), Mod.MODID);
|
||||
|
||||
public static final DeferredHolder<Perk, Perk> KILL_CLIP = DAMAGE_PERKS.register("kill_clip", KillClip::new);
|
||||
public static final DeferredHolder<Perk, Perk> GUTSHOT_STRAIGHT = DAMAGE_PERKS.register("gutshot_straight", GutshotStraight::new);
|
||||
public static final DeferredHolder<Perk, Perk> KILLING_TALLY = DAMAGE_PERKS.register("killing_tally", KillingTally::new);
|
||||
public static final DeferredHolder<Perk, Perk> HEAD_SEEKER = DAMAGE_PERKS.register("head_seeker", HeadSeeker::new);
|
||||
public static final DeferredHolder<Perk, Perk> MONSTER_HUNTER = DAMAGE_PERKS.register("monster_hunter", MonsterHunter::new);
|
||||
public static final DeferredHolder<Perk, Perk> VOLT_OVERLOAD = DAMAGE_PERKS.register("volt_overload", VoltOverload::new);
|
||||
public static final DeferredHolder<Perk, Perk> DESPERADO = DAMAGE_PERKS.register("desperado", Desperado::new);
|
||||
public static final DeferredHolder<Perk, Perk> VORPAL_WEAPON = DAMAGE_PERKS.register("vorpal_weapon", VorpalWeapon::new);
|
||||
public static final DeferredHolder<Perk, Perk> MAGNIFICENT_HOWL = DAMAGE_PERKS.register("magnificent_howl", MagnificentHowl::new);
|
||||
public static final DeferredHolder<Perk, Perk> FIREFLY = DAMAGE_PERKS.register("firefly", Firefly::new);
|
||||
public static final DeferredHolder<Perk, KillClip> KILL_CLIP = DAMAGE_PERKS.register("kill_clip", KillClip::new);
|
||||
public static final DeferredHolder<Perk, GutshotStraight> GUTSHOT_STRAIGHT = DAMAGE_PERKS.register("gutshot_straight", GutshotStraight::new);
|
||||
public static final DeferredHolder<Perk, KillingTally> KILLING_TALLY = DAMAGE_PERKS.register("killing_tally", KillingTally::new);
|
||||
public static final DeferredHolder<Perk, HeadSeeker> HEAD_SEEKER = DAMAGE_PERKS.register("head_seeker", HeadSeeker::new);
|
||||
public static final DeferredHolder<Perk, MonsterHunter> MONSTER_HUNTER = DAMAGE_PERKS.register("monster_hunter", MonsterHunter::new);
|
||||
public static final DeferredHolder<Perk, VoltOverload> VOLT_OVERLOAD = DAMAGE_PERKS.register("volt_overload", VoltOverload::new);
|
||||
public static final DeferredHolder<Perk, Desperado> DESPERADO = DAMAGE_PERKS.register("desperado", Desperado::new);
|
||||
public static final DeferredHolder<Perk, VorpalWeapon> VORPAL_WEAPON = DAMAGE_PERKS.register("vorpal_weapon", VorpalWeapon::new);
|
||||
public static final DeferredHolder<Perk, MagnificentHowl> MAGNIFICENT_HOWL = DAMAGE_PERKS.register("magnificent_howl", MagnificentHowl::new);
|
||||
public static final DeferredHolder<Perk, Firefly> FIREFLY = DAMAGE_PERKS.register("firefly", Firefly::new);
|
||||
|
||||
// public static void registerCompatPerks() {
|
||||
// if (ModList.get().isLoaded(CompatHolder.DMV)) {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
"superbwarfare:field_doctor",
|
||||
"superbwarfare:intelligent_chip",
|
||||
"superbwarfare:monster_hunter",
|
||||
"superbwarfare:cupid_arrow",
|
||||
"!superbwarfare:micro_missile",
|
||||
"!superbwarfare:butterfly_bullet"
|
||||
]
|
||||
|
|
Loading…
Add table
Reference in a new issue