diff options
author | inglettronald <inglettronald@gmail.com> | 2023-01-28 15:30:58 -0600 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-01-28 15:30:58 -0600 |
commit | 7b6fef2966838dffcdecb5870204d363811f4b4f (patch) | |
tree | de6f37e760c313a6187a2a06361ce36d5a08052d | |
parent | d13f43266a82c81962af8471f471a7824a0bcf7b (diff) | |
download | DulkirMod-7b6fef2966838dffcdecb5870204d363811f4b4f.tar.gz DulkirMod-7b6fef2966838dffcdecb5870204d363811f4b4f.tar.bz2 DulkirMod-7b6fef2966838dffcdecb5870204d363811f4b4f.zip |
More tooltip rendering logic and adding vanquisher trigger
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinGuiScreen.java | 32 | ||||
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinItemStack.java | 27 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/config/Config.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/events/ChatEvent.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/DungeonLeap.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/ScalableTooltips.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt | 13 | ||||
-rw-r--r-- | src/main/resources/mixins.dulkirmod.json | 8 |
8 files changed, 64 insertions, 36 deletions
diff --git a/src/main/java/dulkirmod/mixins/MixinGuiScreen.java b/src/main/java/dulkirmod/mixins/MixinGuiScreen.java new file mode 100644 index 0000000..fa4c857 --- /dev/null +++ b/src/main/java/dulkirmod/mixins/MixinGuiScreen.java @@ -0,0 +1,32 @@ +package dulkirmod.mixins; + +import dulkirmod.features.ScalableTooltips; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +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(GuiScreen.class) +public class MixinGuiScreen { + + private static int previousSlotId = -1; + + @Inject(method = "renderToolTip", at = @At("HEAD")) + public void onTooltip(ItemStack stack, int x, int y, CallbackInfo ci) { + GuiScreen screen = (GuiScreen) (Object) this; + if (screen instanceof GuiContainer) { + GuiContainer containerScreen = (GuiContainer) screen; + Slot slot = containerScreen.getSlotUnderMouse(); + if (slot != null && slot.slotNumber != previousSlotId) { + ScalableTooltips.INSTANCE.resetPos(); + previousSlotId = slot.slotNumber; + } + } + } + + +} diff --git a/src/main/java/dulkirmod/mixins/MixinItemStack.java b/src/main/java/dulkirmod/mixins/MixinItemStack.java deleted file mode 100644 index 76440ef..0000000 --- a/src/main/java/dulkirmod/mixins/MixinItemStack.java +++ /dev/null @@ -1,27 +0,0 @@ -package dulkirmod.mixins; -import dulkirmod.features.ScalableTooltips; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -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.CallbackInfoReturnable; - -import java.util.List; - -@Mixin(ItemStack.class) -public abstract class MixinItemStack { - - private static ItemStack previousStack; - - @Inject(method = "getTooltip", at = @At("HEAD")) - public void onTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable<List<String>> cir) { - - ItemStack currentStack = (ItemStack)(Object)this; - if (currentStack != previousStack) { - // reset values here for scrollable tooltips - ScalableTooltips.INSTANCE.resetPos(); - previousStack = currentStack; - } - } -} diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt index 37d2ac1..11f4ea5 100644 --- a/src/main/kotlin/dulkirmod/config/Config.kt +++ b/src/main/kotlin/dulkirmod/config/Config.kt @@ -98,6 +98,14 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so var throttleNotifier = true @Property( + type = PropertyType.SWITCH, + name = "Vanquisher Broadcaster", + description = "sends patcher sendcoords msg when you spawn a vanquisher. might make this put a waypoint later", + category = "Random Beta Features" + ) + var vanqBroadcast = false + + @Property( type = PropertyType.TEXT, name = "Throttle Notifier String", description = "How do you want to tell people you are throttled?", diff --git a/src/main/kotlin/dulkirmod/events/ChatEvent.kt b/src/main/kotlin/dulkirmod/events/ChatEvent.kt index 884e4cc..1b0f232 100644 --- a/src/main/kotlin/dulkirmod/events/ChatEvent.kt +++ b/src/main/kotlin/dulkirmod/events/ChatEvent.kt @@ -1,9 +1,6 @@ package dulkirmod.events -import dulkirmod.features.chat.AbiphoneDND -import dulkirmod.features.chat.Bridge -import dulkirmod.features.chat.FakeMsg -import dulkirmod.features.chat.ThrottleNotif +import dulkirmod.features.chat.* import dulkirmod.utils.Utils.stripColorCodes import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -33,5 +30,8 @@ class ChatEvent { // FAKE MESSAGE SENDER (DULKIR ONLY) FakeMsg.handle(event, unformatted) + + // Quick vanquisher thing + VanquisherTrigger.handle(unformatted) } }
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt index 901c839..d1be829 100644 --- a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt +++ b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt @@ -19,7 +19,7 @@ class DungeonLeap { val lastInLeap = inLeapMenuBool if (!Config.highlightLeap) return - if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) { + if (mc.currentScreen == null || mc.currentScreen !is GuiChest) { inLeapMenuBool = false return } diff --git a/src/main/kotlin/dulkirmod/features/ScalableTooltips.kt b/src/main/kotlin/dulkirmod/features/ScalableTooltips.kt index a3ce2f1..e471849 100644 --- a/src/main/kotlin/dulkirmod/features/ScalableTooltips.kt +++ b/src/main/kotlin/dulkirmod/features/ScalableTooltips.kt @@ -5,6 +5,7 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.FontRenderer import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.RenderHelper +import net.minecraft.item.ItemStack import net.minecraftforge.fml.client.config.GuiUtils import org.lwjgl.input.Keyboard import org.lwjgl.input.Mouse @@ -15,6 +16,7 @@ object ScalableTooltips { // Checks to see if large tooltips should be snapped (for larger than can fit on screen code) var snapFlag: Boolean = true var scaleScale: Float = 0f + var previousStack: ItemStack? = null fun drawScaledHoveringText( textLines: List<String>, diff --git a/src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt b/src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt new file mode 100644 index 0000000..c7d4349 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt @@ -0,0 +1,13 @@ +package dulkirmod.features.chat + +import dulkirmod.DulkirMod +import dulkirmod.config.Config + +object VanquisherTrigger { + fun handle(message: String) { + if (!Config.vanqBroadcast) return + if (message == "A Vanquisher is spawning nearby!") { + DulkirMod.mc.thePlayer.sendChatMessage("/patcher sendcoords") + } + } +}
\ No newline at end of file diff --git a/src/main/resources/mixins.dulkirmod.json b/src/main/resources/mixins.dulkirmod.json index 402acf2..c52d178 100644 --- a/src/main/resources/mixins.dulkirmod.json +++ b/src/main/resources/mixins.dulkirmod.json @@ -4,17 +4,17 @@ "package": "dulkirmod.mixins", "refmap": "mixins.dulkirmod.refmap.json", "client": [ - "MixinItemRenderer", "MixinEntityRenderer", "MixinGuiContainer", + "MixinGuiScreen", + "MixinItemRenderer", "MixinRendererManager" ], "mixins": [ "MixinEntity", "MixinEntityLivingBase", "MixinGuiUtils", - "MixinItemStack", - "MixinWorld", - "MixinOldAnimations" + "MixinOldAnimations", + "MixinWorld" ] } |