Skip to content

Commit

Permalink
new: remove one jar support
Browse files Browse the repository at this point in the history
i dont know why lily did this in the first place, it only leads to dumb complications. no one actually needs this lol
  • Loading branch information
Wyvest committed Nov 1, 2022
1 parent b678ba6 commit 7163ef8
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 338 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ blossom {
version = mod_version
group = "cc.polyfrost"
base {
archivesName.set("$mod_name (1.8.9 & 1.12.2)")
archivesName.set("$mod_name-$platform")
}
loom {
noServerRunConfigs()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod_name = SimpleToggleSprint
mod_id = simpletogglesprint
mod_version = 1.0.0-beta2
mod_version = 1.0.0-beta3

essential.defaults.loom=0

Expand Down
4 changes: 3 additions & 1 deletion root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ plugins {
}

preprocess {
"1.8.9-forge"(10809, "srg") {}
"1.12.2-forge"(11202, "srg") {
"1.8.9-forge"(10809, "srg")
}
}
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ rootProject.name = mod_name
rootProject.buildFileName = "root.gradle.kts"

listOf(
"1.8.9-forge"
"1.8.9-forge",
"1.12.2-forge"
).forEach { version ->
include(":$version")
project(":$version").apply {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import cc.polyfrost.oneconfig.utils.commands.CommandManager
import mynameisjeff.simpletogglesprint.commands.SimpleToggleSprintCommand
import mynameisjeff.simpletogglesprint.core.SimpleToggleSprintConfig
import mynameisjeff.simpletogglesprint.core.checkKeyCode
import mynameisjeff.simpletogglesprint.mixins.accessors.AccessorGameSettings
import mynameisjeff.simpletogglesprint.mixins.accessors.AccessorKeybinding
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
Expand All @@ -35,7 +33,6 @@ import net.minecraftforge.fml.common.gameevent.InputEvent
modid = SimpleToggleSprint.MODID,
name = SimpleToggleSprint.MOD_NAME,
version = SimpleToggleSprint.VERSION,
acceptedMinecraftVersions = "[1.8.9,1.12.2]",
clientSideOnly = true,
modLanguageAdapter = "cc.polyfrost.oneconfig.utils.KotlinLanguageAdapter"
)
Expand All @@ -47,7 +44,7 @@ object SimpleToggleSprint {
val player
get() = UMinecraft.getPlayer()
val gameSettings
get() = UMinecraft.getSettings() as AccessorGameSettings
get() = UMinecraft.getSettings()

var sprintHeld = false
var sneakHeld = false
Expand All @@ -67,8 +64,8 @@ object SimpleToggleSprint {
@SubscribeEvent
fun onInput(event: InputEvent) {
if (!SimpleToggleSprintConfig.enabled) return
val sprint = (gameSettings.keyBindSprint as AccessorKeybinding).keyCode
val sneak = (gameSettings.keyBindSneak as AccessorKeybinding).keyCode
val sprint = gameSettings.keyBindSprint.keyCode
val sneak = gameSettings.keyBindSneak.keyCode
if (!SimpleToggleSprintConfig.keybindToggleSprint && checkKeyCode(sprint)) {
if (SimpleToggleSprintConfig.enabled && SimpleToggleSprintConfig.toggleSprint && !sprintHeld) {
SimpleToggleSprintConfig.toggleSprintState = !SimpleToggleSprintConfig.toggleSprintState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import cc.polyfrost.oneconfig.hud.TextHud
import cc.polyfrost.oneconfig.libs.universal.UKeyboard
import mynameisjeff.simpletogglesprint.SimpleToggleSprint
import mynameisjeff.simpletogglesprint.core.SimpleToggleSprintConfig.ToggleSprintHud.DisplayState.Companion.activeDisplay
import mynameisjeff.simpletogglesprint.mixins.accessors.AccessorEntityPlayer
import mynameisjeff.simpletogglesprint.mixins.accessors.AccessorPlayerCapabilities
import net.minecraft.entity.player.EntityPlayer
import java.io.File

object SimpleToggleSprintConfig : Config(Mod("SimpleToggleSprint", ModType.PVP, VigilanceMigrator(File("./config/simpletogglesprint.toml").absolutePath)), "simpletogglesprint.json") {
Expand Down Expand Up @@ -185,11 +184,11 @@ object SimpleToggleSprintConfig : Config(Mod("SimpleToggleSprint", ModType.PVP,

private fun getCompleteText(text: String?) = if (brackets && text?.isNotEmpty() == true) "[$text]" else text

private enum class DisplayState(val displayText: ToggleSprintHud.() -> String, val displayCheck: (AccessorEntityPlayer) -> Boolean) {
DESCENDINGHELD({ descendingHeld }, { (it.capabilities as AccessorPlayerCapabilities).isFlying && it.isSneaking && SimpleToggleSprint.sneakHeld }),
DESCENDINGTOGGLED({ descendingToggled }, { (it.capabilities as AccessorPlayerCapabilities).isFlying && SimpleToggleSprintConfig.enabled && toggleSprint && toggleSneakState }),
DESCENDING({ descending }, { (it.capabilities as AccessorPlayerCapabilities).isFlying && it.isSneaking }),
FLYING({ flying }, { (it.capabilities as AccessorPlayerCapabilities).isFlying }),
private enum class DisplayState(val displayText: ToggleSprintHud.() -> String, val displayCheck: (EntityPlayer) -> Boolean) {
DESCENDINGHELD({ descendingHeld }, { it.capabilities.isFlying && it.isSneaking && SimpleToggleSprint.sneakHeld }),
DESCENDINGTOGGLED({ descendingToggled }, { it.capabilities.isFlying && SimpleToggleSprintConfig.enabled && toggleSprint && toggleSneakState }),
DESCENDING({ descending }, { it.capabilities.isFlying && it.isSneaking }),
FLYING({ flying }, { it.capabilities.isFlying }),
RIDING({ riding }, { it.isRiding }),
SNEAKHELD({ sneakHeld }, { it.isSneaking && SimpleToggleSprint.sneakHeld }),
TOGGLESNEAK({ sneakToggle }, { SimpleToggleSprintConfig.enabled && toggleSneak && toggleSneakState }),
Expand All @@ -199,7 +198,7 @@ object SimpleToggleSprintConfig : Config(Mod("SimpleToggleSprint", ModType.PVP,
SPRINTING({ sprint }, { it.isSprinting });

val isActive: Boolean
get() = displayCheck(SimpleToggleSprint.player!! as AccessorEntityPlayer)
get() = displayCheck(SimpleToggleSprint.player!!)

companion object {
val ToggleSprintHud.activeDisplay: String?
Expand Down
12 changes: 2 additions & 10 deletions src/main/kotlin/mynameisjeff/simpletogglesprint/core/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,15 @@ package mynameisjeff.simpletogglesprint.core
import cc.polyfrost.oneconfig.libs.universal.UKeyboard
import cc.polyfrost.oneconfig.libs.universal.UScreen
import mynameisjeff.simpletogglesprint.SimpleToggleSprint.gameSettings
import mynameisjeff.simpletogglesprint.mixins.accessors.AccessorKeybinding
import net.minecraft.client.settings.KeyBinding
import net.minecraftforge.common.ForgeVersion
import org.lwjgl.input.Mouse
import kotlin.reflect.full.staticProperties

val is1_12_2 by lazy {
(ForgeVersion::class.staticProperties.find {
it.name == "mcVersion"
}!!.get() as String).startsWith("1.12")
}
fun shouldSetSprint(keyBinding: KeyBinding): Boolean {
return (keyBinding as AccessorKeybinding).isKeyDown || UScreen.currentScreen == null && SimpleToggleSprintConfig.enabled && SimpleToggleSprintConfig.toggleSprint && SimpleToggleSprintConfig.toggleSprintState && keyBinding === gameSettings.keyBindSprint
return keyBinding.isKeyDown || UScreen.currentScreen == null && SimpleToggleSprintConfig.enabled && SimpleToggleSprintConfig.toggleSprint && SimpleToggleSprintConfig.toggleSprintState && keyBinding === gameSettings.keyBindSprint
}

fun shouldSetSneak(keyBinding: KeyBinding): Boolean {
return (keyBinding as AccessorKeybinding).isKeyDown || UScreen.currentScreen == null && SimpleToggleSprintConfig.enabled && SimpleToggleSprintConfig.toggleSneak && SimpleToggleSprintConfig.toggleSneakState && keyBinding === gameSettings.keyBindSneak
return keyBinding.isKeyDown || UScreen.currentScreen == null && SimpleToggleSprintConfig.enabled && SimpleToggleSprintConfig.toggleSneak && SimpleToggleSprintConfig.toggleSneakState && keyBinding === gameSettings.keyBindSneak
}

fun checkKeyCode(keyCode: Int) = if (keyCode > 0) UKeyboard.isKeyDown(keyCode) else Mouse.isButtonDown(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package mynameisjeff.simpletogglesprint.tweaker

import cc.polyfrost.oneconfig.utils.Notifications
import mynameisjeff.simpletogglesprint.core.is1_12_2
import net.minecraftforge.fml.relauncher.CoreModManager
import org.spongepowered.asm.lib.tree.ClassNode
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin
Expand All @@ -38,11 +37,7 @@ class MixinPlugin : IMixinConfigPlugin {
}
}

override fun getRefMapperConfig(): String {
val refMap = if (is1_12_2) "mixins.simpletogglesprint1_12.refmap.json" else "mixins.simpletogglesprint.refmap.json"
println("Using refmap $refMap")
return refMap
}
override fun getRefMapperConfig(): String? = null

override fun shouldApplyMixin(targetClassName: String, mixinClassName: String): Boolean {
return if (mixinClassName.startsWith("mynameisjeff.simpletogglesprint.mixins.playerapi.")) {
Expand Down
7 changes: 1 addition & 6 deletions src/main/resources/mixins.simpletogglesprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
"compatibilityLevel": "JAVA_8",
"package": "mynameisjeff.simpletogglesprint.mixins",
"plugin": "mynameisjeff.simpletogglesprint.tweaker.MixinPlugin",
"refmap": "mixins.simpletogglesprint.refmap.json",
"mixins": [
"accessors.AccessorEntity",
"accessors.AccessorEntityPlayer",
"accessors.AccessorGameSettings",
"accessors.AccessorKeybinding",
"accessors.AccessorPlayerCapabilities",
"accessors.AccessorRenderGameOverlayEvent",
"MixinEntityPlayerSP",
"MixinMovementInputFromOptions",
"playerapi.MixinClientPlayerAPI"
Expand Down
Loading

0 comments on commit 7163ef8

Please sign in to comment.