forked from DFScripting/DFScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added STOP_ALL_SOUNDS, RECEIVE_SOUND (event) and several client value…
…s regarding the event
- Loading branch information
Showing
8 changed files
with
105 additions
and
30 deletions.
There are no files selected for viewing
23 changes: 18 additions & 5 deletions
23
src/main/java/io/github/techstreet/dfscript/event/RecieveSoundEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/techstreet/dfscript/mixin/sound/MSoundSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.github.techstreet.dfscript.mixin.sound; | ||
|
||
import io.github.techstreet.dfscript.event.RecieveSoundEvent; | ||
import io.github.techstreet.dfscript.event.system.EventManager; | ||
import io.github.techstreet.dfscript.util.chat.ChatUtil; | ||
import net.minecraft.client.sound.SoundInstance; | ||
import net.minecraft.client.sound.SoundSystem; | ||
import net.minecraft.network.packet.s2c.play.PlaySoundIdS2CPacket; | ||
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(SoundSystem.class) | ||
public class MSoundSystem { | ||
@Inject(method = "play", at = @At("HEAD"), cancellable = true) | ||
public void play(SoundInstance sound, CallbackInfo ci) { | ||
RecieveSoundEvent event = new RecieveSoundEvent(sound); | ||
EventManager.getInstance().dispatch(event); | ||
|
||
if (event.isCancelled()) { | ||
ci.cancel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters