还是优化弹射物穿透(恼

This commit is contained in:
Atsuishio 2025-06-18 17:51:29 +08:00 committed by Light_Quanta
parent f293eeb09f
commit b0e61f9ef7
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
9 changed files with 50 additions and 47 deletions

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.*;
@ -165,6 +166,8 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
}
causeExplode(result.getLocation());
discard();
}
}
@ -175,6 +178,11 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime();
if (hardness != -1) {
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
if (firstHit) {
causeExplode(blockHitResult.getLocation());
firstHit = false;
Mod.queueServerWork(3, this::discard);
}
this.level().destroyBlock(resultPos, true);
}
}
@ -205,7 +213,6 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
} else {
ParticleTool.spawnMediumExplosionParticles(this.level(), vec3);
}
discard();
}
@Override
@ -271,13 +278,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f));
destroyBlock();
}
@Override
public void destroy(Vec3 pos) {
causeExplode(pos);
}
@Override
public boolean isNoGravity() {
return true;

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
@ -153,6 +154,11 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt
float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime();
if (hardness != -1) {
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
if (firstHit) {
causeExplode(blockHitResult.getLocation());
firstHit = false;
Mod.queueServerWork(3, this::discard);
}
this.level().destroyBlock(resultPos, true);
}
}
@ -220,11 +226,6 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt
}
}
@Override
public void destroy(Vec3 pos) {
causeExplode(pos);
}
private void causeExplode(Vec3 vec3) {
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(),

View file

@ -33,6 +33,8 @@ public abstract class FastThrowableProjectile extends ThrowableItemProjectile im
public int durability = 50;
public boolean firstHit = true;
private boolean isFastMoving = false;
public FastThrowableProjectile(EntityType<? extends ThrowableItemProjectile> pEntityType, Level pLevel) {
@ -97,16 +99,13 @@ public abstract class FastThrowableProjectile extends ThrowableItemProjectile im
this.level().destroyBlock(pos, true);
}
if (hardness == -1 || hardness > durability || durability <= 0) {
destroy(pos.getCenter());
break;
discard();
}
}
}
}
}
public void destroy(Vec3 pos) {
}
@Override
public void syncMotion() {

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities;
@ -128,6 +129,11 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti
float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime();
if (hardness != -1) {
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
if (firstHit) {
causeExplode(blockHitResult.getLocation());
firstHit = false;
Mod.queueServerWork(3, this::discard);
}
this.level().destroyBlock(resultPos, true);
}
}
@ -154,7 +160,6 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti
EventHooks.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnHugeExplosionParticles(this.level(), vec3);
discard();
}
@ -184,11 +189,6 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti
destroyBlock();
}
@Override
public void destroy(Vec3 pos) {
causeExplode(pos);
}
public static void causeRocketExplode(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, true).setDamageMultiplier(damageMultiplier);

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.*;
@ -73,7 +74,7 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo
this.entityData.set(TARGET_X, (float) targetPos.x);
this.entityData.set(TARGET_Y, (float) targetPos.y);
this.entityData.set(TARGET_Z, (float) targetPos.z);
this.durability = 35;
this.durability = 50;
}
public void setMonsterMultiplier(float monsterMultiplier) {
@ -208,6 +209,11 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo
float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime();
if (hardness != -1) {
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
if (firstHit) {
causeExplode(blockHitResult.getLocation());
firstHit = false;
Mod.queueServerWork(3, this::discard);
}
this.level().destroyBlock(resultPos, true);
}
}
@ -234,7 +240,6 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo
EventHooks.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnHugeExplosionParticles(this.level(), vec3);
discard();
}
@Override
@ -357,12 +362,7 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo
this.setDeltaMovement(this.getDeltaMovement().multiply(0.96, 0.96, 0.96));
destroyBlock();
}
@Override
public void destroy(Vec3 pos) {
causeExplode(pos);
}
private PlayState movementPredicate(AnimationState<JavelinMissileEntity> event) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.jvm.idle"));
}

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities;
@ -123,6 +124,11 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit
float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime();
if (hardness != -1) {
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
if (firstHit) {
causeExplode(blockHitResult.getLocation());
firstHit = false;
Mod.queueServerWork(3, this::discard);
}
this.level().destroyBlock(resultPos, true);
}
}
@ -181,7 +187,6 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit
EventHooks.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnHugeExplosionParticles(this.level(), vec3);
discard();
}
@Override
@ -211,11 +216,6 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit
destroyBlock();
}
@Override
public void destroy(Vec3 pos) {
causeExplode(pos);
}
private PlayState movementPredicate(AnimationState<RpgRocketEntity> event) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.rpg.idle"));
}

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
@ -61,7 +62,7 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit
this.damage = damage;
this.explosionDamage = explosionDamage;
this.explosionRadius = explosionRadius;
this.durability = 25;
this.durability = 50;
}
@Override
@ -139,6 +140,11 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit
float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime();
if (hardness != -1) {
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
if (firstHit) {
causeExplode(blockHitResult.getLocation());
firstHit = false;
Mod.queueServerWork(3, this::discard);
}
this.level().destroyBlock(resultPos, true);
}
}
@ -242,13 +248,7 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit
}
destroyBlock();
}
@Override
public void destroy(Vec3 pos) {
causeExplode(pos);
discard();
}
private PlayState movementPredicate(AnimationState<WgMissileEntity> event) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.jvm.idle"));
}

View file

@ -576,10 +576,10 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER));
Entity mortarShell = new MortarShellEntity(controller, level());
assert controller != null;
Entity mortarShell = new MortarShellEntity(controller, level());
Entity c4 = new C4Entity(controller, level());
Entity rpg = new RpgRocketEntity(controller, level(), ExplosionConfig.RPG_EXPLOSION_DAMAGE.get());
Entity rpg = new RpgRocketEntity(controller, level());
CustomExplosion explosion = switch (mode) {
case 1 -> new CustomExplosion(this.level(), this,

View file

@ -236,6 +236,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.15), random.nextFloat() * 0.15f + 1.05f);
}
@Override
public void baseTick() {
super.baseTick();