diff options
8 files changed, 26 insertions, 21 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java index 867f91b..ce84582 100644 --- a/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java @@ -1,20 +1,19 @@ package com.dulkirfabric.mixin; import com.dulkirfabric.events.PlaySoundEvent; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.minecraft.client.sound.SoundInstance; import net.minecraft.client.sound.SoundSystem; 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; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(SoundSystem.class) public class SoundSystemMixin { - @Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", - at = @At("HEAD"), cancellable = true) - public void onSound(SoundInstance sound, CallbackInfo ci) { - if (new PlaySoundEvent(sound).post()) - ci.cancel(); + @ModifyExpressionValue(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sound/SoundInstance;canPlay()Z")) + public boolean onSound(boolean original, SoundInstance sound) { + return !(new PlaySoundEvent(sound).post()); } } diff --git a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt index 8748f20..80f4dc2 100644 --- a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt +++ b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt @@ -48,6 +48,4 @@ object DulkirModFabric : ModInitializer { DulkirConfig.loadConfig() } - //!this.client.options.getPerspective().isFirstPerson(), this.client.options.getPerspective().isFrontView() - }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index d15be19..55b301a 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -61,7 +61,7 @@ object Registrations { ClientReceiveMessageEvents.ALLOW_GAME.register( ClientReceiveMessageEvents.AllowGame { message, overlay -> if (overlay) !OverlayReceivedEvent(message.toString()).post() - else !ChatReceivedEvent(message.toString()).post() + else !ChatReceivedEvent(message).post() } ) WorldRenderEvents.END.register( diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt index 832fae6..7ebe742 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -44,7 +44,7 @@ class DulkirConfig { val builder = ConfigBuilder.create().setTitle(buttonText) builder.setDefaultBackgroundTexture(Identifier("minecraft:textures/block/oak_planks.png")) builder.setGlobalized(true) - builder.setGlobalizedExpanded(true) + builder.setGlobalizedExpanded(false) builder.setParentScreen(mc.currentScreen) builder.setSavingRunnable(::saveConfig) val entryBuilder = builder.entryBuilder() diff --git a/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt b/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt index 892baf1..9f8430d 100644 --- a/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt +++ b/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt @@ -1,6 +1,7 @@ package com.dulkirfabric.events import com.dulkirfabric.events.base.CancellableEvent +import net.minecraft.text.Text data class -ChatReceivedEvent(val message: String): CancellableEvent()
\ No newline at end of file +ChatReceivedEvent(val message: Text): CancellableEvent()
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt b/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt index f3f83e2..8763741 100644 --- a/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt +++ b/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt @@ -2,22 +2,27 @@ package com.dulkirfabric.features.chat import com.dulkirfabric.config.DulkirConfig import com.dulkirfabric.events.ChatReceivedEvent +import com.dulkirfabric.events.OverlayReceivedEvent import com.dulkirfabric.events.PlaySoundEvent import com.dulkirfabric.util.TextUtils +import com.dulkirfabric.util.TextUtils.unformattedString import meteordevelopment.orbit.EventHandler +import net.minecraft.client.sound.Sound +import net.minecraft.text.Text object AbiPhoneDND { private val abiPhoneFormat = "✆ (\\w+) ✆ ".toRegex() - var lastRing = 0L + private var lastRing = 0L //BLOCK ABIPHONE SOUNDS @EventHandler fun onSound(event: PlaySoundEvent) { if (!DulkirConfig.configOptions.abiPhoneDND) return if (System.currentTimeMillis() - lastRing < 5000) { - if (event.sound.sound.identifier.path == "note.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) { - event.isCancelled = true + // TODO: Make this not error out madge + if (event.sound.id.path == "block.note_block.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) { + event.isCancelled = true } } } @@ -25,7 +30,8 @@ object AbiPhoneDND { @EventHandler fun handle(event: ChatReceivedEvent) { if (!DulkirConfig.configOptions.abiPhoneDND) return - val unformatted: String = TextUtils.stripColorCodes(event.message) + val unformatted: String = event.message.unformattedString + println(unformatted) if (unformatted matches abiPhoneFormat && !unformatted.contains("Elle") && !unformatted.contains("Dean")) { val matchResult = abiPhoneFormat.find(unformatted) event.isCancelled = true @@ -37,9 +43,8 @@ object AbiPhoneDND { } } if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]") - && System.currentTimeMillis() - lastRing < 5000 - ) { - event.isCancelled + && System.currentTimeMillis() - lastRing < 5000) { + event.isCancelled = true } } }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt index c239ba0..c3baa9e 100644 --- a/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt @@ -17,6 +17,9 @@ object TextUtils { info("§9Toggled $message §8[$stateText§8]§r") } + val Text.unformattedString + get() = string.replace("§.".toRegex(), "") + fun sendPartyChatMessage(message: String) { this.sendCommand("/pc $message") } diff --git a/src/main/resources/1.0 TODO.txt b/src/main/resources/1.0 TODO.txt index 821e53d..dea1954 100644 --- a/src/main/resources/1.0 TODO.txt +++ b/src/main/resources/1.0 TODO.txt @@ -4,9 +4,8 @@ - Old animation/custom animation ? - Reparty Command - HUD ELEMENTS CODE - - selected block outline customization -LIST OF EASY STUFF:\ +LIST OF EASY STUFF: - Broken Hyp - Abiphone DND - double hook noot noota |