优化爆炸,调整药水炮弹效果云,削弱SVD爆头倍率

This commit is contained in:
Atsuihsio 2025-03-03 10:30:53 +08:00
parent dc8b74f804
commit 0940186599
7 changed files with 39 additions and 76 deletions

View file

@ -241,7 +241,7 @@ public class MortarShellEntity extends ThrowableItemProjectile implements GeoEnt
private void createAreaCloud(Level level) { private void createAreaCloud(Level level) {
if (this.potion == Potions.EMPTY) return; if (this.potion == Potions.EMPTY) return;
AreaEffectCloud cloud = new AreaEffectCloud(level, this.getX(), this.getY(), this.getZ()); AreaEffectCloud cloud = new AreaEffectCloud(level, this.getX() + 0.75 * getDeltaMovement().x, this.getY() + 0.5 * getBbHeight() + 0.75 * getDeltaMovement().y, this.getZ() + 0.75 * getDeltaMovement().z);
cloud.setPotion(this.potion); cloud.setPotion(this.potion);
cloud.setDuration((int) this.damage); cloud.setDuration((int) this.damage);
cloud.setRadius(this.radius); cloud.setRadius(this.radius);

View file

@ -3,12 +3,10 @@ package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity; import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities; import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.ParticleTool; import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.tools.ProjectileTool; import com.atsuishio.superbwarfare.tools.ProjectileTool;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -19,13 +17,11 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock; import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -41,8 +37,6 @@ import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache
import software.bernie.geckolib.core.animation.AnimatableManager; import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil; import software.bernie.geckolib.util.GeckoLibUtil;
import javax.annotation.Nullable;
public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEntity { public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEntity {
private int fuse = 80; private int fuse = 80;
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
@ -78,6 +72,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
@Override @Override
protected void onHit(HitResult result) { protected void onHit(HitResult result) {
if (level() instanceof ServerLevel) {
switch (result.getType()) { switch (result.getType()) {
case BLOCK: case BLOCK:
BlockHitResult blockResult = (BlockHitResult) result; BlockHitResult blockResult = (BlockHitResult) result;
@ -100,24 +95,13 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
} }
} }
if (!(entity instanceof DroneEntity)) { if (!(entity instanceof DroneEntity)) {
causeRgoExplode(this, ProjectileTool.causeCustomExplode(this, ExplosionConfig.RGO_GRENADE_EXPLOSION_DAMAGE.get(), ExplosionConfig.RGO_GRENADE_EXPLOSION_RADIUS.get(), 1.2f);
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
entity, ExplosionConfig.RGO_GRENADE_EXPLOSION_DAMAGE.get(), ExplosionConfig.RGO_GRENADE_EXPLOSION_RADIUS.get(), 1.2f);
} }
break; break;
default: default:
break; break;
} }
} }
public static void causeRgoExplode(ThrowableItemProjectile projectile, @Nullable DamageSource source, Entity entity, float damage, float radius, float damageMultiplier) {
CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile, source, damage,
projectile.getX(), projectile.getY(), projectile.getZ(), radius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(damageMultiplier);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnMediumExplosionParticles(projectile.level(), projectile.position());
projectile.discard();
} }
@Override @Override

View file

@ -1,15 +1,14 @@
package com.atsuishio.superbwarfare.entity.projectile; package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.AnimatedEntity; import com.atsuishio.superbwarfare.entity.AnimatedEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities; import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.ParticleTool; import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.tools.ProjectileTool;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
@ -20,14 +19,12 @@ import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock; import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -45,8 +42,6 @@ import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil; import software.bernie.geckolib.util.GeckoLibUtil;
import javax.annotation.Nullable;
public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity { public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(RpgRocketEntity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(RpgRocketEntity.class, EntityDataSerializers.STRING);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
@ -118,9 +113,7 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
if (this.tickCount > 1) { if (this.tickCount > 1) {
if (this.level() instanceof ServerLevel) { if (this.level() instanceof ServerLevel) {
causeRpgExplode(this, ProjectileTool.causeCustomExplode(this, this.explosion_damage, this.explosion_radius, this.monsterMultiplier);
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
entity, this.explosion_damage, this.explosion_radius, this.monsterMultiplier);
} }
} }
@ -139,9 +132,7 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
if (this.tickCount > 1) { if (this.tickCount > 1) {
if (this.level() instanceof ServerLevel) { if (this.level() instanceof ServerLevel) {
causeRpgExplode(this, ProjectileTool.causeCustomExplode(this, this.explosion_damage, this.explosion_radius, this.monsterMultiplier);
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
this, this.explosion_damage, this.explosion_radius, this.monsterMultiplier);
} }
} }
@ -168,24 +159,12 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
if (this.tickCount > 100 || this.isInWater()) { if (this.tickCount > 100 || this.isInWater()) {
if (this.level() instanceof ServerLevel) { if (this.level() instanceof ServerLevel) {
causeRpgExplode(this, ProjectileTool.causeCustomExplode(this, this.explosion_damage, this.explosion_radius, this.monsterMultiplier);
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
this, this.explosion_damage, this.explosion_radius, this.monsterMultiplier);
} }
this.discard(); this.discard();
} }
} }
public static void causeRpgExplode(ThrowableItemProjectile projectile, @Nullable DamageSource source, Entity target, float damage, float radius, float damageMultiplier) {
CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile, source, damage,
projectile.getX(), projectile.getY(), projectile.getZ(), radius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(damageMultiplier);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnHugeExplosionParticles(projectile.level(), projectile.position());
projectile.discard();
}
private PlayState movementPredicate(AnimationState<RpgRocketEntity> event) { private PlayState movementPredicate(AnimationState<RpgRocketEntity> event) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.rpg.idle")); return event.setAndContinue(RawAnimation.begin().thenLoop("animation.rpg.idle"));
} }

View file

@ -175,7 +175,7 @@ public class VehicleEntity extends Entity {
// 显示火花粒子效果 // 显示火花粒子效果
if (this.sendFireStarParticleOnHurt() && this.level() instanceof ServerLevel serverLevel) { if (this.sendFireStarParticleOnHurt() && this.level() instanceof ServerLevel serverLevel) {
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.5 * getBbHeight(), this.getZ(), 2, 0.4, 0.4, 0.4, 0.2, false);
} }
// 播放受击音效 // 播放受击音效
if (this.playHitSoundOnHurt()) { if (this.playHitSoundOnHurt()) {

View file

@ -21,11 +21,11 @@ public class ProjectileTool {
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
explosion.finalizeExplosion(false); explosion.finalizeExplosion(false);
if (radius <= 5) { if (radius <= 5) {
ParticleTool.spawnSmallExplosionParticles(projectile.level(), projectile.position()); ParticleTool.spawnSmallExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5)));
} else if (radius > 5 && radius < 10) { } else if (radius > 5 && radius < 10) {
ParticleTool.spawnMediumExplosionParticles(projectile.level(), projectile.position()); ParticleTool.spawnMediumExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5)));
} else { } else {
ParticleTool.spawnHugeExplosionParticles(projectile.level(), projectile.position()); ParticleTool.spawnHugeExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5)));
} }
projectile.discard(); projectile.discard();

View file

@ -4,7 +4,7 @@
"RecoilY": 0.018, "RecoilY": 0.018,
"Damage": 270, "Damage": 270,
"ExplosionDamage": 130, "ExplosionDamage": 130,
"ExplosionRadius": 7, "ExplosionRadius": 10,
"Velocity": 4, "Velocity": 4,
"Magazine": 1, "Magazine": 1,
"Weight": 7, "Weight": 7,

View file

@ -5,7 +5,7 @@
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.009, "RecoilY": 0.009,
"Damage": 18, "Damage": 18,
"Headshot": 3, "Headshot": 2.5,
"Velocity": 42, "Velocity": 42,
"Magazine": 10, "Magazine": 10,
"Weight": 5, "Weight": 5,