Skip to content

Commit

Permalink
Reintroduce guiWasNotNull variable in MouseHelperHook
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Oct 13, 2023
1 parent a1cd2b9 commit ec235a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,9 @@ object SpamHider : PersistentSave(File(Skytils.modDir, "spamhider.json")) {
message?.message?.stripControlCodes()
)
if (scaleY > sr.scaledHeight / 2f) {
message.height = message.height + (i * 10 - message.height) * (animDiv * 5)
message.height += (i * 10 - message.height) * (animDiv * 5)
} else if (scaleY < sr.scaledHeight / 2f) {
message.height = message.height + (i * -10 - message.height) * (animDiv * 5)
message.height += (i * -10 - message.height) * (animDiv * 5)
}
var animOnOff = 0.0
if (message.time < 500) {
Expand All @@ -751,7 +751,7 @@ object SpamHider : PersistentSave(File(Skytils.modDir, "spamhider.json")) {
}
animOnOff *= 90.0
animOnOff += 90.0
animOnOff = animOnOff * Math.PI / 180
animOnOff *= Math.PI / 180
animOnOff = sin(animOnOff)
animOnOff *= -1.0
animOnOff += 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,28 @@ import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraftforge.client.event.GuiOpenEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent

object MouseHelperHook {
private var lastOpen = -1L
private var hasScreen = false


@SubscribeEvent
fun onGuiOpen(e: GuiOpenEvent) {
val oldGui = mc.currentScreen
if (e.gui == null) {
lastOpen = -1L
} else if (e.gui is GuiChest && (oldGui is GuiContainer || oldGui == null)) {
if (e.gui is GuiChest && (oldGui is GuiContainer || oldGui == null)) {
lastOpen = System.currentTimeMillis()
}
}


@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
hasScreen = mc.currentScreen != null
}

fun shouldResetMouseToCenter(): Boolean {
return !(Skytils.config.preventCursorReset && System.currentTimeMillis() - lastOpen <= 150)
return !(Skytils.config.preventCursorReset && System.currentTimeMillis() - lastOpen <= 150 && hasScreen)
}
}

0 comments on commit ec235a3

Please sign in to comment.