添加热诱弹音效和HUD提示

This commit is contained in:
Atsuihsio 2025-01-08 05:05:13 +08:00
parent e903095853
commit 39f7d5b921
9 changed files with 47 additions and 22 deletions

View file

@ -2,9 +2,9 @@ package com.atsuishio.superbwarfare.client.overlay;
import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.client.RenderHelper; import com.atsuishio.superbwarfare.client.RenderHelper;
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
import com.atsuishio.superbwarfare.entity.vehicle.IHelicopterEntity; import com.atsuishio.superbwarfare.entity.vehicle.IHelicopterEntity;
import com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.MultiWeaponVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModItems;
@ -37,7 +37,6 @@ import java.text.DecimalFormat;
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*; import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*;
import static com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity.WEAPON_TYPE;
@Mod.EventBusSubscriber(value = Dist.CLIENT) @Mod.EventBusSubscriber(value = Dist.CLIENT)
public class HelicopterHudOverlay { public class HelicopterHudOverlay {
@ -63,7 +62,7 @@ public class HelicopterHudOverlay {
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit)
return; return;
if (player.getVehicle() instanceof IHelicopterEntity iHelicopterEntity && player.getVehicle() instanceof MobileVehicleEntity mobileVehicle && iHelicopterEntity.isDriver(player)) { if (player.getVehicle() instanceof IHelicopterEntity iHelicopterEntity && player.getVehicle() instanceof MobileVehicleEntity mobileVehicle && iHelicopterEntity.isDriver(player) && player.getVehicle() instanceof MultiWeaponVehicleEntity multiWeaponVehicle) {
poseStack.pushPose(); poseStack.pushPose();
poseStack.translate(-6 * ClientEventHandler.turnRot[1],-6 * ClientEventHandler.turnRot[0],0); poseStack.translate(-6 * ClientEventHandler.turnRot[1],-6 * ClientEventHandler.turnRot[0],0);
@ -119,14 +118,14 @@ public class HelicopterHudOverlay {
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72) + "KM/H"), guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72) + "KM/H"),
w / 2 - 140, h / 2, 0x66FF00, false); w / 2 - 140, h / 2, 0x66FF00, false);
if (mobileVehicle instanceof Ah6Entity ah6Entity) { if (multiWeaponVehicle.getWeaponType() == 0) {
if (ah6Entity.getEntityData().get(WEAPON_TYPE) == 0) { guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "" : iHelicopterEntity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, 0x66FF00, false);
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "" : ah6Entity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, 0x66FF00, false); } else {
} else { guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), w / 2 - 160, h / 2 - 60, 0x66FF00, false);
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + ah6Entity.getAmmoCount(player)), w / 2 - 160, h / 2 - 60, 0x66FF00, false);
}
} }
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + iHelicopterEntity.getDecoy()), w / 2 - 160, h / 2 - 50, 0x66FF00, false);
if (lerpVy * 20 < -24) { if (lerpVy * 20 < -24) {
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("SINK RATEPULL UP!"), guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("SINK RATEPULL UP!"),
w / 2 - 53, h / 2 + 24, -65536, false); w / 2 - 53, h / 2 + 24, -65536, false);

View file

@ -139,7 +139,7 @@ public class VehicleConfig {
AH_6_ROCKET_DAMAGE = builder.defineInRange("ah_6_rocket_damage", 75, 1, 10000000); AH_6_ROCKET_DAMAGE = builder.defineInRange("ah_6_rocket_damage", 75, 1, 10000000);
builder.comment("The rocket explosion damage of AH-6"); builder.comment("The rocket explosion damage of AH-6");
AH_6_ROCKET_EXPLOSION_DAMAGE = builder.defineInRange("ah_6_rocket_explosion_damage", 50, 1, 10000000); AH_6_ROCKET_EXPLOSION_DAMAGE = builder.defineInRange("ah_6_rocket_explosion_damage", 60, 1, 10000000);
builder.comment("The rocket explosion radius of AH-6"); builder.comment("The rocket explosion radius of AH-6");
AH_6_ROCKET_EXPLOSION_RADIUS = builder.defineInRange("ah_6_rocket_explosion_radius", 5, 1, 10000000); AH_6_ROCKET_EXPLOSION_RADIUS = builder.defineInRange("ah_6_rocket_explosion_radius", 5, 1, 10000000);

View file

@ -15,7 +15,6 @@ import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
@ -52,7 +51,6 @@ import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache
import software.bernie.geckolib.core.animation.AnimatableManager; import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil; import software.bernie.geckolib.util.GeckoLibUtil;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -199,7 +197,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
public void releaseDecoy() { public void releaseDecoy() {
if (decoyInputDown) { if (decoyInputDown) {
if (this.entityData.get(DECOY_COUNT) > 0) { if (this.entityData.get(DECOY_COUNT) > 0 && this.level() instanceof ServerLevel) {
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
FlareDecoyEntity flareDecoyEntity = new FlareDecoyEntity((LivingEntity) passenger, this.level()); FlareDecoyEntity flareDecoyEntity = new FlareDecoyEntity((LivingEntity) passenger, this.level());
@ -207,19 +205,24 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
flareDecoyEntity.decoyShoot(this, this.getViewVector(1).yRot((45 + 90 * i) * Mth.DEG_TO_RAD), 0.8f, 8); flareDecoyEntity.decoyShoot(this, this.getViewVector(1).yRot((45 + 90 * i) * Mth.DEG_TO_RAD), 0.8f, 8);
this.level().addFreshEntity(flareDecoyEntity); this.level().addFreshEntity(flareDecoyEntity);
} }
this.level().playSound(null, this, ModSounds.DECOY_FIRE.get(), this.getSoundSource(), 1, 1);
if (this.getEntityData().get(DECOY_COUNT) == 6) {
decoyReloadCoolDown = 300;
}
this.getEntityData().set(DECOY_COUNT, this.getEntityData().get(DECOY_COUNT) - 1); this.getEntityData().set(DECOY_COUNT, this.getEntityData().get(DECOY_COUNT) - 1);
} }
decoyInputDown = false; decoyInputDown = false;
} }
if (this.entityData.get(DECOY_COUNT) < 6 && decoyReloadCoolDown == 0) { if (this.entityData.get(DECOY_COUNT) < 6 && decoyReloadCoolDown == 0 && this.level() instanceof ServerLevel) {
this.entityData.set(DECOY_COUNT, this.entityData.get(DECOY_COUNT) + 1); this.entityData.set(DECOY_COUNT, this.entityData.get(DECOY_COUNT) + 1);
this.level().playSound(null, this, ModSounds.DECOY_RELOAD.get(), this.getSoundSource(), 1, 1);
decoyReloadCoolDown = 300; decoyReloadCoolDown = 300;
} }
Player player = (Player) this.getFirstPassenger(); // Player player = (Player) this.getFirstPassenger();
//
if (player != null) { // if (player != null) {
player.displayClientMessage(Component.literal( new DecimalFormat("##").format(this.getEntityData().get(DECOY_COUNT))), true); // player.displayClientMessage(Component.literal( new DecimalFormat("##").format(this.getEntityData().get(DECOY_COUNT))), true);
} // }
} }
@Override @Override
@ -465,7 +468,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
Vector4f worldPositionLeft; Vector4f worldPositionLeft;
if (entityData.get(WEAPON_TYPE) == 0) { if (entityData.get(WEAPON_TYPE) == 0) {
x = 1.4f; x = 1.25f;
y = 0.62f; y = 0.62f;
z = 0.8f; z = 0.8f;
@ -479,7 +482,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
.headShot(2f) .headShot(2f)
.zoom(false); .zoom(false);
projectileRight.heBullet(true, 1); projectileRight.heBullet(true, 3);
projectileRight.bypassArmorRate(0.2f); projectileRight.bypassArmorRate(0.2f);
projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z); projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z);
projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20, projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20,
@ -657,6 +660,11 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
return this.entityData.get(POWER); return this.entityData.get(POWER);
} }
@Override
public int getDecoy() {
return this.entityData.get(DECOY_COUNT);
}
@Override @Override
public void changeWeapon() { public void changeWeapon() {
// entityData.set(WEAPON_TYPE, entityData.get(WEAPON_TYPE) + 1); // entityData.set(WEAPON_TYPE, entityData.get(WEAPON_TYPE) + 1);

View file

@ -7,6 +7,6 @@ public interface IHelicopterEntity extends IArmedVehicleEntity {
float getRotY(float tickDelta); float getRotY(float tickDelta);
float getRotZ(float tickDelta); float getRotZ(float tickDelta);
float getPower(); float getPower();
int getDecoy();
} }

View file

@ -374,5 +374,7 @@ public class ModSounds {
public static final RegistryObject<SoundEvent> LOCKING_WARNING = REGISTRY.register("locking_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("locking_warning"))); public static final RegistryObject<SoundEvent> LOCKING_WARNING = REGISTRY.register("locking_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("locking_warning")));
public static final RegistryObject<SoundEvent> LOCKED_WARNING = REGISTRY.register("locked_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("locked_warning"))); public static final RegistryObject<SoundEvent> LOCKED_WARNING = REGISTRY.register("locked_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("locked_warning")));
public static final RegistryObject<SoundEvent> MISSILE_WARNING = REGISTRY.register("missile_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("missile_warning"))); public static final RegistryObject<SoundEvent> MISSILE_WARNING = REGISTRY.register("missile_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("missile_warning")));
public static final RegistryObject<SoundEvent> DECOY_FIRE = REGISTRY.register("decoy_fire", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("decoy_fire")));
public static final RegistryObject<SoundEvent> DECOY_RELOAD = REGISTRY.register("decoy_reload", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("decoy_reload")));
} }

View file

@ -2640,5 +2640,21 @@
"stream": false "stream": false
} }
] ]
},
"decoy_reload": {
"sounds": [
{
"name": "superbwarfare:helicopter/decoy_reload",
"stream": false
}
]
},
"decoy_fire": {
"sounds": [
{
"name": "superbwarfare:helicopter/decoy_fire",
"stream": false
}
]
} }
} }