调整数值,添加C4音效
This commit is contained in:
parent
806053a404
commit
fdc7016c72
9 changed files with 71 additions and 28 deletions
|
@ -1,10 +1,10 @@
|
|||
package com.atsuishio.superbwarfare.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
|
@ -21,7 +21,6 @@ import net.minecraft.sounds.SoundSource;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
|
@ -45,7 +44,6 @@ public class C4Entity extends Projectile implements GeoEntity {
|
|||
|
||||
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.STRING);
|
||||
protected static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.STRING);
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.FLOAT);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
protected boolean inGround;
|
||||
protected boolean onEntity;
|
||||
|
@ -63,23 +61,11 @@ public class C4Entity extends Projectile implements GeoEntity {
|
|||
@Override
|
||||
protected void defineSynchedData() {
|
||||
this.entityData.define(LAST_ATTACKER_UUID, "undefined");
|
||||
this.entityData.define(HEALTH, 10f);
|
||||
this.entityData.define(TARGET_UUID, "undefined");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
return !this.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hurt(DamageSource source, float amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compound) {
|
||||
compound.putFloat("Health", this.entityData.get(HEALTH));
|
||||
compound.putString("Target", this.entityData.get(TARGET_UUID));
|
||||
compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID));
|
||||
|
||||
|
@ -90,10 +76,6 @@ public class C4Entity extends Projectile implements GeoEntity {
|
|||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compound) {
|
||||
if (compound.contains("Health")) {
|
||||
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
||||
}
|
||||
|
||||
if (compound.contains("LastAttacker")) {
|
||||
this.entityData.set(LAST_ATTACKER_UUID, compound.getString("LastAttacker"));
|
||||
}
|
||||
|
@ -130,6 +112,14 @@ public class C4Entity extends Projectile implements GeoEntity {
|
|||
this.explode();
|
||||
}
|
||||
|
||||
if (ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get() - tickCount > 39 && tickCount %((20 * (ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get() - tickCount)) / ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get() + 1) == 0) {
|
||||
this.level().playSound(null, this.getOnPos(), ModSounds.C4_BEEP.get(), SoundSource.PLAYERS, 1, 1);
|
||||
}
|
||||
|
||||
if (tickCount == ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get() - 39) {
|
||||
this.level().playSound(null, this.getOnPos(), ModSounds.C4_FINAL.get(), SoundSource.PLAYERS, 2, 1);
|
||||
}
|
||||
|
||||
Vec3 motion = this.getDeltaMovement();
|
||||
if (this.xRotO == 0.0F && this.yRotO == 0.0F && !this.inGround) {
|
||||
double d0 = motion.horizontalDistance();
|
||||
|
@ -319,22 +309,25 @@ public class C4Entity extends Projectile implements GeoEntity {
|
|||
this.inGround = true;
|
||||
}
|
||||
|
||||
public void explode() {
|
||||
if (!this.level().isClientSide()) {
|
||||
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
||||
ModUtils.queueServerWork(1, () -> this.triggerExplode(this));
|
||||
}
|
||||
this.discard();
|
||||
}
|
||||
private void explode() {
|
||||
Vec3 pos = position();
|
||||
|
||||
if (onEntity) {
|
||||
Entity target = EntityFindUtil.findEntity(level(), entityData.get(TARGET_UUID));
|
||||
if (target != null) {
|
||||
pos = target.position();
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerExplode(Entity target) {
|
||||
CustomExplosion explosion = new CustomExplosion(level(), this,
|
||||
ModDamageTypes.causeProjectileBoomDamage(level().registryAccess(), this, this.getOwner()), ExplosionConfig.C4_EXPLOSION_DAMAGE.get(),
|
||||
target.getX(), target.getY(), target.getZ(), ExplosionConfig.C4_EXPLOSION_RADIUS.get(), ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||
pos.x, pos.y, pos.z, ExplosionConfig.C4_EXPLOSION_RADIUS.get(), ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||
explosion.explode();
|
||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(level(), explosion);
|
||||
ParticleTool.spawnHugeExplosionParticles(level(), position());
|
||||
explosion.finalizeExplosion(false);
|
||||
|
||||
this.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
|||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||
import com.atsuishio.superbwarfare.entity.C4Entity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.EnergyVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
|
||||
|
@ -215,6 +216,18 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
|||
.multiply(0.3f, ModDamageTypes.CANNON_FIRE)
|
||||
.multiply(0.04f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
||||
.custom((source, damage) -> getSourceAngle(source, 3) * damage)
|
||||
.custom((source, damage) -> {
|
||||
if (source.getDirectEntity() instanceof C4Entity) {
|
||||
return 40f * damage;
|
||||
}
|
||||
return damage;
|
||||
})
|
||||
.custom((source, damage) -> {
|
||||
if (source.getDirectEntity() instanceof DroneEntity) {
|
||||
return 8f * damage;
|
||||
}
|
||||
return damage;
|
||||
})
|
||||
.reduce(12);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,6 +154,12 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
.multiply(0.7f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
||||
.multiply(8.5f, ModDamageTypes.VEHICLE_STRIKE)
|
||||
.custom((source, damage) -> getSourceAngle(source, 0.4f) * damage)
|
||||
.custom((source, damage) -> {
|
||||
if (source.getDirectEntity() instanceof DroneEntity) {
|
||||
return 1.5f * damage;
|
||||
}
|
||||
return damage;
|
||||
})
|
||||
.reduce(8);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,6 +143,12 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
.multiply(0.85f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
||||
.multiply(10f, ModDamageTypes.VEHICLE_STRIKE)
|
||||
.custom((source, damage) -> getSourceAngle(source, 0.25f) * damage)
|
||||
.custom((source, damage) -> {
|
||||
if (source.getDirectEntity() instanceof DroneEntity) {
|
||||
return 1.5f * damage;
|
||||
}
|
||||
return damage;
|
||||
})
|
||||
.reduce(7);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
|||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||
import com.atsuishio.superbwarfare.entity.C4Entity;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity;
|
||||
|
@ -188,6 +189,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
}
|
||||
return damage;
|
||||
})
|
||||
.custom((source, damage) -> {
|
||||
if (source.getDirectEntity() instanceof C4Entity || source.getDirectEntity() instanceof DroneEntity) {
|
||||
return 3f * damage;
|
||||
}
|
||||
return damage;
|
||||
})
|
||||
.reduce(9);
|
||||
}
|
||||
|
||||
|
|
|
@ -423,5 +423,7 @@ public class ModSounds {
|
|||
public static final RegistryObject<SoundEvent> YX_100_FAR = REGISTRY.register("yx_100_far", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("yx_100_far")));
|
||||
public static final RegistryObject<SoundEvent> YX_100_VERYFAR = REGISTRY.register("yx_100_veryfar", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("yx_100_veryfar")));
|
||||
public static final RegistryObject<SoundEvent> TURRET_TURN = REGISTRY.register("turret_turn", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("turret_turn")));
|
||||
public static final RegistryObject<SoundEvent> C4_BEEP = REGISTRY.register("c4_beep", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_beep")));
|
||||
public static final RegistryObject<SoundEvent> C4_FINAL = REGISTRY.register("c4_final", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_final")));
|
||||
}
|
||||
|
||||
|
|
|
@ -2915,5 +2915,21 @@
|
|||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"c4_beep": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:c4/c4_beep",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"c4_final": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:c4/c4_final",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
BIN
src/main/resources/assets/superbwarfare/sounds/c4/c4_beep.ogg
Normal file
BIN
src/main/resources/assets/superbwarfare/sounds/c4/c4_beep.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/superbwarfare/sounds/c4/c4_final.ogg
Normal file
BIN
src/main/resources/assets/superbwarfare/sounds/c4/c4_final.ogg
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue