mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 22:16:01 +00:00
Implement entity audio source switching
This commit is contained in:
1 parent
b8b22db8ee
commit
d9de587543
9 files changed
+163
-46
No files matched your search
@@ -19,6 +19,7 @@ import it.unimi.dsi.fastutil.floats.FloatUnaryOperator;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.User;
|
||||
@@ -32,6 +33,7 @@ import net.minecraft.client.multiplayer.chat.report.ReportEnvironment;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.client.sounds.SoundManager;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.login.ServerboundHelloPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -158,6 +160,23 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sounds/SoundManager;updateSource(Lnet/minecraft/client/Camera;)V"))
|
||||
public void runTick_updateSource(SoundManager instance, Camera camera, Operation<Void> original) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.audioSourceEntity != null && this.level != null) {
|
||||
Entity sourceEntity = this.level.getEntities().get(editorState.audioSourceEntity);
|
||||
if (sourceEntity != null) {
|
||||
Camera dummyCamera = new Camera();
|
||||
dummyCamera.eyeHeight = sourceEntity.getEyeHeight();
|
||||
dummyCamera.setup(this.level, sourceEntity, false, false, 1.0f);
|
||||
instance.updateSource(dummyCamera);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
original.call(instance, camera);
|
||||
}
|
||||
|
||||
@Inject(method = "runTick", at=@At(value = "INVOKE", target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;blitToScreen(II)V", shift = At.Shift.AFTER))
|
||||
public void afterMainBlit(boolean bl, CallbackInfo ci) {
|
||||
if (!RenderSystem.isOnRenderThread()) return;
|
||||
|
||||
Reference in new issue
Block a user