调整音效系统

This commit is contained in:
17146 2025-05-12 01:33:26 +08:00 committed by Light_Quanta
parent 99a10e1fca
commit 1e1b58ffba
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
5 changed files with 38 additions and 63 deletions

View file

@ -16,6 +16,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@ -77,20 +78,12 @@ public abstract class AbstractLaserEntity extends Entity implements TraceableEnt
this.on = false;
}
}
// @Override
// public Packet<ClientGamePacketListener> getAddEntityPacket() {
// return NetworkHooks.getEntitySpawningPacket(this);
// }
@Override
protected void readAdditionalSaveData(CompoundTag pCompound) {
protected void readAdditionalSaveData(@NotNull CompoundTag pCompound) {
}
@Override
protected void addAdditionalSaveData(CompoundTag pCompound) {
protected void addAdditionalSaveData(@NotNull CompoundTag pCompound) {
}
protected void beamTick() {
@ -107,11 +100,11 @@ public abstract class AbstractLaserEntity extends Entity implements TraceableEnt
}
@Override
public void push(Entity entityIn) {
public void push(@NotNull Entity entityIn) {
}
@Override
public PushReaction getPistonPushReaction() {
public @NotNull PushReaction getPistonPushReaction() {
return PushReaction.IGNORE;
}

View file

@ -9,6 +9,7 @@ import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
import java.util.List;
@ -111,7 +112,7 @@ public class LaserEntity extends AbstractLaserEntity {
}
@Override
protected void readAdditionalSaveData(CompoundTag compoundTag) {
protected void readAdditionalSaveData(@NotNull CompoundTag compoundTag) {
if (this.caster == null) {
discard();
}

View file

@ -84,12 +84,6 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit
this.monsterMultiplier = monsterMultiplier;
}
// TOD AEP
// @Override
// public @NotNull Packet<ClientGamePacketListener> getAddEntityPacket() {
// return NetworkHooks.getEntitySpawningPacket(this);
// }
@Override
protected @NotNull Item getDefaultItem() {
return ModItems.ROCKET.get();

View file

@ -1,44 +0,0 @@
package com.atsuishio.superbwarfare.event;
import com.atsuishio.superbwarfare.client.LoudlyEntitySoundInstance;
import com.atsuishio.superbwarfare.client.VehicleFireSoundInstance;
import com.atsuishio.superbwarfare.client.VehicleSoundInstance;
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.TrackEntity;
import net.minecraft.client.Minecraft;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
public class ClientSoundHandler {
@SubscribeEvent
public static void handleJoinLevelEvent(EntityJoinLevelEvent event) {
if (event.getLevel().isClientSide) {
com.atsuishio.superbwarfare.Mod.queueClientWork(60, () -> {
if (event.getEntity() instanceof MobileVehicleEntity mobileVehicle) {
Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(mobileVehicle, mobileVehicle.getEngineSound()));
Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.SwimSound(mobileVehicle));
}
if (event.getEntity() instanceof MobileVehicleEntity mobileVehicle && mobileVehicle instanceof TrackEntity) {
Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.TrackSound(mobileVehicle));
}
if (event.getEntity() instanceof LoudlyEntity) {
Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySound(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));
}
});
}
}
}

View file

@ -1,5 +1,14 @@
package com.atsuishio.superbwarfare.mixins;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.client.LoudlyEntitySoundInstance;
import com.atsuishio.superbwarfare.client.VehicleFireSoundInstance;
import com.atsuishio.superbwarfare.client.VehicleSoundInstance;
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.TrackEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.ModKeyMappings;
import net.minecraft.client.Minecraft;
@ -69,4 +78,26 @@ public abstract class ClientPacketListenerMixin {
vehicle.entityIndexOverride = null;
}
@Inject(method = "postAddEntitySoundInstance(Lnet/minecraft/world/entity/Entity;)V", at = @At("RETURN"))
private void postAddEntitySoundInstance(Entity pEntity, CallbackInfo ci) {
Mod.queueClientWork(60, () -> {
if (pEntity instanceof MobileVehicleEntity mobileVehicle) {
Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(mobileVehicle, mobileVehicle.getEngineSound()));
Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.SwimSound(mobileVehicle));
}
if (pEntity instanceof MobileVehicleEntity mobileVehicle && mobileVehicle instanceof TrackEntity) {
Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.TrackSound(mobileVehicle));
}
if (pEntity instanceof LoudlyEntity) {
Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySound(pEntity));
Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySoundClose(pEntity));
}
if (pEntity instanceof MobileVehicleEntity mobileVehicle && mobileVehicle instanceof A10Entity) {
Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.A10FireSound(mobileVehicle));
}
if (pEntity instanceof MobileVehicleEntity mobileVehicle && mobileVehicle instanceof Hpj11Entity) {
Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.HPJ11CloseFireSound(mobileVehicle));
}
});
}
}