diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java index 57092558a..04cec468c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java @@ -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 LAST_ATTACKER_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.STRING); protected static final EntityDataAccessor TARGET_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.STRING); - public static final EntityDataAccessor 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 diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java index 871a97854..463605930 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java @@ -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); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 276140a01..b6243c80e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -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); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 5aab6b546..a6a5236e6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -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); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index 897686c12..018495c95 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -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); } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java index a56a1df81..9b60321dc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java @@ -423,5 +423,7 @@ public class ModSounds { public static final RegistryObject YX_100_FAR = REGISTRY.register("yx_100_far", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("yx_100_far"))); public static final RegistryObject YX_100_VERYFAR = REGISTRY.register("yx_100_veryfar", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("yx_100_veryfar"))); public static final RegistryObject TURRET_TURN = REGISTRY.register("turret_turn", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("turret_turn"))); + public static final RegistryObject C4_BEEP = REGISTRY.register("c4_beep", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_beep"))); + public static final RegistryObject C4_FINAL = REGISTRY.register("c4_final", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_final"))); } diff --git a/src/main/resources/assets/superbwarfare/sounds.json b/src/main/resources/assets/superbwarfare/sounds.json index bc3fa88ab..fe7cbbddc 100644 --- a/src/main/resources/assets/superbwarfare/sounds.json +++ b/src/main/resources/assets/superbwarfare/sounds.json @@ -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 + } + ] } } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/sounds/c4/c4_beep.ogg b/src/main/resources/assets/superbwarfare/sounds/c4/c4_beep.ogg new file mode 100644 index 000000000..4bcd75c51 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/c4/c4_beep.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/c4/c4_final.ogg b/src/main/resources/assets/superbwarfare/sounds/c4/c4_final.ogg new file mode 100644 index 000000000..033e702af Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/c4/c4_final.ogg differ