diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java index 2f7a91870..8f8c48fbd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java @@ -29,6 +29,7 @@ import org.joml.Math; import java.text.DecimalFormat; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; +import static com.atsuishio.superbwarfare.client.overlay.VehicleHudOverlay.renderKillIndicator; @Mod.EventBusSubscriber(value = Dist.CLIENT) public class CannonHudOverlay { @@ -122,6 +123,8 @@ public class CannonHudOverlay { preciseBlit(event.getGuiGraphics(), ModUtils.loc("textures/screens/cannon/cannon_crosshair_notzoom.png"), k, l, 0, 0.0F, i, j, i, j); } + renderKillIndicator(guiGraphics, w, h); + poseStack.popPose(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java index 008ac2bf3..67930bfe8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java @@ -41,6 +41,7 @@ public class CrossHairOverlay { public static int HIT_INDICATOR = 0; public static int HEAD_INDICATOR = 0; public static int KILL_INDICATOR = 0; + public static int VEHICLE_INDICATOR = 0; private static float scopeScale = 1f; public static float gunRot; @@ -166,6 +167,10 @@ public class CrossHairOverlay { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker.png"), posX + moveX, posY + moveY, 0, 0, 16, 16, 16, 16); } + if (VEHICLE_INDICATOR > 0) { + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker_vehicle.png"), posX + moveX, posY + moveY, 0, 0, 16, 16, 16, 16); + } + if (HEAD_INDICATOR > 0) { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/headshot_mark.png"), posX + moveX, posY + moveY, 0, 0, 16, 16, 16, 16); } @@ -196,5 +201,6 @@ public class CrossHairOverlay { HEAD_INDICATOR = Math.max(0, HEAD_INDICATOR - 1); HIT_INDICATOR = Math.max(0, HIT_INDICATOR - 1); KILL_INDICATOR = Math.max(0, KILL_INDICATOR - 1); + VEHICLE_INDICATOR = Math.max(0, VEHICLE_INDICATOR - 1); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java index dbc42933a..e0895163c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java @@ -213,6 +213,10 @@ public class HelicopterHudOverlay { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker.png"), posX, posY, 0, 0, 16, 16, 16, 16); } + if (VEHICLE_INDICATOR > 0) { + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker_vehicle.png"), posX, posY, 0, 0, 16, 16, 16, 16); + } + if (HEAD_INDICATOR > 0) { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/headshot_mark.png"), posX, posY, 0, 0, 16, 16, 16, 16); } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java index e8cb7c91e..0a09e833c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java @@ -365,7 +365,7 @@ public class VehicleHudOverlay { } } - private static void renderKillIndicator(GuiGraphics guiGraphics, float w, float h) { + public static void renderKillIndicator(GuiGraphics guiGraphics, float w, float h) { float posX = w / 2f - 7.5f + (float) (2 * (java.lang.Math.random() - 0.5f)); float posY = h / 2f - 7.5f + (float) (2 * (java.lang.Math.random() - 0.5f)); float rate = (40 - KILL_INDICATOR * 5) / 5.5f; @@ -374,6 +374,10 @@ public class VehicleHudOverlay { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker.png"), posX, posY, 0, 0, 16, 16, 16, 16); } + if (VEHICLE_INDICATOR > 0) { + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker_vehicle.png"), posX, posY, 0, 0, 16, 16, 16, 16); + } + if (HEAD_INDICATOR > 0) { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/headshot_mark.png"), posX, posY, 0, 0, 16, 16, 16, 16); } @@ -398,6 +402,10 @@ public class VehicleHudOverlay { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker.png"), posX, posY, 0, 0, 16, 16, 16, 16); } + if (VEHICLE_INDICATOR > 0) { + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker_vehicle.png"), posX, posY, 0, 0, 16, 16, 16, 16); + } + if (HEAD_INDICATOR > 0) { preciseBlit(guiGraphics, ModUtils.loc("textures/screens/headshot_mark.png"), posX, posY, 0, 0, 16, 16, 16, 16); } diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java index c055fdb47..27fca66db 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java @@ -167,7 +167,7 @@ public class VehicleConfig { AH_6_CANNON_DAMAGE = builder.defineInRange("ah_6_cannon_damage", 25, 1, 10000000); builder.comment("The rocket damage of AH-6"); - AH_6_ROCKET_DAMAGE = builder.defineInRange("ah_6_rocket_damage", 75, 1, 10000000); + AH_6_ROCKET_DAMAGE = builder.defineInRange("ah_6_rocket_damage", 120, 1, 10000000); builder.comment("The rocket explosion damage of AH-6"); AH_6_ROCKET_EXPLOSION_DAMAGE = builder.defineInRange("ah_6_rocket_explosion_damage", 60, 1, 10000000); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index dd5271c2e..d72daad2a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -187,7 +187,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(Math.max(amount - 2, 0)); + this.hurt(Math.max(amount - 2, 0), source.getEntity(), true); return true; } 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 808c09e94..65a85d8a0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java @@ -157,10 +157,10 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, amount *= 0.1f; } if (source.is(ModDamageTypes.LUNGE_MINE)) { - amount *= 0.1f; + amount *= 0.12f; } if (source.is(ModDamageTypes.CANNON_FIRE)) { - amount *= 0.2f; + amount *= 0.22f; } if (source.is(ModTags.DamageTypes.PROJECTILE)) { amount *= 0f; @@ -173,7 +173,7 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(Math.max(amount - 16, 0)); + this.hurt(Math.max(amount - 10, 0), source.getEntity(), true); return true; } 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 f78eb467c..25a710f2f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -198,7 +198,7 @@ public class Bmp2Entity extends ContainerMobileEntity implements GeoEntity, ICha } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(Math.max(amount - 8, 0)); + this.hurt(Math.max(amount - 8, 0), source.getEntity(), true); return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java index 06cb733ad..db6faf374 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java @@ -107,7 +107,7 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity { @Override public boolean hurt(DamageSource source, float amount) { super.hurt(source, amount); - this.hurt(amount); + this.hurt(amount, source.getEntity(), false); return true; } 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 b774995bd..a85113d15 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -194,7 +194,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(Math.max(amount - 7, 0)); + this.hurt(Math.max(amount - 7, 0), source.getEntity(), true); return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java index 36176dbad..755a34fbd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -166,7 +166,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(Math.max(amount - 8, 0)); + this.hurt(Math.max(amount - 8, 0), source.getEntity(), true); return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java index cee24cafc..57ec7bf97 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -173,7 +173,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(Math.max(amount - 8, 0)); + this.hurt(Math.max(amount - 8, 0), source.getEntity(), true); return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index 9c58809db..8b9e70867 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -176,7 +176,7 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity, } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(Math.max(amount - 2, 0)); + this.hurt(Math.max(amount - 2, 0), source.getEntity(), true); return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java index 525e70659..ec1b4b169 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java @@ -101,7 +101,7 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity { amount *= 2f; } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(amount); + this.hurt(amount, source.getEntity(), true); return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java index dda675e3b..0d8dcf72b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java @@ -6,18 +6,23 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModParticleTypes; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.item.ContainerBlockItem; +import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage; +import com.atsuishio.superbwarfare.tools.EntityFindUtil; import com.atsuishio.superbwarfare.tools.ParticleTool; import com.atsuishio.superbwarfare.tools.VectorTool; import com.google.common.collect.Lists; import com.mojang.math.Axis; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; @@ -33,6 +38,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; +import net.minecraftforge.network.PacketDistributor; import org.jetbrains.annotations.NotNull; import org.joml.Math; import org.joml.Matrix4f; @@ -179,8 +185,14 @@ public class VehicleEntity extends Entity { } - public void hurt(float pHealAmount) { + public void hurt(float pHealAmount, Entity attacker, boolean send) { if (this.level() instanceof ServerLevel) { + if (attacker instanceof ServerPlayer player && pHealAmount > 0 && this.getHealth() > 0 && send && !(this instanceof DroneEntity)) { + var holder = Holder.direct(ModSounds.INDICATION_VEHICLE.get()); + player.connection.send(new ClientboundSoundPacket(holder, SoundSource.PLAYERS, player.getX(), player.getEyeY(), player.getZ(), 0.25f + (2.75f * pHealAmount / getMaxHealth()), random.nextFloat() * 0.1f + 0.9f, player.level().random.nextLong())); + + ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(3, 5)); + } this.setHealth(this.getHealth() - pHealAmount); } } @@ -262,8 +274,10 @@ public class VehicleEntity extends Entity { travel(); + Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); + if (this.getHealth() <= 0.1 * this.getMaxHealth()) { - this.hurt(0.1f); + this.hurt(0.1f, attacker, false); } else { if (!(this instanceof DroneEntity)) { this.heal(0.05f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java index 380f3fd84..2f849f71f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java @@ -106,7 +106,7 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity { public boolean hurt(DamageSource source, float amount) { super.hurt(source, amount); this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - this.hurt(amount); + this.hurt(amount, source.getEntity(), true); return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java index 41a151722..80ae7b2d6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java @@ -33,6 +33,7 @@ public class ModSounds { public static final RegistryObject HIT = REGISTRY.register("hit", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("hit"))); public static final RegistryObject TARGET_DOWN = REGISTRY.register("targetdown", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("targetdown"))); public static final RegistryObject INDICATION = REGISTRY.register("indication", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("indication"))); + public static final RegistryObject INDICATION_VEHICLE = REGISTRY.register("indication_vehicle", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("indication_vehicle"))); public static final RegistryObject JUMP = REGISTRY.register("jump", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("jump"))); public static final RegistryObject DOUBLE_JUMP = REGISTRY.register("doublejump", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("doublejump"))); diff --git a/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java b/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java index 04a803ba7..0d32f8c95 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java @@ -48,6 +48,7 @@ public class ClientPacketHandler { switch (message.type) { case 1 -> CrossHairOverlay.HEAD_INDICATOR = message.value; case 2 -> CrossHairOverlay.KILL_INDICATOR = message.value; + case 3 -> CrossHairOverlay.VEHICLE_INDICATOR = message.value; default -> CrossHairOverlay.HIT_INDICATOR = message.value; } } diff --git a/src/main/resources/assets/superbwarfare/sounds.json b/src/main/resources/assets/superbwarfare/sounds.json index 1fc0cbee0..b1fca0b3b 100644 --- a/src/main/resources/assets/superbwarfare/sounds.json +++ b/src/main/resources/assets/superbwarfare/sounds.json @@ -1815,6 +1815,14 @@ } ] }, + "indication_vehicle": { + "sounds": [ + { + "name": "superbwarfare:indication_vehicle", + "stream": false + } + ] + }, "jump": { "sounds": [ { diff --git a/src/main/resources/assets/superbwarfare/sounds/Vehicle_Interior_Armor_Impact_Wave 0 0 0.mp3 b/src/main/resources/assets/superbwarfare/sounds/Vehicle_Interior_Armor_Impact_Wave 0 0 0.mp3 new file mode 100644 index 000000000..9ffb1e8f6 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/Vehicle_Interior_Armor_Impact_Wave 0 0 0.mp3 differ diff --git a/src/main/resources/assets/superbwarfare/sounds/indication_vehicle.ogg b/src/main/resources/assets/superbwarfare/sounds/indication_vehicle.ogg new file mode 100644 index 000000000..e71f8f95b Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/indication_vehicle.ogg differ diff --git a/src/main/resources/assets/superbwarfare/textures/screens/hit_marker_vehicle.png b/src/main/resources/assets/superbwarfare/textures/screens/hit_marker_vehicle.png new file mode 100644 index 000000000..7c98585e2 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/screens/hit_marker_vehicle.png differ