优化部分投射物写法
This commit is contained in:
parent
8bccd8426b
commit
7be151d630
1 changed files with 17 additions and 29 deletions
|
@ -127,6 +127,9 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
if (compound.contains("Radius")) {
|
if (compound.contains("Radius")) {
|
||||||
this.explosionRadius = compound.getFloat("Radius");
|
this.explosionRadius = compound.getFloat("Radius");
|
||||||
}
|
}
|
||||||
|
if (compound.contains("Durability")) {
|
||||||
|
this.durability = compound.getInt("Durability");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,6 +139,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
compound.putFloat("Damage", this.damage);
|
compound.putFloat("Damage", this.damage);
|
||||||
compound.putFloat("ExplosionDamage", this.explosionDamage);
|
compound.putFloat("ExplosionDamage", this.explosionDamage);
|
||||||
compound.putFloat("Radius", this.explosionRadius);
|
compound.putFloat("Radius", this.explosionRadius);
|
||||||
|
compound.putInt("Durability", this.durability);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,11 +150,9 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
@Override
|
@Override
|
||||||
protected void onHitEntity(EntityHitResult result) {
|
protected void onHitEntity(EntityHitResult result) {
|
||||||
Entity entity = result.getEntity();
|
Entity entity = result.getEntity();
|
||||||
if (this.getOwner() != null && this.getOwner().getVehicle() != null && entity == this.getOwner().getVehicle())
|
|
||||||
return;
|
|
||||||
if (this.level() instanceof ServerLevel) {
|
|
||||||
if (entity == this.getOwner() || (this.getOwner() != null && entity == this.getOwner().getVehicle()))
|
if (entity == this.getOwner() || (this.getOwner() != null && entity == this.getOwner().getVehicle()))
|
||||||
return;
|
return;
|
||||||
|
if (this.level() instanceof ServerLevel) {
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
||||||
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||||
|
@ -166,10 +168,10 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
apExplode(result.getLocation().add(getDeltaMovement().normalize().scale(i)));
|
causeExplode(result.getLocation().add(getDeltaMovement().normalize().scale(i)), this.explosionRadius * 0.5f, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
causeExplode(result.getLocation());
|
causeExplode(result.getLocation(), this.explosionRadius, true);
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +185,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
|
|
||||||
if (hardness == -1) {
|
if (hardness == -1) {
|
||||||
this.discard();
|
this.discard();
|
||||||
causeExplode(blockHitResult.getLocation());
|
causeExplode(blockHitResult.getLocation(), this.explosionRadius, true);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
|
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
|
||||||
|
@ -191,7 +193,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
causeExplode(blockHitResult.getLocation());
|
causeExplode(blockHitResult.getLocation(), this.explosionRadius, true);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i));
|
Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i));
|
||||||
|
@ -203,7 +205,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
|
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
|
||||||
this.level().destroyBlock(pos, true);
|
this.level().destroyBlock(pos, true);
|
||||||
}
|
}
|
||||||
apExplode(hitPos);
|
causeExplode(hitPos, this.explosionRadius * 0.5f, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +215,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void causeExplode(Vec3 vec3) {
|
private void causeExplode(Vec3 vec3, float radius, boolean isHuge) {
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||||
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(),
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(),
|
||||||
this,
|
this,
|
||||||
|
@ -222,32 +224,18 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
|
||||||
vec3.x,
|
vec3.x,
|
||||||
vec3.y,
|
vec3.y,
|
||||||
vec3.z,
|
vec3.z,
|
||||||
explosionRadius,
|
radius,
|
||||||
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true).
|
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true).
|
||||||
setDamageMultiplier(1);
|
setDamageMultiplier(1);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
EventHooks.onExplosionStart(this.level(), explosion);
|
EventHooks.onExplosionStart(this.level(), explosion);
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
|
if (isHuge) {
|
||||||
ParticleTool.spawnHugeExplosionParticles(this.level(), vec3);
|
ParticleTool.spawnHugeExplosionParticles(this.level(), vec3);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
private void apExplode(Vec3 vec3) {
|
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
|
||||||
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(),
|
|
||||||
this,
|
|
||||||
this.getOwner()),
|
|
||||||
explosionDamage,
|
|
||||||
vec3.x,
|
|
||||||
vec3.y,
|
|
||||||
vec3.z,
|
|
||||||
explosionRadius * 0.5f,
|
|
||||||
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true).
|
|
||||||
setDamageMultiplier(1);
|
|
||||||
explosion.explode();
|
|
||||||
EventHooks.onExplosionStart(this.level(), explosion);
|
|
||||||
explosion.finalizeExplosion(false);
|
|
||||||
ParticleTool.spawnMediumExplosionParticles(this.level(), vec3);
|
ParticleTool.spawnMediumExplosionParticles(this.level(), vec3);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue