添加屁声
This commit is contained in:
parent
e10b227cce
commit
b9a6a3e2b2
11 changed files with 209 additions and 44 deletions
|
@ -0,0 +1,117 @@
|
||||||
|
package com.atsuishio.superbwarfare.client;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.A10Entity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.Hpj11Entity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance;
|
||||||
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
|
||||||
|
public abstract class VehicleFireSoundInstance extends AbstractTickableSoundInstance {
|
||||||
|
|
||||||
|
private final Minecraft client;
|
||||||
|
private final Entity entity;
|
||||||
|
private double lastDistance;
|
||||||
|
private int fade = 0;
|
||||||
|
private boolean die = false;
|
||||||
|
|
||||||
|
public VehicleFireSoundInstance(SoundEvent sound, Minecraft client, Entity entity) {
|
||||||
|
super(sound, SoundSource.AMBIENT, entity.getCommandSenderWorld().getRandom());
|
||||||
|
this.client = client;
|
||||||
|
this.entity = entity;
|
||||||
|
this.looping = true;
|
||||||
|
this.delay = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract boolean canPlay(Entity entity);
|
||||||
|
|
||||||
|
protected abstract float getPitch(Entity entity);
|
||||||
|
|
||||||
|
protected abstract float getVolume(Entity entity);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
var player = this.client.player;
|
||||||
|
if (entity.isRemoved() || player == null) {
|
||||||
|
this.stop();
|
||||||
|
return;
|
||||||
|
} else if (!this.canPlay(entity)) {
|
||||||
|
this.die = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.die) {
|
||||||
|
if (this.fade > 0) this.fade--;
|
||||||
|
else if (this.fade == 0) {
|
||||||
|
this.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (this.fade < 3) {
|
||||||
|
this.fade++;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.volume = this.getVolume(this.entity) * fade;
|
||||||
|
|
||||||
|
this.x = this.entity.getX();
|
||||||
|
this.y = this.entity.getY();
|
||||||
|
this.z = this.entity.getZ();
|
||||||
|
|
||||||
|
this.pitch = this.getPitch(this.entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class A10FireSound extends VehicleSoundInstance {
|
||||||
|
public A10FireSound(MobileVehicleEntity mobileVehicle) {
|
||||||
|
super(ModSounds.A_10_FIRE.get(), Minecraft.getInstance(), mobileVehicle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canPlay(MobileVehicleEntity mobileVehicle) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getPitch(MobileVehicleEntity mobileVehicle) {
|
||||||
|
if (mobileVehicle instanceof A10Entity a10Entity) {
|
||||||
|
return a10Entity.shootingPitch();
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getVolume(MobileVehicleEntity mobileVehicle) {
|
||||||
|
if (mobileVehicle instanceof A10Entity a10Entity) {
|
||||||
|
return a10Entity.shootingVolume();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HPJ11CloseFireSound extends VehicleSoundInstance {
|
||||||
|
public HPJ11CloseFireSound(MobileVehicleEntity mobileVehicle) {
|
||||||
|
super(ModSounds.HPJ_11_FIRE_3P.get(), Minecraft.getInstance(), mobileVehicle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canPlay(MobileVehicleEntity mobileVehicle) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getPitch(MobileVehicleEntity mobileVehicle) {
|
||||||
|
if (mobileVehicle instanceof Hpj11Entity hpj11Entity) {
|
||||||
|
return hpj11Entity.shootingPitch();
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getVolume(MobileVehicleEntity mobileVehicle) {
|
||||||
|
if (mobileVehicle instanceof Hpj11Entity hpj11Entity) {
|
||||||
|
return hpj11Entity.shootingVolume();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,8 +39,8 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
|
|
||||||
public static final ResourceLocation ID = Mod.loc("aircraft_hud");
|
public static final ResourceLocation ID = Mod.loc("aircraft_hud");
|
||||||
|
|
||||||
private static float scopeScale = 1;
|
|
||||||
private static float lerpVy = 1;
|
private static float lerpVy = 1;
|
||||||
|
private static float lerpG = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, @NotNull DeltaTracker deltaTracker) {
|
public void render(GuiGraphics guiGraphics, @NotNull DeltaTracker deltaTracker) {
|
||||||
|
@ -123,10 +123,18 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/speed_frame.png"), x + 108 - 36, y - 64, 0, 0, 36, 12, 36, 12);
|
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/speed_frame.png"), x + 108 - 36, y - 64, 0, 0, 36, 12, 36, 12);
|
||||||
//垂直速度
|
//垂直速度
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(lerpVy * 20)), (int) x - 96, (int) y + 60, 0x66FF00, false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(lerpVy * 20)), (int) x - 96, (int) y + 60, 0x66FF00, false);
|
||||||
|
//加速度
|
||||||
|
lerpG = (float) Mth.lerp(0.1f * partialTick, lerpG, mobileVehicle.acceleration / 9.8);
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("M"), (int) x - 105, (int) y + 70, 0x66FF00, false);
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("0.2"), (int) x - 96, (int) y + 70, 0x66FF00, false);
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("G"), (int) x - 105, (int) y + 78, 0x66FF00, false);
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.DECIMAL_FORMAT_1ZZ.format(lerpG)), (int) x - 96, (int) y + 78, 0x66FF00, false);
|
||||||
|
|
||||||
// 热诱弹
|
// 热诱弹
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("IR FLARES " + aircraftEntity.getDecoy()), (int) x + 72, (int) y, 0x66FF00, false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("IR FLARES " + aircraftEntity.getDecoy()), (int) x + 72, (int) y, 0x66FF00, false);
|
||||||
|
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("TGT"), (int) x + 76, (int) y + 78, 0x66FF00, false);
|
||||||
|
|
||||||
|
|
||||||
if (mobileVehicle instanceof A10Entity a10Entity) {
|
if (mobileVehicle instanceof A10Entity a10Entity) {
|
||||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
|
||||||
public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity, WeaponVehicleEntity, AircraftEntity {
|
public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity, WeaponVehicleEntity, AircraftEntity {
|
||||||
public static final EntityDataAccessor<Integer> LOADED_ROCKET = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> LOADED_ROCKET = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
||||||
|
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
private float yRotSync;
|
private float yRotSync;
|
||||||
private boolean fly;
|
private boolean fly;
|
||||||
|
@ -103,7 +104,8 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||||
super.defineSynchedData(builder);
|
super.defineSynchedData(builder);
|
||||||
builder.define(LOADED_ROCKET, 0);
|
builder.define(LOADED_ROCKET, 0)
|
||||||
|
.define(FIRE_TIME, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -205,6 +207,10 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
} else {
|
} else {
|
||||||
this.setZRot(this.roll * 0.99f);
|
this.setZRot(this.roll * 0.99f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entityData.get(FIRE_TIME) > 0) {
|
||||||
|
entityData.set(FIRE_TIME, entityData.get(FIRE_TIME) - 1);
|
||||||
|
}
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,11 +303,11 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER));
|
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER));
|
||||||
|
|
||||||
if (!onGround() && getDeltaMovement().dot(getViewVector(1)) * 72 > 150) {
|
if (!onGround() && getDeltaMovement().dot(getViewVector(1)) * 72 > 120) {
|
||||||
flyTime = Math.min(flyTime + 1, 20);
|
flyTime = Math.min(flyTime + 1, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDeltaMovement().dot(getViewVector(1)) * 72 < 150 && fly) {
|
if (getDeltaMovement().dot(getViewVector(1)) * 72 < 120 && fly) {
|
||||||
flyTime = Math.max(flyTime - 1, 0);
|
flyTime = Math.max(flyTime - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,6 +548,9 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
Vector4f worldPosition = transformPosition(transform, 0.1321625f, -0.56446875f, 7.85210625f);
|
Vector4f worldPosition = transformPosition(transform, 0.1321625f, -0.56446875f, 7.85210625f);
|
||||||
|
|
||||||
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
|
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
|
||||||
|
|
||||||
|
entityData.set(FIRE_TIME, Math.min(entityData.get(FIRE_TIME) + 6, 6));
|
||||||
|
|
||||||
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
||||||
|
|
||||||
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
|
@ -550,15 +559,15 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x, worldPosition.y, worldPosition.z, 1, 0, 0, 0, 0, false);
|
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x, worldPosition.y, worldPosition.z, 1, 0, 0, 0, 0, false);
|
||||||
|
|
||||||
BlockPos pos = BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z));
|
// BlockPos pos = BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||||
|
|
||||||
if (!player.level().isClientSide) {
|
// if (!player.level().isClientSide) {
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
// if (player instanceof ServerPlayer serverPlayer) {
|
||||||
serverPlayer.level().playSound(null, pos, ModSounds.HPJ_11_FIRE_3P.get(), SoundSource.PLAYERS, 6, random.nextFloat() * 0.05f + 1);
|
// serverPlayer.level().playSound(null, pos, ModSounds.HPJ_11_FIRE_3P.get(), SoundSource.PLAYERS, 6, random.nextFloat() * 0.05f + 1);
|
||||||
serverPlayer.level().playSound(null, pos, ModSounds.HPJ_11_FAR.get(), SoundSource.PLAYERS, 12, random.nextFloat() * 0.05f + 1);
|
// serverPlayer.level().playSound(null, pos, ModSounds.HPJ_11_FAR.get(), SoundSource.PLAYERS, 12, random.nextFloat() * 0.05f + 1);
|
||||||
serverPlayer.level().playSound(null, pos, ModSounds.HPJ_11_VERYFAR.get(), SoundSource.PLAYERS, 24, random.nextFloat() * 0.05f + 1);
|
// serverPlayer.level().playSound(null, pos, ModSounds.HPJ_11_VERYFAR.get(), SoundSource.PLAYERS, 24, random.nextFloat() * 0.05f + 1);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!hasCreativeAmmo) {
|
if (!hasCreativeAmmo) {
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
|
@ -628,6 +637,14 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float shootingVolume() {
|
||||||
|
return entityData.get(FIRE_TIME) * 0.3f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float shootingPitch() {
|
||||||
|
return 0.7f + entityData.get(FIRE_TIME) * 0.05f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int mainGunRpm(Player player) {
|
public int mainGunRpm(Player player) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -14,7 +14,6 @@ import com.atsuishio.superbwarfare.entity.vehicle.weapon.SmallCannonShellWeapon;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||||
import com.atsuishio.superbwarfare.tools.*;
|
import com.atsuishio.superbwarfare.tools.*;
|
||||||
|
@ -65,6 +64,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
public static final EntityDataAccessor<Boolean> ACTIVE = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.BOOLEAN);
|
public static final EntityDataAccessor<Boolean> ACTIVE = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.BOOLEAN);
|
||||||
public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.STRING);
|
public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.STRING);
|
||||||
public static final EntityDataAccessor<Optional<UUID>> OWNER_UUID = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.OPTIONAL_UUID);
|
public static final EntityDataAccessor<Optional<UUID>> OWNER_UUID = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.OPTIONAL_UUID);
|
||||||
|
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.INT);
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public Hpj11Entity(EntityType<Hpj11Entity> type, Level world) {
|
public Hpj11Entity(EntityType<Hpj11Entity> type, Level world) {
|
||||||
|
@ -83,7 +83,8 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
.define(GUN_ROTATE, 0f)
|
.define(GUN_ROTATE, 0f)
|
||||||
.define(TARGET_UUID, "none")
|
.define(TARGET_UUID, "none")
|
||||||
.define(OWNER_UUID, Optional.empty())
|
.define(OWNER_UUID, Optional.empty())
|
||||||
.define(ACTIVE, false);
|
.define(ACTIVE, false)
|
||||||
|
.define(FIRE_TIME, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -238,6 +239,10 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
autoAim();
|
autoAim();
|
||||||
|
|
||||||
|
if (entityData.get(FIRE_TIME) > 0) {
|
||||||
|
entityData.set(FIRE_TIME, entityData.get(FIRE_TIME) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
lowHealthWarning();
|
lowHealthWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,6 +471,8 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
boolean hasCreativeAmmo = (getFirstPassenger() instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) || hasItem(ModItems.CREATIVE_AMMO_BOX.get());
|
boolean hasCreativeAmmo = (getFirstPassenger() instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) || hasItem(ModItems.CREATIVE_AMMO_BOX.get());
|
||||||
|
|
||||||
|
entityData.set(FIRE_TIME, Math.min(entityData.get(FIRE_TIME) + 3, 3));
|
||||||
|
|
||||||
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
||||||
|
|
||||||
Matrix4f transform = getBarrelTransform(1);
|
Matrix4f transform = getBarrelTransform(1);
|
||||||
|
@ -475,12 +482,6 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y + 0.001, getLookAngle().z, 30, 0.75f);
|
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y + 0.001, getLookAngle().z, 30, 0.75f);
|
||||||
level().addFreshEntity(entityToSpawn);
|
level().addFreshEntity(entityToSpawn);
|
||||||
|
|
||||||
if (!player.level().isClientSide) {
|
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
|
||||||
serverPlayer.level().playSound(null, this.getOnPos(), ModSounds.HPJ_11_FIRE_3P.get(), SoundSource.PLAYERS, 16, random.nextFloat() * 0.05f + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.entityData.set(GUN_ROTATE, entityData.get(GUN_ROTATE) + 0.5f);
|
this.entityData.set(GUN_ROTATE, entityData.get(GUN_ROTATE) + 0.5f);
|
||||||
this.entityData.set(HEAT, this.entityData.get(HEAT) + 2);
|
this.entityData.set(HEAT, this.entityData.get(HEAT) + 2);
|
||||||
this.entityData.set(ANIM_TIME, 1);
|
this.entityData.set(ANIM_TIME, 1);
|
||||||
|
@ -492,6 +493,14 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float shootingVolume() {
|
||||||
|
return entityData.get(FIRE_TIME) * 0.4f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float shootingPitch() {
|
||||||
|
return 0.8f + entityData.get(FIRE_TIME) * 0.1f;
|
||||||
|
}
|
||||||
|
|
||||||
public Matrix4f getBarrelTransform(float ticks) {
|
public Matrix4f getBarrelTransform(float ticks) {
|
||||||
Matrix4f transformV = getVehicleFlatTransform(ticks);
|
Matrix4f transformV = getVehicleFlatTransform(ticks);
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
|
@ -210,8 +208,6 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
this.level().playSound(null, getOnPos(), SoundEvents.IRON_DOOR_OPEN, SoundSource.PLAYERS, 1, 1);
|
this.level().playSound(null, getOnPos(), SoundEvents.IRON_DOOR_OPEN, SoundSource.PLAYERS, 1, 1);
|
||||||
upInputDown = false;
|
upInputDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.displayClientMessage(Component.literal("speed: " + FormatTool.format2D(getDeltaMovement().dot(getViewVector(1)) * 20)), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.995f);
|
this.entityData.set(POWER, this.entityData.get(POWER) * 0.995f);
|
||||||
|
|
|
@ -64,6 +64,9 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
|
||||||
public static final EntityDataAccessor<Integer> DECOY_COUNT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> DECOY_COUNT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Integer> GEAR_ROT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> GEAR_ROT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
|
||||||
|
|
||||||
|
private Vec3 previousVelocity = Vec3.ZERO;
|
||||||
|
|
||||||
|
public double acceleration;
|
||||||
public int decoyReloadCoolDown;
|
public int decoyReloadCoolDown;
|
||||||
public static boolean IGNORE_ENTITY_GROUND_CHECK_STEPPING = false;
|
public static boolean IGNORE_ENTITY_GROUND_CHECK_STEPPING = false;
|
||||||
public boolean leftInputDown;
|
public boolean leftInputDown;
|
||||||
|
@ -194,6 +197,19 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
|
||||||
|
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
|
||||||
|
// 获取当前速度(deltaMovement 是当前速度向量)
|
||||||
|
Vec3 currentVelocity = this.getDeltaMovement();
|
||||||
|
|
||||||
|
// 计算加速度向量(时间间隔 Δt = 0.05秒)
|
||||||
|
Vec3 accelerationVec = currentVelocity.subtract(previousVelocity).scale(20); // scale(1/0.05) = scale(20)
|
||||||
|
|
||||||
|
// 计算加速度的绝对值
|
||||||
|
acceleration = accelerationVec.length() * 20;
|
||||||
|
|
||||||
|
// 更新前一时刻的速度
|
||||||
|
previousVelocity = currentVelocity;
|
||||||
|
|
||||||
|
|
||||||
engineSound.accept(this);
|
engineSound.accept(this);
|
||||||
|
|
||||||
double direct = (90 - calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
|
double direct = (90 - calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.atsuishio.superbwarfare.event;
|
package com.atsuishio.superbwarfare.event;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.client.LoudlyEntitySoundInstance;
|
import com.atsuishio.superbwarfare.client.LoudlyEntitySoundInstance;
|
||||||
|
import com.atsuishio.superbwarfare.client.VehicleFireSoundInstance;
|
||||||
import com.atsuishio.superbwarfare.client.VehicleSoundInstance;
|
import com.atsuishio.superbwarfare.client.VehicleSoundInstance;
|
||||||
import com.atsuishio.superbwarfare.entity.LoudlyEntity;
|
import com.atsuishio.superbwarfare.entity.LoudlyEntity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.A10Entity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.Hpj11Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.TrackEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.TrackEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -28,6 +31,12 @@ public class ClientSoundHandler {
|
||||||
Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySound(event.getEntity()));
|
Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySound(event.getEntity()));
|
||||||
Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySoundClose(event.getEntity()));
|
Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySoundClose(event.getEntity()));
|
||||||
}
|
}
|
||||||
|
if (event.getEntity() instanceof MobileVehicleEntity mobileVehicle && mobileVehicle instanceof A10Entity) {
|
||||||
|
Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.A10FireSound(mobileVehicle));
|
||||||
|
}
|
||||||
|
if (event.getEntity() instanceof MobileVehicleEntity mobileVehicle && mobileVehicle instanceof Hpj11Entity) {
|
||||||
|
Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.HPJ11CloseFireSound(mobileVehicle));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -438,13 +438,12 @@ public class ModSounds {
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> INSIDIOUS_RELOAD_EMPTY = REGISTRY.register("insidious_reload_empty", () -> SoundEvent.createVariableRangeEvent(Mod.loc("insidious_reload_empty")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> INSIDIOUS_RELOAD_EMPTY = REGISTRY.register("insidious_reload_empty", () -> SoundEvent.createVariableRangeEvent(Mod.loc("insidious_reload_empty")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> SMOKE_FIRE = REGISTRY.register("smoke_fire", () -> SoundEvent.createVariableRangeEvent(Mod.loc("smoke_fire")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> SMOKE_FIRE = REGISTRY.register("smoke_fire", () -> SoundEvent.createVariableRangeEvent(Mod.loc("smoke_fire")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> HPJ_11_FIRE_3P = REGISTRY.register("hpj_11_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hpj_11_fire_3p")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> HPJ_11_FIRE_3P = REGISTRY.register("hpj_11_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hpj_11_fire_3p")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> HPJ_11_FAR = REGISTRY.register("hpj_11_far", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hpj_11_far")));
|
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> HPJ_11_VERYFAR = REGISTRY.register("hpj_11_veryfar", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hpj_11_veryfar")));
|
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> TRACK_MOVE = REGISTRY.register("track_move", () -> SoundEvent.createVariableRangeEvent(Mod.loc("track_move")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> TRACK_MOVE = REGISTRY.register("track_move", () -> SoundEvent.createVariableRangeEvent(Mod.loc("track_move")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> ROCKET_FLY = REGISTRY.register("rocket_fly", () -> SoundEvent.createVariableRangeEvent(Mod.loc("rocket_fly")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> ROCKET_FLY = REGISTRY.register("rocket_fly", () -> SoundEvent.createVariableRangeEvent(Mod.loc("rocket_fly")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> SHELL_FLY = REGISTRY.register("shell_fly", () -> SoundEvent.createVariableRangeEvent(Mod.loc("shell_fly")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> SHELL_FLY = REGISTRY.register("shell_fly", () -> SoundEvent.createVariableRangeEvent(Mod.loc("shell_fly")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> ROCKET_ENGINE = REGISTRY.register("rocket_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("rocket_engine")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> ROCKET_ENGINE = REGISTRY.register("rocket_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("rocket_engine")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> VEHICLE_SWIM = REGISTRY.register("vehicle_swim", () -> SoundEvent.createVariableRangeEvent(Mod.loc("vehicle_swim")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> VEHICLE_SWIM = REGISTRY.register("vehicle_swim", () -> SoundEvent.createVariableRangeEvent(Mod.loc("vehicle_swim")));
|
||||||
public static final DeferredHolder<SoundEvent, SoundEvent> A_10_ENGINE = REGISTRY.register("a10_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("a10_engine")));
|
public static final DeferredHolder<SoundEvent, SoundEvent> A_10_ENGINE = REGISTRY.register("a10_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("a10_engine")));
|
||||||
|
public static final DeferredHolder<SoundEvent, SoundEvent> A_10_FIRE = REGISTRY.register("a10_fire", () -> SoundEvent.createVariableRangeEvent(Mod.loc("a10_fire")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3044,24 +3044,9 @@
|
||||||
"hpj_11_fire_3p": {
|
"hpj_11_fire_3p": {
|
||||||
"sounds": [
|
"sounds": [
|
||||||
{
|
{
|
||||||
"name": "superbwarfare:hpj11/hpj_11_fire_3p",
|
"attenuation_distance": 192,
|
||||||
"stream": false
|
"stream": true,
|
||||||
}
|
"name": "superbwarfare:hpj11/hpj_11_fire_3p"
|
||||||
]
|
|
||||||
},
|
|
||||||
"hpj_11_far": {
|
|
||||||
"sounds": [
|
|
||||||
{
|
|
||||||
"name": "superbwarfare:hpj11/hpj_11_far",
|
|
||||||
"stream": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"hpj_11_veryfar": {
|
|
||||||
"sounds": [
|
|
||||||
{
|
|
||||||
"name": "superbwarfare:hpj11/hpj_11_veryfar",
|
|
||||||
"stream": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -3118,5 +3103,14 @@
|
||||||
"name": "superbwarfare:a10/a10_engine"
|
"name": "superbwarfare:a10/a10_engine"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"a10_fire": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"attenuation_distance": 256,
|
||||||
|
"stream": true,
|
||||||
|
"name": "superbwarfare:a10/a10_fire"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
src/main/resources/assets/superbwarfare/sounds/a10/a10_fire.ogg
Normal file
BIN
src/main/resources/assets/superbwarfare/sounds/a10/a10_fire.ogg
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue