aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-01-18 00:10:25 +0100
committerLinnea Gräf <nea@nea.moe>2024-01-18 17:55:53 +0100
commitd7902e06cd7285c72cd4ea2be6f18ead56a8775e (patch)
treefe07a4644bd889a4402d66105e0e6679f104cfb2 /src/main/java/moe/nea/firmament/mixins
parentac151c8ebc4c5546795cdbf5b0c179183e2c71d1 (diff)
downloadFirmament-d7902e06cd7285c72cd4ea2be6f18ead56a8775e.tar.gz
Firmament-d7902e06cd7285c72cd4ea2be6f18ead56a8775e.tar.bz2
Firmament-d7902e06cd7285c72cd4ea2be6f18ead56a8775e.zip
Add Ancestral Spade solver
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java b/src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java
new file mode 100644
index 0000000..64f8765
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java
@@ -0,0 +1,35 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.mixins;
+
+import moe.nea.firmament.events.SoundReceiveEvent;
+import net.minecraft.client.network.ClientPlayNetworkHandler;
+import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
+import net.minecraft.util.math.Vec3d;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(ClientPlayNetworkHandler.class)
+public class SoundReceiveEventPatch {
+ @Inject(method = "onPlaySound", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;DDDLnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/sound/SoundCategory;FFJ)V"), cancellable = true)
+ private void postEventWhenSoundIsPlayed(PlaySoundS2CPacket packet, CallbackInfo ci) {
+ var event = new SoundReceiveEvent(
+ packet.getSound(),
+ packet.getCategory(),
+ new Vec3d(packet.getX(), packet.getY(), packet.getZ()),
+ packet.getPitch(),
+ packet.getVolume(),
+ packet.getSeed()
+ );
+ SoundReceiveEvent.Companion.publish(event);
+ if (event.getCancelled()) {
+ ci.cancel();
+ }
+ }
+}