aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinChatStyle.java44
-rw-r--r--src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt22
-rw-r--r--src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt22
-rw-r--r--src/main/kotlin/skytils/skytilsmod/mixins/extensions/ExtensionChatStyle.kt25
-rw-r--r--src/main/resources/mixins.skytils.json1
5 files changed, 101 insertions, 13 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinChatStyle.java b/src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinChatStyle.java
new file mode 100644
index 00000000..9f7b1b6a
--- /dev/null
+++ b/src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinChatStyle.java
@@ -0,0 +1,44 @@
+/*
+ * Skytils - Hypixel Skyblock Quality of Life Mod
+ * Copyright (C) 2021 Skytils
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package skytils.skytilsmod.mixins.transformers.util;
+
+import net.minecraft.util.ChatStyle;
+import org.spongepowered.asm.mixin.Implements;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Unique;
+import skytils.skytilsmod.features.impl.handlers.ChatTabs;
+import skytils.skytilsmod.mixins.extensions.ExtensionChatStyle;
+
+@Mixin(ChatStyle.class)
+public class MixinChatStyle implements ExtensionChatStyle {
+ @Unique
+ ChatTabs.ChatTab[] chatTab = null;
+
+ @Unique
+ @Override
+ public ChatTabs.ChatTab[] getChatTabType() {
+ return chatTab;
+ }
+
+ @Unique
+ @Override
+ public void setChatTabType(ChatTabs.ChatTab[] type) {
+ chatTab = type;
+ }
+}
diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt
index c850d061..e62a2129 100644
--- a/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt
+++ b/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt
@@ -20,22 +20,42 @@ package skytils.skytilsmod.features.impl.handlers
import gg.essential.universal.UResolution
import net.minecraft.client.gui.GuiChat
+import net.minecraft.network.play.server.S02PacketChat
import net.minecraft.util.IChatComponent
import net.minecraftforge.client.event.GuiScreenEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.network.FMLNetworkEvent
import skytils.skytilsmod.Skytils
import skytils.skytilsmod.Skytils.Companion.mc
+import skytils.skytilsmod.events.PacketEvent
import skytils.skytilsmod.gui.elements.CleanButton
+import skytils.skytilsmod.mixins.extensions.ExtensionChatStyle
import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiNewChat
import skytils.skytilsmod.utils.Utils
object ChatTabs {
var selectedTab = ChatTab.ALL
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ fun onChat(event: PacketEvent.ReceiveEvent) {
+ if (!Utils.isOnHypixel || !Skytils.config.chatTabs || event.packet !is S02PacketChat) return
+
+ val style = event.packet.chatComponent.chatStyle
+ style as ExtensionChatStyle
+ if (style.chatTabType == null) {
+ style.chatTabType = ChatTab.values().filter { it.isValid(event.packet.chatComponent) }.toTypedArray()
+ }
+ }
+
fun shouldAllow(component: IChatComponent): Boolean {
if (!Utils.isOnHypixel || !Skytils.config.chatTabs) return true
- return selectedTab.isValid(component)
+ val style = component.chatStyle
+ style as ExtensionChatStyle
+ if (style.chatTabType == null) {
+ style.chatTabType = ChatTab.values().filter { it.isValid(component) }.toTypedArray()
+ }
+ return style.chatTabType!!.contains(selectedTab)
}
@SubscribeEvent
diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt
index 42f75b92..70fbae08 100644
--- a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt
+++ b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt
@@ -108,18 +108,16 @@ class SlayerFeatures {
}
if (under != null) {
val blockUnder = mc.theWorld.getBlockState(under)
- var isDanger = false
- if (blockUnder.block === Blocks.stone_slab && blockUnder.getValue(BlockHalfStoneSlab.VARIANT) == BlockStoneSlab.EnumType.QUARTZ) {
- isDanger = true
- } else if (blockUnder.block === Blocks.quartz_stairs || blockUnder.block === Blocks.acacia_stairs) {
- isDanger = true
- } else if (blockUnder.block === Blocks.wooden_slab && blockUnder.getValue(BlockHalfWoodSlab.VARIANT) == BlockPlanks.EnumType.ACACIA) {
- isDanger = true
- } else if (blockUnder.block === Blocks.stained_hardened_clay) {
- val color = Blocks.stained_hardened_clay.getMetaFromState(blockUnder)
- if (color == 0 || color == 8 || color == 14) isDanger = true
- } else if (blockUnder.block === Blocks.bedrock) {
- isDanger = true
+ val isDanger = when {
+ blockUnder.block === Blocks.stone_slab && blockUnder.getValue(BlockHalfStoneSlab.VARIANT) == BlockStoneSlab.EnumType.QUARTZ -> true
+ blockUnder.block === Blocks.quartz_stairs || blockUnder.block === Blocks.acacia_stairs -> true
+ blockUnder.block === Blocks.wooden_slab && blockUnder.getValue(BlockHalfWoodSlab.VARIANT) == BlockPlanks.EnumType.ACACIA -> true
+ blockUnder.block === Blocks.stained_hardened_clay -> {
+ val color = Blocks.stained_hardened_clay.getMetaFromState(blockUnder)
+ color == 0 || color == 8 || color == 14
+ }
+ blockUnder.block === Blocks.bedrock -> true
+ else -> false
}
if (isDanger) {
mc.thePlayer.playSound("random.orb", 1f, 1f)
diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/extensions/ExtensionChatStyle.kt b/src/main/kotlin/skytils/skytilsmod/mixins/extensions/ExtensionChatStyle.kt
new file mode 100644
index 00000000..9691f00d
--- /dev/null
+++ b/src/main/kotlin/skytils/skytilsmod/mixins/extensions/ExtensionChatStyle.kt
@@ -0,0 +1,25 @@
+/*
+ * Skytils - Hypixel Skyblock Quality of Life Mod
+ * Copyright (C) 2021 Skytils
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package skytils.skytilsmod.mixins.extensions
+
+import skytils.skytilsmod.features.impl.handlers.ChatTabs
+
+interface ExtensionChatStyle {
+ var chatTabType: Array<ChatTabs.ChatTab>?
+} \ No newline at end of file
diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json
index 869ed977..e406e495 100644
--- a/src/main/resources/mixins.skytils.json
+++ b/src/main/resources/mixins.skytils.json
@@ -56,6 +56,7 @@
"renderer.MixinTileEntityItemStackRenderer",
"renderer.MixinTileEntitySkullRenderer",
"sk1eroam.MixinAnimationHandler",
+ "util.MixinChatStyle",
"util.MixinIChatComponent$Serializer",
"util.MixinUtil",
"world.MixinChunk",