diff options
-rw-r--r-- | build.gradle.kts | 6 | ||||
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinItem.java | 2 | ||||
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinSoundManager.java | 18 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/events/Events.kt | 10 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/ImpactDisplay.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/ReaperDisplay.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt | 22 | ||||
-rw-r--r-- | src/main/resources/mixins.dulkirmod.json | 13 |
8 files changed, 53 insertions, 26 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 17e5cc7..803d132 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,6 @@ loom { property("asmhelper.verbose", "true") arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") arg("--mixin", "mixins.dulkirmod.json") - arg("--tweakClass", "gg.essential.loader.stage0.EssentialSetupTweaker") } } forge { @@ -72,13 +71,12 @@ dependencies { minecraft("com.mojang:minecraft:1.8.9") mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") - shadowImpl("gg.essential:loader-launchwrapper:1.1.3") // If you don't want mixins, remove these lines - compileOnly("org.spongepowered:mixin:0.8.5-SNAPSHOT") { + compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") { isTransitive = false } - annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor") + annotationProcessor("net.fabricmc:sponge-mixin:0.11.4+mixin.0.8.5") // If you don't want to log in with your real minecraft account, remove this line runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.0") diff --git a/src/main/java/dulkirmod/mixins/MixinItem.java b/src/main/java/dulkirmod/mixins/MixinItem.java index 62ae99d..8f14151 100644 --- a/src/main/java/dulkirmod/mixins/MixinItem.java +++ b/src/main/java/dulkirmod/mixins/MixinItem.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = {Item.class}) +@Mixin(Item.class) public class MixinItem { @Inject(method = "shouldCauseReequipAnimation", at = @At("HEAD"), cancellable = true, remap = false) diff --git a/src/main/java/dulkirmod/mixins/MixinSoundManager.java b/src/main/java/dulkirmod/mixins/MixinSoundManager.java new file mode 100644 index 0000000..f4e228f --- /dev/null +++ b/src/main/java/dulkirmod/mixins/MixinSoundManager.java @@ -0,0 +1,18 @@ +package dulkirmod.mixins; + +import dulkirmod.events.AlwaysPlaySoundEvent; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.SoundManager; +import net.minecraftforge.common.MinecraftForge; +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(SoundManager.class) +public class MixinSoundManager { + @Inject(at = @At("HEAD"), method = "playSound") + public void onSound(ISound p_sound, CallbackInfo ci) { + MinecraftForge.EVENT_BUS.post(new AlwaysPlaySoundEvent(p_sound, (SoundManager) (Object) this)); + } +} diff --git a/src/main/kotlin/dulkirmod/events/Events.kt b/src/main/kotlin/dulkirmod/events/Events.kt index af6c02a..092c07d 100644 --- a/src/main/kotlin/dulkirmod/events/Events.kt +++ b/src/main/kotlin/dulkirmod/events/Events.kt @@ -1,9 +1,19 @@ package dulkirmod.events +import net.minecraft.client.audio.ISound +import net.minecraft.client.audio.SoundManager import net.minecraft.entity.Entity +import net.minecraftforge.client.event.sound.PlaySoundEvent import net.minecraftforge.fml.common.eventhandler.Event /** * Fired when an entity is removed from the world. */ class EntityRemovedEvent(val entity: Entity) : Event() + +/** + * Always fired when a sound is played, as opposed to [PlaySoundEvent], which does not get fired when the master volume is 0. + */ +data class AlwaysPlaySoundEvent(val sound: ISound, val soundManager: SoundManager) : Event() { + val name = sound.soundLocation.resourcePath +}
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt b/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt index 9415edc..5e473ee 100644 --- a/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt +++ b/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt @@ -1,8 +1,8 @@ package dulkirmod.features +import dulkirmod.events.AlwaysPlaySoundEvent import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound -import net.minecraftforge.client.event.sound.PlaySoundEvent import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable @@ -25,7 +25,7 @@ object ImpactDisplay { } @SubscribeEvent - fun onSound(event: PlaySoundEvent) { + fun onSound(event: AlwaysPlaySoundEvent) { if (event.name != "mob.zombie.remedy") return if (event.sound.pitch != 0.6984127f) return if (event.sound.volume != 1.0f) return diff --git a/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt b/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt index c595775..5d7207f 100644 --- a/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt +++ b/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt @@ -1,8 +1,8 @@ package dulkirmod.features +import dulkirmod.events.AlwaysPlaySoundEvent import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound -import net.minecraftforge.client.event.sound.PlaySoundEvent import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable @@ -25,7 +25,7 @@ object ReaperDisplay { } @SubscribeEvent - fun onSound(event: PlaySoundEvent) { + fun onSound(event: AlwaysPlaySoundEvent) { if (event.name != "mob.zombie.remedy") return if (event.sound.pitch != 1.0f) return if (event.sound.volume != .5f) return diff --git a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt index d91e59e..242e226 100644 --- a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt +++ b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt @@ -1,9 +1,9 @@ package dulkirmod.features.chat import dulkirmod.config.DulkirConfig +import dulkirmod.events.AlwaysPlaySoundEvent import dulkirmod.utils.TextUtils import net.minecraftforge.client.event.ClientChatReceivedEvent -import net.minecraftforge.client.event.sound.PlaySoundEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -11,16 +11,16 @@ private val abiphoneFormat = "✆ (\\w+) ✆ ".toRegex() private var lastRing: Long = 0 object AbiphoneDND { - //BLOCK ABIPHONE SOUNDS - @SubscribeEvent(receiveCanceled = false, priority = EventPriority.LOW) - fun onSound(event: PlaySoundEvent) { - if (!DulkirConfig.abiDND) return - if (System.currentTimeMillis() - lastRing < 5000) { - if (event.name == "note.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) { - event.result = null - } - } - } + //BLOCK ABIPHONE SOUNDS + @SubscribeEvent(receiveCanceled = false, priority = EventPriority.LOW) + fun onSound(event: AlwaysPlaySoundEvent) { + if (!DulkirConfig.abiDND) return + if (System.currentTimeMillis() - lastRing < 5000) { + if (event.name == "note.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) { + event.result = null + } + } + } fun handle(event: ClientChatReceivedEvent, unformatted: String) { if (!DulkirConfig.abiDND) return diff --git a/src/main/resources/mixins.dulkirmod.json b/src/main/resources/mixins.dulkirmod.json index a30c6d8..a6684b3 100644 --- a/src/main/resources/mixins.dulkirmod.json +++ b/src/main/resources/mixins.dulkirmod.json @@ -1,21 +1,22 @@ { "compatibilityLevel": "JAVA_8", - "minVersion": "0.8", + "minVersion": "0.6", "package": "dulkirmod.mixins", "refmap": "mixins.dulkirmod.refmap.json", "client": [ "AccessorRenderManager", + "MixinEntity", + "MixinEntityLivingBase", "MixinEntityRenderer", "MixinGuiContainer", "MixinGuiScreen", - "MixinItemRenderer", - "MixinLayerArmorBase", - "MixinRenderManager", - "MixinEntity", - "MixinEntityLivingBase", "MixinGuiUtils", "MixinItem", + "MixinItemRenderer", + "MixinLayerArmorBase", "MixinOldAnimations", + "MixinRenderManager", + "MixinSoundManager", "MixinWorld" ] } |