diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java index 34018df11..d7e60c109 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity; +import com.atsuishio.superbwarfare.entity.vehicle.MultiWeaponVehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.tools.SeekTool; @@ -32,6 +33,7 @@ import java.text.DecimalFormat; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*; +import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT; import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.HEAT; @Mod.EventBusSubscriber(value = Dist.CLIENT) @@ -53,7 +55,7 @@ public class LandArmorHudOverlay { Vec3 cameraPos = camera.getPosition(); if (player == null) return; - if (player.getVehicle() instanceof Lav150Entity lav150 && lav150.isDriver(player)) { + if (player.getVehicle() instanceof Lav150Entity lav150 && lav150.isDriver(player) && player.getVehicle() instanceof MultiWeaponVehicleEntity multiWeaponVehicle) { poseStack.pushPose(); poseStack.translate(-8 * ClientEventHandler.turnRot[1], -8 * ClientEventHandler.turnRot[0], 0); @@ -137,8 +139,14 @@ public class LandArmorHudOverlay { //武器名称 if (player.getVehicle() instanceof Lav150Entity lav) { - double heat = 1 - lav.getEntityData().get(HEAT) / 100.0F; - guiGraphics.drawString(mc.font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : lav.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false); + if (multiWeaponVehicle.getWeaponType() == 0) { + double heat = 1 - lav.getEntityData().get(HEAT) / 100.0F; + guiGraphics.drawString(mc.font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : lav.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false); + } else { + double heat = 1 - lav.getEntityData().get(COAX_HEAT) / 100.0F; + guiGraphics.drawString(mc.font, Component.literal("7.62MM COAX " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : lav.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false); + } + } //血量 diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Lav150Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Lav150Renderer.java index 2bcbb1d6c..e63ca7eef 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Lav150Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Lav150Renderer.java @@ -67,10 +67,13 @@ public class Lav150Renderer extends GeoEntityRenderer { if (name.equals("barrel")) { bone.setRotX(-Mth.lerp(partialTick, animatable.turretXRotO, animatable.getTurretXRot()) * Mth.DEG_TO_RAD); } + if (name.equals("flare")) { + bone.setRotZ((float) (0.5 * (Math.random() - 0.5))); + } + if (name.equals("flare2")) { + bone.setRotZ((float) (0.5 * (Math.random() - 0.5))); + } -// if (name.equals("flare")) { -// bone.setRotZ((float) (0.5 * (Math.random() - 0.5))); -// } super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); } 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 21583d514..3d7fa9b45 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -526,7 +526,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli .headShot(2f) .zoom(false); - projectileRight.heBullet(true, 3); + projectileRight.heBullet(true, 2); projectileRight.bypassArmorRate(0.2f); projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z); projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20, 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 921751347..53bc7bb96 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; +import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.ModVariables; @@ -62,12 +63,15 @@ import java.util.List; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; -public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IChargeEntity, IArmedVehicleEntity { +public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IChargeEntity, IArmedVehicleEntity, MultiWeaponVehicleEntity { public static final EntityDataAccessor FIRE_ANIM = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor DELTA_ROT = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor HEAT = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor COAX_HEAT = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor LOADED_COAX_AMMO = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor WEAPON_TYPE = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); public static final float MAX_HEALTH = VehicleConfig.LAV_150_HP.get(); public static final int MAX_ENERGY = VehicleConfig.LAV_150_MAX_ENERGY.get(); @@ -84,6 +88,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC public float leftWheelRotO; public float rightWheelRotO; public boolean cannotFire; + public boolean cannotFireCoax; public Lav150Entity(PlayMessages.SpawnEntity packet, Level world) { this(ModEntities.LAV_150.get(), world); @@ -101,16 +106,21 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC this.entityData.define(FIRE_ANIM, 0); this.entityData.define(DELTA_ROT, 0f); this.entityData.define(HEAT, 0); + this.entityData.define(COAX_HEAT, 0); + this.entityData.define(WEAPON_TYPE, 0); + this.entityData.define(LOADED_COAX_AMMO, 0); } @Override public void addAdditionalSaveData(CompoundTag compound) { super.addAdditionalSaveData(compound); + compound.putInt("LoadedCoaxAmmo", this.entityData.get(LOADED_COAX_AMMO)); } @Override public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); + this.entityData.set(LOADED_COAX_AMMO, compound.getInt("LoadedCoaxAmmo")); } @Override @@ -194,10 +204,38 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC cannotFire = false; } - if (this.level() instanceof ServerLevel) { - this.entityData.set(AMMO, this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).mapToInt(ItemStack::getCount).sum()); + if (this.entityData.get(COAX_HEAT) > 0) { + this.entityData.set(COAX_HEAT, this.entityData.get(COAX_HEAT) - 1); } + if (this.entityData.get(COAX_HEAT) < 40) { + cannotFireCoax = false; + } + + if (this.level() instanceof ServerLevel) { + Player player = (Player) this.getFirstPassenger(); + if (player != null) { + if ((this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO_BOX.get())).mapToInt(ItemStack::getCount).sum() > 0 && this.getEntityData().get(LOADED_COAX_AMMO) < 500)) { + this.entityData.set(LOADED_COAX_AMMO, this.getEntityData().get(LOADED_COAX_AMMO) + 30); + this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO_BOX.get())).findFirst().ifPresent(stack -> stack.shrink(1)); + } + if ((this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO.get())).mapToInt(ItemStack::getCount).sum() > 0 && this.getEntityData().get(LOADED_COAX_AMMO) < 500)) { + this.entityData.set(LOADED_COAX_AMMO, this.getEntityData().get(LOADED_COAX_AMMO) + 5); + this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); + } + } + + if (this.getEntityData().get(WEAPON_TYPE) == 0) { + this.entityData.set(AMMO, this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).mapToInt(ItemStack::getCount).sum()); + } else { + this.entityData.set(AMMO, this.getEntityData().get(LOADED_COAX_AMMO)); + } + } + +// if (this.level() instanceof ServerLevel) { +// this.entityData.set(AMMO, this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).mapToInt(ItemStack::getCount).sum()); +// } + Entity driver = this.getFirstPassenger(); if (driver instanceof Player player) { if (this.entityData.get(HEAT) > 100) { @@ -206,6 +244,12 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f); } } + if (this.entityData.get(COAX_HEAT) > 100) { + cannotFireCoax = true; + if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { + SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f); + } + } } double fluidFloat; @@ -271,49 +315,86 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC @Override public void vehicleShoot(Player player) { - if (this.cannotFire) return; - Matrix4f transform = getBarrelTransform(); + if (entityData.get(WEAPON_TYPE) == 0) { + if (this.cannotFire) return; + float x = -0.0234375f; + float y = 0f; + float z = 4f; - float x = -0.0234375f; - float y = 0f; - float z = 4f; + Vector4f worldPosition = transformPosition(transform, x, y, z); + SmallCannonShellEntity smallCannonShell = new SmallCannonShellEntity(player, this.level(), + VehicleConfig.LAV_150_CANNON_DAMAGE.get(), + VehicleConfig.LAV_150_CANNON_EXPLOSION_DAMAGE.get(), + VehicleConfig.LAV_150_CANNON_EXPLOSION_RADIUS.get()); - Vector4f worldPosition = transformPosition(transform, x, y, z); - SmallCannonShellEntity smallCannonShell = new SmallCannonShellEntity(player, this.level(), - VehicleConfig.LAV_150_CANNON_DAMAGE.get(), - VehicleConfig.LAV_150_CANNON_EXPLOSION_DAMAGE.get(), - VehicleConfig.LAV_150_CANNON_EXPLOSION_RADIUS.get()); + smallCannonShell.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); + smallCannonShell.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, 22, + 0.25f); + this.level().addFreshEntity(smallCannonShell); - smallCannonShell.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); - smallCannonShell.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, 22, - 0.25f); - this.level().addFreshEntity(smallCannonShell); + sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z, 1, 0.02, 0.02, 0.02, 0, false); - sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z, 1, 0.02, 0.02, 0.02, 0, false); + float pitch = this.entityData.get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - this.entityData.get(HEAT))); - float pitch = this.entityData.get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - this.entityData.get(HEAT))); + if (!player.level().isClientSide) { + if (player instanceof ServerPlayer serverPlayer) { + serverPlayer.playSound(ModSounds.LAV_CANNON_FIRE_3P.get(), 4, pitch); + serverPlayer.playSound(ModSounds.LAV_CANNON_FAR.get(), 12, pitch); + serverPlayer.playSound(ModSounds.LAV_CANNON_VERYFAR.get(), 24, pitch); + } + } - if (!player.level().isClientSide) { - if (player instanceof ServerPlayer serverPlayer) { - serverPlayer.playSound(ModSounds.LAV_CANNON_FIRE_3P.get(), 4, pitch); - serverPlayer.playSound(ModSounds.LAV_CANNON_FAR.get(), 12, pitch); - serverPlayer.playSound(ModSounds.LAV_CANNON_VERYFAR.get(), 24, pitch); + Level level = player.level(); + final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ()); + + for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { + if (target instanceof ServerPlayer serverPlayer) { + ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 9, this.getX(), this.getEyeY(), this.getZ())); + } + } + + this.entityData.set(HEAT, this.entityData.get(HEAT) + 7); + this.entityData.set(FIRE_ANIM, 3); + this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); + + } else if (entityData.get(WEAPON_TYPE) == 1) { + if (this.cannotFireCoax) return; + float x = 0.3f; + float y = 0.08f; + float z = 0.7f; + + Vector4f worldPosition = transformPosition(transform, x, y, z); + + if (this.entityData.get(LOADED_COAX_AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) { + ProjectileEntity projectileRight = new ProjectileEntity(player.level()) + .shooter(player) + .damage(9.5f) + .headShot(2f) + .zoom(false); + + projectileRight.bypassArmorRate(0.2f); + projectileRight.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); + projectileRight.shoot(player, getBarrelVector(1).x, getBarrelVector(1).y + 0.002f, getBarrelVector(1).z, 36, + 0.25f); + this.level().addFreshEntity(projectileRight); + + if (!player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) { + this.entityData.set(LOADED_COAX_AMMO, this.getEntityData().get(LOADED_COAX_AMMO) - 1); + } + } + + this.entityData.set(COAX_HEAT, this.entityData.get(COAX_HEAT) + 3); + this.entityData.set(FIRE_ANIM, 2); + + if (!player.level().isClientSide) { + if (player instanceof ServerPlayer serverPlayer) { + serverPlayer.playSound(ModSounds.M_60_FIRE_3P.get(), 3, 1); + serverPlayer.playSound(ModSounds.M_60_FAR.get(), 6, 1); + serverPlayer.playSound(ModSounds.M_60_VERYFAR.get(), 12, 1); + } } } - - Level level = player.level(); - final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ()); - - for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { - if (target instanceof ServerPlayer serverPlayer) { - ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 9, this.getX(), this.getEyeY(), this.getZ())); - } - } - - this.entityData.set(HEAT, this.entityData.get(HEAT) + 7); - this.entityData.set(FIRE_ANIM, 3); - this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } public final Vec3 getBarrelVector(float pPartialTicks) { @@ -367,11 +448,11 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC } if (forwardInputDown) { - this.entityData.set(POWER, this.entityData.get(POWER) + 0.006f); + this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.015f, 0.2f)); } if (backInputDown) { - this.entityData.set(POWER, this.entityData.get(POWER) - 0.008f); + this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.01f, -0.2f)); } if (rightInputDown) { @@ -564,10 +645,14 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC } private PlayState firePredicate(AnimationState event) { - if (this.entityData.get(FIRE_ANIM) > 1) { + if (this.entityData.get(FIRE_ANIM) > 1 && entityData.get(WEAPON_TYPE) == 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire")); } + if (this.entityData.get(FIRE_ANIM) > 0 && entityData.get(WEAPON_TYPE) == 1) { + return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire2")); + } + return event.setAndContinue(RawAnimation.begin().thenLoop("animation.lav.idle")); } @@ -608,13 +693,22 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC @Override public int mainGunRpm() { + if (entityData.get(WEAPON_TYPE) == 0) { + return 300; + } else if (entityData.get(WEAPON_TYPE) == 1) { + return 600; + } return 300; } @Override public boolean canShoot(Player player) { - return (this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) - && !cannotFire; + if (entityData.get(WEAPON_TYPE) == 0) { + return (this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) && !cannotFire; + } else if (entityData.get(WEAPON_TYPE) == 1) { + return (this.entityData.get(LOADED_COAX_AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) && !cannotFireCoax; + } + return false; } @Override @@ -636,4 +730,20 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC public int zoomFov() { return 3; } + + @Override + public void changeWeapon() { + if (entityData.get(WEAPON_TYPE) == 0) { + this.level().playSound(null, this, ModSounds.INTO_MISSILE.get(), this.getSoundSource(), 1, 1); + entityData.set(WEAPON_TYPE, 1); + } else if (entityData.get(WEAPON_TYPE) == 1) { + entityData.set(WEAPON_TYPE, 0); + this.level().playSound(null, this, ModSounds.INTO_CANNON.get(), this.getSoundSource(), 1, 1); + } + } + + @Override + public int getWeaponType() { + return entityData.get(WEAPON_TYPE); + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 0ca0e0ff6..a4ddff82f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -4,10 +4,7 @@ import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.client.ClickHandler; import com.atsuishio.superbwarfare.config.client.DisplayConfig; import com.atsuishio.superbwarfare.entity.DroneEntity; -import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity; -import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; -import com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity; -import com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity; +import com.atsuishio.superbwarfare.entity.vehicle.*; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.network.ModVariables; @@ -62,7 +59,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; -import static com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity.WEAPON_TYPE; +import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT; import static com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity.HEAT; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) @@ -682,19 +679,28 @@ public class ClientEventHandler { player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch); player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1); } - if (iVehicle instanceof Ah6Entity ah6Entity) { - float pitch = ah6Entity.heat <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - ah6Entity.heat)); - if (ah6Entity.getEntityData().get(WEAPON_TYPE) == 0) { - ah6Entity.heat += 5; - player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch); - } else if (ah6Entity.getEntityData().get(WEAPON_TYPE) == 1) { - player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1); + + if (iVehicle instanceof MultiWeaponVehicleEntity multiWeaponVehicle) { + if (iVehicle instanceof Ah6Entity ah6Entity) { + float pitch = ah6Entity.heat <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - ah6Entity.heat)); + if (multiWeaponVehicle.getWeaponType() == 0) { + ah6Entity.heat += 5; + player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch); + } else if (multiWeaponVehicle.getWeaponType() == 1) { + player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1); + } + } + if (iVehicle instanceof Lav150Entity lav150) { + if (multiWeaponVehicle.getWeaponType() == 0) { + float pitch = lav150.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - lav150.getEntityData().get(HEAT))); + player.playSound(ModSounds.LAV_CANNON_FIRE_1P.get(), 1f, pitch); + player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1); + } else if (multiWeaponVehicle.getWeaponType() == 1) { + float pitch = lav150.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - lav150.getEntityData().get(COAX_HEAT))); + player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch); + } + } - } - if (iVehicle instanceof Lav150Entity lav150) { - float pitch = lav150.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - lav150.getEntityData().get(HEAT))); - player.playSound(ModSounds.LAV_CANNON_FIRE_1P.get(), 1f, pitch); - player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java index 6aeddb245..b8f65366f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java @@ -402,5 +402,6 @@ public class ModSounds { public static final RegistryObject LAV_CANNON_VERYFAR = REGISTRY.register("lav_cannon_veryfar", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_veryfar"))); public static final RegistryObject LAV_ENGINE = REGISTRY.register("lav_engine", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_engine"))); public static final RegistryObject LAV_ENGINE_1P = REGISTRY.register("lav_engine_1p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_engine_1p"))); + public static final RegistryObject COAX_FIRE_1P = REGISTRY.register("coax_fire_1p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("coax_fire_1p"))); } diff --git a/src/main/resources/assets/superbwarfare/animations/lav.animation.json b/src/main/resources/assets/superbwarfare/animations/lav.animation.json index 80e7b109f..38d2cec5b 100644 --- a/src/main/resources/assets/superbwarfare/animations/lav.animation.json +++ b/src/main/resources/assets/superbwarfare/animations/lav.animation.json @@ -1,6 +1,17 @@ { "format_version": "1.8.0", "animations": { + "animation.lav.idle": { + "animation_length": 0.25, + "bones": { + "flare": { + "scale": 0 + }, + "flare2": { + "scale": 0 + } + } + }, "animation.lav.fire": { "animation_length": 0.4, "bones": { @@ -29,14 +40,27 @@ "0.0917": [0, 0, 0], "0.15": [0, 0, 0] } + }, + "flare2": { + "scale": 0 } } }, - "animation.lav.idle": { - "animation_length": 0.25, + "animation.lav.fire2": { + "animation_length": 0.4, "bones": { "flare": { "scale": 0 + }, + "flare2": { + "scale": { + "0.0": [0, 0, 0], + "0.0083": [8, 8, 8], + "0.05": [11, 11, 11], + "0.075": [1, 1, 1], + "0.0917": [0, 0, 0], + "0.15": [0, 0, 0] + } } } } diff --git a/src/main/resources/assets/superbwarfare/geo/lav150.geo.json b/src/main/resources/assets/superbwarfare/geo/lav150.geo.json index f34b125ce..5a6861978 100644 --- a/src/main/resources/assets/superbwarfare/geo/lav150.geo.json +++ b/src/main/resources/assets/superbwarfare/geo/lav150.geo.json @@ -3003,7 +3003,23 @@ { "name": "barrel", "parent": "cannon", - "pivot": [0.375, 43.8072, -13.2] + "pivot": [0.375, 43.8072, -13.2], + "cubes": [ + { + "origin": [4.13625, 43.11845, -22.40424], + "size": [1.1275, 1.1275, 9.54], + "pivot": [4.825, 43.8072, -21.13424], + "rotation": [0, 0, -45], + "uv": { + "north": {"uv": [69, 98], "uv_size": [-1, 1]}, + "east": {"uv": [283, 87], "uv_size": [-18, 1]}, + "south": {"uv": [70, 121], "uv_size": [-1, 1]}, + "west": {"uv": [27, 135], "uv_size": [-18, 1]}, + "up": {"uv": [143, 266], "uv_size": [-1, 18]}, + "down": {"uv": [174, 284], "uv_size": [-1, -18]} + } + } + ] }, { "name": "flare", @@ -3352,6 +3368,51 @@ } ] }, + { + "name": "flare2", + "parent": "barrel", + "pivot": [4.825, 43.61482, -24.2707], + "cubes": [ + { + "origin": [4.54891, 43.33874, -24.29418], + "size": [0.55217, 0.55217, 0], + "uv": { + "north": {"uv": [512, 0], "uv_size": [-128, 128]}, + "south": {"uv": [384, 0], "uv_size": [128, 128]} + } + }, + { + "origin": [4.13051, 43.38427, -24.59305], + "size": [1.38897, 0.46109, 0], + "pivot": [4.825, 43.61482, -24.59304], + "rotation": [0, -90, -60], + "uv": { + "north": {"uv": [512, 0], "uv_size": [-103, 128]}, + "south": {"uv": [409, 0], "uv_size": [103, 128]} + } + }, + { + "origin": [4.13051, 43.38427, -24.59305], + "size": [1.38897, 0.46109, 0], + "pivot": [4.825, 43.61482, -24.59304], + "rotation": [0, -90, -120], + "uv": { + "north": {"uv": [512, 0], "uv_size": [-103, 128]}, + "south": {"uv": [409, 0], "uv_size": [103, 128]} + } + }, + { + "origin": [4.13051, 43.38427, -24.59305], + "size": [1.38897, 0.46109, 0], + "pivot": [4.825, 43.61482, -24.59304], + "rotation": [0, -90, 0], + "uv": { + "north": {"uv": [512, 0], "uv_size": [-103, 128]}, + "south": {"uv": [409, 0], "uv_size": [103, 128]} + } + } + ] + }, { "name": "main", "parent": "root", diff --git a/src/main/resources/assets/superbwarfare/sounds.json b/src/main/resources/assets/superbwarfare/sounds.json index 692afd5dd..c1bacd299 100644 --- a/src/main/resources/assets/superbwarfare/sounds.json +++ b/src/main/resources/assets/superbwarfare/sounds.json @@ -2750,5 +2750,12 @@ "name": "superbwarfare:lav/lav_engine_1p" } ] + }, + "coax_fire_1p": { + "sounds": [ + { + "name": "superbwarfare:lav/coax_fire_1p" + } + ] } } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/sounds/lav/coax_fire_1p.ogg b/src/main/resources/assets/superbwarfare/sounds/lav/coax_fire_1p.ogg new file mode 100644 index 000000000..2b7c0d6c9 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/lav/coax_fire_1p.ogg differ diff --git a/src/main/resources/assets/superbwarfare/textures/entity/lav150.png b/src/main/resources/assets/superbwarfare/textures/entity/lav150.png index d89ba89bd..1028cd15b 100644 Binary files a/src/main/resources/assets/superbwarfare/textures/entity/lav150.png and b/src/main/resources/assets/superbwarfare/textures/entity/lav150.png differ