From e35aaa5b64cc6f3b6a94662bb7a4b7c4ce7ecf30 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Tue, 7 Jan 2025 02:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=9D=A2=E5=8C=85=E5=BC=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/ProjectileEntity.java | 58 ++++++++++++++----- .../superbwarfare/event/GunEventHandler.java | 5 ++ .../superbwarfare/init/ModPerks.java | 2 + .../assets/superbwarfare/lang/en_us.json | 2 + .../assets/superbwarfare/lang/zh_cn.json | 2 + 5 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java index 1a9a48ed4..aa16a4fe9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java @@ -100,11 +100,12 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa private boolean fireBullet = false; private int fireLevel = 0; private boolean dragonBreath = false; - private double knockback = 0.05; + private float knockback = 0.05f; + private boolean forceKnockback = false; private final ArrayList mobEffects = new ArrayList<>(); - public ProjectileEntity(EntityType p_i50159_1_, Level p_i50159_2_) { - super(p_i50159_1_, p_i50159_2_); + public ProjectileEntity(EntityType entityType, Level level) { + super(entityType, level); this.noCulling = true; } @@ -112,8 +113,8 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa super(ModEntities.PROJECTILE.get(), level); } - public ProjectileEntity(PlayMessages.SpawnEntity packet, Level world) { - super(ModEntities.PROJECTILE.get(), world); + public ProjectileEntity(PlayMessages.SpawnEntity packet, Level level) { + super(ModEntities.PROJECTILE.get(), level); } @Nullable @@ -244,7 +245,6 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa public void tick() { super.tick(); this.updateHeading(); - this.onProjectileTick(); Vec3 vec = this.getDeltaMovement(); @@ -308,14 +308,31 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa } @Override - protected void readAdditionalSaveData(CompoundTag compoundTag) { + protected void readAdditionalSaveData(CompoundTag tag) { + this.damage = tag.getFloat("Damage"); + this.headShot = tag.getFloat("HeadShot"); + this.monsterMultiple = tag.getFloat("MonsterMultiple"); + this.legShot = tag.getFloat("LegShot"); + this.bypassArmorRate = tag.getFloat("BypassArmorRate"); + this.undeadMultiple = tag.getFloat("UndeadMultiple"); + this.knockback = tag.getFloat("Knockback"); + + this.beast = tag.getBoolean("Beast"); + this.forceKnockback = tag.getBoolean("ForceKnockback"); } @Override - protected void addAdditionalSaveData(CompoundTag compoundTag) { - } + protected void addAdditionalSaveData(CompoundTag tag) { + tag.putFloat("Damage", this.damage); + tag.putFloat("HeadShot", this.headShot); + tag.putFloat("MonsterMultiple", this.monsterMultiple); + tag.putFloat("LegShot", this.legShot); + tag.putFloat("BypassArmorRate", this.bypassArmorRate); + tag.putFloat("UndeadMultiple", this.undeadMultiple); + tag.putFloat("Knockback", this.knockback); - protected void onProjectileTick() { + tag.putBoolean("Beast", this.beast); + tag.putBoolean("ForceKnockback", this.forceKnockback); } private void onHit(HitResult result) { @@ -549,10 +566,16 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa public void performOnHit(Entity entity, float damage, boolean headshot, double knockback) { if (entity instanceof LivingEntity living) { - ICustomKnockback iCustomKnockback = ICustomKnockback.getInstance(living); - iCustomKnockback.superbWarfare$setKnockbackStrength(knockback); - performDamage(entity, damage, headshot); - iCustomKnockback.superbWarfare$resetKnockbackStrength(); + if (this.forceKnockback) { + Vec3 vec3 = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize(); + living.addDeltaMovement(vec3.scale(knockback)); + performDamage(entity, damage, headshot); + } else { + ICustomKnockback iCustomKnockback = ICustomKnockback.getInstance(living); + iCustomKnockback.superbWarfare$setKnockbackStrength(knockback); + performDamage(entity, damage, headshot); + iCustomKnockback.superbWarfare$resetKnockbackStrength(); + } } else { performDamage(entity, damage, headshot); } @@ -864,8 +887,13 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa this.entityData.set(COLOR_B, rgb[2]); } - public ProjectileEntity knockback(double knockback) { + public ProjectileEntity knockback(float knockback) { this.knockback = knockback; return this; } + + public ProjectileEntity forceKnockback() { + this.forceKnockback = true; + return this; + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java index b54dff1d1..27887e4bc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java @@ -225,6 +225,11 @@ public class GunEventHandler { } projectile.effect(mobEffectInstances); } + + if (perk.descriptionId.equals("bread_bullet")) { + projectile.knockback(level * 0.3f); + projectile.forceKnockback(); + } } bypassArmorRate = Math.max(bypassArmorRate, 0); diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java b/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java index 0e069a708..81042a479 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModPerks.java @@ -77,6 +77,8 @@ public class ModPerks { if (ModList.get().isLoaded(CompatHolder.DMV)) { AMMO_PERKS.register("blade_bullet", () -> new AmmoPerk(new AmmoPerk.Builder("blade_bullet", Perk.Type.AMMO) .bypassArmorRate(-0.2f).damageRate(0.7f).speedRate(0.8f).rgb(0xB4, 0x4B, 0x88).mobEffect(() -> CompatHolder.DMV_BLEEDING))); + AMMO_PERKS.register("bread_bullet", () -> new AmmoPerk(new AmmoPerk.Builder("bread_bullet", Perk.Type.AMMO) + .bypassArmorRate(1.0f).damageRate(0.5f).speedRate(0.6f).rgb(0xde, 0xab, 0x82).mobEffect(() -> MobEffects.MOVEMENT_SLOWDOWN))); } if (ModList.get().isLoaded(CompatHolder.VRC)) { AMMO_PERKS.register("curse_flame_bullet", () -> new AmmoPerk(new AmmoPerk.Builder("curse_flame_bullet", Perk.Type.AMMO) diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index b4fdba173..6bb4e7864 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -271,6 +271,8 @@ "des.superbwarfare.incendiary_bullet": "The bullet will ignites the target after hitting the target", "item.superbwarfare.butterfly_bullet": "Butterfly Bullet", "des.superbwarfare.butterfly_bullet": "Replace the bullet with Rain Shower Butterfly", + "item.superbwarfare.bread_bullet": "Bread Bullet", + "des.superbwarfare.bread_bullet": "命中后会使目标移速下降,并造成强大的击退", "item.superbwarfare.heal_clip": "Heal Clip", "des.superbwarfare.heal_clip": "Reloading after dealing a final blow will heal you and your nearby allies", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index fa03a73d6..49ca87cf8 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -270,6 +270,8 @@ "des.superbwarfare.incendiary_bullet": "子弹在命中后点燃目标", "item.superbwarfare.butterfly_bullet": "蝴蝶弹", "des.superbwarfare.butterfly_bullet": "将子弹替换成骤雨之蝶", + "item.superbwarfare.bread_bullet": "面包弹", + "des.superbwarfare.bread_bullet": "命中后会使目标移速下降,并造成强大的击退", "item.superbwarfare.heal_clip": "治疗弹匣", "des.superbwarfare.heal_clip": "最后一击后短时间内填装,可治疗自身和附近队友",