Search in sources :

Example 1 with SoundFixWrapper

use of org.valkyrienskies.mod.fixes.SoundFixWrapper in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsClient method onPlaySoundEvent.

@SubscribeEvent
public void onPlaySoundEvent(PlaySoundEvent event) {
    if (Minecraft.getMinecraft().world != null) {
        ISound sound = event.getSound();
        BlockPos pos = new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(Minecraft.getMinecraft().world, pos);
        if (physicsObject.isPresent()) {
            Vector3d newSoundLocation = new Vector3d(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
            physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(newSoundLocation, TransformType.SUBSPACE_TO_GLOBAL);
            SoundFixWrapper soundFix = new SoundFixWrapper(sound, newSoundLocation);
            event.setResultSound(soundFix);
        }
    }
}
Also used : ISound(net.minecraft.client.audio.ISound) Vector3d(org.joml.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) SoundFixWrapper(org.valkyrienskies.mod.fixes.SoundFixWrapper) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ISound (net.minecraft.client.audio.ISound)1 BlockPos (net.minecraft.util.math.BlockPos)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 Vector3d (org.joml.Vector3d)1 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)1 SoundFixWrapper (org.valkyrienskies.mod.fixes.SoundFixWrapper)1