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 5b3b08e64..d7749e2b5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java @@ -36,6 +36,7 @@ import org.joml.Matrix4f; import org.joml.Vector4f; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; +import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.HEAT; @Mod.EventBusSubscriber(value = Dist.CLIENT) public class HelicopterHudOverlay { @@ -119,7 +120,7 @@ public class HelicopterHudOverlay { if (mobileVehicle instanceof Ah6Entity ah6Entity) { if (weaponVehicle.getWeaponIndex(0) == 0) { - double heat = 1 - ah6Entity.heat / 100.0F; + double heat = 1 - ah6Entity.getEntityData().get(HEAT) / 100.0F; guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false); } else { guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), w / 2 - 160, h / 2 - 60, 0x66FF00, false); @@ -187,7 +188,7 @@ public class HelicopterHudOverlay { if (mobileVehicle instanceof Ah6Entity ah6Entity) { if (weaponVehicle.getWeaponIndex(0) == 0) { - double heat = ah6Entity.heat / 100.0F; + double heat = ah6Entity.getEntityData().get(HEAT) / 100.0F; guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), 25, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false); } else { guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), 25, -9, -1, false); 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 d2ae929a6..43c888d24 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java @@ -48,9 +48,7 @@ import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*; import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.LOADED_MISSILE; import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.MISSILE_COUNT; -import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT; -import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.HEAT; -import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.AMMO; +import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.*; @Mod.EventBusSubscriber(value = Dist.CLIENT) public class VehicleHudOverlay { @@ -280,8 +278,11 @@ public class VehicleHudOverlay { if (player.getVehicle() instanceof Yx100Entity yx100) { if (weaponVehicle.getWeaponIndex(0) == 0) { guiGraphics.drawString(mc.font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false); - } else { + } else if (weaponVehicle.getWeaponIndex(0) == 1) { guiGraphics.drawString(mc.font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false); + } else if (weaponVehicle.getWeaponIndex(0) == 2) { + double heat = 1 - yx100.getEntityData().get(COAX_HEAT) / 100.0F; + guiGraphics.drawString(mc.font, Component.literal(" 12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false); } } @@ -333,8 +334,11 @@ public class VehicleHudOverlay { if (weaponVehicle instanceof Yx100Entity yx100) { if (weaponVehicle.getWeaponIndex(0) == 0) { guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false); - } else { + } else if (weaponVehicle.getWeaponIndex(0) == 1) { guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false); + } else if (weaponVehicle.getWeaponIndex(0) == 2) { + double heat2 = yx100.getEntityData().get(COAX_HEAT) / 100.0F; + guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java index b44e6f8ac..b428608ae 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java @@ -32,10 +32,9 @@ import org.joml.Math; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.client.overlay.VehicleHudOverlay.renderKillIndicator3P; -import static com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity.AMMO; -import static com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity.HEAT; -import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.MACHINE_GUN_HEAT; import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.MG_AMMO; +import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.AMMO; +import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.HEAT; @Mod.EventBusSubscriber(value = Dist.CLIENT) public class VehicleMgHudOverlay { @@ -96,7 +95,7 @@ public class VehicleMgHudOverlay { // YX-100 if (player.getVehicle() instanceof Yx100Entity yx100) { - double heat = yx100.getEntityData().get(MACHINE_GUN_HEAT) / 100.0F; + double heat = yx100.getEntityData().get(HEAT) / 100.0F; guiGraphics.drawString(mc.font, Component.literal(".50 HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(MG_AMMO))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false); } 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 f41d1f700..8f1691f31 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -14,7 +14,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.*; +import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.CustomExplosion; +import com.atsuishio.superbwarfare.tools.InventoryTool; +import com.atsuishio.superbwarfare.tools.ParticleTool; import com.google.common.collect.Lists; import com.mojang.math.Axis; import net.minecraft.core.BlockPos; @@ -75,8 +78,6 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity public double velocity; public int decoyReloadCoolDown; public int fireIndex; - - public int heat; public int holdTick; public int holdPowerTick; @@ -164,24 +165,6 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity setZRot(getRoll() * (backInputDown ? 0.9f : 0.99f)); - if (heat > 0) { - heat--; - } - - if (heat < 40) { - cannotFire = false; - } - - Entity driver = this.getFirstPassenger(); - if (driver instanceof Player player) { - if (heat > 100) { - cannotFire = true; - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f); - } - } - } - if (this.level() instanceof ServerLevel) { if (reloadCoolDown > 0) { reloadCoolDown--; @@ -603,6 +586,8 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity } + this.entityData.set(HEAT, this.entityData.get(HEAT) + 5); + if (!player.level().isClientSide) { if (player instanceof ServerPlayer serverPlayer) { serverPlayer.playSound(ModSounds.HELICOPTER_CANNON_FIRE_3P.get(), 4, 1); 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 a76d9dbf0..5d295e7f7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -13,7 +13,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.WgMissileWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.*; +import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.CustomExplosion; +import com.atsuishio.superbwarfare.tools.InventoryTool; +import com.atsuishio.superbwarfare.tools.ParticleTool; import com.mojang.math.Axis; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; @@ -178,25 +181,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit setRightTrack(0); } - if (this.entityData.get(HEAT) > 0) { - this.entityData.set(HEAT, this.entityData.get(HEAT) - 1); - } - - if (this.entityData.get(FIRE_ANIM) > 0) { - this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1); - } - - if (this.entityData.get(HEAT) < 40) { - cannotFire = false; - } - - 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) { if (reloadCoolDown > 0) { @@ -205,22 +189,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit this.handleAmmo(); } - Entity driver = this.getFirstPassenger(); - if (driver instanceof Player player) { - if (this.entityData.get(HEAT) > 100) { - cannotFire = true; - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - 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; fluidFloat = 0.052 * getSubmergedHeight(this); this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0)); 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 d21ae4356..679059271 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -12,7 +12,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.weapon.SmallCannonShellWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.*; +import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.CustomExplosion; +import com.atsuishio.superbwarfare.tools.InventoryTool; +import com.atsuishio.superbwarfare.tools.ParticleTool; import com.mojang.math.Axis; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; @@ -155,46 +158,10 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt super.baseTick(); - if (this.entityData.get(HEAT) > 0) { - this.entityData.set(HEAT, this.entityData.get(HEAT) - 1); - } - - if (this.entityData.get(FIRE_ANIM) > 0) { - this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1); - } - - if (this.entityData.get(HEAT) < 40) { - cannotFire = false; - } - - 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) { this.handleAmmo(); } - Entity driver = this.getFirstPassenger(); - if (driver instanceof Player player) { - if (this.entityData.get(HEAT) > 100) { - cannotFire = true; - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - 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; fluidFloat = 0.052 * getSubmergedHeight(this); this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0)); 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 1ecc69c4d..5a92fbe98 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -13,7 +13,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.ModVariables; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.*; +import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.CustomExplosion; +import com.atsuishio.superbwarfare.tools.InventoryTool; +import com.atsuishio.superbwarfare.tools.ParticleTool; import com.mojang.math.Axis; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; @@ -126,32 +129,6 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo public void baseTick() { super.baseTick(); - if (this.entityData.get(HEAT) > 0) { - this.entityData.set(HEAT, this.entityData.get(HEAT) - 1); - } - - if (this.entityData.get(FIRE_ANIM) > 0) { - this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1); - } - - if (this.entityData.get(HEAT) < 40) { - cannotFire = false; - } - - if (this.level() instanceof ServerLevel) { - this.handleAmmo(); - } - - Entity driver = this.getFirstPassenger(); - if (driver instanceof Player player) { - if (this.entityData.get(HEAT) > 100) { - cannotFire = true; - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f); - } - } - } - double fluidFloat; fluidFloat = 0.12 * getSubmergedHeight(this); this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0)); 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 0a3bc09c4..23ef18225 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -69,7 +69,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti public static final EntityDataAccessor MG_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor GUN_FIRE_TIME = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); - public static final EntityDataAccessor MACHINE_GUN_HEAT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final float MAX_HEALTH = VehicleConfig.YX_100_HP.get(); public static final int MAX_ENERGY = VehicleConfig.YX_100_MAX_ENERGY.get(); @@ -134,7 +133,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti this.entityData.define(LOADED_AMMO, 0); this.entityData.define(CANNON_FIRE_TIME, 0); this.entityData.define(GUN_FIRE_TIME, 0); - this.entityData.define(MACHINE_GUN_HEAT, 0); } @Override @@ -213,10 +211,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti this.entityData.set(GUN_FIRE_TIME, this.entityData.get(GUN_FIRE_TIME) - 1); } - if (this.entityData.get(MACHINE_GUN_HEAT) > 0) { - this.entityData.set(MACHINE_GUN_HEAT, this.entityData.get(MACHINE_GUN_HEAT) - 1); - } - if (reloadCoolDown == 70 && this.getFirstPassenger() instanceof Player player) { SoundTool.playLocalSound(player, ModSounds.YX_100_RELOAD.get()); } @@ -228,20 +222,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti this.handleAmmo(); } - if (this.entityData.get(MACHINE_GUN_HEAT) < 40) { - cannotFire = false; - } - - Entity gunner = this.getNthEntity(1); - if (gunner instanceof Player player) { - if (this.entityData.get(MACHINE_GUN_HEAT) > 100) { - cannotFire = true; - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f); - } - } - } - if (this.onGround()) { float f0 = 0.54f + 0.25f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90; this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.05 * this.getDeltaMovement().horizontalDistance()))); @@ -414,7 +394,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti this.level().addFreshEntity(projectileEntity); - float pitch = this.entityData.get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(MACHINE_GUN_HEAT))); + float pitch = this.entityData.get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(HEAT))); if (!player.level().isClientSide) { if (player instanceof ServerPlayer serverPlayer) { @@ -425,7 +405,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti } this.entityData.set(GUN_FIRE_TIME, 2); - this.entityData.set(MACHINE_GUN_HEAT, this.entityData.get(MACHINE_GUN_HEAT) + 4); + this.entityData.set(HEAT, this.entityData.get(HEAT) + 4); Level level = player.level(); final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java index 92dc79877..76929c171 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java @@ -20,6 +20,7 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.entity.AreaEffectCloud; import net.minecraft.world.entity.Entity; @@ -141,6 +142,35 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity { turretYRotO = deltaT + getTurretYRot(); } + if (this.entityData.get(HEAT) > 0) { + this.entityData.set(HEAT, this.entityData.get(HEAT) - 1); + } + + if (this.entityData.get(COAX_HEAT) > 0) { + this.entityData.set(COAX_HEAT, this.entityData.get(COAX_HEAT) - 1); + } + + if (this.entityData.get(FIRE_ANIM) > 0) { + this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1); + } + + if (this.entityData.get(HEAT) < 40) { + cannotFire = false; + } + + if (this.entityData.get(COAX_HEAT) < 40) { + cannotFireCoax = false; + } + + if (this.entityData.get(HEAT) > 100) { + cannotFire = true; + this.level().playSound(null, this.getOnPos(), ModSounds.MINIGUN_OVERHEAT.get(), SoundSource.PLAYERS, 1, 1); + } + if (this.entityData.get(COAX_HEAT) > 100) { + cannotFireCoax = true; + this.level().playSound(null, this.getOnPos(), ModSounds.MINIGUN_OVERHEAT.get(), SoundSource.PLAYERS, 1, 1); + } + preventStacking(); crushEntities(this.getDeltaMovement()); if (!(this instanceof DroneEntity)) { diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 7582c2265..477f3d828 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -62,9 +62,8 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; -import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT; -import static com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity.HEAT; -import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.MACHINE_GUN_HEAT; +import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.COAX_HEAT; +import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.HEAT; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ClientEventHandler { @@ -739,9 +738,8 @@ public class ClientEventHandler { } if (iVehicle instanceof Ah6Entity ah6Entity) { - float pitch = ah6Entity.heat <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - ah6Entity.heat)); + float pitch = ah6Entity.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - ah6Entity.getEntityData().get(HEAT))); if (ah6Entity.getWeaponIndex(0) == 0) { - ah6Entity.heat += 5; player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch); } else if (ah6Entity.getWeaponIndex(0) == 1) { player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1); @@ -772,7 +770,7 @@ public class ClientEventHandler { } if (iVehicle instanceof Yx100Entity yx100) { if (type == 1) { - float pitch = yx100.getEntityData().get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(MACHINE_GUN_HEAT))); + float pitch = yx100.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(HEAT))); player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch); player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1); } else {