Skip to content

Commit 22c49f8

Browse files
committed
updated methods + removed mixins
1 parent 4712b74 commit 22c49f8

File tree

13 files changed

+64
-339
lines changed

13 files changed

+64
-339
lines changed

build.gradle.kts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ java {
2626
// Minecraft configuration:
2727
loom {
2828
log4jConfigs.from(file("log4j2.xml"))
29-
launchConfigs {
30-
"client" {
31-
// If you don't want mixins, remove these lines
32-
property("mixin.debug", "true")
33-
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
34-
}
35-
}
29+
launchConfigs { "client" {} }
3630
runConfigs {
3731
"client" {
3832
if (SystemUtils.IS_OS_MAC_OSX) {
@@ -44,16 +38,6 @@ loom {
4438
}
4539
forge {
4640
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
47-
// If you don't want mixins, remove this lines
48-
mixinConfig("mixins.$modid.json")
49-
if (transformerFile.exists()) {
50-
println("Installing access transformer")
51-
accessTransformer(transformerFile)
52-
}
53-
}
54-
// If you don't want mixins, remove these lines
55-
mixin {
56-
defaultRefmapName.set("mixins.$modid.refmap.json")
5741
}
5842
}
5943

@@ -86,12 +70,6 @@ dependencies {
8670
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
8771

8872
shadowImpl(kotlin("stdlib-jdk8"))
89-
90-
// If you don't want mixins, remove these lines
91-
shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
92-
isTransitive = false
93-
}
94-
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
9573
}
9674

9775
// Tasks:
@@ -105,12 +83,6 @@ tasks.withType(org.gradle.jvm.tasks.Jar::class) {
10583
manifest.attributes.run {
10684
this["FMLCorePluginContainsFMLMod"] = "true"
10785
this["ForceLoadAsMod"] = "true"
108-
109-
// If you don't want mixins, remove these lines
110-
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
111-
this["MixinConfigs"] = "mixins.$modid.json"
112-
if (transformerFile.exists())
113-
this["FMLAT"] = "${modid}_at.cfg"
11486
}
11587
}
11688

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g
33
baseGroup = com.github.subat0m1c.rawinput
44
mcVersion = 1.8.9
55
modid = rawinput
6-
version = 1.0.0
6+
version = 1.0.1

src/main/java/com/github/subat0m1c/rawinput/init/AutoDiscoveryMixinPlugin.java

Lines changed: 0 additions & 188 deletions
This file was deleted.

src/main/java/com/github/subat0m1c/rawinput/mixin/MixinGuiClose.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/main/kotlin/com/github/subat0m1c/rawinput/RawInput.kt

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,25 @@
11
package com.github.subat0m1c.rawinput
22

33
import com.github.subat0m1c.rawinput.RawInputMain.Companion.mc
4-
import com.github.subat0m1c.rawinput.RawInputMain.Companion.scope
5-
import com.github.subat0m1c.rawinput.commands.ConfigCommand.Companion.waitTime
6-
import com.github.subat0m1c.rawinput.commands.ToggleCommand.Companion.enabled
7-
import kotlinx.coroutines.Job
8-
import kotlinx.coroutines.cancel
9-
import kotlinx.coroutines.launch
104
import net.java.games.input.Controller
115
import net.java.games.input.ControllerEnvironment
126
import net.java.games.input.Mouse
137
import net.minecraft.util.ChatComponentText
14-
import net.minecraft.util.IChatComponent
158

169
object RawInput {
17-
var rawInputJob: Job? = null
18-
19-
var dx = 0
20-
var dy = 0
21-
var controllers: Array<Controller>? = null
2210
var mouse: Mouse? = null
2311

24-
fun closeRawInput(message: String) {
25-
rawInputJob?.cancel(message)
26-
rawInputJob = null
27-
}
28-
29-
fun relaunchRawInput(message: String) {
30-
rawInputJob?.cancel(message)
31-
controllers = ControllerEnvironment.getDefaultEnvironment().controllers
32-
rawInputJob = launchRawInput()
33-
}
34-
35-
@JvmStatic
36-
fun guiClosed() {
37-
dx = 0
38-
dy = 0
39-
}
40-
41-
private fun launchRawInput() = scope.launch {
42-
controllers?.let { controllers ->
43-
while (enabled) {
44-
if (mouse == null) {
45-
for (controller in controllers) {
46-
if (controller.type == Controller.Type.MOUSE) {
47-
controller.poll()
48-
val mouseController = controller as Mouse
49-
if (mouseController.x.pollData != 0f || mouseController.y.pollData != 0f) {
50-
mouse = mouseController
51-
mc.thePlayer?.addChatMessage(ChatComponentText("Mouse found: ${mouseController.name}")) ?: println("Mouse found: ${mouseController.name}")
52-
break
53-
}
54-
}
55-
}
12+
fun findMouse() {
13+
for (controller in ControllerEnvironment.getDefaultEnvironment().controllers) {
14+
if (controller.type == Controller.Type.MOUSE) {
15+
controller.poll()
16+
val mouseController = controller as Mouse
17+
if (mouseController.x.pollData != 0f || mouseController.y.pollData != 0f) {
18+
mouse = mouseController
19+
mc.thePlayer?.addChatMessage(ChatComponentText("Mouse found: ${mouseController.name}"))
20+
?: println("Mouse found: ${mouseController.name}")
21+
break
5622
}
57-
58-
mouse?.let { mouse ->
59-
mouse.poll()
60-
dx += mouse.x.pollData.toInt()
61-
dy += mouse.y.pollData.toInt()
62-
}
63-
64-
Thread.sleep(0, waitTime)
6523
}
6624
}
6725
}

src/main/kotlin/com/github/subat0m1c/rawinput/RawInputMain.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
package com.github.subat0m1c.rawinput
22

3-
import com.github.subat0m1c.rawinput.RawInput.relaunchRawInput
43
import com.github.subat0m1c.rawinput.commands.ConfigCommand
54
import com.github.subat0m1c.rawinput.commands.RescanCommand
65
import com.github.subat0m1c.rawinput.commands.ToggleCommand
76
import com.github.subat0m1c.rawinput.commands.ToggleCommand.Companion.enabled
87
import com.github.subat0m1c.rawinput.config.ConfigManager
98
import kotlinx.coroutines.*
109
import net.minecraft.client.Minecraft
10+
import net.minecraft.util.ChatComponentText
1111
import net.minecraftforge.client.ClientCommandHandler
1212
import net.minecraftforge.common.MinecraftForge
1313
import net.minecraftforge.fml.common.Mod
1414
import net.minecraftforge.fml.common.event.FMLInitializationEvent
1515

1616
@Mod(modid = "rawinput", useMetadata = true)
1717
class RawInputMain {
18+
1819
@Mod.EventHandler
1920
fun init(event: FMLInitializationEvent) {
2021
MinecraftForge.EVENT_BUS.register(this)
2122
setOf(ToggleCommand(), RescanCommand(), ConfigCommand()).forEach { ClientCommandHandler.instance.registerCommand(it) }
2223
ConfigManager.awaitLoad()
2324

24-
if (enabled) {
25-
mc.mouseHelper = RawMouseHelper()
26-
relaunchRawInput("Initial rawinput launch")
27-
}
25+
if (enabled) mc.mouseHelper = RawMouseHelper()
2826
}
2927

3028
companion object {

0 commit comments

Comments
 (0)